diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b53024f9..2be2de72e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -266,6 +266,7 @@ By @sagudev in [#10307](https://github.com/gfx-rs/wgpu/pull/10307). - Prevent invalid IR from being generated when using a ray query in a loop. By @Vecvec in [#9945](https://github.com/gfx-rs/wgpu/pull/9945) - Raise a type error, rather than panic, for some cases of an invalid `select` argument type in WGSL constant evaluation. By @ErichDonGubler in [#10350](https://github.com/gfx-rs/wgpu/pull/10350). - Fix `sign` returning unexpected values for floating-point arguments in the HLSL backend. By @ErichDonGubler in [#10434](https://github.com/gfx-rs/wgpu/pull/10434). +- Fix invalid MSL generated for `textureSampleGrad` with 3D and cube textures, which emitted `metal::gradient2d` for every texture dimension. By @ErichDonGubler in [#10573](https://github.com/gfx-rs/wgpu/pull/10573). #### DX12 diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 4b0731c52..575fc6c8d 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -1364,7 +1364,21 @@ impl Writer { write!(self.out, ")")?; } crate::SampleLevel::Gradient { x, y } => { - write!(self.out, ", {NAMESPACE}::gradient2d(")?; + let dim = match *context.resolve_type(image) { + crate::TypeInner::Image { dim, .. } => dim, + ref other => unreachable!("Unexpected type {other:?}"), + }; + let gradient = match dim { + crate::ImageDimension::D2 => "gradient2d", + crate::ImageDimension::D3 => "gradient3d", + crate::ImageDimension::Cube => "gradientcube", + // `image_needs_lod` is false for 1D images, so the + // `!has_levels` arm above has already handled them. + crate::ImageDimension::D1 => { + unreachable!("1D image can't be sampled with a gradient") + } + }; + write!(self.out, ", {NAMESPACE}::{gradient}(")?; self.put_expression(x, context, true)?; write!(self.out, ", ")?; self.put_expression(y, context, true)?; diff --git a/naga/tests/in/wgsl/image.wgsl b/naga/tests/in/wgsl/image.wgsl index 5ea62d241..3c6ec0fc1 100644 --- a/naga/tests/in/wgsl/image.wgsl +++ b/naga/tests/in/wgsl/image.wgsl @@ -127,6 +127,7 @@ fn texture_sample() -> @location(0) vec4 { a += textureSampleLevel(image_2d, sampler_reg, tc, level); a += textureSampleLevel(image_2d, sampler_reg, tc, level, offset); a += textureSampleBias(image_2d, sampler_reg, tc, 2.0, offset); + a += textureSampleGrad(image_2d, sampler_reg, tc, tc, tc); a += textureSampleBaseClampToEdge(image_2d, sampler_reg, tc); a += textureSample(image_2d_array, sampler_reg, tc, 0u); a += textureSample(image_2d_array, sampler_reg, tc, 0u, offset); @@ -138,12 +139,16 @@ fn texture_sample() -> @location(0) vec4 { a += textureSampleLevel(image_2d_array, sampler_reg, tc, 0, level); a += textureSampleLevel(image_2d_array, sampler_reg, tc, 0, level, offset); a += textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, offset); + a += textureSampleGrad(image_cube, sampler_reg, tc3, tc3, tc3); a += textureSample(image_cube_array, sampler_reg, tc3, 0u); a += textureSampleLevel(image_cube_array, sampler_reg, tc3, 0u, level); a += textureSampleBias(image_cube_array, sampler_reg, tc3, 0u, 2.0); + a += textureSampleGrad(image_cube_array, sampler_reg, tc3, 0u, tc3, tc3); a += textureSample(image_cube_array, sampler_reg, tc3, 0); a += textureSampleLevel(image_cube_array, sampler_reg, tc3, 0, level); a += textureSampleBias(image_cube_array, sampler_reg, tc3, 0, 2.0); + a += textureSampleGrad(image_cube_array, sampler_reg, tc3, 0, tc3, tc3); + a += textureSampleGrad(image_3d, sampler_reg, tc3, tc3, tc3); return a; } diff --git a/naga/tests/out/glsl/wgsl-image.texture_sample.Fragment.glsl b/naga/tests/out/glsl/wgsl-image.texture_sample.Fragment.glsl index 99614b6ab..bbe4843cf 100644 --- a/naga/tests/out/glsl/wgsl-image.texture_sample.Fragment.glsl +++ b/naga/tests/out/glsl/wgsl-image.texture_sample.Fragment.glsl @@ -5,8 +5,12 @@ uniform sampler2D _group_0_binding_1_fs; uniform sampler2DArray _group_0_binding_4_fs; +uniform samplerCube _group_0_binding_5_fs; + uniform samplerCubeArray _group_0_binding_6_fs; +uniform sampler3D _group_0_binding_7_fs; + layout(location = 0) out vec4 _fs2p_location0; void main() { @@ -33,58 +37,73 @@ void main() { vec4 _e41 = textureOffset(_group_0_binding_1_fs, vec2(_e1), ivec2(3, 1), 2.0); a = (_e37 + _e41); vec4 _e43 = a; - vec4 _e46 = textureLod(_group_0_binding_1_fs, vec2(_e1), 0.0); + vec4 _e46 = textureGrad(_group_0_binding_1_fs, vec2(_e1), _e1, _e1); a = (_e43 + _e46); vec4 _e48 = a; - vec4 _e52 = texture(_group_0_binding_4_fs, vec3(_e1, 0u)); - a = (_e48 + _e52); - vec4 _e54 = a; - vec4 _e58 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1)); - a = (_e54 + _e58); - vec4 _e60 = a; - vec4 _e64 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3); - a = (_e60 + _e64); - vec4 _e66 = a; - vec4 _e70 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3, ivec2(3, 1)); - a = (_e66 + _e70); - vec4 _e72 = a; - vec4 _e77 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1), 2.0); - a = (_e72 + _e77); - vec4 _e79 = a; - vec4 _e83 = texture(_group_0_binding_4_fs, vec3(_e1, 0)); - a = (_e79 + _e83); - vec4 _e85 = a; - vec4 _e89 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1)); - a = (_e85 + _e89); - vec4 _e91 = a; - vec4 _e95 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0), 2.3); - a = (_e91 + _e95); - vec4 _e97 = a; - vec4 _e101 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0), 2.3, ivec2(3, 1)); - a = (_e97 + _e101); - vec4 _e103 = a; - vec4 _e108 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1), 2.0); - a = (_e103 + _e108); - vec4 _e110 = a; - vec4 _e114 = texture(_group_0_binding_6_fs, vec4(_e3, 0u)); - a = (_e110 + _e114); - vec4 _e116 = a; - vec4 _e120 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0u), 2.3); - a = (_e116 + _e120); - vec4 _e122 = a; - vec4 _e127 = texture(_group_0_binding_6_fs, vec4(_e3, 0u), 2.0); - a = (_e122 + _e127); - vec4 _e129 = a; - vec4 _e133 = texture(_group_0_binding_6_fs, vec4(_e3, 0)); - a = (_e129 + _e133); - vec4 _e135 = a; - vec4 _e139 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0), 2.3); - a = (_e135 + _e139); - vec4 _e141 = a; - vec4 _e146 = texture(_group_0_binding_6_fs, vec4(_e3, 0), 2.0); - a = (_e141 + _e146); - vec4 _e148 = a; - _fs2p_location0 = _e148; + vec4 _e51 = textureLod(_group_0_binding_1_fs, vec2(_e1), 0.0); + a = (_e48 + _e51); + vec4 _e53 = a; + vec4 _e57 = texture(_group_0_binding_4_fs, vec3(_e1, 0u)); + a = (_e53 + _e57); + vec4 _e59 = a; + vec4 _e63 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1)); + a = (_e59 + _e63); + vec4 _e65 = a; + vec4 _e69 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3); + a = (_e65 + _e69); + vec4 _e71 = a; + vec4 _e75 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0u), 2.3, ivec2(3, 1)); + a = (_e71 + _e75); + vec4 _e77 = a; + vec4 _e82 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0u), ivec2(3, 1), 2.0); + a = (_e77 + _e82); + vec4 _e84 = a; + vec4 _e88 = texture(_group_0_binding_4_fs, vec3(_e1, 0)); + a = (_e84 + _e88); + vec4 _e90 = a; + vec4 _e94 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1)); + a = (_e90 + _e94); + vec4 _e96 = a; + vec4 _e100 = textureLod(_group_0_binding_4_fs, vec3(_e1, 0), 2.3); + a = (_e96 + _e100); + vec4 _e102 = a; + vec4 _e106 = textureLodOffset(_group_0_binding_4_fs, vec3(_e1, 0), 2.3, ivec2(3, 1)); + a = (_e102 + _e106); + vec4 _e108 = a; + vec4 _e113 = textureOffset(_group_0_binding_4_fs, vec3(_e1, 0), ivec2(3, 1), 2.0); + a = (_e108 + _e113); + vec4 _e115 = a; + vec4 _e118 = textureGrad(_group_0_binding_5_fs, vec3(_e3), _e3, _e3); + a = (_e115 + _e118); + vec4 _e120 = a; + vec4 _e124 = texture(_group_0_binding_6_fs, vec4(_e3, 0u)); + a = (_e120 + _e124); + vec4 _e126 = a; + vec4 _e130 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0u), 2.3); + a = (_e126 + _e130); + vec4 _e132 = a; + vec4 _e137 = texture(_group_0_binding_6_fs, vec4(_e3, 0u), 2.0); + a = (_e132 + _e137); + vec4 _e139 = a; + vec4 _e143 = textureGrad(_group_0_binding_6_fs, vec4(_e3, 0u), _e3, _e3); + a = (_e139 + _e143); + vec4 _e145 = a; + vec4 _e149 = texture(_group_0_binding_6_fs, vec4(_e3, 0)); + a = (_e145 + _e149); + vec4 _e151 = a; + vec4 _e155 = textureLod(_group_0_binding_6_fs, vec4(_e3, 0), 2.3); + a = (_e151 + _e155); + vec4 _e157 = a; + vec4 _e162 = texture(_group_0_binding_6_fs, vec4(_e3, 0), 2.0); + a = (_e157 + _e162); + vec4 _e164 = a; + vec4 _e168 = textureGrad(_group_0_binding_6_fs, vec4(_e3, 0), _e3, _e3); + a = (_e164 + _e168); + vec4 _e170 = a; + vec4 _e173 = textureGrad(_group_0_binding_7_fs, vec3(_e3), _e3, _e3); + a = (_e170 + _e173); + vec4 _e175 = a; + _fs2p_location0 = _e175; return; } diff --git a/naga/tests/out/hlsl/wgsl-image.hlsl b/naga/tests/out/hlsl/wgsl-image.hlsl index b3b381469..d6102cff7 100644 --- a/naga/tests/out/hlsl/wgsl-image.hlsl +++ b/naga/tests/out/hlsl/wgsl-image.hlsl @@ -291,58 +291,73 @@ float4 texture_sample() : SV_Target0 float4 _e41 = image_2d.SampleBias(sampler_reg, _e1, 2.0, int2(int2(int(3), int(1)))); a = (_e37 + _e41); float4 _e43 = a; - float4 _e46 = nagaTextureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + float4 _e46 = image_2d.SampleGrad(sampler_reg, _e1, _e1, _e1); a = (_e43 + _e46); float4 _e48 = a; - float4 _e52 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u)); - a = (_e48 + _e52); - float4 _e54 = a; - float4 _e58 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u), int2(int2(int(3), int(1)))); - a = (_e54 + _e58); - float4 _e60 = a; - float4 _e64 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3); - a = (_e60 + _e64); - float4 _e66 = a; - float4 _e70 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3, int2(int2(int(3), int(1)))); - a = (_e66 + _e70); - float4 _e72 = a; - float4 _e77 = image_2d_array.SampleBias(sampler_reg, float3(_e1, 0u), 2.0, int2(int2(int(3), int(1)))); - a = (_e72 + _e77); - float4 _e79 = a; - float4 _e83 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0))); - a = (_e79 + _e83); - float4 _e85 = a; - float4 _e89 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0)), int2(int2(int(3), int(1)))); - a = (_e85 + _e89); - float4 _e91 = a; - float4 _e95 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3); - a = (_e91 + _e95); - float4 _e97 = a; - float4 _e101 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3, int2(int2(int(3), int(1)))); - a = (_e97 + _e101); - float4 _e103 = a; - float4 _e108 = image_2d_array.SampleBias(sampler_reg, float3(_e1, int(0)), 2.0, int2(int2(int(3), int(1)))); - a = (_e103 + _e108); - float4 _e110 = a; - float4 _e114 = image_cube_array.Sample(sampler_reg, float4(_e3, 0u)); - a = (_e110 + _e114); - float4 _e116 = a; - float4 _e120 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, 0u), 2.3); - a = (_e116 + _e120); - float4 _e122 = a; - float4 _e127 = image_cube_array.SampleBias(sampler_reg, float4(_e3, 0u), 2.0); - a = (_e122 + _e127); - float4 _e129 = a; - float4 _e133 = image_cube_array.Sample(sampler_reg, float4(_e3, int(0))); - a = (_e129 + _e133); - float4 _e135 = a; - float4 _e139 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, int(0)), 2.3); - a = (_e135 + _e139); - float4 _e141 = a; - float4 _e146 = image_cube_array.SampleBias(sampler_reg, float4(_e3, int(0)), 2.0); - a = (_e141 + _e146); - float4 _e148 = a; - return _e148; + float4 _e51 = nagaTextureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + a = (_e48 + _e51); + float4 _e53 = a; + float4 _e57 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u)); + a = (_e53 + _e57); + float4 _e59 = a; + float4 _e63 = image_2d_array.Sample(sampler_reg, float3(_e1, 0u), int2(int2(int(3), int(1)))); + a = (_e59 + _e63); + float4 _e65 = a; + float4 _e69 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3); + a = (_e65 + _e69); + float4 _e71 = a; + float4 _e75 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, 0u), 2.3, int2(int2(int(3), int(1)))); + a = (_e71 + _e75); + float4 _e77 = a; + float4 _e82 = image_2d_array.SampleBias(sampler_reg, float3(_e1, 0u), 2.0, int2(int2(int(3), int(1)))); + a = (_e77 + _e82); + float4 _e84 = a; + float4 _e88 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0))); + a = (_e84 + _e88); + float4 _e90 = a; + float4 _e94 = image_2d_array.Sample(sampler_reg, float3(_e1, int(0)), int2(int2(int(3), int(1)))); + a = (_e90 + _e94); + float4 _e96 = a; + float4 _e100 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3); + a = (_e96 + _e100); + float4 _e102 = a; + float4 _e106 = image_2d_array.SampleLevel(sampler_reg, float3(_e1, int(0)), 2.3, int2(int2(int(3), int(1)))); + a = (_e102 + _e106); + float4 _e108 = a; + float4 _e113 = image_2d_array.SampleBias(sampler_reg, float3(_e1, int(0)), 2.0, int2(int2(int(3), int(1)))); + a = (_e108 + _e113); + float4 _e115 = a; + float4 _e118 = image_cube.SampleGrad(sampler_reg, _e3, _e3, _e3); + a = (_e115 + _e118); + float4 _e120 = a; + float4 _e124 = image_cube_array.Sample(sampler_reg, float4(_e3, 0u)); + a = (_e120 + _e124); + float4 _e126 = a; + float4 _e130 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, 0u), 2.3); + a = (_e126 + _e130); + float4 _e132 = a; + float4 _e137 = image_cube_array.SampleBias(sampler_reg, float4(_e3, 0u), 2.0); + a = (_e132 + _e137); + float4 _e139 = a; + float4 _e143 = image_cube_array.SampleGrad(sampler_reg, float4(_e3, 0u), _e3, _e3); + a = (_e139 + _e143); + float4 _e145 = a; + float4 _e149 = image_cube_array.Sample(sampler_reg, float4(_e3, int(0))); + a = (_e145 + _e149); + float4 _e151 = a; + float4 _e155 = image_cube_array.SampleLevel(sampler_reg, float4(_e3, int(0)), 2.3); + a = (_e151 + _e155); + float4 _e157 = a; + float4 _e162 = image_cube_array.SampleBias(sampler_reg, float4(_e3, int(0)), 2.0); + a = (_e157 + _e162); + float4 _e164 = a; + float4 _e168 = image_cube_array.SampleGrad(sampler_reg, float4(_e3, int(0)), _e3, _e3); + a = (_e164 + _e168); + float4 _e170 = a; + float4 _e173 = image_3d.SampleGrad(sampler_reg, _e3, _e3, _e3); + a = (_e170 + _e173); + float4 _e175 = a; + return _e175; } float texture_sample_comparison() : SV_Target0 diff --git a/naga/tests/out/msl/wgsl-image.metal b/naga/tests/out/msl/wgsl-image.metal index 1ce4fd19c..d69cfa264 100644 --- a/naga/tests/out/msl/wgsl-image.metal +++ b/naga/tests/out/msl/wgsl-image.metal @@ -133,7 +133,9 @@ fragment texture_sampleOutput texture_sample( metal::texture1d image_1d [[user(fake0)]] , metal::texture2d image_2d [[user(fake0)]] , metal::texture2d_array image_2d_array [[user(fake0)]] +, metal::texturecube image_cube [[user(fake0)]] , metal::texturecube_array image_cube_array [[user(fake0)]] +, metal::texture3d image_3d [[user(fake0)]] , metal::sampler sampler_reg [[user(fake0)]] ) { metal::float4 a = {}; @@ -159,58 +161,73 @@ fragment texture_sampleOutput texture_sample( metal::float4 _e41 = image_2d.sample(sampler_reg, _e1, metal::bias(2.0), _e6); a = _e37 + _e41; metal::float4 _e43 = a; - metal::float4 _e46 = nagaTextureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + metal::float4 _e46 = image_2d.sample(sampler_reg, _e1, metal::gradient2d(_e1, _e1)); a = _e43 + _e46; metal::float4 _e48 = a; - metal::float4 _e52 = image_2d_array.sample(sampler_reg, _e1, 0u); - a = _e48 + _e52; - metal::float4 _e54 = a; - metal::float4 _e58 = image_2d_array.sample(sampler_reg, _e1, 0u, _e6); - a = _e54 + _e58; - metal::float4 _e60 = a; - metal::float4 _e64 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3)); - a = _e60 + _e64; - metal::float4 _e66 = a; - metal::float4 _e70 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3), _e6); - a = _e66 + _e70; - metal::float4 _e72 = a; - metal::float4 _e77 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::bias(2.0), _e6); - a = _e72 + _e77; - metal::float4 _e79 = a; - metal::float4 _e83 = image_2d_array.sample(sampler_reg, _e1, 0); - a = _e79 + _e83; - metal::float4 _e85 = a; - metal::float4 _e89 = image_2d_array.sample(sampler_reg, _e1, 0, _e6); - a = _e85 + _e89; - metal::float4 _e91 = a; - metal::float4 _e95 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3)); - a = _e91 + _e95; - metal::float4 _e97 = a; - metal::float4 _e101 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3), _e6); - a = _e97 + _e101; - metal::float4 _e103 = a; - metal::float4 _e108 = image_2d_array.sample(sampler_reg, _e1, 0, metal::bias(2.0), _e6); - a = _e103 + _e108; - metal::float4 _e110 = a; - metal::float4 _e114 = image_cube_array.sample(sampler_reg, _e3, 0u); - a = _e110 + _e114; - metal::float4 _e116 = a; - metal::float4 _e120 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::level(2.3)); - a = _e116 + _e120; - metal::float4 _e122 = a; - metal::float4 _e127 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::bias(2.0)); - a = _e122 + _e127; - metal::float4 _e129 = a; - metal::float4 _e133 = image_cube_array.sample(sampler_reg, _e3, 0); - a = _e129 + _e133; - metal::float4 _e135 = a; - metal::float4 _e139 = image_cube_array.sample(sampler_reg, _e3, 0, metal::level(2.3)); - a = _e135 + _e139; - metal::float4 _e141 = a; - metal::float4 _e146 = image_cube_array.sample(sampler_reg, _e3, 0, metal::bias(2.0)); - a = _e141 + _e146; - metal::float4 _e148 = a; - return texture_sampleOutput { _e148 }; + metal::float4 _e51 = nagaTextureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + a = _e48 + _e51; + metal::float4 _e53 = a; + metal::float4 _e57 = image_2d_array.sample(sampler_reg, _e1, 0u); + a = _e53 + _e57; + metal::float4 _e59 = a; + metal::float4 _e63 = image_2d_array.sample(sampler_reg, _e1, 0u, _e6); + a = _e59 + _e63; + metal::float4 _e65 = a; + metal::float4 _e69 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3)); + a = _e65 + _e69; + metal::float4 _e71 = a; + metal::float4 _e75 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::level(2.3), _e6); + a = _e71 + _e75; + metal::float4 _e77 = a; + metal::float4 _e82 = image_2d_array.sample(sampler_reg, _e1, 0u, metal::bias(2.0), _e6); + a = _e77 + _e82; + metal::float4 _e84 = a; + metal::float4 _e88 = image_2d_array.sample(sampler_reg, _e1, 0); + a = _e84 + _e88; + metal::float4 _e90 = a; + metal::float4 _e94 = image_2d_array.sample(sampler_reg, _e1, 0, _e6); + a = _e90 + _e94; + metal::float4 _e96 = a; + metal::float4 _e100 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3)); + a = _e96 + _e100; + metal::float4 _e102 = a; + metal::float4 _e106 = image_2d_array.sample(sampler_reg, _e1, 0, metal::level(2.3), _e6); + a = _e102 + _e106; + metal::float4 _e108 = a; + metal::float4 _e113 = image_2d_array.sample(sampler_reg, _e1, 0, metal::bias(2.0), _e6); + a = _e108 + _e113; + metal::float4 _e115 = a; + metal::float4 _e118 = image_cube.sample(sampler_reg, _e3, metal::gradientcube(_e3, _e3)); + a = _e115 + _e118; + metal::float4 _e120 = a; + metal::float4 _e124 = image_cube_array.sample(sampler_reg, _e3, 0u); + a = _e120 + _e124; + metal::float4 _e126 = a; + metal::float4 _e130 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::level(2.3)); + a = _e126 + _e130; + metal::float4 _e132 = a; + metal::float4 _e137 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::bias(2.0)); + a = _e132 + _e137; + metal::float4 _e139 = a; + metal::float4 _e143 = image_cube_array.sample(sampler_reg, _e3, 0u, metal::gradientcube(_e3, _e3)); + a = _e139 + _e143; + metal::float4 _e145 = a; + metal::float4 _e149 = image_cube_array.sample(sampler_reg, _e3, 0); + a = _e145 + _e149; + metal::float4 _e151 = a; + metal::float4 _e155 = image_cube_array.sample(sampler_reg, _e3, 0, metal::level(2.3)); + a = _e151 + _e155; + metal::float4 _e157 = a; + metal::float4 _e162 = image_cube_array.sample(sampler_reg, _e3, 0, metal::bias(2.0)); + a = _e157 + _e162; + metal::float4 _e164 = a; + metal::float4 _e168 = image_cube_array.sample(sampler_reg, _e3, 0, metal::gradientcube(_e3, _e3)); + a = _e164 + _e168; + metal::float4 _e170 = a; + metal::float4 _e173 = image_3d.sample(sampler_reg, _e3, metal::gradient3d(_e3, _e3)); + a = _e170 + _e173; + metal::float4 _e175 = a; + return texture_sampleOutput { _e175 }; } diff --git a/naga/tests/out/spv/wgsl-image.spvasm b/naga/tests/out/spv/wgsl-image.spvasm index 21532c12c..e156fec33 100644 --- a/naga/tests/out/spv/wgsl-image.spvasm +++ b/naga/tests/out/spv/wgsl-image.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 569 +; Bound: 597 OpCapability Shader OpCapability Image1D OpCapability Sampled1D @@ -14,15 +14,15 @@ OpEntryPoint GLCompute %199 "depth_load" %197 OpEntryPoint Vertex %222 "queries" %220 OpEntryPoint Vertex %274 "levels_queries" %273 OpEntryPoint Fragment %305 "texture_sample" %304 -OpEntryPoint Fragment %463 "texture_sample_comparison" %461 -OpEntryPoint Fragment %518 "gather" %517 -OpEntryPoint Fragment %552 "depth_no_comparison" %551 +OpEntryPoint Fragment %491 "texture_sample_comparison" %489 +OpEntryPoint Fragment %546 "gather" %545 +OpEntryPoint Fragment %580 "depth_no_comparison" %579 OpExecutionMode %98 LocalSize 16 1 1 OpExecutionMode %199 LocalSize 16 1 1 OpExecutionMode %305 OriginUpperLeft -OpExecutionMode %463 OriginUpperLeft -OpExecutionMode %518 OriginUpperLeft -OpExecutionMode %552 OriginUpperLeft +OpExecutionMode %491 OriginUpperLeft +OpExecutionMode %546 OriginUpperLeft +OpExecutionMode %580 OriginUpperLeft %3 = OpString "image.wgsl" OpSource Unknown 0 %3 "@group(0) @binding(0) var image_mipmapped_src: texture_2d; @@ -153,6 +153,7 @@ fn texture_sample() -> @location(0) vec4 { a += textureSampleLevel(image_2d, sampler_reg, tc, level); a += textureSampleLevel(image_2d, sampler_reg, tc, level, offset); a += textureSampleBias(image_2d, sampler_reg, tc, 2.0, offset); + a += textureSampleGrad(image_2d, sampler_reg, tc, tc, tc); a += textureSampleBaseClampToEdge(image_2d, sampler_reg, tc); a += textureSample(image_2d_array, sampler_reg, tc, 0u); a += textureSample(image_2d_array, sampler_reg, tc, 0u, offset); @@ -164,12 +165,16 @@ fn texture_sample() -> @location(0) vec4 { a += textureSampleLevel(image_2d_array, sampler_reg, tc, 0, level); a += textureSampleLevel(image_2d_array, sampler_reg, tc, 0, level, offset); a += textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, offset); + a += textureSampleGrad(image_cube, sampler_reg, tc3, tc3, tc3); a += textureSample(image_cube_array, sampler_reg, tc3, 0u); a += textureSampleLevel(image_cube_array, sampler_reg, tc3, 0u, level); a += textureSampleBias(image_cube_array, sampler_reg, tc3, 0u, 2.0); + a += textureSampleGrad(image_cube_array, sampler_reg, tc3, 0u, tc3, tc3); a += textureSample(image_cube_array, sampler_reg, tc3, 0); a += textureSampleLevel(image_cube_array, sampler_reg, tc3, 0, level); a += textureSampleBias(image_cube_array, sampler_reg, tc3, 0, 2.0); + a += textureSampleGrad(image_cube_array, sampler_reg, tc3, 0, tc3, tc3); + a += textureSampleGrad(image_3d, sampler_reg, tc3, tc3, tc3); return a; } @@ -257,11 +262,11 @@ OpName %199 "depth_load" OpName %222 "queries" OpName %274 "levels_queries" OpName %305 "texture_sample" -OpName %320 "a" -OpName %463 "texture_sample_comparison" -OpName %468 "a" -OpName %518 "gather" -OpName %552 "depth_no_comparison" +OpName %322 "a" +OpName %491 "texture_sample_comparison" +OpName %496 "a" +OpName %546 "gather" +OpName %580 "depth_no_comparison" OpDecorate %29 DescriptorSet 0 OpDecorate %29 Binding 0 OpDecorate %31 DescriptorSet 0 @@ -314,9 +319,9 @@ OpDecorate %197 BuiltIn LocalInvocationId OpDecorate %220 BuiltIn Position OpDecorate %273 BuiltIn Position OpDecorate %304 Location 0 -OpDecorate %461 Location 0 -OpDecorate %517 Location 0 -OpDecorate %551 Location 0 +OpDecorate %489 Location 0 +OpDecorate %545 Location 0 +OpDecorate %579 Location 0 %2 = OpTypeVoid %5 = OpTypeInt 32 0 %4 = OpTypeImage %5 2D 0 0 0 1 Unknown @@ -412,37 +417,39 @@ OpDecorate %551 Location 0 %231 = OpConstant %5 0 %273 = OpVariable %221 Output %304 = OpVariable %221 Output -%311 = OpConstant %8 0.5 -%312 = OpTypeVector %8 2 -%313 = OpConstantComposite %312 %311 %311 -%314 = OpTypeVector %8 3 -%315 = OpConstantComposite %314 %311 %311 %311 -%316 = OpConstant %15 3 -%317 = OpConstantComposite %14 %316 %88 -%318 = OpConstant %8 2.3 -%319 = OpConstant %8 2 -%321 = OpTypePointer Function %24 -%322 = OpConstantNull %24 -%325 = OpTypeSampledImage %16 -%330 = OpTypeSampledImage %17 -%354 = OpConstant %8 1 -%355 = OpConstantComposite %312 %354 %354 -%362 = OpTypeSampledImage %19 -%423 = OpTypeSampledImage %21 -%462 = OpTypePointer Output %8 -%461 = OpVariable %462 Output -%469 = OpTypePointer Function %8 -%470 = OpConstantNull %8 -%473 = OpTypeSampledImage %26 -%478 = OpTypeSampledImage %27 -%491 = OpTypeSampledImage %28 -%517 = OpVariable %221 Output -%528 = OpConstant %5 1 -%531 = OpConstant %5 3 -%536 = OpTypeSampledImage %4 -%539 = OpTypeVector %15 4 -%540 = OpTypeSampledImage %18 -%551 = OpVariable %221 Output +%313 = OpConstant %8 0.5 +%314 = OpTypeVector %8 2 +%315 = OpConstantComposite %314 %313 %313 +%316 = OpTypeVector %8 3 +%317 = OpConstantComposite %316 %313 %313 %313 +%318 = OpConstant %15 3 +%319 = OpConstantComposite %14 %318 %88 +%320 = OpConstant %8 2.3 +%321 = OpConstant %8 2 +%323 = OpTypePointer Function %24 +%324 = OpConstantNull %24 +%327 = OpTypeSampledImage %16 +%332 = OpTypeSampledImage %17 +%360 = OpConstant %8 1 +%361 = OpConstantComposite %314 %360 %360 +%368 = OpTypeSampledImage %19 +%429 = OpTypeSampledImage %20 +%434 = OpTypeSampledImage %21 +%483 = OpTypeSampledImage %22 +%490 = OpTypePointer Output %8 +%489 = OpVariable %490 Output +%497 = OpTypePointer Function %8 +%498 = OpConstantNull %8 +%501 = OpTypeSampledImage %26 +%506 = OpTypeSampledImage %27 +%519 = OpTypeSampledImage %28 +%545 = OpVariable %221 Output +%556 = OpConstant %5 1 +%559 = OpConstant %5 3 +%564 = OpTypeSampledImage %4 +%567 = OpTypeVector %15 4 +%568 = OpTypeSampledImage %18 +%579 = OpVariable %221 Output %70 = OpFunction %14 None %71 %72 = OpFunctionParameter %14 %73 = OpFunctionParameter %14 @@ -729,396 +736,442 @@ OpReturn OpFunctionEnd %305 = OpFunction %2 None %99 %303 = OpLabel -%320 = OpVariable %321 Function %322 +%322 = OpVariable %323 Function %324 %306 = OpLoad %16 %44 %307 = OpLoad %17 %46 %308 = OpLoad %19 %51 -%309 = OpLoad %21 %55 -%310 = OpLoad %25 %61 -OpBranch %323 -%323 = OpLabel +%309 = OpLoad %20 %53 +%310 = OpLoad %21 %55 +%311 = OpLoad %22 %57 +%312 = OpLoad %25 %61 +OpBranch %325 +%325 = OpLabel OpLine %3 119 16 OpLine %3 120 17 OpLine %3 121 20 OpLine %3 1 1 -%324 = OpLoad %24 %320 +%326 = OpLoad %24 %322 OpLine %3 124 5 -%326 = OpSampledImage %325 %306 %310 -%327 = OpImageSampleImplicitLod %24 %326 %311 -%328 = OpFAdd %24 %324 %327 +%328 = OpSampledImage %327 %306 %312 +%329 = OpImageSampleImplicitLod %24 %328 %313 +%330 = OpFAdd %24 %326 %329 OpLine %3 124 5 -OpStore %320 %328 +OpStore %322 %330 OpLine %3 1 1 -%329 = OpLoad %24 %320 +%331 = OpLoad %24 %322 OpLine %3 125 5 -%331 = OpSampledImage %330 %307 %310 -%332 = OpImageSampleImplicitLod %24 %331 %313 -%333 = OpFAdd %24 %329 %332 +%333 = OpSampledImage %332 %307 %312 +%334 = OpImageSampleImplicitLod %24 %333 %315 +%335 = OpFAdd %24 %331 %334 OpLine %3 125 5 -OpStore %320 %333 +OpStore %322 %335 OpLine %3 1 1 -%334 = OpLoad %24 %320 +%336 = OpLoad %24 %322 OpLine %3 126 5 -%335 = OpSampledImage %330 %307 %310 -%336 = OpImageSampleImplicitLod %24 %335 %313 ConstOffset %317 -%337 = OpFAdd %24 %334 %336 +%337 = OpSampledImage %332 %307 %312 +%338 = OpImageSampleImplicitLod %24 %337 %315 ConstOffset %319 +%339 = OpFAdd %24 %336 %338 OpLine %3 126 5 -OpStore %320 %337 +OpStore %322 %339 OpLine %3 1 1 -%338 = OpLoad %24 %320 +%340 = OpLoad %24 %322 OpLine %3 127 5 -%339 = OpSampledImage %330 %307 %310 -%340 = OpImageSampleExplicitLod %24 %339 %313 Lod %318 -%341 = OpFAdd %24 %338 %340 +%341 = OpSampledImage %332 %307 %312 +%342 = OpImageSampleExplicitLod %24 %341 %315 Lod %320 +%343 = OpFAdd %24 %340 %342 OpLine %3 127 5 -OpStore %320 %341 +OpStore %322 %343 OpLine %3 1 1 -%342 = OpLoad %24 %320 +%344 = OpLoad %24 %322 OpLine %3 128 5 -%343 = OpSampledImage %330 %307 %310 -%344 = OpImageSampleExplicitLod %24 %343 %313 Lod|ConstOffset %318 %317 -%345 = OpFAdd %24 %342 %344 +%345 = OpSampledImage %332 %307 %312 +%346 = OpImageSampleExplicitLod %24 %345 %315 Lod|ConstOffset %320 %319 +%347 = OpFAdd %24 %344 %346 OpLine %3 128 5 -OpStore %320 %345 +OpStore %322 %347 OpLine %3 1 1 -%346 = OpLoad %24 %320 +%348 = OpLoad %24 %322 OpLine %3 129 5 -%347 = OpSampledImage %330 %307 %310 -%348 = OpImageSampleImplicitLod %24 %347 %313 Bias|ConstOffset %319 %317 -%349 = OpFAdd %24 %346 %348 +%349 = OpSampledImage %332 %307 %312 +%350 = OpImageSampleImplicitLod %24 %349 %315 Bias|ConstOffset %321 %319 +%351 = OpFAdd %24 %348 %350 OpLine %3 129 5 -OpStore %320 %349 +OpStore %322 %351 OpLine %3 1 1 -%350 = OpLoad %24 %320 +%352 = OpLoad %24 %322 OpLine %3 130 5 -%351 = OpImageQuerySizeLod %111 %307 %231 -%352 = OpConvertUToF %312 %351 -%353 = OpFDiv %312 %313 %352 -%356 = OpFSub %312 %355 %353 -%357 = OpExtInst %312 %1 NClamp %313 %353 %356 -%358 = OpSampledImage %330 %307 %310 -%359 = OpImageSampleExplicitLod %24 %358 %357 Lod %214 -%360 = OpFAdd %24 %350 %359 +%353 = OpSampledImage %332 %307 %312 +%354 = OpImageSampleExplicitLod %24 %353 %315 Grad %315 %315 +%355 = OpFAdd %24 %352 %354 OpLine %3 130 5 -OpStore %320 %360 +OpStore %322 %355 OpLine %3 1 1 -%361 = OpLoad %24 %320 +%356 = OpLoad %24 %322 OpLine %3 131 5 -%363 = OpConvertUToF %8 %231 -%364 = OpCompositeConstruct %314 %313 %363 -%365 = OpSampledImage %362 %308 %310 -%366 = OpImageSampleImplicitLod %24 %365 %364 -%367 = OpFAdd %24 %361 %366 +%357 = OpImageQuerySizeLod %111 %307 %231 +%358 = OpConvertUToF %314 %357 +%359 = OpFDiv %314 %315 %358 +%362 = OpFSub %314 %361 %359 +%363 = OpExtInst %314 %1 NClamp %315 %359 %362 +%364 = OpSampledImage %332 %307 %312 +%365 = OpImageSampleExplicitLod %24 %364 %363 Lod %214 +%366 = OpFAdd %24 %356 %365 OpLine %3 131 5 -OpStore %320 %367 +OpStore %322 %366 OpLine %3 1 1 -%368 = OpLoad %24 %320 +%367 = OpLoad %24 %322 OpLine %3 132 5 %369 = OpConvertUToF %8 %231 -%370 = OpCompositeConstruct %314 %313 %369 -%371 = OpSampledImage %362 %308 %310 -%372 = OpImageSampleImplicitLod %24 %371 %370 ConstOffset %317 -%373 = OpFAdd %24 %368 %372 +%370 = OpCompositeConstruct %316 %315 %369 +%371 = OpSampledImage %368 %308 %312 +%372 = OpImageSampleImplicitLod %24 %371 %370 +%373 = OpFAdd %24 %367 %372 OpLine %3 132 5 -OpStore %320 %373 +OpStore %322 %373 OpLine %3 1 1 -%374 = OpLoad %24 %320 +%374 = OpLoad %24 %322 OpLine %3 133 5 %375 = OpConvertUToF %8 %231 -%376 = OpCompositeConstruct %314 %313 %375 -%377 = OpSampledImage %362 %308 %310 -%378 = OpImageSampleExplicitLod %24 %377 %376 Lod %318 +%376 = OpCompositeConstruct %316 %315 %375 +%377 = OpSampledImage %368 %308 %312 +%378 = OpImageSampleImplicitLod %24 %377 %376 ConstOffset %319 %379 = OpFAdd %24 %374 %378 OpLine %3 133 5 -OpStore %320 %379 +OpStore %322 %379 OpLine %3 1 1 -%380 = OpLoad %24 %320 +%380 = OpLoad %24 %322 OpLine %3 134 5 %381 = OpConvertUToF %8 %231 -%382 = OpCompositeConstruct %314 %313 %381 -%383 = OpSampledImage %362 %308 %310 -%384 = OpImageSampleExplicitLod %24 %383 %382 Lod|ConstOffset %318 %317 +%382 = OpCompositeConstruct %316 %315 %381 +%383 = OpSampledImage %368 %308 %312 +%384 = OpImageSampleExplicitLod %24 %383 %382 Lod %320 %385 = OpFAdd %24 %380 %384 OpLine %3 134 5 -OpStore %320 %385 +OpStore %322 %385 OpLine %3 1 1 -%386 = OpLoad %24 %320 +%386 = OpLoad %24 %322 OpLine %3 135 5 %387 = OpConvertUToF %8 %231 -%388 = OpCompositeConstruct %314 %313 %387 -%389 = OpSampledImage %362 %308 %310 -%390 = OpImageSampleImplicitLod %24 %389 %388 Bias|ConstOffset %319 %317 +%388 = OpCompositeConstruct %316 %315 %387 +%389 = OpSampledImage %368 %308 %312 +%390 = OpImageSampleExplicitLod %24 %389 %388 Lod|ConstOffset %320 %319 %391 = OpFAdd %24 %386 %390 OpLine %3 135 5 -OpStore %320 %391 +OpStore %322 %391 OpLine %3 1 1 -%392 = OpLoad %24 %320 +%392 = OpLoad %24 %322 OpLine %3 136 5 -%393 = OpConvertSToF %8 %77 -%394 = OpCompositeConstruct %314 %313 %393 -%395 = OpSampledImage %362 %308 %310 -%396 = OpImageSampleImplicitLod %24 %395 %394 +%393 = OpConvertUToF %8 %231 +%394 = OpCompositeConstruct %316 %315 %393 +%395 = OpSampledImage %368 %308 %312 +%396 = OpImageSampleImplicitLod %24 %395 %394 Bias|ConstOffset %321 %319 %397 = OpFAdd %24 %392 %396 OpLine %3 136 5 -OpStore %320 %397 +OpStore %322 %397 OpLine %3 1 1 -%398 = OpLoad %24 %320 +%398 = OpLoad %24 %322 OpLine %3 137 5 %399 = OpConvertSToF %8 %77 -%400 = OpCompositeConstruct %314 %313 %399 -%401 = OpSampledImage %362 %308 %310 -%402 = OpImageSampleImplicitLod %24 %401 %400 ConstOffset %317 +%400 = OpCompositeConstruct %316 %315 %399 +%401 = OpSampledImage %368 %308 %312 +%402 = OpImageSampleImplicitLod %24 %401 %400 %403 = OpFAdd %24 %398 %402 OpLine %3 137 5 -OpStore %320 %403 +OpStore %322 %403 OpLine %3 1 1 -%404 = OpLoad %24 %320 +%404 = OpLoad %24 %322 OpLine %3 138 5 %405 = OpConvertSToF %8 %77 -%406 = OpCompositeConstruct %314 %313 %405 -%407 = OpSampledImage %362 %308 %310 -%408 = OpImageSampleExplicitLod %24 %407 %406 Lod %318 +%406 = OpCompositeConstruct %316 %315 %405 +%407 = OpSampledImage %368 %308 %312 +%408 = OpImageSampleImplicitLod %24 %407 %406 ConstOffset %319 %409 = OpFAdd %24 %404 %408 OpLine %3 138 5 -OpStore %320 %409 +OpStore %322 %409 OpLine %3 1 1 -%410 = OpLoad %24 %320 +%410 = OpLoad %24 %322 OpLine %3 139 5 %411 = OpConvertSToF %8 %77 -%412 = OpCompositeConstruct %314 %313 %411 -%413 = OpSampledImage %362 %308 %310 -%414 = OpImageSampleExplicitLod %24 %413 %412 Lod|ConstOffset %318 %317 +%412 = OpCompositeConstruct %316 %315 %411 +%413 = OpSampledImage %368 %308 %312 +%414 = OpImageSampleExplicitLod %24 %413 %412 Lod %320 %415 = OpFAdd %24 %410 %414 OpLine %3 139 5 -OpStore %320 %415 +OpStore %322 %415 OpLine %3 1 1 -%416 = OpLoad %24 %320 +%416 = OpLoad %24 %322 OpLine %3 140 5 %417 = OpConvertSToF %8 %77 -%418 = OpCompositeConstruct %314 %313 %417 -%419 = OpSampledImage %362 %308 %310 -%420 = OpImageSampleImplicitLod %24 %419 %418 Bias|ConstOffset %319 %317 +%418 = OpCompositeConstruct %316 %315 %417 +%419 = OpSampledImage %368 %308 %312 +%420 = OpImageSampleExplicitLod %24 %419 %418 Lod|ConstOffset %320 %319 %421 = OpFAdd %24 %416 %420 OpLine %3 140 5 -OpStore %320 %421 +OpStore %322 %421 OpLine %3 1 1 -%422 = OpLoad %24 %320 +%422 = OpLoad %24 %322 OpLine %3 141 5 -%424 = OpConvertUToF %8 %231 -%425 = OpCompositeConstruct %24 %315 %424 -%426 = OpSampledImage %423 %309 %310 -%427 = OpImageSampleImplicitLod %24 %426 %425 -%428 = OpFAdd %24 %422 %427 +%423 = OpConvertSToF %8 %77 +%424 = OpCompositeConstruct %316 %315 %423 +%425 = OpSampledImage %368 %308 %312 +%426 = OpImageSampleImplicitLod %24 %425 %424 Bias|ConstOffset %321 %319 +%427 = OpFAdd %24 %422 %426 OpLine %3 141 5 -OpStore %320 %428 +OpStore %322 %427 OpLine %3 1 1 -%429 = OpLoad %24 %320 +%428 = OpLoad %24 %322 OpLine %3 142 5 -%430 = OpConvertUToF %8 %231 -%431 = OpCompositeConstruct %24 %315 %430 -%432 = OpSampledImage %423 %309 %310 -%433 = OpImageSampleExplicitLod %24 %432 %431 Lod %318 -%434 = OpFAdd %24 %429 %433 +%430 = OpSampledImage %429 %309 %312 +%431 = OpImageSampleExplicitLod %24 %430 %317 Grad %317 %317 +%432 = OpFAdd %24 %428 %431 OpLine %3 142 5 -OpStore %320 %434 +OpStore %322 %432 OpLine %3 1 1 -%435 = OpLoad %24 %320 +%433 = OpLoad %24 %322 OpLine %3 143 5 -%436 = OpConvertUToF %8 %231 -%437 = OpCompositeConstruct %24 %315 %436 -%438 = OpSampledImage %423 %309 %310 -%439 = OpImageSampleImplicitLod %24 %438 %437 Bias %319 -%440 = OpFAdd %24 %435 %439 +%435 = OpConvertUToF %8 %231 +%436 = OpCompositeConstruct %24 %317 %435 +%437 = OpSampledImage %434 %310 %312 +%438 = OpImageSampleImplicitLod %24 %437 %436 +%439 = OpFAdd %24 %433 %438 OpLine %3 143 5 -OpStore %320 %440 +OpStore %322 %439 OpLine %3 1 1 -%441 = OpLoad %24 %320 +%440 = OpLoad %24 %322 OpLine %3 144 5 -%442 = OpConvertSToF %8 %77 -%443 = OpCompositeConstruct %24 %315 %442 -%444 = OpSampledImage %423 %309 %310 -%445 = OpImageSampleImplicitLod %24 %444 %443 -%446 = OpFAdd %24 %441 %445 +%441 = OpConvertUToF %8 %231 +%442 = OpCompositeConstruct %24 %317 %441 +%443 = OpSampledImage %434 %310 %312 +%444 = OpImageSampleExplicitLod %24 %443 %442 Lod %320 +%445 = OpFAdd %24 %440 %444 OpLine %3 144 5 -OpStore %320 %446 +OpStore %322 %445 OpLine %3 1 1 -%447 = OpLoad %24 %320 +%446 = OpLoad %24 %322 OpLine %3 145 5 -%448 = OpConvertSToF %8 %77 -%449 = OpCompositeConstruct %24 %315 %448 -%450 = OpSampledImage %423 %309 %310 -%451 = OpImageSampleExplicitLod %24 %450 %449 Lod %318 -%452 = OpFAdd %24 %447 %451 +%447 = OpConvertUToF %8 %231 +%448 = OpCompositeConstruct %24 %317 %447 +%449 = OpSampledImage %434 %310 %312 +%450 = OpImageSampleImplicitLod %24 %449 %448 Bias %321 +%451 = OpFAdd %24 %446 %450 OpLine %3 145 5 -OpStore %320 %452 +OpStore %322 %451 OpLine %3 1 1 -%453 = OpLoad %24 %320 +%452 = OpLoad %24 %322 OpLine %3 146 5 -%454 = OpConvertSToF %8 %77 -%455 = OpCompositeConstruct %24 %315 %454 -%456 = OpSampledImage %423 %309 %310 -%457 = OpImageSampleImplicitLod %24 %456 %455 Bias %319 -%458 = OpFAdd %24 %453 %457 +%453 = OpConvertUToF %8 %231 +%454 = OpCompositeConstruct %24 %317 %453 +%455 = OpSampledImage %434 %310 %312 +%456 = OpImageSampleExplicitLod %24 %455 %454 Grad %317 %317 +%457 = OpFAdd %24 %452 %456 OpLine %3 146 5 -OpStore %320 %458 +OpStore %322 %457 OpLine %3 1 1 -%459 = OpLoad %24 %320 -OpStore %304 %459 +%458 = OpLoad %24 %322 +OpLine %3 147 5 +%459 = OpConvertSToF %8 %77 +%460 = OpCompositeConstruct %24 %317 %459 +%461 = OpSampledImage %434 %310 %312 +%462 = OpImageSampleImplicitLod %24 %461 %460 +%463 = OpFAdd %24 %458 %462 +OpLine %3 147 5 +OpStore %322 %463 +OpLine %3 1 1 +%464 = OpLoad %24 %322 +OpLine %3 148 5 +%465 = OpConvertSToF %8 %77 +%466 = OpCompositeConstruct %24 %317 %465 +%467 = OpSampledImage %434 %310 %312 +%468 = OpImageSampleExplicitLod %24 %467 %466 Lod %320 +%469 = OpFAdd %24 %464 %468 +OpLine %3 148 5 +OpStore %322 %469 +OpLine %3 1 1 +%470 = OpLoad %24 %322 +OpLine %3 149 5 +%471 = OpConvertSToF %8 %77 +%472 = OpCompositeConstruct %24 %317 %471 +%473 = OpSampledImage %434 %310 %312 +%474 = OpImageSampleImplicitLod %24 %473 %472 Bias %321 +%475 = OpFAdd %24 %470 %474 +OpLine %3 149 5 +OpStore %322 %475 +OpLine %3 1 1 +%476 = OpLoad %24 %322 +OpLine %3 150 5 +%477 = OpConvertSToF %8 %77 +%478 = OpCompositeConstruct %24 %317 %477 +%479 = OpSampledImage %434 %310 %312 +%480 = OpImageSampleExplicitLod %24 %479 %478 Grad %317 %317 +%481 = OpFAdd %24 %476 %480 +OpLine %3 150 5 +OpStore %322 %481 +OpLine %3 1 1 +%482 = OpLoad %24 %322 +OpLine %3 151 5 +%484 = OpSampledImage %483 %311 %312 +%485 = OpImageSampleExplicitLod %24 %484 %317 Grad %317 %317 +%486 = OpFAdd %24 %482 %485 +OpLine %3 151 5 +OpStore %322 %486 +OpLine %3 1 1 +%487 = OpLoad %24 %322 +OpStore %304 %487 OpReturn OpFunctionEnd -%463 = OpFunction %2 None %99 -%460 = OpLabel -%468 = OpVariable %469 Function %470 -%464 = OpLoad %25 %63 -%465 = OpLoad %26 %64 -%466 = OpLoad %27 %66 -%467 = OpLoad %28 %68 -OpBranch %471 -%471 = OpLabel -OpLine %3 161 14 -OpLine %3 162 15 +%491 = OpFunction %2 None %99 +%488 = OpLabel +%496 = OpVariable %497 Function %498 +%492 = OpLoad %25 %63 +%493 = OpLoad %26 %64 +%494 = OpLoad %27 %66 +%495 = OpLoad %28 %68 +OpBranch %499 +%499 = OpLabel +OpLine %3 166 14 +OpLine %3 167 15 OpLine %3 1 1 -%472 = OpLoad %8 %468 -OpLine %3 165 5 -%474 = OpSampledImage %473 %465 %464 -%475 = OpImageSampleDrefImplicitLod %8 %474 %313 %311 -%476 = OpFAdd %8 %472 %475 -OpLine %3 165 5 -OpStore %468 %476 -OpLine %3 1 1 -%477 = OpLoad %8 %468 -OpLine %3 166 5 -%479 = OpConvertUToF %8 %231 -%480 = OpCompositeConstruct %314 %313 %479 -%481 = OpSampledImage %478 %466 %464 -%482 = OpImageSampleDrefImplicitLod %8 %481 %480 %311 -%483 = OpFAdd %8 %477 %482 -OpLine %3 166 5 -OpStore %468 %483 -OpLine %3 1 1 -%484 = OpLoad %8 %468 -OpLine %3 167 5 -%485 = OpConvertSToF %8 %77 -%486 = OpCompositeConstruct %314 %313 %485 -%487 = OpSampledImage %478 %466 %464 -%488 = OpImageSampleDrefImplicitLod %8 %487 %486 %311 -%489 = OpFAdd %8 %484 %488 -OpLine %3 167 5 -OpStore %468 %489 -OpLine %3 1 1 -%490 = OpLoad %8 %468 -OpLine %3 168 5 -%492 = OpSampledImage %491 %467 %464 -%493 = OpImageSampleDrefImplicitLod %8 %492 %315 %311 -%494 = OpFAdd %8 %490 %493 -OpLine %3 168 5 -OpStore %468 %494 -OpLine %3 1 1 -%495 = OpLoad %8 %468 -OpLine %3 169 5 -%496 = OpSampledImage %473 %465 %464 -%497 = OpImageSampleDrefExplicitLod %8 %496 %313 %311 Lod %214 -%498 = OpFAdd %8 %495 %497 -OpLine %3 169 5 -OpStore %468 %498 -OpLine %3 1 1 -%499 = OpLoad %8 %468 +%500 = OpLoad %8 %496 OpLine %3 170 5 -%500 = OpConvertUToF %8 %231 -%501 = OpCompositeConstruct %314 %313 %500 -%502 = OpSampledImage %478 %466 %464 -%503 = OpImageSampleDrefExplicitLod %8 %502 %501 %311 Lod %214 -%504 = OpFAdd %8 %499 %503 +%502 = OpSampledImage %501 %493 %492 +%503 = OpImageSampleDrefImplicitLod %8 %502 %315 %313 +%504 = OpFAdd %8 %500 %503 OpLine %3 170 5 -OpStore %468 %504 +OpStore %496 %504 OpLine %3 1 1 -%505 = OpLoad %8 %468 +%505 = OpLoad %8 %496 OpLine %3 171 5 -%506 = OpConvertSToF %8 %77 -%507 = OpCompositeConstruct %314 %313 %506 -%508 = OpSampledImage %478 %466 %464 -%509 = OpImageSampleDrefExplicitLod %8 %508 %507 %311 Lod %214 -%510 = OpFAdd %8 %505 %509 +%507 = OpConvertUToF %8 %231 +%508 = OpCompositeConstruct %316 %315 %507 +%509 = OpSampledImage %506 %494 %492 +%510 = OpImageSampleDrefImplicitLod %8 %509 %508 %313 +%511 = OpFAdd %8 %505 %510 OpLine %3 171 5 -OpStore %468 %510 +OpStore %496 %511 OpLine %3 1 1 -%511 = OpLoad %8 %468 +%512 = OpLoad %8 %496 OpLine %3 172 5 -%512 = OpSampledImage %491 %467 %464 -%513 = OpImageSampleDrefExplicitLod %8 %512 %315 %311 Lod %214 -%514 = OpFAdd %8 %511 %513 +%513 = OpConvertSToF %8 %77 +%514 = OpCompositeConstruct %316 %315 %513 +%515 = OpSampledImage %506 %494 %492 +%516 = OpImageSampleDrefImplicitLod %8 %515 %514 %313 +%517 = OpFAdd %8 %512 %516 OpLine %3 172 5 -OpStore %468 %514 +OpStore %496 %517 OpLine %3 1 1 -%515 = OpLoad %8 %468 -OpStore %461 %515 +%518 = OpLoad %8 %496 +OpLine %3 173 5 +%520 = OpSampledImage %519 %495 %492 +%521 = OpImageSampleDrefImplicitLod %8 %520 %317 %313 +%522 = OpFAdd %8 %518 %521 +OpLine %3 173 5 +OpStore %496 %522 +OpLine %3 1 1 +%523 = OpLoad %8 %496 +OpLine %3 174 5 +%524 = OpSampledImage %501 %493 %492 +%525 = OpImageSampleDrefExplicitLod %8 %524 %315 %313 Lod %214 +%526 = OpFAdd %8 %523 %525 +OpLine %3 174 5 +OpStore %496 %526 +OpLine %3 1 1 +%527 = OpLoad %8 %496 +OpLine %3 175 5 +%528 = OpConvertUToF %8 %231 +%529 = OpCompositeConstruct %316 %315 %528 +%530 = OpSampledImage %506 %494 %492 +%531 = OpImageSampleDrefExplicitLod %8 %530 %529 %313 Lod %214 +%532 = OpFAdd %8 %527 %531 +OpLine %3 175 5 +OpStore %496 %532 +OpLine %3 1 1 +%533 = OpLoad %8 %496 +OpLine %3 176 5 +%534 = OpConvertSToF %8 %77 +%535 = OpCompositeConstruct %316 %315 %534 +%536 = OpSampledImage %506 %494 %492 +%537 = OpImageSampleDrefExplicitLod %8 %536 %535 %313 Lod %214 +%538 = OpFAdd %8 %533 %537 +OpLine %3 176 5 +OpStore %496 %538 +OpLine %3 1 1 +%539 = OpLoad %8 %496 +OpLine %3 177 5 +%540 = OpSampledImage %519 %495 %492 +%541 = OpImageSampleDrefExplicitLod %8 %540 %317 %313 Lod %214 +%542 = OpFAdd %8 %539 %541 +OpLine %3 177 5 +OpStore %496 %542 +OpLine %3 1 1 +%543 = OpLoad %8 %496 +OpStore %489 %543 OpReturn OpFunctionEnd -%518 = OpFunction %2 None %99 -%516 = OpLabel -%519 = OpLoad %17 %46 -%520 = OpLoad %4 %48 -%521 = OpLoad %18 %49 -%522 = OpLoad %25 %61 -%523 = OpLoad %25 %63 -%524 = OpLoad %26 %64 -OpBranch %525 -%525 = OpLabel -OpLine %3 178 14 -OpLine %3 180 15 -%526 = OpSampledImage %330 %519 %522 -%527 = OpImageGather %24 %526 %313 %528 -OpLine %3 181 22 -%529 = OpSampledImage %330 %519 %522 -%530 = OpImageGather %24 %529 %313 %531 ConstOffset %317 -OpLine %3 182 21 -%532 = OpSampledImage %473 %524 %523 -%533 = OpImageDrefGather %24 %532 %313 %311 -OpLine %3 183 28 -%534 = OpSampledImage %473 %524 %523 -%535 = OpImageDrefGather %24 %534 %313 %311 ConstOffset %317 -OpLine %3 185 13 -%537 = OpSampledImage %536 %520 %522 -%538 = OpImageGather %119 %537 %313 %231 -OpLine %3 186 13 -%541 = OpSampledImage %540 %521 %522 -%542 = OpImageGather %539 %541 %313 %231 -OpLine %3 187 13 -%543 = OpConvertUToF %24 %538 -%544 = OpConvertSToF %24 %542 -%545 = OpFAdd %24 %543 %544 -OpLine %3 189 12 -%546 = OpFAdd %24 %527 %530 -%547 = OpFAdd %24 %546 %533 -%548 = OpFAdd %24 %547 %535 -%549 = OpFAdd %24 %548 %545 -OpStore %517 %549 +%546 = OpFunction %2 None %99 +%544 = OpLabel +%547 = OpLoad %17 %46 +%548 = OpLoad %4 %48 +%549 = OpLoad %18 %49 +%550 = OpLoad %25 %61 +%551 = OpLoad %25 %63 +%552 = OpLoad %26 %64 +OpBranch %553 +%553 = OpLabel +OpLine %3 183 14 +OpLine %3 185 15 +%554 = OpSampledImage %332 %547 %550 +%555 = OpImageGather %24 %554 %315 %556 +OpLine %3 186 22 +%557 = OpSampledImage %332 %547 %550 +%558 = OpImageGather %24 %557 %315 %559 ConstOffset %319 +OpLine %3 187 21 +%560 = OpSampledImage %501 %552 %551 +%561 = OpImageDrefGather %24 %560 %315 %313 +OpLine %3 188 28 +%562 = OpSampledImage %501 %552 %551 +%563 = OpImageDrefGather %24 %562 %315 %313 ConstOffset %319 +OpLine %3 190 13 +%565 = OpSampledImage %564 %548 %550 +%566 = OpImageGather %119 %565 %315 %231 +OpLine %3 191 13 +%569 = OpSampledImage %568 %549 %550 +%570 = OpImageGather %567 %569 %315 %231 +OpLine %3 192 13 +%571 = OpConvertUToF %24 %566 +%572 = OpConvertSToF %24 %570 +%573 = OpFAdd %24 %571 %572 +OpLine %3 194 12 +%574 = OpFAdd %24 %555 %558 +%575 = OpFAdd %24 %574 %561 +%576 = OpFAdd %24 %575 %563 +%577 = OpFAdd %24 %576 %573 +OpStore %545 %577 OpReturn OpFunctionEnd -%552 = OpFunction %2 None %99 -%550 = OpLabel -%553 = OpLoad %25 %61 -%554 = OpLoad %26 %64 -OpBranch %555 -%555 = OpLabel -OpLine %3 194 14 -OpLine %3 196 15 -%556 = OpSampledImage %473 %554 %553 -%557 = OpImageSampleImplicitLod %24 %556 %313 -%558 = OpCompositeExtract %8 %557 0 -OpLine %3 197 22 -%559 = OpSampledImage %473 %554 %553 -%560 = OpImageGather %24 %559 %313 %231 -OpLine %3 198 21 -%561 = OpSampledImage %473 %554 %553 -%563 = OpConvertSToF %8 %88 -%562 = OpImageSampleExplicitLod %24 %561 %313 Lod %563 -%564 = OpCompositeExtract %8 %562 0 -OpLine %3 196 15 -%565 = OpCompositeConstruct %24 %558 %558 %558 %558 -%566 = OpFAdd %24 %565 %560 -%567 = OpCompositeConstruct %24 %564 %564 %564 %564 -%568 = OpFAdd %24 %566 %567 -OpStore %551 %568 +%580 = OpFunction %2 None %99 +%578 = OpLabel +%581 = OpLoad %25 %61 +%582 = OpLoad %26 %64 +OpBranch %583 +%583 = OpLabel +OpLine %3 199 14 +OpLine %3 201 15 +%584 = OpSampledImage %501 %582 %581 +%585 = OpImageSampleImplicitLod %24 %584 %315 +%586 = OpCompositeExtract %8 %585 0 +OpLine %3 202 22 +%587 = OpSampledImage %501 %582 %581 +%588 = OpImageGather %24 %587 %315 %231 +OpLine %3 203 21 +%589 = OpSampledImage %501 %582 %581 +%591 = OpConvertSToF %8 %88 +%590 = OpImageSampleExplicitLod %24 %589 %315 Lod %591 +%592 = OpCompositeExtract %8 %590 0 +OpLine %3 201 15 +%593 = OpCompositeConstruct %24 %586 %586 %586 %586 +%594 = OpFAdd %24 %593 %588 +%595 = OpCompositeConstruct %24 %592 %592 %592 %592 +%596 = OpFAdd %24 %594 %595 +OpStore %579 %596 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/wgsl-image.spvasm.glsl b/naga/tests/out/spv/wgsl-image.spvasm.glsl index e39a257ab..804225485 100644 --- a/naga/tests/out/spv/wgsl-image.spvasm.glsl +++ b/naga/tests/out/spv/wgsl-image.spvasm.glsl @@ -211,40 +211,47 @@ void main() a += textureLod(sampler2D(image_2d, sampler_reg), vec2(0.5), 2.2999999523162841796875); a += textureLodOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), 2.2999999523162841796875, ivec2(3, 1)); a += textureOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1), 2.0); - vec2 _353 = vec2(0.5) / vec2(uvec2(textureSize(image_2d, int(0u)))); - a += textureLod(sampler2D(image_2d, sampler_reg), spvNClamp(vec2(0.5), _353, vec2(1.0) - _353), 0.0); - float _363 = float(0u); - a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _363)); + a += textureGrad(sampler2D(image_2d, sampler_reg), vec2(0.5), vec2(0.5), vec2(0.5)); + vec2 _359 = vec2(0.5) / vec2(uvec2(textureSize(image_2d, int(0u)))); + a += textureLod(sampler2D(image_2d, sampler_reg), spvNClamp(vec2(0.5), _359, vec2(1.0) - _359), 0.0); float _369 = float(0u); - a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _369), ivec2(3, 1)); + a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _369)); float _375 = float(0u); - a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _375), 2.2999999523162841796875); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _375), ivec2(3, 1)); float _381 = float(0u); - a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _381), 2.2999999523162841796875, ivec2(3, 1)); + a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _381), 2.2999999523162841796875); float _387 = float(0u); - a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _387), ivec2(3, 1), 2.0); - float _393 = float(0); - a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _393)); + a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _387), 2.2999999523162841796875, ivec2(3, 1)); + float _393 = float(0u); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _393), ivec2(3, 1), 2.0); float _399 = float(0); - a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _399), ivec2(3, 1)); + a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _399)); float _405 = float(0); - a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _405), 2.2999999523162841796875); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _405), ivec2(3, 1)); float _411 = float(0); - a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _411), 2.2999999523162841796875, ivec2(3, 1)); + a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _411), 2.2999999523162841796875); float _417 = float(0); - a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _417), ivec2(3, 1), 2.0); - float _424 = float(0u); - a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _424)); - float _430 = float(0u); - a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _430), 2.2999999523162841796875); - float _436 = float(0u); - a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _436), 2.0); - float _442 = float(0); - a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _442)); - float _448 = float(0); - a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _448), 2.2999999523162841796875); - float _454 = float(0); - a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _454), 2.0); + a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _417), 2.2999999523162841796875, ivec2(3, 1)); + float _423 = float(0); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _423), ivec2(3, 1), 2.0); + a += textureGrad(samplerCube(image_cube, sampler_reg), vec3(0.5), vec3(0.5), vec3(0.5)); + float _435 = float(0u); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _435)); + float _441 = float(0u); + a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _441), 2.2999999523162841796875); + float _447 = float(0u); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _447), 2.0); + float _453 = float(0u); + a += textureGrad(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _453), vec3(0.5), vec3(0.5)); + float _459 = float(0); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _459)); + float _465 = float(0); + a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _465), 2.2999999523162841796875); + float _471 = float(0); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _471), 2.0); + float _477 = float(0); + a += textureGrad(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _477), vec3(0.5), vec3(0.5)); + a += textureGrad(sampler3D(image_3d, sampler_reg), vec3(0.5), vec3(0.5), vec3(0.5)); _304 = a; } @@ -277,24 +284,24 @@ layout(set = 1, binding = 2) uniform texture2D image_2d_depth; layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; layout(set = 1, binding = 4) uniform textureCube image_cube_depth; -layout(location = 0) out float _461; +layout(location = 0) out float _489; void main() { float a = 0.0; a += texture(sampler2DShadow(image_2d_depth, sampler_cmp), vec3(vec2(0.5), 0.5)); - float _479 = float(0u); - a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _479), 0.5)); - float _485 = float(0); - a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _485), 0.5)); + float _507 = float(0u); + a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _507), 0.5)); + float _513 = float(0); + a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _513), 0.5)); a += texture(samplerCubeShadow(image_cube_depth, sampler_cmp), vec4(vec3(0.5), 0.5)); a += textureLod(sampler2DShadow(image_2d_depth, sampler_cmp), vec3(vec2(0.5), 0.5), 0.0); - float _500 = float(0u); - a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _500), 0.5), vec2(0.0), vec2(0.0)); - float _506 = float(0); - a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _506), 0.5), vec2(0.0), vec2(0.0)); + float _528 = float(0u); + a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _528), 0.5), vec2(0.0), vec2(0.0)); + float _534 = float(0); + a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _534), 0.5), vec2(0.0), vec2(0.0)); a += textureGrad(samplerCubeShadow(image_cube_depth, sampler_cmp), vec4(vec3(0.5), 0.5), vec3(0.0), vec3(0.0)); - _461 = a; + _489 = a; } @@ -326,11 +333,11 @@ layout(set = 1, binding = 2) uniform texture2D image_2d_depth; layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; layout(set = 1, binding = 4) uniform textureCube image_cube_depth; -layout(location = 0) out vec4 _517; +layout(location = 0) out vec4 _545; void main() { - _517 = (((textureGather(sampler2D(image_2d, sampler_reg), vec2(0.5), int(1u)) + textureGatherOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1), int(3u))) + textureGather(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5)) + textureGatherOffset(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5, ivec2(3, 1))) + (vec4(textureGather(usampler2D(image_2d_u32, sampler_reg), vec2(0.5))) + vec4(textureGather(isampler2D(image_2d_i32, sampler_reg), vec2(0.5)))); + _545 = (((textureGather(sampler2D(image_2d, sampler_reg), vec2(0.5), int(1u)) + textureGatherOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1), int(3u))) + textureGather(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5)) + textureGatherOffset(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5, ivec2(3, 1))) + (vec4(textureGather(usampler2D(image_2d_u32, sampler_reg), vec2(0.5))) + vec4(textureGather(isampler2D(image_2d_i32, sampler_reg), vec2(0.5)))); } @@ -362,11 +369,11 @@ layout(set = 1, binding = 2) uniform texture2D image_2d_depth; layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; layout(set = 1, binding = 4) uniform textureCube image_cube_depth; -layout(location = 0) out vec4 _551; +layout(location = 0) out vec4 _579; void main() { - float _563 = float(1); - _551 = (vec4(texture(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5)).x) + textureGather(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5))) + vec4(textureLod(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5), _563).x); + float _591 = float(1); + _579 = (vec4(texture(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5)).x) + textureGather(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5))) + vec4(textureLod(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5), _591).x); } diff --git a/naga/tests/out/wgsl/wgsl-image.wgsl b/naga/tests/out/wgsl/wgsl-image.wgsl index 5a04e3e27..6e611b0d2 100644 --- a/naga/tests/out/wgsl/wgsl-image.wgsl +++ b/naga/tests/out/wgsl/wgsl-image.wgsl @@ -137,58 +137,73 @@ fn texture_sample() -> @location(0) vec4 { let _e41 = textureSampleBias(image_2d, sampler_reg, _e1, 2f, vec2(3i, 1i)); a = (_e37 + _e41); let _e43 = a; - let _e46 = textureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + let _e46 = textureSampleGrad(image_2d, sampler_reg, _e1, _e1, _e1); a = (_e43 + _e46); let _e48 = a; - let _e52 = textureSample(image_2d_array, sampler_reg, _e1, 0u); - a = (_e48 + _e52); - let _e54 = a; - let _e58 = textureSample(image_2d_array, sampler_reg, _e1, 0u, vec2(3i, 1i)); - a = (_e54 + _e58); - let _e60 = a; - let _e64 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f); - a = (_e60 + _e64); - let _e66 = a; - let _e70 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f, vec2(3i, 1i)); - a = (_e66 + _e70); - let _e72 = a; - let _e77 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0u, 2f, vec2(3i, 1i)); - a = (_e72 + _e77); - let _e79 = a; - let _e83 = textureSample(image_2d_array, sampler_reg, _e1, 0i); - a = (_e79 + _e83); - let _e85 = a; - let _e89 = textureSample(image_2d_array, sampler_reg, _e1, 0i, vec2(3i, 1i)); - a = (_e85 + _e89); - let _e91 = a; - let _e95 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f); - a = (_e91 + _e95); - let _e97 = a; - let _e101 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f, vec2(3i, 1i)); - a = (_e97 + _e101); - let _e103 = a; - let _e108 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0i, 2f, vec2(3i, 1i)); - a = (_e103 + _e108); - let _e110 = a; - let _e114 = textureSample(image_cube_array, sampler_reg, _e3, 0u); - a = (_e110 + _e114); - let _e116 = a; - let _e120 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0u, 2.3f); - a = (_e116 + _e120); - let _e122 = a; - let _e127 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0u, 2f); - a = (_e122 + _e127); - let _e129 = a; - let _e133 = textureSample(image_cube_array, sampler_reg, _e3, 0i); - a = (_e129 + _e133); - let _e135 = a; - let _e139 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0i, 2.3f); - a = (_e135 + _e139); - let _e141 = a; - let _e146 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0i, 2f); - a = (_e141 + _e146); - let _e148 = a; - return _e148; + let _e51 = textureSampleBaseClampToEdge(image_2d, sampler_reg, _e1); + a = (_e48 + _e51); + let _e53 = a; + let _e57 = textureSample(image_2d_array, sampler_reg, _e1, 0u); + a = (_e53 + _e57); + let _e59 = a; + let _e63 = textureSample(image_2d_array, sampler_reg, _e1, 0u, vec2(3i, 1i)); + a = (_e59 + _e63); + let _e65 = a; + let _e69 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f); + a = (_e65 + _e69); + let _e71 = a; + let _e75 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0u, 2.3f, vec2(3i, 1i)); + a = (_e71 + _e75); + let _e77 = a; + let _e82 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0u, 2f, vec2(3i, 1i)); + a = (_e77 + _e82); + let _e84 = a; + let _e88 = textureSample(image_2d_array, sampler_reg, _e1, 0i); + a = (_e84 + _e88); + let _e90 = a; + let _e94 = textureSample(image_2d_array, sampler_reg, _e1, 0i, vec2(3i, 1i)); + a = (_e90 + _e94); + let _e96 = a; + let _e100 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f); + a = (_e96 + _e100); + let _e102 = a; + let _e106 = textureSampleLevel(image_2d_array, sampler_reg, _e1, 0i, 2.3f, vec2(3i, 1i)); + a = (_e102 + _e106); + let _e108 = a; + let _e113 = textureSampleBias(image_2d_array, sampler_reg, _e1, 0i, 2f, vec2(3i, 1i)); + a = (_e108 + _e113); + let _e115 = a; + let _e118 = textureSampleGrad(image_cube, sampler_reg, _e3, _e3, _e3); + a = (_e115 + _e118); + let _e120 = a; + let _e124 = textureSample(image_cube_array, sampler_reg, _e3, 0u); + a = (_e120 + _e124); + let _e126 = a; + let _e130 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0u, 2.3f); + a = (_e126 + _e130); + let _e132 = a; + let _e137 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0u, 2f); + a = (_e132 + _e137); + let _e139 = a; + let _e143 = textureSampleGrad(image_cube_array, sampler_reg, _e3, 0u, _e3, _e3); + a = (_e139 + _e143); + let _e145 = a; + let _e149 = textureSample(image_cube_array, sampler_reg, _e3, 0i); + a = (_e145 + _e149); + let _e151 = a; + let _e155 = textureSampleLevel(image_cube_array, sampler_reg, _e3, 0i, 2.3f); + a = (_e151 + _e155); + let _e157 = a; + let _e162 = textureSampleBias(image_cube_array, sampler_reg, _e3, 0i, 2f); + a = (_e157 + _e162); + let _e164 = a; + let _e168 = textureSampleGrad(image_cube_array, sampler_reg, _e3, 0i, _e3, _e3); + a = (_e164 + _e168); + let _e170 = a; + let _e173 = textureSampleGrad(image_3d, sampler_reg, _e3, _e3, _e3); + a = (_e170 + _e173); + let _e175 = a; + return _e175; } @fragment