diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp index 20d6fe9..4176830 100644 --- a/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp +++ b/reference/opt/shaders-msl/asm/comp/bitcast_sar.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = uint4(int4(_5._m1) >> _5._m0); - _6._m0 = uint4(_5._m0 >> int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); - _6._m0 = uint4(_5._m0 >> _5._m0); - _6._m1 = int4(_5._m1) >> int4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = int4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> int4(_5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = uint4(int4(_23) >> _22); + _6._m0 = uint4(_22 >> int4(_23)); + _6._m0 = uint4(int4(_23) >> int4(_23)); + _6._m0 = uint4(_22 >> _22); + _6._m1 = int4(_23) >> int4(_23); + _6._m1 = _22 >> _22; + _6._m1 = int4(_23) >> _22; + _6._m1 = _22 >> int4(_23); } diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp index f18b318..6b80dff 100644 --- a/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ b/reference/opt/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = uint4(int4(_5._m1) / _5._m0); - _6._m0 = uint4(_5._m0 / int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); - _6._m0 = uint4(_5._m0 / _5._m0); - _6._m1 = int4(_5._m1) / int4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = int4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / int4(_5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = uint4(int4(_23) / _22); + _6._m0 = uint4(_22 / int4(_23)); + _6._m0 = uint4(int4(_23) / int4(_23)); + _6._m0 = uint4(_22 / _22); + _6._m1 = int4(_23) / int4(_23); + _6._m1 = _22 / _22; + _6._m1 = int4(_23) / _22; + _6._m1 = _22 / int4(_23); } diff --git a/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp b/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp index 9fd60be..1dfca39 100644 --- a/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp +++ b/reference/opt/shaders-msl/asm/comp/bitcast_slr.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = _5._m1 >> uint4(_5._m0); - _6._m0 = uint4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uint4(_5._m0) >> uint4(_5._m0); - _6._m1 = int4(_5._m1 >> _5._m1); - _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); - _6._m1 = int4(_5._m1 >> uint4(_5._m0)); - _6._m1 = int4(uint4(_5._m0) >> _5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = _23 >> uint4(_22); + _6._m0 = uint4(_22) >> _23; + _6._m0 = _23 >> _23; + _6._m0 = uint4(_22) >> uint4(_22); + _6._m1 = int4(_23 >> _23); + _6._m1 = int4(uint4(_22) >> uint4(_22)); + _6._m1 = int4(_23 >> uint4(_22)); + _6._m1 = int4(uint4(_22) >> _23); } diff --git a/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag index 2ac8cbe..18fb7dc 100644 --- a/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -154,6 +154,7 @@ 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 { @@ -179,7 +180,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(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 * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); + float3 _271 = ((in.IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); float4 _298; do { diff --git a/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 97daea5..6bf9540 100644 --- a/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/reference/opt/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -114,7 +114,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _129 = _109; } - float3 _133 = float4(0.0).xyz + (_129 * 0.5); + float3 _130 = _129 * 0.5; + float3 _133 = float4(0.0).xyz + _130; float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); _28 _135 = _77; _135._m0 = _134; @@ -130,7 +131,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _176 = _156; } - float3 _180 = _134.xyz + (_176 * 0.5); + float3 _177 = _176 * 0.5; + float3 _180 = _134.xyz + _177; float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); _28 _182 = _135; _182._m0 = _181; @@ -146,7 +148,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _223 = _203; } - float3 _227 = _181.xyz + (_223 * 0.75); + float3 _224 = _223 * 0.75; + float3 _227 = _181.xyz + _224; float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); _28 _229 = _182; _229._m0 = _228; @@ -162,7 +165,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _270 = _250; } - float3 _274 = _228.xyz + (_270 * 0.5); + float3 _271 = _270 * 0.5; + float3 _274 = _228.xyz + _271; float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); _28 _276 = _229; _276._m0 = _275; @@ -178,7 +182,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _317 = _297; } - float3 _321 = _275.xyz + (_317 * 0.5); + float3 _318 = _317 * 0.5; + float3 _321 = _275.xyz + _318; float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); _28 _323 = _276; _323._m0 = _322; @@ -194,7 +199,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _364 = _344; } - float3 _368 = _322.xyz + (_364 * 0.75); + float3 _365 = _364 * 0.75; + float3 _368 = _322.xyz + _365; float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); _28 _370 = _323; _370._m0 = _369; @@ -210,7 +216,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _411 = _391; } - float3 _415 = _369.xyz + (_411 * 1.0); + float3 _412 = _411 * 1.0; + float3 _415 = _369.xyz + _412; float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); _28 _417 = _370; _417._m0 = _416; @@ -226,7 +233,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _458 = _438; } - float3 _462 = _416.xyz + (_458 * 0.75); + float3 _459 = _458 * 0.75; + float3 _462 = _416.xyz + _459; float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); _28 _464 = _417; _464._m0 = _463; @@ -242,7 +250,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _505 = _485; } - float3 _509 = _463.xyz + (_505 * 0.5); + float3 _506 = _505 * 0.5; + float3 _509 = _463.xyz + _506; float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); _28 _511 = _464; _511._m0 = _510; @@ -258,7 +267,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _552 = _532; } - float3 _556 = _510.xyz + (_552 * 0.5); + float3 _553 = _552 * 0.5; + float3 _556 = _510.xyz + _553; float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); _28 _558 = _511; _558._m0 = _557; @@ -274,7 +284,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _599 = _579; } - float3 _603 = _557.xyz + (_599 * 0.75); + float3 _600 = _599 * 0.75; + float3 _603 = _557.xyz + _600; float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); _28 _605 = _558; _605._m0 = _604; @@ -290,7 +301,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _646 = _626; } - float3 _650 = _604.xyz + (_646 * 0.5); + float3 _647 = _646 * 0.5; + float3 _650 = _604.xyz + _647; float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); _28 _652 = _605; _652._m0 = _651; diff --git a/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp b/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp index 79398b4..bdb3eeb 100644 --- a/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp +++ b/reference/opt/shaders/asm/comp/bitcast_iequal.asm.comp @@ -15,10 +15,12 @@ layout(binding = 1, std430) buffer _4_6 void main() { - bvec4 _34 = equal(ivec4(_5._m1), _5._m0); - bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); - bvec4 _36 = equal(_5._m1, _5._m1); - bvec4 _37 = equal(_5._m0, _5._m0); + ivec4 _30 = _5._m0; + uvec4 _31 = _5._m1; + bvec4 _34 = equal(ivec4(_31), _30); + bvec4 _35 = equal(_30, ivec4(_31)); + bvec4 _36 = equal(_31, _31); + bvec4 _37 = equal(_30, _30); _6._m0 = mix(uvec4(0u), uvec4(1u), _34); _6._m0 = mix(uvec4(0u), uvec4(1u), _35); _6._m0 = mix(uvec4(0u), uvec4(1u), _36); diff --git a/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp b/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp index 42a4ed0..283b444 100644 --- a/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp +++ b/reference/opt/shaders/asm/comp/bitcast_sar.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); - _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 >> _5._m0); - _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = ivec4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> ivec4(_5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = uvec4(ivec4(_23) >> _22); + _6._m0 = uvec4(_22 >> ivec4(_23)); + _6._m0 = uvec4(ivec4(_23) >> ivec4(_23)); + _6._m0 = uvec4(_22 >> _22); + _6._m1 = ivec4(_23) >> ivec4(_23); + _6._m1 = _22 >> _22; + _6._m1 = ivec4(_23) >> _22; + _6._m1 = _22 >> ivec4(_23); } diff --git a/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp b/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp index eeb97e1..e28c481 100644 --- a/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp +++ b/reference/opt/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); - _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 / _5._m0); - _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = ivec4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / ivec4(_5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = uvec4(ivec4(_23) / _22); + _6._m0 = uvec4(_22 / ivec4(_23)); + _6._m0 = uvec4(ivec4(_23) / ivec4(_23)); + _6._m0 = uvec4(_22 / _22); + _6._m1 = ivec4(_23) / ivec4(_23); + _6._m1 = _22 / _22; + _6._m1 = ivec4(_23) / _22; + _6._m1 = _22 / ivec4(_23); } diff --git a/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp b/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp index 25245e6..78efaf3 100644 --- a/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp +++ b/reference/opt/shaders/asm/comp/bitcast_slr.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = _5._m1 >> uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); - _6._m1 = ivec4(_5._m1 >> _5._m1); - _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); - _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); - _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = _23 >> uvec4(_22); + _6._m0 = uvec4(_22) >> _23; + _6._m0 = _23 >> _23; + _6._m0 = uvec4(_22) >> uvec4(_22); + _6._m1 = ivec4(_23 >> _23); + _6._m1 = ivec4(uvec4(_22) >> uvec4(_22)); + _6._m1 = ivec4(_23 >> uvec4(_22)); + _6._m1 = ivec4(uvec4(_22) >> _23); } diff --git a/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag index 98116cf..0179717 100644 --- a/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/opt/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -147,6 +147,7 @@ void main() _193 = _192; break; } while (false); + vec4 _194 = _193 * 1.0; vec4 _220; do { @@ -172,7 +173,7 @@ void main() 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 * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); + vec3 _271 = ((IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); vec4 _298; do { diff --git a/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag b/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag index 1c211ca..cdaf787 100644 --- a/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ b/reference/opt/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -110,7 +110,8 @@ void main() { _129 = _109; } - vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); + vec3 _130 = _129 * 0.5; + vec3 _133 = vec4(0.0).xyz + _130; vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); _28 _135 = _77; _135._m0 = _134; @@ -126,7 +127,8 @@ void main() { _176 = _156; } - vec3 _180 = _134.xyz + (_176 * 0.5); + vec3 _177 = _176 * 0.5; + vec3 _180 = _134.xyz + _177; vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); _28 _182 = _135; _182._m0 = _181; @@ -142,7 +144,8 @@ void main() { _223 = _203; } - vec3 _227 = _181.xyz + (_223 * 0.75); + vec3 _224 = _223 * 0.75; + vec3 _227 = _181.xyz + _224; vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); _28 _229 = _182; _229._m0 = _228; @@ -158,7 +161,8 @@ void main() { _270 = _250; } - vec3 _274 = _228.xyz + (_270 * 0.5); + vec3 _271 = _270 * 0.5; + vec3 _274 = _228.xyz + _271; vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); _28 _276 = _229; _276._m0 = _275; @@ -174,7 +178,8 @@ void main() { _317 = _297; } - vec3 _321 = _275.xyz + (_317 * 0.5); + vec3 _318 = _317 * 0.5; + vec3 _321 = _275.xyz + _318; vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); _28 _323 = _276; _323._m0 = _322; @@ -190,7 +195,8 @@ void main() { _364 = _344; } - vec3 _368 = _322.xyz + (_364 * 0.75); + vec3 _365 = _364 * 0.75; + vec3 _368 = _322.xyz + _365; vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); _28 _370 = _323; _370._m0 = _369; @@ -206,7 +212,8 @@ void main() { _411 = _391; } - vec3 _415 = _369.xyz + (_411 * 1.0); + vec3 _412 = _411 * 1.0; + vec3 _415 = _369.xyz + _412; vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); _28 _417 = _370; _417._m0 = _416; @@ -222,7 +229,8 @@ void main() { _458 = _438; } - vec3 _462 = _416.xyz + (_458 * 0.75); + vec3 _459 = _458 * 0.75; + vec3 _462 = _416.xyz + _459; vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); _28 _464 = _417; _464._m0 = _463; @@ -238,7 +246,8 @@ void main() { _505 = _485; } - vec3 _509 = _463.xyz + (_505 * 0.5); + vec3 _506 = _505 * 0.5; + vec3 _509 = _463.xyz + _506; vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); _28 _511 = _464; _511._m0 = _510; @@ -254,7 +263,8 @@ void main() { _552 = _532; } - vec3 _556 = _510.xyz + (_552 * 0.5); + vec3 _553 = _552 * 0.5; + vec3 _556 = _510.xyz + _553; vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); _28 _558 = _511; _558._m0 = _557; @@ -270,7 +280,8 @@ void main() { _599 = _579; } - vec3 _603 = _557.xyz + (_599 * 0.75); + vec3 _600 = _599 * 0.75; + vec3 _603 = _557.xyz + _600; vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); _28 _605 = _558; _605._m0 = _604; @@ -286,7 +297,8 @@ void main() { _646 = _626; } - vec3 _650 = _604.xyz + (_646 * 0.5); + vec3 _647 = _646 * 0.5; + vec3 _650 = _604.xyz + _647; vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); _28 _652 = _605; _652._m0 = _651; diff --git a/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp b/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp index 20d6fe9..4176830 100644 --- a/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp +++ b/reference/shaders-msl/asm/comp/bitcast_sar.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = uint4(int4(_5._m1) >> _5._m0); - _6._m0 = uint4(_5._m0 >> int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) >> int4(_5._m1)); - _6._m0 = uint4(_5._m0 >> _5._m0); - _6._m1 = int4(_5._m1) >> int4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = int4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> int4(_5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = uint4(int4(_23) >> _22); + _6._m0 = uint4(_22 >> int4(_23)); + _6._m0 = uint4(int4(_23) >> int4(_23)); + _6._m0 = uint4(_22 >> _22); + _6._m1 = int4(_23) >> int4(_23); + _6._m1 = _22 >> _22; + _6._m1 = int4(_23) >> _22; + _6._m1 = _22 >> int4(_23); } diff --git a/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp b/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp index f18b318..6b80dff 100644 --- a/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp +++ b/reference/shaders-msl/asm/comp/bitcast_sdiv.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = uint4(int4(_5._m1) / _5._m0); - _6._m0 = uint4(_5._m0 / int4(_5._m1)); - _6._m0 = uint4(int4(_5._m1) / int4(_5._m1)); - _6._m0 = uint4(_5._m0 / _5._m0); - _6._m1 = int4(_5._m1) / int4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = int4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / int4(_5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = uint4(int4(_23) / _22); + _6._m0 = uint4(_22 / int4(_23)); + _6._m0 = uint4(int4(_23) / int4(_23)); + _6._m0 = uint4(_22 / _22); + _6._m1 = int4(_23) / int4(_23); + _6._m1 = _22 / _22; + _6._m1 = int4(_23) / _22; + _6._m1 = _22 / int4(_23); } diff --git a/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp b/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp index 9fd60be..1dfca39 100644 --- a/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp +++ b/reference/shaders-msl/asm/comp/bitcast_slr.asm.comp @@ -17,13 +17,15 @@ struct _4 kernel void main0(device _3& _5 [[buffer(0)]], device _4& _6 [[buffer(1)]]) { - _6._m0 = _5._m1 >> uint4(_5._m0); - _6._m0 = uint4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uint4(_5._m0) >> uint4(_5._m0); - _6._m1 = int4(_5._m1 >> _5._m1); - _6._m1 = int4(uint4(_5._m0) >> uint4(_5._m0)); - _6._m1 = int4(_5._m1 >> uint4(_5._m0)); - _6._m1 = int4(uint4(_5._m0) >> _5._m1); + int4 _22 = _5._m0; + uint4 _23 = _5._m1; + _6._m0 = _23 >> uint4(_22); + _6._m0 = uint4(_22) >> _23; + _6._m0 = _23 >> _23; + _6._m0 = uint4(_22) >> uint4(_22); + _6._m1 = int4(_23 >> _23); + _6._m1 = int4(uint4(_22) >> uint4(_22)); + _6._m1 = int4(_23 >> uint4(_22)); + _6._m1 = int4(uint4(_22) >> _23); } diff --git a/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag index 2ac8cbe..18fb7dc 100644 --- a/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/shaders-msl/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -154,6 +154,7 @@ 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 { @@ -179,7 +180,7 @@ fragment main0_out main0(main0_in in [[stage_in]], constant CB0& _19 [[buffer(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 * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); + float3 _271 = ((in.IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (StudsMapTexture.sample(StudsMapSampler, _156.UvStuds).x * 2.0); float4 _298; do { diff --git a/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag b/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag index 97daea5..6bf9540 100644 --- a/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag +++ b/reference/shaders-msl/asm/frag/vector-shuffle-oom.asm.frag @@ -114,7 +114,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _129 = _109; } - float3 _133 = float4(0.0).xyz + (_129 * 0.5); + float3 _130 = _129 * 0.5; + float3 _133 = float4(0.0).xyz + _130; float4 _134 = float4(_133.x, _133.y, _133.z, float4(0.0).w); _28 _135 = _77; _135._m0 = _134; @@ -130,7 +131,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _176 = _156; } - float3 _180 = _134.xyz + (_176 * 0.5); + float3 _177 = _176 * 0.5; + float3 _180 = _134.xyz + _177; float4 _181 = float4(_180.x, _180.y, _180.z, _134.w); _28 _182 = _135; _182._m0 = _181; @@ -146,7 +148,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _223 = _203; } - float3 _227 = _181.xyz + (_223 * 0.75); + float3 _224 = _223 * 0.75; + float3 _227 = _181.xyz + _224; float4 _228 = float4(_227.x, _227.y, _227.z, _181.w); _28 _229 = _182; _229._m0 = _228; @@ -162,7 +165,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _270 = _250; } - float3 _274 = _228.xyz + (_270 * 0.5); + float3 _271 = _270 * 0.5; + float3 _274 = _228.xyz + _271; float4 _275 = float4(_274.x, _274.y, _274.z, _228.w); _28 _276 = _229; _276._m0 = _275; @@ -178,7 +182,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _317 = _297; } - float3 _321 = _275.xyz + (_317 * 0.5); + float3 _318 = _317 * 0.5; + float3 _321 = _275.xyz + _318; float4 _322 = float4(_321.x, _321.y, _321.z, _275.w); _28 _323 = _276; _323._m0 = _322; @@ -194,7 +199,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _364 = _344; } - float3 _368 = _322.xyz + (_364 * 0.75); + float3 _365 = _364 * 0.75; + float3 _368 = _322.xyz + _365; float4 _369 = float4(_368.x, _368.y, _368.z, _322.w); _28 _370 = _323; _370._m0 = _369; @@ -210,7 +216,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _411 = _391; } - float3 _415 = _369.xyz + (_411 * 1.0); + float3 _412 = _411 * 1.0; + float3 _415 = _369.xyz + _412; float4 _416 = float4(_415.x, _415.y, _415.z, _369.w); _28 _417 = _370; _417._m0 = _416; @@ -226,7 +233,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _458 = _438; } - float3 _462 = _416.xyz + (_458 * 0.75); + float3 _459 = _458 * 0.75; + float3 _462 = _416.xyz + _459; float4 _463 = float4(_462.x, _462.y, _462.z, _416.w); _28 _464 = _417; _464._m0 = _463; @@ -242,7 +250,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _505 = _485; } - float3 _509 = _463.xyz + (_505 * 0.5); + float3 _506 = _505 * 0.5; + float3 _509 = _463.xyz + _506; float4 _510 = float4(_509.x, _509.y, _509.z, _463.w); _28 _511 = _464; _511._m0 = _510; @@ -258,7 +267,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _552 = _532; } - float3 _556 = _510.xyz + (_552 * 0.5); + float3 _553 = _552 * 0.5; + float3 _556 = _510.xyz + _553; float4 _557 = float4(_556.x, _556.y, _556.z, _510.w); _28 _558 = _511; _558._m0 = _557; @@ -274,7 +284,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _599 = _579; } - float3 _603 = _557.xyz + (_599 * 0.75); + float3 _600 = _599 * 0.75; + float3 _603 = _557.xyz + _600; float4 _604 = float4(_603.x, _603.y, _603.z, _557.w); _28 _605 = _558; _605._m0 = _604; @@ -290,7 +301,8 @@ fragment main0_out main0(constant _6& _7 [[buffer(0)]], constant _10& _11 [[buff { _646 = _626; } - float3 _650 = _604.xyz + (_646 * 0.5); + float3 _647 = _646 * 0.5; + float3 _650 = _604.xyz + _647; float4 _651 = float4(_650.x, _650.y, _650.z, _604.w); _28 _652 = _605; _652._m0 = _651; diff --git a/reference/shaders/asm/comp/bitcast_iequal.asm.comp b/reference/shaders/asm/comp/bitcast_iequal.asm.comp index 79398b4..bdb3eeb 100644 --- a/reference/shaders/asm/comp/bitcast_iequal.asm.comp +++ b/reference/shaders/asm/comp/bitcast_iequal.asm.comp @@ -15,10 +15,12 @@ layout(binding = 1, std430) buffer _4_6 void main() { - bvec4 _34 = equal(ivec4(_5._m1), _5._m0); - bvec4 _35 = equal(_5._m0, ivec4(_5._m1)); - bvec4 _36 = equal(_5._m1, _5._m1); - bvec4 _37 = equal(_5._m0, _5._m0); + ivec4 _30 = _5._m0; + uvec4 _31 = _5._m1; + bvec4 _34 = equal(ivec4(_31), _30); + bvec4 _35 = equal(_30, ivec4(_31)); + bvec4 _36 = equal(_31, _31); + bvec4 _37 = equal(_30, _30); _6._m0 = mix(uvec4(0u), uvec4(1u), _34); _6._m0 = mix(uvec4(0u), uvec4(1u), _35); _6._m0 = mix(uvec4(0u), uvec4(1u), _36); diff --git a/reference/shaders/asm/comp/bitcast_sar.asm.comp b/reference/shaders/asm/comp/bitcast_sar.asm.comp index 42a4ed0..283b444 100644 --- a/reference/shaders/asm/comp/bitcast_sar.asm.comp +++ b/reference/shaders/asm/comp/bitcast_sar.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = uvec4(ivec4(_5._m1) >> _5._m0); - _6._m0 = uvec4(_5._m0 >> ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) >> ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 >> _5._m0); - _6._m1 = ivec4(_5._m1) >> ivec4(_5._m1); - _6._m1 = _5._m0 >> _5._m0; - _6._m1 = ivec4(_5._m1) >> _5._m0; - _6._m1 = _5._m0 >> ivec4(_5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = uvec4(ivec4(_23) >> _22); + _6._m0 = uvec4(_22 >> ivec4(_23)); + _6._m0 = uvec4(ivec4(_23) >> ivec4(_23)); + _6._m0 = uvec4(_22 >> _22); + _6._m1 = ivec4(_23) >> ivec4(_23); + _6._m1 = _22 >> _22; + _6._m1 = ivec4(_23) >> _22; + _6._m1 = _22 >> ivec4(_23); } diff --git a/reference/shaders/asm/comp/bitcast_sdiv.asm.comp b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp index eeb97e1..e28c481 100644 --- a/reference/shaders/asm/comp/bitcast_sdiv.asm.comp +++ b/reference/shaders/asm/comp/bitcast_sdiv.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = uvec4(ivec4(_5._m1) / _5._m0); - _6._m0 = uvec4(_5._m0 / ivec4(_5._m1)); - _6._m0 = uvec4(ivec4(_5._m1) / ivec4(_5._m1)); - _6._m0 = uvec4(_5._m0 / _5._m0); - _6._m1 = ivec4(_5._m1) / ivec4(_5._m1); - _6._m1 = _5._m0 / _5._m0; - _6._m1 = ivec4(_5._m1) / _5._m0; - _6._m1 = _5._m0 / ivec4(_5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = uvec4(ivec4(_23) / _22); + _6._m0 = uvec4(_22 / ivec4(_23)); + _6._m0 = uvec4(ivec4(_23) / ivec4(_23)); + _6._m0 = uvec4(_22 / _22); + _6._m1 = ivec4(_23) / ivec4(_23); + _6._m1 = _22 / _22; + _6._m1 = ivec4(_23) / _22; + _6._m1 = _22 / ivec4(_23); } diff --git a/reference/shaders/asm/comp/bitcast_slr.asm.comp b/reference/shaders/asm/comp/bitcast_slr.asm.comp index 25245e6..78efaf3 100644 --- a/reference/shaders/asm/comp/bitcast_slr.asm.comp +++ b/reference/shaders/asm/comp/bitcast_slr.asm.comp @@ -15,13 +15,15 @@ layout(binding = 1, std430) buffer _4_6 void main() { - _6._m0 = _5._m1 >> uvec4(_5._m0); - _6._m0 = uvec4(_5._m0) >> _5._m1; - _6._m0 = _5._m1 >> _5._m1; - _6._m0 = uvec4(_5._m0) >> uvec4(_5._m0); - _6._m1 = ivec4(_5._m1 >> _5._m1); - _6._m1 = ivec4(uvec4(_5._m0) >> uvec4(_5._m0)); - _6._m1 = ivec4(_5._m1 >> uvec4(_5._m0)); - _6._m1 = ivec4(uvec4(_5._m0) >> _5._m1); + ivec4 _22 = _5._m0; + uvec4 _23 = _5._m1; + _6._m0 = _23 >> uvec4(_22); + _6._m0 = uvec4(_22) >> _23; + _6._m0 = _23 >> _23; + _6._m0 = uvec4(_22) >> uvec4(_22); + _6._m1 = ivec4(_23 >> _23); + _6._m1 = ivec4(uvec4(_22) >> uvec4(_22)); + _6._m1 = ivec4(_23 >> uvec4(_22)); + _6._m1 = ivec4(uvec4(_22) >> _23); } diff --git a/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag index 98116cf..0179717 100644 --- a/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag +++ b/reference/shaders/asm/frag/inliner-dominator-inside-loop.asm.frag @@ -147,6 +147,7 @@ void main() _193 = _192; break; } while (false); + vec4 _194 = _193 * 1.0; vec4 _220; do { @@ -172,7 +173,7 @@ void main() 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 * (_193 * 1.0).xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); + vec3 _271 = ((IN_Color.xyz * _194.xyz) * (1.0 + (_256.x * 0.300000011920928955078125))) * (texture(SPIRV_Cross_CombinedStudsMapTextureStudsMapSampler, _156.UvStuds).x * 2.0); vec4 _298; do { diff --git a/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag b/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag index 1c211ca..cdaf787 100644 --- a/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag +++ b/reference/shaders/asm/frag/vector-shuffle-oom.asm.frag @@ -110,7 +110,8 @@ void main() { _129 = _109; } - vec3 _133 = vec4(0.0).xyz + (_129 * 0.5); + vec3 _130 = _129 * 0.5; + vec3 _133 = vec4(0.0).xyz + _130; vec4 _134 = vec4(_133.x, _133.y, _133.z, vec4(0.0).w); _28 _135 = _77; _135._m0 = _134; @@ -126,7 +127,8 @@ void main() { _176 = _156; } - vec3 _180 = _134.xyz + (_176 * 0.5); + vec3 _177 = _176 * 0.5; + vec3 _180 = _134.xyz + _177; vec4 _181 = vec4(_180.x, _180.y, _180.z, _134.w); _28 _182 = _135; _182._m0 = _181; @@ -142,7 +144,8 @@ void main() { _223 = _203; } - vec3 _227 = _181.xyz + (_223 * 0.75); + vec3 _224 = _223 * 0.75; + vec3 _227 = _181.xyz + _224; vec4 _228 = vec4(_227.x, _227.y, _227.z, _181.w); _28 _229 = _182; _229._m0 = _228; @@ -158,7 +161,8 @@ void main() { _270 = _250; } - vec3 _274 = _228.xyz + (_270 * 0.5); + vec3 _271 = _270 * 0.5; + vec3 _274 = _228.xyz + _271; vec4 _275 = vec4(_274.x, _274.y, _274.z, _228.w); _28 _276 = _229; _276._m0 = _275; @@ -174,7 +178,8 @@ void main() { _317 = _297; } - vec3 _321 = _275.xyz + (_317 * 0.5); + vec3 _318 = _317 * 0.5; + vec3 _321 = _275.xyz + _318; vec4 _322 = vec4(_321.x, _321.y, _321.z, _275.w); _28 _323 = _276; _323._m0 = _322; @@ -190,7 +195,8 @@ void main() { _364 = _344; } - vec3 _368 = _322.xyz + (_364 * 0.75); + vec3 _365 = _364 * 0.75; + vec3 _368 = _322.xyz + _365; vec4 _369 = vec4(_368.x, _368.y, _368.z, _322.w); _28 _370 = _323; _370._m0 = _369; @@ -206,7 +212,8 @@ void main() { _411 = _391; } - vec3 _415 = _369.xyz + (_411 * 1.0); + vec3 _412 = _411 * 1.0; + vec3 _415 = _369.xyz + _412; vec4 _416 = vec4(_415.x, _415.y, _415.z, _369.w); _28 _417 = _370; _417._m0 = _416; @@ -222,7 +229,8 @@ void main() { _458 = _438; } - vec3 _462 = _416.xyz + (_458 * 0.75); + vec3 _459 = _458 * 0.75; + vec3 _462 = _416.xyz + _459; vec4 _463 = vec4(_462.x, _462.y, _462.z, _416.w); _28 _464 = _417; _464._m0 = _463; @@ -238,7 +246,8 @@ void main() { _505 = _485; } - vec3 _509 = _463.xyz + (_505 * 0.5); + vec3 _506 = _505 * 0.5; + vec3 _509 = _463.xyz + _506; vec4 _510 = vec4(_509.x, _509.y, _509.z, _463.w); _28 _511 = _464; _511._m0 = _510; @@ -254,7 +263,8 @@ void main() { _552 = _532; } - vec3 _556 = _510.xyz + (_552 * 0.5); + vec3 _553 = _552 * 0.5; + vec3 _556 = _510.xyz + _553; vec4 _557 = vec4(_556.x, _556.y, _556.z, _510.w); _28 _558 = _511; _558._m0 = _557; @@ -270,7 +280,8 @@ void main() { _599 = _579; } - vec3 _603 = _557.xyz + (_599 * 0.75); + vec3 _600 = _599 * 0.75; + vec3 _603 = _557.xyz + _600; vec4 _604 = vec4(_603.x, _603.y, _603.z, _557.w); _28 _605 = _558; _605._m0 = _604; @@ -286,7 +297,8 @@ void main() { _646 = _626; } - vec3 _650 = _604.xyz + (_646 * 0.5); + vec3 _647 = _646 * 0.5; + vec3 _650 = _604.xyz + _647; vec4 _651 = vec4(_650.x, _650.y, _650.z, _604.w); _28 _652 = _605; _652._m0 = _651; diff --git a/reference/shaders/tesc/water_tess.tesc b/reference/shaders/tesc/water_tess.tesc index 26611b8..4daaa45 100644 --- a/reference/shaders/tesc/water_tess.tesc +++ b/reference/shaders/tesc/water_tess.tesc @@ -27,7 +27,8 @@ bool frustum_cull(vec2 p0) 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; - bool _205 = any(lessThanEqual(_199, vec3(-radius))); + float _200 = radius; + bool _205 = any(lessThanEqual(_199, vec3(-_200))); bool _215; if (!_205) { diff --git a/spirv_cross.cpp b/spirv_cross.cpp index f752532..9bbb582 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -2647,6 +2647,14 @@ void Compiler::inherit_expression_dependencies(uint32_t dst, uint32_t source_exp } auto &e = get(dst); + auto *phi = maybe_get(source_expression); + if (phi && phi->phi_variable) + { + // We have used a phi variable, which can change at the end of the block, + // so make sure we take a dependency on this phi variable. + phi->dependees.push_back(dst); + } + auto *s = maybe_get(source_expression); if (!s) return; @@ -2659,6 +2667,7 @@ void Compiler::inherit_expression_dependencies(uint32_t dst, uint32_t source_exp e_deps.insert(end(e_deps), begin(s_deps), end(s_deps)); // Eliminate duplicated dependencies. + sort(begin(e_deps), end(e_deps)); e_deps.erase(unique(begin(e_deps), end(e_deps)), end(e_deps)); } diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index d1c24d2..7e1de90 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -3239,6 +3239,8 @@ void CompilerGLSL::emit_binary_op_cast(uint32_t result_type, uint32_t result_id, expr += join(cast_op0, " ", op, " ", cast_op1); emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); } void CompilerGLSL::emit_unary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, const char *op) @@ -3280,6 +3282,8 @@ void CompilerGLSL::emit_binary_func_op_cast(uint32_t result_type, uint32_t resul } emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1)); + inherit_expression_dependencies(result_id, op0); + inherit_expression_dependencies(result_id, op1); } void CompilerGLSL::emit_trinary_func_op(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1, @@ -3503,6 +3507,9 @@ void CompilerGLSL::emit_mix_op(uint32_t result_type, uint32_t id, uint32_t left, } emit_op(result_type, id, expr, should_forward(left) && should_forward(right) && should_forward(lerp)); + inherit_expression_dependencies(id, left); + inherit_expression_dependencies(id, right); + inherit_expression_dependencies(id, lerp); } else emit_trinary_func_op(result_type, id, left, right, lerp, "mix"); @@ -3588,6 +3595,8 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) if (i.offset + length > spirv.size()) SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); + vector inherited_expressions; + uint32_t result_type = ops[0]; uint32_t id = ops[1]; uint32_t img = ops[2]; @@ -3599,6 +3608,8 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) bool fetch = false; const uint32_t *opt = nullptr; + inherited_expressions.push_back(coord); + switch (op) { case OpImageSampleDrefImplicitLod: @@ -3677,6 +3688,9 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) break; } + if (dref) + inherited_expressions.push_back(dref); + if (proj) coord_components++; if (imgtype.image.arrayed) @@ -3702,6 +3716,7 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) if (length && (flags & flag)) { v = *opt++; + inherited_expressions.push_back(v); length--; } }; @@ -3725,6 +3740,8 @@ void CompilerGLSL::emit_texture_op(const Instruction &i) expr += ")"; emit_op(result_type, id, expr, forward); + for (auto &inherit : inherited_expressions) + inherit_expression_dependencies(id, inherit); } // Returns the function name for a texture sampling function for the specified image and sampling characteristics. @@ -5803,7 +5820,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) { uint32_t result_type = ops[0]; uint32_t id = ops[1]; - const auto *elems = &ops[2]; + const auto * const elems = &ops[2]; length -= 2; bool forward = true; @@ -5887,6 +5904,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } emit_op(result_type, id, constructor_op, forward); + for (uint32_t i = 0; i < length; i++) + inherit_expression_dependencies(id, elems[i]); break; } @@ -5915,6 +5934,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) auto expr = access_chain_internal(ops[2], &ops[3], 1, false); emit_op(result_type, id, expr, should_forward(ops[2])); + inherit_expression_dependencies(id, ops[2]); + inherit_expression_dependencies(id, ops[3]); break; } @@ -5951,12 +5972,14 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // from expression causing it to be forced to an actual temporary in GLSL. auto expr = access_chain_internal(ops[2], &ops[3], length, true, true); auto &e = emit_op(result_type, id, expr, true, !expression_is_forwarded(ops[2])); + inherit_expression_dependencies(id, ops[2]); e.base_expression = ops[2]; } else { auto expr = access_chain_internal(ops[2], &ops[3], length, true); emit_op(result_type, id, expr, should_forward(ops[2]), !expression_is_forwarded(ops[2])); + inherit_expression_dependencies(id, ops[2]); } break; } @@ -6008,6 +6031,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // For pointer types, we copy the pointer itself. statement(declare_temporary(result_type, id), to_expression(rhs), ";"); set(id, to_name(id), result_type, true); + inherit_expression_dependencies(id, rhs); } else { @@ -6082,6 +6106,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) // We inherit the forwardedness from our arguments to avoid flushing out to temporaries when it's not really needed. emit_op(result_type, id, expr, should_fwd, trivial_forward); + inherit_expression_dependencies(id, vec0); + inherit_expression_dependencies(id, vec1); break; } @@ -6483,6 +6509,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } emit_op(result_type, id, op, should_forward(arg)); + inherit_expression_dependencies(id, arg); break; } @@ -6960,6 +6987,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction) } else emit_op(result_type, id, imgexpr, false); + + inherit_expression_dependencies(id, ops[2]); + if (type.image.ms) + inherit_expression_dependencies(id, ops[5]); break; } @@ -8312,6 +8343,8 @@ void CompilerGLSL::flush_phi(uint32_t from, uint32_t to) if (!optimize_read_modify_write(lhs, rhs)) statement(lhs, " = ", rhs, ";"); } + + register_write(phi.function_variable); } } } diff --git a/spirv_hlsl.cpp b/spirv_hlsl.cpp index b4343a3..c779fab 100644 --- a/spirv_hlsl.cpp +++ b/spirv_hlsl.cpp @@ -2299,6 +2299,8 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) if (i.offset + length > spirv.size()) SPIRV_CROSS_THROW("Compiler::parse() opcode out of range."); + vector inherited_expressions; + uint32_t result_type = ops[0]; uint32_t id = ops[1]; uint32_t img = ops[2]; @@ -2311,6 +2313,8 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) auto *combined_image = maybe_get(img); auto img_expr = to_expression(combined_image ? combined_image->image : img); + inherited_expressions.push_back(coord); + switch (op) { case OpImageSampleDrefImplicitLod: @@ -2384,6 +2388,9 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) break; } + if (dref) + inherited_expressions.push_back(dref); + if (proj) coord_components++; if (imgtype.image.arrayed) @@ -2410,6 +2417,7 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) if (length && (flags & flag)) { v = *opt++; + inherited_expressions.push_back(v); length--; } }; @@ -2694,6 +2702,9 @@ void CompilerHLSL::emit_texture_op(const Instruction &i) { emit_op(result_type, id, expr, forward, false); } + + for (auto &inherit : inherited_expressions) + inherit_expression_dependencies(id, inherit); } string CompilerHLSL::to_resource_binding(const SPIRVariable &var) @@ -3911,6 +3922,10 @@ void CompilerHLSL::emit_instruction(const Instruction &instruction) } else emit_op(result_type, id, imgexpr, false); + + inherit_expression_dependencies(id, ops[2]); + if (type.image.ms) + inherit_expression_dependencies(id, ops[5]); break; }