Do not eagerly invalidate all active variables on a branch.

This is not necessary, as we must emit an invalidating store before we
potentially consume an invalid expression. In fact, we're a bit
conservative here in this case for example:

int tmp = variable;
if (...)
{
    variable = 10;
}
else
{
    // Consuming tmp here is fine, but it was
    // invalidated while emitting other branch.
    // Technically, we need to study if there is an invalidating store
    // in the CFG between the loading block and this block, and the other
    // branch will not be a part of that analysis.
    int tmp2 = tmp * tmp;
}

Fixing this case means complex CFG traversal *everywhere*, and it feels like overkill.

Fixing this exposed a bug with access chains, so fix a bug where expression dependencies were not
inherited properly in access chains. Access chains are now considered forwarded if there
is at least one dependency which is also forwarded.
This commit is contained in:
Hans-Kristian Arntzen 2019-07-24 11:10:18 +02:00
parent 18bcc9b790
commit 461f1506e7
20 changed files with 86 additions and 176 deletions

View File

@ -115,7 +115,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_129 = _109;
}
float3 _130 = _129 * 0.5;
float2 _144 = fast::clamp(_82 + (float2(-1.0) * _7._m0.xy), _95, _96);
float3 _156 = float3(_11._m5) * fast::clamp(_8.sample(_9, _144, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _160 = _12.sample(_13, _144, level(0.0));
@ -129,7 +128,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_176 = _156;
}
float3 _177 = _176 * 0.5;
float2 _191 = fast::clamp(_82 + (float2(0.0, -1.0) * _7._m0.xy), _95, _96);
float3 _203 = float3(_11._m5) * fast::clamp(_8.sample(_9, _191, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _207 = _12.sample(_13, _191, level(0.0));
@ -143,7 +141,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_223 = _203;
}
float3 _224 = _223 * 0.75;
float2 _238 = fast::clamp(_82 + (float2(1.0, -1.0) * _7._m0.xy), _95, _96);
float3 _250 = float3(_11._m5) * fast::clamp(_8.sample(_9, _238, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _254 = _12.sample(_13, _238, level(0.0));
@ -157,7 +154,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_270 = _250;
}
float3 _271 = _270 * 0.5;
float2 _285 = fast::clamp(_82 + (float2(-2.0, 0.0) * _7._m0.xy), _95, _96);
float3 _297 = float3(_11._m5) * fast::clamp(_8.sample(_9, _285, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _301 = _12.sample(_13, _285, level(0.0));
@ -171,7 +167,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_317 = _297;
}
float3 _318 = _317 * 0.5;
float2 _332 = fast::clamp(_82 + (float2(-1.0, 0.0) * _7._m0.xy), _95, _96);
float3 _344 = float3(_11._m5) * fast::clamp(_8.sample(_9, _332, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _348 = _12.sample(_13, _332, level(0.0));
@ -185,7 +180,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_364 = _344;
}
float3 _365 = _364 * 0.75;
float2 _379 = fast::clamp(_82, _95, _96);
float3 _391 = float3(_11._m5) * fast::clamp(_8.sample(_9, _379, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _395 = _12.sample(_13, _379, level(0.0));
@ -199,7 +193,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_411 = _391;
}
float3 _412 = _411 * 1.0;
float2 _426 = fast::clamp(_82 + (float2(1.0, 0.0) * _7._m0.xy), _95, _96);
float3 _438 = float3(_11._m5) * fast::clamp(_8.sample(_9, _426, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _442 = _12.sample(_13, _426, level(0.0));
@ -213,7 +206,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_458 = _438;
}
float3 _459 = _458 * 0.75;
float2 _473 = fast::clamp(_82 + (float2(2.0, 0.0) * _7._m0.xy), _95, _96);
float3 _485 = float3(_11._m5) * fast::clamp(_8.sample(_9, _473, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _489 = _12.sample(_13, _473, level(0.0));
@ -227,7 +219,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_505 = _485;
}
float3 _506 = _505 * 0.5;
float2 _520 = fast::clamp(_82 + (float2(-1.0, 1.0) * _7._m0.xy), _95, _96);
float3 _532 = float3(_11._m5) * fast::clamp(_8.sample(_9, _520, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _536 = _12.sample(_13, _520, level(0.0));
@ -241,7 +232,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_552 = _532;
}
float3 _553 = _552 * 0.5;
float2 _567 = fast::clamp(_82 + (float2(0.0, 1.0) * _7._m0.xy), _95, _96);
float3 _579 = float3(_11._m5) * fast::clamp(_8.sample(_9, _567, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _583 = _12.sample(_13, _567, level(0.0));
@ -255,7 +245,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_599 = _579;
}
float3 _600 = _599 * 0.75;
float2 _614 = fast::clamp(_82 + _7._m0.xy, _95, _96);
float3 _626 = float3(_11._m5) * fast::clamp(_8.sample(_9, _614, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _630 = _12.sample(_13, _614, level(0.0));
@ -269,7 +258,6 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_646 = _626;
}
float3 _647 = _646 * 0.5;
float2 _661 = fast::clamp(_82 + (float2(0.0, 2.0) * _7._m0.xy), _95, _96);
float3 _673 = float3(_11._m5) * fast::clamp(_8.sample(_9, _661, level(0.0)).w * _7._m1, 0.0, 1.0);
float4 _677 = _12.sample(_13, _661, level(0.0));
@ -283,7 +271,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_693 = _673;
}
float3 _702 = ((((((((((((_130.xyz + _177).xyz + _224).xyz + _271).xyz + _318).xyz + _365).xyz + _412).xyz + _459).xyz + _506).xyz + _553).xyz + _600).xyz + _647).xyz + (_693 * 0.5)).xyz * float3(0.125);
float3 _702 = (((((((((((((_129 * 0.5).xyz + (_176 * 0.5)).xyz + (_223 * 0.75)).xyz + (_270 * 0.5)).xyz + (_317 * 0.5)).xyz + (_364 * 0.75)).xyz + (_411 * 1.0)).xyz + (_458 * 0.75)).xyz + (_505 * 0.5)).xyz + (_552 * 0.5)).xyz + (_599 * 0.75)).xyz + (_646 * 0.5)).xyz + (_693 * 0.5)).xyz * float3(0.125);
_28 _704 = _74;
_704._m0 = float4(_702.x, _702.y, _702.z, float4(0.0).w);
_28 _705 = _704;

View File

@ -51,22 +51,13 @@ fragment main0_out main0()
out.FragColor += _62;
int2 _148;
_148 = int2(0);
int _102;
for (;;)
for (; _148.x < 10; )
{
_102 = _148.x;
if (_102 < 10)
{
out.FragColor += _148.y;
int2 _144 = _148;
_144.x = _102 + 4;
_148 = _144;
continue;
}
else
{
break;
}
out.FragColor += _148.y;
int2 _144 = _148;
_144.x = _148.x + 4;
_148 = _144;
continue;
}
for (int _150 = _62; _150 < 40; )
{

View File

@ -16,13 +16,12 @@ layout(binding = 1, std430) buffer outputData
void main()
{
float _25 = _12.inputDataArray[gl_LocalInvocationID.x];
bool _31 = _25 > 0.0;
bool _31 = _12.inputDataArray[gl_LocalInvocationID.x] > 0.0;
uvec4 _37 = uvec4(unpackUint2x32(ballotARB(_31)), 0u, 0u);
uint _44 = mbcntAMD(packUint2x32(uvec2(_37.xy)));
if (_31)
{
_74.outputDataArray[_44] = _25;
_74.outputDataArray[_44] = _12.inputDataArray[gl_LocalInvocationID.x];
}
}

View File

@ -48,10 +48,12 @@ void main()
}
else
{
_227++;
uint _204 = _227 + uint(1);
_227 = _204;
continue;
}
_227++;
uint _204 = _227 + uint(1);
_227 = _204;
continue;
}
else

View File

@ -111,7 +111,6 @@ void main()
{
_129 = _109;
}
vec3 _130 = _129 * 0.5;
vec2 _144 = clamp(_82 + (vec2(-1.0) * _7._m0.xy), _95, _96);
vec3 _156 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _144, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _160 = textureLod(SPIRV_Cross_Combined_1, _144, 0.0);
@ -125,7 +124,6 @@ void main()
{
_176 = _156;
}
vec3 _177 = _176 * 0.5;
vec2 _191 = clamp(_82 + (vec2(0.0, -1.0) * _7._m0.xy), _95, _96);
vec3 _203 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _191, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _207 = textureLod(SPIRV_Cross_Combined_1, _191, 0.0);
@ -139,7 +137,6 @@ void main()
{
_223 = _203;
}
vec3 _224 = _223 * 0.75;
vec2 _238 = clamp(_82 + (vec2(1.0, -1.0) * _7._m0.xy), _95, _96);
vec3 _250 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _238, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _254 = textureLod(SPIRV_Cross_Combined_1, _238, 0.0);
@ -153,7 +150,6 @@ void main()
{
_270 = _250;
}
vec3 _271 = _270 * 0.5;
vec2 _285 = clamp(_82 + (vec2(-2.0, 0.0) * _7._m0.xy), _95, _96);
vec3 _297 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _285, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _301 = textureLod(SPIRV_Cross_Combined_1, _285, 0.0);
@ -167,7 +163,6 @@ void main()
{
_317 = _297;
}
vec3 _318 = _317 * 0.5;
vec2 _332 = clamp(_82 + (vec2(-1.0, 0.0) * _7._m0.xy), _95, _96);
vec3 _344 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _332, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _348 = textureLod(SPIRV_Cross_Combined_1, _332, 0.0);
@ -181,7 +176,6 @@ void main()
{
_364 = _344;
}
vec3 _365 = _364 * 0.75;
vec2 _379 = clamp(_82, _95, _96);
vec3 _391 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _379, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _395 = textureLod(SPIRV_Cross_Combined_1, _379, 0.0);
@ -195,7 +189,6 @@ void main()
{
_411 = _391;
}
vec3 _412 = _411 * 1.0;
vec2 _426 = clamp(_82 + (vec2(1.0, 0.0) * _7._m0.xy), _95, _96);
vec3 _438 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _426, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _442 = textureLod(SPIRV_Cross_Combined_1, _426, 0.0);
@ -209,7 +202,6 @@ void main()
{
_458 = _438;
}
vec3 _459 = _458 * 0.75;
vec2 _473 = clamp(_82 + (vec2(2.0, 0.0) * _7._m0.xy), _95, _96);
vec3 _485 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _473, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _489 = textureLod(SPIRV_Cross_Combined_1, _473, 0.0);
@ -223,7 +215,6 @@ void main()
{
_505 = _485;
}
vec3 _506 = _505 * 0.5;
vec2 _520 = clamp(_82 + (vec2(-1.0, 1.0) * _7._m0.xy), _95, _96);
vec3 _532 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _520, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _536 = textureLod(SPIRV_Cross_Combined_1, _520, 0.0);
@ -237,7 +228,6 @@ void main()
{
_552 = _532;
}
vec3 _553 = _552 * 0.5;
vec2 _567 = clamp(_82 + (vec2(0.0, 1.0) * _7._m0.xy), _95, _96);
vec3 _579 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _567, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _583 = textureLod(SPIRV_Cross_Combined_1, _567, 0.0);
@ -251,7 +241,6 @@ void main()
{
_599 = _579;
}
vec3 _600 = _599 * 0.75;
vec2 _614 = clamp(_82 + _7._m0.xy, _95, _96);
vec3 _626 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _614, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _630 = textureLod(SPIRV_Cross_Combined_1, _614, 0.0);
@ -265,7 +254,6 @@ void main()
{
_646 = _626;
}
vec3 _647 = _646 * 0.5;
vec2 _661 = clamp(_82 + (vec2(0.0, 2.0) * _7._m0.xy), _95, _96);
vec3 _673 = _11._m5 * clamp(textureLod(SPIRV_Cross_Combined, _661, 0.0).w * _7._m1, 0.0, 1.0);
vec4 _677 = textureLod(SPIRV_Cross_Combined_1, _661, 0.0);
@ -279,7 +267,7 @@ void main()
{
_693 = _673;
}
vec3 _702 = ((((((((((((_130.xyz + _177).xyz + _224).xyz + _271).xyz + _318).xyz + _365).xyz + _412).xyz + _459).xyz + _506).xyz + _553).xyz + _600).xyz + _647).xyz + (_693 * 0.5)).xyz * vec3(0.125);
vec3 _702 = (((((((((((((_129 * 0.5).xyz + (_176 * 0.5)).xyz + (_223 * 0.75)).xyz + (_270 * 0.5)).xyz + (_317 * 0.5)).xyz + (_364 * 0.75)).xyz + (_411 * 1.0)).xyz + (_458 * 0.75)).xyz + (_505 * 0.5)).xyz + (_552 * 0.5)).xyz + (_599 * 0.75)).xyz + (_646 * 0.5)).xyz + (_693 * 0.5)).xyz * vec3(0.125);
_28 _704 = _74;
_704._m0 = vec4(_702.x, _702.y, _702.z, vec4(0.0).w);
_28 _705 = _704;

View File

@ -46,22 +46,13 @@ void main()
FragColor += _62;
mediump ivec2 _148;
_148 = ivec2(0);
mediump int _102;
for (;;)
for (; _148.x < 10; )
{
_102 = _148.x;
if (_102 < 10)
{
FragColor += _148.y;
mediump ivec2 _144 = _148;
_144.x = _102 + 4;
_148 = _144;
continue;
}
else
{
break;
}
FragColor += _148.y;
mediump ivec2 _144 = _148;
_144.x = _148.x + 4;
_148 = _144;
continue;
}
for (mediump int _150 = _62; _150 < 40; )
{

View File

@ -33,26 +33,15 @@ void main()
}
default:
{
mediump int _84;
vec4 _88;
_88 = _82;
_84 = 0;
mediump int _50;
for (;;)
for (mediump int _84 = 0; _84 < _18; )
{
_50 = _84 + 1;
if (_84 < _18)
{
vec4 _72 = _88;
_72.y = _88.y + 0.5;
_88 = _72;
_84 = _50;
continue;
}
else
{
break;
}
vec4 _72 = _88;
_72.y = _88.y + 0.5;
_88 = _72;
_84++;
continue;
}
_89 = _88;
continue;

View File

@ -154,7 +154,6 @@ fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)
_193 = _192;
break;
} while (false);
float4 _194 = _193 * 1.0;
float4 _220;
do
{
@ -172,16 +171,15 @@ fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(0)
_220 = _219;
break;
} while (false);
float2 _221 = _220.wy;
float2 _223 = float2(1.0);
float2 _224 = (_221 * 2.0) - _223;
float2 _224 = (_220.wy * 2.0) - _223;
float3 _232 = float3(_224, sqrt(fast::clamp(1.0 + dot(-_224, _224), 0.0, 1.0)));
float2 _240 = (NormalDetailMapTexture.sample(NormalDetailMapSampler, (_166 * 0.0)).wy * 2.0) - _223;
float2 _252 = _232.xy + (float3(_240, sqrt(fast::clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0);
float3 _253 = float3(_252.x, _252.y, _232.z);
float2 _255 = _253.xy * _165;
float3 _256 = float3(_255.x, _255.y, _253.z);
float3 _271 = ((in.IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0);
float3 _271 = ((in.IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0);
float4 _298;
do
{

View File

@ -1,5 +1,3 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
@ -12,19 +10,6 @@ struct main0_out
float4 gl_Position [[position]];
};
// Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
template<typename T, uint N>
void spvArrayCopyFromStack1(thread T (&dst)[N], thread const T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
template<typename T, uint N>
void spvArrayCopyFromConstant1(thread T (&dst)[N], constant T (&src)[N])
{
for (uint i = 0; i < N; dst[i] = src[i], i++);
}
vertex main0_out main0()
{
main0_out out = {};
@ -35,12 +20,10 @@ vertex main0_out main0()
_25++;
continue;
}
float _31[2];
spvArrayCopyFromStack1(_31, _23);
float _37;
if (as_type<uint>(3.0) != 0u)
{
_37 = _31[0];
_37 = _23[0];
}
else
{

View File

@ -95,11 +95,13 @@ kernel void main0(const device SSBO& _24 [[buffer(0)]], device SSBO2& _177 [[buf
{
if (l == 5)
{
l++;
int _172 = l;
l = _172 + 1;
continue;
}
idat += float4(1.0);
l++;
int _172 = l;
l = _172 + 1;
continue;
}
_177.out_data[ident] = idat;

View File

@ -31,9 +31,10 @@ kernel void main0(device foo& buf [[buffer(0)]], constant bar& cb [[buffer(1)]],
{
device foo* _46 = select_buffer(buf, cb);
device foo* _45 = _46;
device foo* _48 = _45;
device int* _52;
device int* _55;
_52 = &_45->a[0u];
_52 = &_48->a[0u];
_55 = &buf.a[0u];
int _57;
int _58;

View File

@ -144,8 +144,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_129 = _109;
}
float3 _130 = _129 * 0.5;
float3 _133 = float4(0.0).xyz + _130;
float3 _133 = float4(0.0).xyz + (_129 * 0.5);
float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w);
_28 _135 = _77;
_135._m0 = _134;
@ -161,8 +160,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_176 = _156;
}
float3 _177 = _176 * 0.5;
float3 _180 = _134.xyz + _177;
float3 _180 = _134.xyz + (_176 * 0.5);
float4 _181 = float4(_180.x, _180.y, _180.z, _134.w);
_28 _182 = _135;
_182._m0 = _181;
@ -178,8 +176,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_223 = _203;
}
float3 _224 = _223 * 0.75;
float3 _227 = _181.xyz + _224;
float3 _227 = _181.xyz + (_223 * 0.75);
float4 _228 = float4(_227.x, _227.y, _227.z, _181.w);
_28 _229 = _182;
_229._m0 = _228;
@ -195,8 +192,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_270 = _250;
}
float3 _271 = _270 * 0.5;
float3 _274 = _228.xyz + _271;
float3 _274 = _228.xyz + (_270 * 0.5);
float4 _275 = float4(_274.x, _274.y, _274.z, _228.w);
_28 _276 = _229;
_276._m0 = _275;
@ -212,8 +208,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_317 = _297;
}
float3 _318 = _317 * 0.5;
float3 _321 = _275.xyz + _318;
float3 _321 = _275.xyz + (_317 * 0.5);
float4 _322 = float4(_321.x, _321.y, _321.z, _275.w);
_28 _323 = _276;
_323._m0 = _322;
@ -229,8 +224,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_364 = _344;
}
float3 _365 = _364 * 0.75;
float3 _368 = _322.xyz + _365;
float3 _368 = _322.xyz + (_364 * 0.75);
float4 _369 = float4(_368.x, _368.y, _368.z, _322.w);
_28 _370 = _323;
_370._m0 = _369;
@ -246,8 +240,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_411 = _391;
}
float3 _412 = _411 * 1.0;
float3 _415 = _369.xyz + _412;
float3 _415 = _369.xyz + (_411 * 1.0);
float4 _416 = float4(_415.x, _415.y, _415.z, _369.w);
_28 _417 = _370;
_417._m0 = _416;
@ -263,8 +256,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_458 = _438;
}
float3 _459 = _458 * 0.75;
float3 _462 = _416.xyz + _459;
float3 _462 = _416.xyz + (_458 * 0.75);
float4 _463 = float4(_462.x, _462.y, _462.z, _416.w);
_28 _464 = _417;
_464._m0 = _463;
@ -280,8 +272,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_505 = _485;
}
float3 _506 = _505 * 0.5;
float3 _509 = _463.xyz + _506;
float3 _509 = _463.xyz + (_505 * 0.5);
float4 _510 = float4(_509.x, _509.y, _509.z, _463.w);
_28 _511 = _464;
_511._m0 = _510;
@ -297,8 +288,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_552 = _532;
}
float3 _553 = _552 * 0.5;
float3 _556 = _510.xyz + _553;
float3 _556 = _510.xyz + (_552 * 0.5);
float4 _557 = float4(_556.x, _556.y, _556.z, _510.w);
_28 _558 = _511;
_558._m0 = _557;
@ -314,8 +304,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_599 = _579;
}
float3 _600 = _599 * 0.75;
float3 _603 = _557.xyz + _600;
float3 _603 = _557.xyz + (_599 * 0.75);
float4 _604 = float4(_603.x, _603.y, _603.z, _557.w);
_28 _605 = _558;
_605._m0 = _604;
@ -331,8 +320,7 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff
{
_646 = _626;
}
float3 _647 = _646 * 0.5;
float3 _650 = _604.xyz + _647;
float3 _650 = _604.xyz + (_646 * 0.5);
float4 _651 = float4(_650.x, _650.y, _650.z, _604.w);
_28 _652 = _605;
_652._m0 = _651;

View File

@ -36,9 +36,7 @@ bool frustum_cull(thread const float2& p0, constant UBO& v_41)
float radius = 0.5 * length(bb_max - bb_min);
float3 f0 = float3(dot(v_41.uFrustum[0], float4(center, 1.0)), dot(v_41.uFrustum[1], float4(center, 1.0)), dot(v_41.uFrustum[2], float4(center, 1.0)));
float3 f1 = float3(dot(v_41.uFrustum[3], float4(center, 1.0)), dot(v_41.uFrustum[4], float4(center, 1.0)), dot(v_41.uFrustum[5], float4(center, 1.0)));
float3 _199 = f0;
float _200 = radius;
bool _205 = any(_199 <= float3(-_200));
bool _205 = any(f0 <= float3(-radius));
bool _215;
if (!_205)
{

View File

@ -147,7 +147,6 @@ void main()
_193 = _192;
break;
} while (false);
vec4 _194 = _193 * 1.0;
vec4 _220;
do
{
@ -165,16 +164,15 @@ void main()
_220 = _219;
break;
} while (false);
vec2 _221 = _220.wy;
vec2 _223 = vec2(1.0);
vec2 _224 = (_221 * 2.0) - _223;
vec2 _224 = (_220.wy * 2.0) - _223;
vec3 _232 = vec3(_224, sqrt(clamp(1.0 + dot(-_224, _224), 0.0, 1.0)));
vec2 _240 = (texture(SPIRV_Cross_CombinedNormalDetailMapTextureNormalDetailMapSampler, _166 * 0.0).wy * 2.0) - _223;
vec2 _252 = _232.xy + (vec3(_240, sqrt(clamp(1.0 + dot(-_240, _240), 0.0, 1.0))).xy * 0.0);
vec3 _253 = vec3(_252.x, _252.y, _232.z);
vec2 _255 = _253.xy * _165;
vec3 _256 = vec3(_255.x, _255.y, _253.z);
vec3 _271 = ((IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0);
vec3 _271 = ((IN_Color.xyz * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0);
vec4 _298;
do
{

View File

@ -93,11 +93,13 @@ void main()
{
if (l == 5)
{
l++;
int _172 = l;
l = _172 + 1;
continue;
}
idat += vec4(1.0);
l++;
int _172 = l;
l = _172 + 1;
continue;
}
_177.out_data[ident] = idat;

View File

@ -110,8 +110,7 @@ void main()
{
_129 = _109;
}
vec3 _130 = _129 * 0.5;
vec3 _133 = vec4(0.0).xyz + _130;
vec3 _133 = vec4(0.0).xyz + (_129 * 0.5);
vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w);
_28 _135 = _77;
_135._m0 = _134;
@ -127,8 +126,7 @@ void main()
{
_176 = _156;
}
vec3 _177 = _176 * 0.5;
vec3 _180 = _134.xyz + _177;
vec3 _180 = _134.xyz + (_176 * 0.5);
vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w);
_28 _182 = _135;
_182._m0 = _181;
@ -144,8 +142,7 @@ void main()
{
_223 = _203;
}
vec3 _224 = _223 * 0.75;
vec3 _227 = _181.xyz + _224;
vec3 _227 = _181.xyz + (_223 * 0.75);
vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w);
_28 _229 = _182;
_229._m0 = _228;
@ -161,8 +158,7 @@ void main()
{
_270 = _250;
}
vec3 _271 = _270 * 0.5;
vec3 _274 = _228.xyz + _271;
vec3 _274 = _228.xyz + (_270 * 0.5);
vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w);
_28 _276 = _229;
_276._m0 = _275;
@ -178,8 +174,7 @@ void main()
{
_317 = _297;
}
vec3 _318 = _317 * 0.5;
vec3 _321 = _275.xyz + _318;
vec3 _321 = _275.xyz + (_317 * 0.5);
vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w);
_28 _323 = _276;
_323._m0 = _322;
@ -195,8 +190,7 @@ void main()
{
_364 = _344;
}
vec3 _365 = _364 * 0.75;
vec3 _368 = _322.xyz + _365;
vec3 _368 = _322.xyz + (_364 * 0.75);
vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w);
_28 _370 = _323;
_370._m0 = _369;
@ -212,8 +206,7 @@ void main()
{
_411 = _391;
}
vec3 _412 = _411 * 1.0;
vec3 _415 = _369.xyz + _412;
vec3 _415 = _369.xyz + (_411 * 1.0);
vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w);
_28 _417 = _370;
_417._m0 = _416;
@ -229,8 +222,7 @@ void main()
{
_458 = _438;
}
vec3 _459 = _458 * 0.75;
vec3 _462 = _416.xyz + _459;
vec3 _462 = _416.xyz + (_458 * 0.75);
vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w);
_28 _464 = _417;
_464._m0 = _463;
@ -246,8 +238,7 @@ void main()
{
_505 = _485;
}
vec3 _506 = _505 * 0.5;
vec3 _509 = _463.xyz + _506;
vec3 _509 = _463.xyz + (_505 * 0.5);
vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w);
_28 _511 = _464;
_511._m0 = _510;
@ -263,8 +254,7 @@ void main()
{
_552 = _532;
}
vec3 _553 = _552 * 0.5;
vec3 _556 = _510.xyz + _553;
vec3 _556 = _510.xyz + (_552 * 0.5);
vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w);
_28 _558 = _511;
_558._m0 = _557;
@ -280,8 +270,7 @@ void main()
{
_599 = _579;
}
vec3 _600 = _599 * 0.75;
vec3 _603 = _557.xyz + _600;
vec3 _603 = _557.xyz + (_599 * 0.75);
vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w);
_28 _605 = _558;
_605._m0 = _604;
@ -297,8 +286,7 @@ void main()
{
_646 = _626;
}
vec3 _647 = _646 * 0.5;
vec3 _650 = _604.xyz + _647;
vec3 _650 = _604.xyz + (_646 * 0.5);
vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w);
_28 _652 = _605;
_652._m0 = _651;

View File

@ -27,7 +27,6 @@ uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
{
_86 = a.x;
}
uint _94 = _86;
uint _97;
if (sel.y)
{
@ -37,7 +36,7 @@ uvec2 workaround_mix(uvec2 a, uvec2 b, bvec2 sel)
{
_97 = a.y;
}
return uvec2(_94, _97);
return uvec2(_86, _97);
}
vec2 alias(vec2 i, vec2 N)

View File

@ -26,9 +26,7 @@ bool frustum_cull(vec2 p0)
float radius = 0.5 * length(bb_max - bb_min);
vec3 f0 = vec3(dot(_41.uFrustum[0], vec4(center, 1.0)), dot(_41.uFrustum[1], vec4(center, 1.0)), dot(_41.uFrustum[2], vec4(center, 1.0)));
vec3 f1 = vec3(dot(_41.uFrustum[3], vec4(center, 1.0)), dot(_41.uFrustum[4], vec4(center, 1.0)), dot(_41.uFrustum[5], vec4(center, 1.0)));
vec3 _199 = f0;
float _200 = radius;
bool _205 = any(lessThanEqual(_199, vec3(-_200)));
bool _205 = any(lessThanEqual(f0, vec3(-radius)));
bool _215;
if (!_205)
{

View File

@ -67,7 +67,6 @@ vec2 warp_position()
{
_110 = 0u;
}
uint _116 = _110;
uint _120;
if (uPosition.y < 32u)
{
@ -77,7 +76,7 @@ vec2 warp_position()
{
_120 = 0u;
}
uvec2 rounding = uvec2(_116, _120);
uvec2 rounding = uvec2(_110, _120);
vec4 lower_upper_snapped = vec4((uPosition + rounding).xyxy & (~mask).xxyy);
return mix(lower_upper_snapped.xy, lower_upper_snapped.zw, vec2(fract_lod));
}

View File

@ -7829,12 +7829,24 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (meta.storage_is_invariant)
set_decoration(ops[1], DecorationInvariant);
// If we have some expression dependencies in our access chain, this access chain is technically a forwarded
// temporary which could be subject to invalidation.
// Need to assume we're forwarded while calling inherit_expression_depdendencies.
forwarded_temporaries.insert(ops[1]);
// The access chain itself is never forced to a temporary, but its dependencies might.
suppressed_usage_tracking.insert(ops[1]);
for (uint32_t i = 2; i < length; i++)
{
inherit_expression_dependencies(ops[1], ops[i]);
add_implied_read_expression(expr, ops[i]);
}
// If we have no dependencies after all, i.e., all indices in the access chain are immutable temporaries,
// we're not forwarded after all.
if (expr.expression_dependencies.empty())
forwarded_temporaries.erase(ops[1]);
break;
}
@ -8230,9 +8242,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{
// Need a copy.
// For pointer types, we copy the pointer itself.
statement(declare_temporary(result_type, id), to_expression(rhs), ";");
statement(declare_temporary(result_type, id), to_unpacked_expression(rhs), ";");
set<SPIRExpression>(id, to_name(id), result_type, true);
inherit_expression_dependencies(id, rhs);
}
else
{
@ -8249,7 +8260,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// If we're copying an access chain, need to inherit the read expressions.
auto *rhs_expr = maybe_get<SPIRExpression>(rhs);
if (rhs_expr)
{
e.implied_read_expressions = rhs_expr->implied_read_expressions;
e.expression_dependencies = rhs_expr->expression_dependencies;
}
}
break;
}
@ -11130,16 +11144,11 @@ void CompilerGLSL::branch_to_continue(uint32_t from, uint32_t to)
{
// Just emit the whole block chain as is.
auto usage_counts = expression_usage_counts;
auto invalid = invalid_expressions;
emit_block_chain(to_block);
// Expression usage counts and invalid expressions
// are moot after returning from the continue block.
// Since we emit the same block multiple times,
// we don't want to invalidate ourselves.
// Expression usage counts are moot after returning from the continue block.
expression_usage_counts = usage_counts;
invalid_expressions = invalid;
}
else
{
@ -11182,7 +11191,6 @@ void CompilerGLSL::branch(uint32_t from, uint32_t to)
{
flush_phi(from, to);
flush_control_dependent_expressions(from);
flush_all_active_variables();
// This is only a continue if we branch to our loop dominator.
if ((ir.block_meta[to] & ParsedIR::BLOCK_META_LOOP_HEADER_BIT) != 0 && get<SPIRBlock>(from).loop_dominator == to)