diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index cf8092d71a..27eeeb05c5 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -351,8 +351,10 @@ struct MultiplanarExternalTexture::State { single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_a); // textureLoad(plane0, coord, 0); plane_0_call = b.Call("textureLoad", "plane0", "coord", 0_a); - // textureLoad(plane1, coord, 0); - plane_1_call = b.Call("textureLoad", "plane1", "coord", 0_a); + // let coord1 = coord >> 1; + stmts.Push(b.Decl(b.Let("coord1", b.Shr("coord", b.vec2(1_a))))); + // textureLoad(plane1, coord1, 0); + plane_1_call = b.Call("textureLoad", "plane1", "coord1", 0_a); break; default: TINT_ICE(Transform, b.Diagnostics()) << "unhandled builtin: " << call_type; diff --git a/src/tint/transform/multiplanar_external_texture_test.cc b/src/tint/transform/multiplanar_external_texture_test.cc index 3307f9d99f..916d56b838 100644 --- a/src/tint/transform/multiplanar_external_texture_test.cc +++ b/src/tint/transform/multiplanar_external_texture_test.cc @@ -435,11 +435,12 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -450,11 +451,12 @@ fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord } fn textureLoadExternal_1(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -526,11 +528,12 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -541,11 +544,12 @@ fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord } fn textureLoadExternal_1(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -644,11 +648,12 @@ fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp } fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -739,11 +744,12 @@ fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp } fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl index d0f098eaa5..d403968f93 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl @@ -37,11 +37,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl index d0f098eaa5..d403968f93 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl @@ -37,11 +37,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/bug/tint/1739.wgsl.expected.glsl b/test/tint/bug/tint/1739.wgsl.expected.glsl index 2e0bcd3f6a..cdc0b3c285 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.glsl +++ b/test/tint/bug/tint/1739.wgsl.expected.glsl @@ -54,11 +54,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/bug/tint/1739.wgsl.expected.msl b/test/tint/bug/tint/1739.wgsl.expected.msl index 834c6d5c9e..e892cd9951 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.msl +++ b/test/tint/bug/tint/1739.wgsl.expected.msl @@ -49,11 +49,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, int2 coord, ExternalTextureParams params) { + int2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/bug/tint/1739.wgsl.expected.spvasm b/test/tint/bug/tint/1739.wgsl.expected.spvasm index 35659d8341..059885cc09 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.spvasm +++ b/test/tint/bug/tint/1739.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 196 +; Bound: 197 ; Schema: 0 OpCapability Shader OpCapability ImageQuery @@ -136,28 +136,28 @@ %mat3v2float = OpTypeMatrix %v2float 3 %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %70 = OpTypeFunction %v4float %3 %3 %v2int %ExternalTextureParams - %uint_1 = OpConstant %uint 1 - %87 = OpConstantNull %int - %float_1 = OpConstant %float 1 - %100 = OpConstantNull %uint - %118 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 - %void = OpTypeVoid - %133 = OpTypeFunction %void - %int_10 = OpConstant %int 10 - %139 = OpConstantComposite %v2int %int_10 %int_10 - %140 = OpConstantNull %v2int %v2uint = OpTypeVector %uint 2 + %uint_1 = OpConstant %uint 1 + %81 = OpConstantComposite %v2uint %uint_1 %uint_1 + %90 = OpConstantNull %int + %float_1 = OpConstant %float 1 + %103 = OpConstantNull %uint + %121 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %void = OpTypeVoid + %136 = OpTypeFunction %void + %int_10 = OpConstant %int 10 + %142 = OpConstantComposite %v2int %int_10 %int_10 + %143 = OpConstantNull %v2int %int_0 = OpConstant %int 0 - %147 = OpConstantComposite %v2uint %uint_1 %uint_1 %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %159 = OpConstantNull %v4float + %160 = OpConstantNull %v4float %int_70 = OpConstant %int 70 %int_118 = OpConstant %int 118 - %172 = OpConstantComposite %v2int %int_70 %int_118 + %173 = OpConstantComposite %v2int %int_70 %int_118 %int_1 = OpConstant %int 1 - %187 = OpConstantComposite %v2int %int_1 %87 + %188 = OpConstantComposite %v2int %int_1 %90 %tint_clamp = OpFunction %v2int None %20 %e = OpFunctionParameter %v2int %low = OpFunctionParameter %v2int @@ -210,113 +210,114 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %78 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %50 - %80 = OpCompositeExtract %uint %params_0 0 - %82 = OpIEqual %bool %80 %uint_1 - OpSelectionMerge %83 None - OpBranchConditional %82 %84 %85 - %84 = OpLabel - %86 = OpImageFetch %v4float %plane0 %coord Lod %87 - %88 = OpVectorShuffle %v3float %86 %86 0 1 2 - OpStore %color %88 - OpBranch %83 - %85 = OpLabel - %89 = OpImageFetch %v4float %plane0 %coord Lod %87 - %90 = OpCompositeExtract %float %89 0 - %91 = OpImageFetch %v4float %plane1 %coord Lod %87 - %92 = OpVectorShuffle %v2float %91 %91 0 1 + %82 = OpShiftRightArithmetic %v2int %coord %81 + %84 = OpCompositeExtract %uint %params_0 0 + %85 = OpIEqual %bool %84 %uint_1 + OpSelectionMerge %86 None + OpBranchConditional %85 %87 %88 + %87 = OpLabel + %89 = OpImageFetch %v4float %plane0 %coord Lod %90 + %91 = OpVectorShuffle %v3float %89 %89 0 1 2 + OpStore %color %91 + OpBranch %86 + %88 = OpLabel + %92 = OpImageFetch %v4float %plane0 %coord Lod %90 %93 = OpCompositeExtract %float %92 0 - %94 = OpCompositeExtract %float %92 1 - %96 = OpCompositeConstruct %v4float %90 %93 %94 %float_1 - %97 = OpCompositeExtract %mat3v4float %params_0 2 - %98 = OpVectorTimesMatrix %v3float %96 %97 - OpStore %color %98 - OpBranch %83 - %83 = OpLabel - %99 = OpCompositeExtract %uint %params_0 1 - %101 = OpIEqual %bool %99 %100 - OpSelectionMerge %102 None - OpBranchConditional %101 %103 %102 - %103 = OpLabel - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 3 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 - OpStore %color %104 - %107 = OpCompositeExtract %mat3v3float %params_0 5 + %94 = OpImageFetch %v4float %plane1 %82 Lod %90 + %95 = OpVectorShuffle %v2float %94 %94 0 1 + %96 = OpCompositeExtract %float %95 0 + %97 = OpCompositeExtract %float %95 1 + %99 = OpCompositeConstruct %v4float %93 %96 %97 %float_1 + %100 = OpCompositeExtract %mat3v4float %params_0 2 + %101 = OpVectorTimesMatrix %v3float %99 %100 + OpStore %color %101 + OpBranch %86 + %86 = OpLabel + %102 = OpCompositeExtract %uint %params_0 1 + %104 = OpIEqual %bool %102 %103 + OpSelectionMerge %105 None + OpBranchConditional %104 %106 %105 + %106 = OpLabel %108 = OpLoad %v3float %color - %109 = OpMatrixTimesVector %v3float %107 %108 - OpStore %color %109 + %109 = OpCompositeExtract %GammaTransferParams %params_0 3 + %107 = OpFunctionCall %v3float %gammaCorrection %108 %109 + OpStore %color %107 + %110 = OpCompositeExtract %mat3v3float %params_0 5 %111 = OpLoad %v3float %color - %112 = OpCompositeExtract %GammaTransferParams %params_0 4 - %110 = OpFunctionCall %v3float %gammaCorrection %111 %112 - OpStore %color %110 - OpBranch %102 - %102 = OpLabel - %113 = OpLoad %v3float %color - %114 = OpCompositeExtract %float %113 0 - %115 = OpCompositeExtract %float %113 1 - %116 = OpCompositeExtract %float %113 2 - %117 = OpCompositeConstruct %v4float %114 %115 %116 %float_1 - OpReturnValue %117 + %112 = OpMatrixTimesVector %v3float %110 %111 + OpStore %color %112 + %114 = OpLoad %v3float %color + %115 = OpCompositeExtract %GammaTransferParams %params_0 4 + %113 = OpFunctionCall %v3float %gammaCorrection %114 %115 + OpStore %color %113 + OpBranch %105 + %105 = OpLabel + %116 = OpLoad %v3float %color + %117 = OpCompositeExtract %float %116 0 + %118 = OpCompositeExtract %float %116 1 + %119 = OpCompositeExtract %float %116 2 + %120 = OpCompositeConstruct %v4float %117 %118 %119 %float_1 + OpReturnValue %120 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %118 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %121 %val = OpFunctionParameter %ExternalTextureParams_std140 - %121 = OpLabel - %122 = OpCompositeExtract %uint %val 0 - %123 = OpCompositeExtract %uint %val 1 - %124 = OpCompositeExtract %mat3v4float %val 2 - %125 = OpCompositeExtract %GammaTransferParams %val 3 - %126 = OpCompositeExtract %GammaTransferParams %val 4 - %127 = OpCompositeExtract %mat3v3float %val 5 - %128 = OpCompositeExtract %v2float %val 6 - %129 = OpCompositeExtract %v2float %val 7 - %130 = OpCompositeExtract %v2float %val 8 - %131 = OpCompositeConstruct %mat3v2float %128 %129 %130 - %132 = OpCompositeConstruct %ExternalTextureParams %122 %123 %124 %125 %126 %127 %131 - OpReturnValue %132 + %124 = OpLabel + %125 = OpCompositeExtract %uint %val 0 + %126 = OpCompositeExtract %uint %val 1 + %127 = OpCompositeExtract %mat3v4float %val 2 + %128 = OpCompositeExtract %GammaTransferParams %val 3 + %129 = OpCompositeExtract %GammaTransferParams %val 4 + %130 = OpCompositeExtract %mat3v3float %val 5 + %131 = OpCompositeExtract %v2float %val 6 + %132 = OpCompositeExtract %v2float %val 7 + %133 = OpCompositeExtract %v2float %val 8 + %134 = OpCompositeConstruct %mat3v2float %131 %132 %133 + %135 = OpCompositeConstruct %ExternalTextureParams %125 %126 %127 %128 %129 %130 %134 + OpReturnValue %135 OpFunctionEnd - %main = OpFunction %void None %133 - %136 = OpLabel - %red = OpVariable %_ptr_Function_v4float Function %159 - %green = OpVariable %_ptr_Function_v4float Function %159 - %145 = OpLoad %3 %t - %144 = OpImageQuerySizeLod %v2uint %145 %int_0 - %148 = OpISub %v2uint %144 %147 - %141 = OpBitcast %v2int %148 - %137 = OpFunctionCall %v2int %tint_clamp %139 %140 %141 - %150 = OpLoad %3 %t - %151 = OpLoad %3 %ext_tex_plane_1 - %155 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %156 = OpLoad %ExternalTextureParams_std140 %155 - %152 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %156 - %149 = OpFunctionCall %v4float %textureLoadExternal %150 %151 %137 %152 - OpStore %red %149 - %164 = OpLoad %19 %outImage - %163 = OpImageQuerySize %v2uint %164 - %165 = OpISub %v2uint %163 %147 - %161 = OpBitcast %v2int %165 - %160 = OpFunctionCall %v2int %tint_clamp %140 %140 %161 - %167 = OpLoad %19 %outImage - %168 = OpLoad %v4float %red - OpImageWrite %167 %160 %168 - %176 = OpLoad %3 %t - %175 = OpImageQuerySizeLod %v2uint %176 %int_0 - %177 = OpISub %v2uint %175 %147 - %173 = OpBitcast %v2int %177 - %169 = OpFunctionCall %v2int %tint_clamp %172 %140 %173 - %179 = OpLoad %3 %t - %180 = OpLoad %3 %ext_tex_plane_1 - %182 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %183 = OpLoad %ExternalTextureParams_std140 %182 - %181 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %183 - %178 = OpFunctionCall %v4float %textureLoadExternal %179 %180 %169 %181 - OpStore %green %178 - %191 = OpLoad %19 %outImage - %190 = OpImageQuerySize %v2uint %191 - %192 = OpISub %v2uint %190 %147 - %188 = OpBitcast %v2int %192 - %185 = OpFunctionCall %v2int %tint_clamp %187 %140 %188 - %194 = OpLoad %19 %outImage - %195 = OpLoad %v4float %green - OpImageWrite %194 %185 %195 + %main = OpFunction %void None %136 + %139 = OpLabel + %red = OpVariable %_ptr_Function_v4float Function %160 + %green = OpVariable %_ptr_Function_v4float Function %160 + %147 = OpLoad %3 %t + %146 = OpImageQuerySizeLod %v2uint %147 %int_0 + %149 = OpISub %v2uint %146 %81 + %144 = OpBitcast %v2int %149 + %140 = OpFunctionCall %v2int %tint_clamp %142 %143 %144 + %151 = OpLoad %3 %t + %152 = OpLoad %3 %ext_tex_plane_1 + %156 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %157 = OpLoad %ExternalTextureParams_std140 %156 + %153 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %157 + %150 = OpFunctionCall %v4float %textureLoadExternal %151 %152 %140 %153 + OpStore %red %150 + %165 = OpLoad %19 %outImage + %164 = OpImageQuerySize %v2uint %165 + %166 = OpISub %v2uint %164 %81 + %162 = OpBitcast %v2int %166 + %161 = OpFunctionCall %v2int %tint_clamp %143 %143 %162 + %168 = OpLoad %19 %outImage + %169 = OpLoad %v4float %red + OpImageWrite %168 %161 %169 + %177 = OpLoad %3 %t + %176 = OpImageQuerySizeLod %v2uint %177 %int_0 + %178 = OpISub %v2uint %176 %81 + %174 = OpBitcast %v2int %178 + %170 = OpFunctionCall %v2int %tint_clamp %173 %143 %174 + %180 = OpLoad %3 %t + %181 = OpLoad %3 %ext_tex_plane_1 + %183 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %184 = OpLoad %ExternalTextureParams_std140 %183 + %182 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %184 + %179 = OpFunctionCall %v4float %textureLoadExternal %180 %181 %170 %182 + OpStore %green %179 + %192 = OpLoad %19 %outImage + %191 = OpImageQuerySize %v2uint %192 + %193 = OpISub %v2uint %191 %81 + %189 = OpBitcast %v2int %193 + %186 = OpFunctionCall %v2int %tint_clamp %188 %143 %189 + %195 = OpLoad %19 %outImage + %196 = OpLoad %v4float %green + OpImageWrite %195 %186 %196 OpReturn OpFunctionEnd diff --git a/test/tint/bug/tint/1739.wgsl.expected.wgsl b/test/tint/bug/tint/1739.wgsl.expected.wgsl index f4c25e6d40..e87373cafc 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.wgsl +++ b/test/tint/bug/tint/1739.wgsl.expected.wgsl @@ -35,11 +35,12 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureLoadExternal(plane0 : texture_2d, plane1 : texture_2d, coord : vec2, params : ExternalTextureParams) -> vec4 { + let coord1 = (coord >> vec2(1)); var color : vec3; if ((params.numPlanes == 1)) { color = textureLoad(plane0, coord, 0).rgb; } else { - color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1) * params.yuvToRgbConversionMatrix); + color = (vec4(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord1, 0).rg, 1) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl index efe4f1a72f..1d6c1c10ca 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, uint2 coord, ExternalTextureParams params) { + const uint2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(uint3(coord, uint(0))).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord, uint(0))).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord1, uint(0))).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl index efe4f1a72f..1d6c1c10ca 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, uint2 coord, ExternalTextureParams params) { + const uint2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(uint3(coord, uint(0))).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord, uint(0))).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord1, uint(0))).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl index f20ac3428b..a5f0e0a260 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl @@ -45,11 +45,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -130,11 +131,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -209,11 +211,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl index b96779516d..016c2a797b 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl @@ -45,11 +45,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, uint2 coord, ExternalTextureParams params) { + uint2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm index 97b8218b77..166be15367 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 156 +; Bound: 157 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -139,18 +139,18 @@ %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams %uint_1 = OpConstant %uint 1 + %74 = OpConstantComposite %v2uint %uint_1 %uint_1 %int = OpTypeInt 32 1 - %82 = OpConstantNull %int + %84 = OpConstantNull %int %float_1 = OpConstant %float 1 - %95 = OpConstantNull %uint - %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %97 = OpConstantNull %uint + %115 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %128 = OpTypeFunction %void - %135 = OpConstantComposite %v2uint %uint_1 %uint_1 + %130 = OpTypeFunction %void %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %143 = OpTypeFunction %v4float + %144 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -194,101 +194,102 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %72 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %74 = OpCompositeExtract %uint %params_0 0 - %76 = OpIEqual %bool %74 %uint_1 - OpSelectionMerge %77 None - OpBranchConditional %76 %78 %79 - %78 = OpLabel - %80 = OpImageFetch %v4float %plane0 %coord Lod %82 - %83 = OpVectorShuffle %v3float %80 %80 0 1 2 - OpStore %color %83 - OpBranch %77 + %75 = OpShiftRightLogical %v2uint %coord %74 + %77 = OpCompositeExtract %uint %params_0 0 + %78 = OpIEqual %bool %77 %uint_1 + OpSelectionMerge %79 None + OpBranchConditional %78 %80 %81 + %80 = OpLabel + %82 = OpImageFetch %v4float %plane0 %coord Lod %84 + %85 = OpVectorShuffle %v3float %82 %82 0 1 2 + OpStore %color %85 + OpBranch %79 + %81 = OpLabel + %86 = OpImageFetch %v4float %plane0 %coord Lod %84 + %87 = OpCompositeExtract %float %86 0 + %88 = OpImageFetch %v4float %plane1 %75 Lod %84 + %89 = OpVectorShuffle %v2float %88 %88 0 1 + %90 = OpCompositeExtract %float %89 0 + %91 = OpCompositeExtract %float %89 1 + %93 = OpCompositeConstruct %v4float %87 %90 %91 %float_1 + %94 = OpCompositeExtract %mat3v4float %params_0 2 + %95 = OpVectorTimesMatrix %v3float %93 %94 + OpStore %color %95 + OpBranch %79 %79 = OpLabel - %84 = OpImageFetch %v4float %plane0 %coord Lod %82 - %85 = OpCompositeExtract %float %84 0 - %86 = OpImageFetch %v4float %plane1 %coord Lod %82 - %87 = OpVectorShuffle %v2float %86 %86 0 1 - %88 = OpCompositeExtract %float %87 0 - %89 = OpCompositeExtract %float %87 1 - %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1 - %92 = OpCompositeExtract %mat3v4float %params_0 2 - %93 = OpVectorTimesMatrix %v3float %91 %92 - OpStore %color %93 - OpBranch %77 - %77 = OpLabel - %94 = OpCompositeExtract %uint %params_0 1 - %96 = OpIEqual %bool %94 %95 - OpSelectionMerge %97 None - OpBranchConditional %96 %98 %97 - %98 = OpLabel - %100 = OpLoad %v3float %color - %101 = OpCompositeExtract %GammaTransferParams %params_0 3 - %99 = OpFunctionCall %v3float %gammaCorrection %100 %101 - OpStore %color %99 - %102 = OpCompositeExtract %mat3v3float %params_0 5 - %103 = OpLoad %v3float %color - %104 = OpMatrixTimesVector %v3float %102 %103 - OpStore %color %104 - %106 = OpLoad %v3float %color - %107 = OpCompositeExtract %GammaTransferParams %params_0 4 - %105 = OpFunctionCall %v3float %gammaCorrection %106 %107 - OpStore %color %105 - OpBranch %97 - %97 = OpLabel + %96 = OpCompositeExtract %uint %params_0 1 + %98 = OpIEqual %bool %96 %97 + OpSelectionMerge %99 None + OpBranchConditional %98 %100 %99 + %100 = OpLabel + %102 = OpLoad %v3float %color + %103 = OpCompositeExtract %GammaTransferParams %params_0 3 + %101 = OpFunctionCall %v3float %gammaCorrection %102 %103 + OpStore %color %101 + %104 = OpCompositeExtract %mat3v3float %params_0 5 + %105 = OpLoad %v3float %color + %106 = OpMatrixTimesVector %v3float %104 %105 + OpStore %color %106 %108 = OpLoad %v3float %color - %109 = OpCompositeExtract %float %108 0 - %110 = OpCompositeExtract %float %108 1 - %111 = OpCompositeExtract %float %108 2 - %112 = OpCompositeConstruct %v4float %109 %110 %111 %float_1 - OpReturnValue %112 + %109 = OpCompositeExtract %GammaTransferParams %params_0 4 + %107 = OpFunctionCall %v3float %gammaCorrection %108 %109 + OpStore %color %107 + OpBranch %99 + %99 = OpLabel + %110 = OpLoad %v3float %color + %111 = OpCompositeExtract %float %110 0 + %112 = OpCompositeExtract %float %110 1 + %113 = OpCompositeExtract %float %110 2 + %114 = OpCompositeConstruct %v4float %111 %112 %113 %float_1 + OpReturnValue %114 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %115 %val = OpFunctionParameter %ExternalTextureParams_std140 - %116 = OpLabel - %117 = OpCompositeExtract %uint %val 0 - %118 = OpCompositeExtract %uint %val 1 - %119 = OpCompositeExtract %mat3v4float %val 2 - %120 = OpCompositeExtract %GammaTransferParams %val 3 - %121 = OpCompositeExtract %GammaTransferParams %val 4 - %122 = OpCompositeExtract %mat3v3float %val 5 - %123 = OpCompositeExtract %v2float %val 6 - %124 = OpCompositeExtract %v2float %val 7 - %125 = OpCompositeExtract %v2float %val 8 - %126 = OpCompositeConstruct %mat3v2float %123 %124 %125 - %127 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %126 - OpReturnValue %127 + %118 = OpLabel + %119 = OpCompositeExtract %uint %val 0 + %120 = OpCompositeExtract %uint %val 1 + %121 = OpCompositeExtract %mat3v4float %val 2 + %122 = OpCompositeExtract %GammaTransferParams %val 3 + %123 = OpCompositeExtract %GammaTransferParams %val 4 + %124 = OpCompositeExtract %mat3v3float %val 5 + %125 = OpCompositeExtract %v2float %val 6 + %126 = OpCompositeExtract %v2float %val 7 + %127 = OpCompositeExtract %v2float %val 8 + %128 = OpCompositeConstruct %mat3v2float %125 %126 %127 + %129 = OpCompositeConstruct %ExternalTextureParams %119 %120 %121 %122 %123 %124 %128 + OpReturnValue %129 OpFunctionEnd -%textureLoad_1bfdfb = OpFunction %void None %128 - %131 = OpLabel +%textureLoad_1bfdfb = OpFunction %void None %130 + %133 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %133 = OpLoad %11 %arg_0 - %134 = OpLoad %11 %ext_tex_plane_1 - %139 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %140 = OpLoad %ExternalTextureParams_std140 %139 - %136 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %140 - %132 = OpFunctionCall %v4float %textureLoadExternal %133 %134 %135 %136 - OpStore %res %132 + %135 = OpLoad %11 %arg_0 + %136 = OpLoad %11 %ext_tex_plane_1 + %140 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %141 = OpLoad %ExternalTextureParams_std140 %140 + %137 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %141 + %134 = OpFunctionCall %v4float %textureLoadExternal %135 %136 %74 %137 + OpStore %res %134 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %143 - %145 = OpLabel - %146 = OpFunctionCall %void %textureLoad_1bfdfb +%vertex_main_inner = OpFunction %v4float None %144 + %146 = OpLabel + %147 = OpFunctionCall %void %textureLoad_1bfdfb OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %128 - %148 = OpLabel - %149 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %149 +%vertex_main = OpFunction %void None %130 + %149 = OpLabel + %150 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %150 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %128 - %151 = OpLabel - %152 = OpFunctionCall %void %textureLoad_1bfdfb +%fragment_main = OpFunction %void None %130 + %152 = OpLabel + %153 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %128 - %154 = OpLabel - %155 = OpFunctionCall %void %textureLoad_1bfdfb +%compute_main = OpFunction %void None %130 + %155 = OpLabel + %156 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl index 8c1ebf33df..c7f820632e 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.dxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl index 8c1ebf33df..c7f820632e 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.fxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl index 93f5c75009..a2b7930815 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl @@ -45,11 +45,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -130,11 +131,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -209,11 +211,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl index 467303ea69..812bf58301 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl @@ -45,11 +45,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, int2 coord, ExternalTextureParams params) { + int2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm index a6467db281..2142ab27c8 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 157 +; Bound: 160 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -139,19 +139,21 @@ %mat3v2float = OpTypeMatrix %v2float 3 %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams + %v2uint = OpTypeVector %uint 2 %uint_1 = OpConstant %uint 1 - %82 = OpConstantNull %int + %76 = OpConstantComposite %v2uint %uint_1 %uint_1 + %85 = OpConstantNull %int %float_1 = OpConstant %float 1 - %95 = OpConstantNull %uint - %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %98 = OpConstantNull %uint + %116 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %128 = OpTypeFunction %void + %131 = OpTypeFunction %void %int_1 = OpConstant %int 1 - %136 = OpConstantComposite %v2int %int_1 %int_1 + %139 = OpConstantComposite %v2int %int_1 %int_1 %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %144 = OpTypeFunction %v4float + %147 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -195,101 +197,102 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %75 = OpCompositeExtract %uint %params_0 0 - %77 = OpIEqual %bool %75 %uint_1 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %80 - %79 = OpLabel - %81 = OpImageFetch %v4float %plane0 %coord Lod %82 - %83 = OpVectorShuffle %v3float %81 %81 0 1 2 - OpStore %color %83 - OpBranch %78 - %80 = OpLabel - %84 = OpImageFetch %v4float %plane0 %coord Lod %82 - %85 = OpCompositeExtract %float %84 0 - %86 = OpImageFetch %v4float %plane1 %coord Lod %82 - %87 = OpVectorShuffle %v2float %86 %86 0 1 + %77 = OpShiftRightArithmetic %v2int %coord %76 + %79 = OpCompositeExtract %uint %params_0 0 + %80 = OpIEqual %bool %79 %uint_1 + OpSelectionMerge %81 None + OpBranchConditional %80 %82 %83 + %82 = OpLabel + %84 = OpImageFetch %v4float %plane0 %coord Lod %85 + %86 = OpVectorShuffle %v3float %84 %84 0 1 2 + OpStore %color %86 + OpBranch %81 + %83 = OpLabel + %87 = OpImageFetch %v4float %plane0 %coord Lod %85 %88 = OpCompositeExtract %float %87 0 - %89 = OpCompositeExtract %float %87 1 - %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1 - %92 = OpCompositeExtract %mat3v4float %params_0 2 - %93 = OpVectorTimesMatrix %v3float %91 %92 - OpStore %color %93 - OpBranch %78 - %78 = OpLabel - %94 = OpCompositeExtract %uint %params_0 1 - %96 = OpIEqual %bool %94 %95 - OpSelectionMerge %97 None - OpBranchConditional %96 %98 %97 - %98 = OpLabel - %100 = OpLoad %v3float %color - %101 = OpCompositeExtract %GammaTransferParams %params_0 3 - %99 = OpFunctionCall %v3float %gammaCorrection %100 %101 - OpStore %color %99 - %102 = OpCompositeExtract %mat3v3float %params_0 5 + %89 = OpImageFetch %v4float %plane1 %77 Lod %85 + %90 = OpVectorShuffle %v2float %89 %89 0 1 + %91 = OpCompositeExtract %float %90 0 + %92 = OpCompositeExtract %float %90 1 + %94 = OpCompositeConstruct %v4float %88 %91 %92 %float_1 + %95 = OpCompositeExtract %mat3v4float %params_0 2 + %96 = OpVectorTimesMatrix %v3float %94 %95 + OpStore %color %96 + OpBranch %81 + %81 = OpLabel + %97 = OpCompositeExtract %uint %params_0 1 + %99 = OpIEqual %bool %97 %98 + OpSelectionMerge %100 None + OpBranchConditional %99 %101 %100 + %101 = OpLabel %103 = OpLoad %v3float %color - %104 = OpMatrixTimesVector %v3float %102 %103 - OpStore %color %104 + %104 = OpCompositeExtract %GammaTransferParams %params_0 3 + %102 = OpFunctionCall %v3float %gammaCorrection %103 %104 + OpStore %color %102 + %105 = OpCompositeExtract %mat3v3float %params_0 5 %106 = OpLoad %v3float %color - %107 = OpCompositeExtract %GammaTransferParams %params_0 4 - %105 = OpFunctionCall %v3float %gammaCorrection %106 %107 - OpStore %color %105 - OpBranch %97 - %97 = OpLabel - %108 = OpLoad %v3float %color - %109 = OpCompositeExtract %float %108 0 - %110 = OpCompositeExtract %float %108 1 - %111 = OpCompositeExtract %float %108 2 - %112 = OpCompositeConstruct %v4float %109 %110 %111 %float_1 - OpReturnValue %112 + %107 = OpMatrixTimesVector %v3float %105 %106 + OpStore %color %107 + %109 = OpLoad %v3float %color + %110 = OpCompositeExtract %GammaTransferParams %params_0 4 + %108 = OpFunctionCall %v3float %gammaCorrection %109 %110 + OpStore %color %108 + OpBranch %100 + %100 = OpLabel + %111 = OpLoad %v3float %color + %112 = OpCompositeExtract %float %111 0 + %113 = OpCompositeExtract %float %111 1 + %114 = OpCompositeExtract %float %111 2 + %115 = OpCompositeConstruct %v4float %112 %113 %114 %float_1 + OpReturnValue %115 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %116 %val = OpFunctionParameter %ExternalTextureParams_std140 - %116 = OpLabel - %117 = OpCompositeExtract %uint %val 0 - %118 = OpCompositeExtract %uint %val 1 - %119 = OpCompositeExtract %mat3v4float %val 2 - %120 = OpCompositeExtract %GammaTransferParams %val 3 - %121 = OpCompositeExtract %GammaTransferParams %val 4 - %122 = OpCompositeExtract %mat3v3float %val 5 - %123 = OpCompositeExtract %v2float %val 6 - %124 = OpCompositeExtract %v2float %val 7 - %125 = OpCompositeExtract %v2float %val 8 - %126 = OpCompositeConstruct %mat3v2float %123 %124 %125 - %127 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %126 - OpReturnValue %127 + %119 = OpLabel + %120 = OpCompositeExtract %uint %val 0 + %121 = OpCompositeExtract %uint %val 1 + %122 = OpCompositeExtract %mat3v4float %val 2 + %123 = OpCompositeExtract %GammaTransferParams %val 3 + %124 = OpCompositeExtract %GammaTransferParams %val 4 + %125 = OpCompositeExtract %mat3v3float %val 5 + %126 = OpCompositeExtract %v2float %val 6 + %127 = OpCompositeExtract %v2float %val 7 + %128 = OpCompositeExtract %v2float %val 8 + %129 = OpCompositeConstruct %mat3v2float %126 %127 %128 + %130 = OpCompositeConstruct %ExternalTextureParams %120 %121 %122 %123 %124 %125 %129 + OpReturnValue %130 OpFunctionEnd -%textureLoad_8acf41 = OpFunction %void None %128 - %131 = OpLabel +%textureLoad_8acf41 = OpFunction %void None %131 + %134 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %133 = OpLoad %11 %arg_0 - %134 = OpLoad %11 %ext_tex_plane_1 - %140 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %141 = OpLoad %ExternalTextureParams_std140 %140 - %137 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %141 - %132 = OpFunctionCall %v4float %textureLoadExternal %133 %134 %136 %137 - OpStore %res %132 + %136 = OpLoad %11 %arg_0 + %137 = OpLoad %11 %ext_tex_plane_1 + %143 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %144 = OpLoad %ExternalTextureParams_std140 %143 + %140 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %144 + %135 = OpFunctionCall %v4float %textureLoadExternal %136 %137 %139 %140 + OpStore %res %135 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %144 - %146 = OpLabel - %147 = OpFunctionCall %void %textureLoad_8acf41 +%vertex_main_inner = OpFunction %v4float None %147 + %149 = OpLabel + %150 = OpFunctionCall %void %textureLoad_8acf41 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %128 - %149 = OpLabel - %150 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %150 +%vertex_main = OpFunction %void None %131 + %152 = OpLabel + %153 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %153 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %128 - %152 = OpLabel - %153 = OpFunctionCall %void %textureLoad_8acf41 - OpReturn - OpFunctionEnd -%compute_main = OpFunction %void None %128 +%fragment_main = OpFunction %void None %131 %155 = OpLabel %156 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd +%compute_main = OpFunction %void None %131 + %158 = OpLabel + %159 = OpFunctionCall %void %textureLoad_8acf41 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl index 93cec7b899..4bd893fab1 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, uint2 coord, ExternalTextureParams params) { + const uint2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(uint3(coord, uint(0))).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord, uint(0))).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord1, uint(0))).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl index 93cec7b899..4bd893fab1 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.fxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, uint2 coord, ExternalTextureParams params) { + const uint2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(uint3(coord, uint(0))).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord, uint(0))).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(uint3(coord, uint(0))).r, plane1.Load(uint3(coord1, uint(0))).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl index 64681a8540..2cc4ccf8de 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl @@ -45,11 +45,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -131,11 +132,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -211,11 +213,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uvec2 coord, ExternalTextureParams params) { + uvec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, ivec2(coord), 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, ivec2(coord), 0).r, texelFetch(plane1_1, ivec2(coord1), 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl index a8df5b26dc..64cfbf5c1e 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl @@ -45,11 +45,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, uint2 coord, ExternalTextureParams params) { + uint2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm index 64a3bcd2cf..0da3af8e1c 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 160 +; Bound: 161 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -140,20 +140,20 @@ %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams %uint_1 = OpConstant %uint 1 + %74 = OpConstantComposite %v2uint %uint_1 %uint_1 %int = OpTypeInt 32 1 - %82 = OpConstantNull %int + %84 = OpConstantNull %int %float_1 = OpConstant %float 1 - %95 = OpConstantNull %uint - %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %97 = OpConstantNull %uint + %115 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %128 = OpTypeFunction %void - %132 = OpConstantComposite %v2uint %uint_1 %uint_1 + %130 = OpTypeFunction %void %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %135 = OpConstantNull %v2uint + %136 = OpConstantNull %v2uint %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %147 = OpTypeFunction %v4float + %148 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -197,104 +197,105 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %72 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %74 = OpCompositeExtract %uint %params_0 0 - %76 = OpIEqual %bool %74 %uint_1 - OpSelectionMerge %77 None - OpBranchConditional %76 %78 %79 - %78 = OpLabel - %80 = OpImageFetch %v4float %plane0 %coord Lod %82 - %83 = OpVectorShuffle %v3float %80 %80 0 1 2 - OpStore %color %83 - OpBranch %77 + %75 = OpShiftRightLogical %v2uint %coord %74 + %77 = OpCompositeExtract %uint %params_0 0 + %78 = OpIEqual %bool %77 %uint_1 + OpSelectionMerge %79 None + OpBranchConditional %78 %80 %81 + %80 = OpLabel + %82 = OpImageFetch %v4float %plane0 %coord Lod %84 + %85 = OpVectorShuffle %v3float %82 %82 0 1 2 + OpStore %color %85 + OpBranch %79 + %81 = OpLabel + %86 = OpImageFetch %v4float %plane0 %coord Lod %84 + %87 = OpCompositeExtract %float %86 0 + %88 = OpImageFetch %v4float %plane1 %75 Lod %84 + %89 = OpVectorShuffle %v2float %88 %88 0 1 + %90 = OpCompositeExtract %float %89 0 + %91 = OpCompositeExtract %float %89 1 + %93 = OpCompositeConstruct %v4float %87 %90 %91 %float_1 + %94 = OpCompositeExtract %mat3v4float %params_0 2 + %95 = OpVectorTimesMatrix %v3float %93 %94 + OpStore %color %95 + OpBranch %79 %79 = OpLabel - %84 = OpImageFetch %v4float %plane0 %coord Lod %82 - %85 = OpCompositeExtract %float %84 0 - %86 = OpImageFetch %v4float %plane1 %coord Lod %82 - %87 = OpVectorShuffle %v2float %86 %86 0 1 - %88 = OpCompositeExtract %float %87 0 - %89 = OpCompositeExtract %float %87 1 - %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1 - %92 = OpCompositeExtract %mat3v4float %params_0 2 - %93 = OpVectorTimesMatrix %v3float %91 %92 - OpStore %color %93 - OpBranch %77 - %77 = OpLabel - %94 = OpCompositeExtract %uint %params_0 1 - %96 = OpIEqual %bool %94 %95 - OpSelectionMerge %97 None - OpBranchConditional %96 %98 %97 - %98 = OpLabel - %100 = OpLoad %v3float %color - %101 = OpCompositeExtract %GammaTransferParams %params_0 3 - %99 = OpFunctionCall %v3float %gammaCorrection %100 %101 - OpStore %color %99 - %102 = OpCompositeExtract %mat3v3float %params_0 5 - %103 = OpLoad %v3float %color - %104 = OpMatrixTimesVector %v3float %102 %103 - OpStore %color %104 - %106 = OpLoad %v3float %color - %107 = OpCompositeExtract %GammaTransferParams %params_0 4 - %105 = OpFunctionCall %v3float %gammaCorrection %106 %107 - OpStore %color %105 - OpBranch %97 - %97 = OpLabel + %96 = OpCompositeExtract %uint %params_0 1 + %98 = OpIEqual %bool %96 %97 + OpSelectionMerge %99 None + OpBranchConditional %98 %100 %99 + %100 = OpLabel + %102 = OpLoad %v3float %color + %103 = OpCompositeExtract %GammaTransferParams %params_0 3 + %101 = OpFunctionCall %v3float %gammaCorrection %102 %103 + OpStore %color %101 + %104 = OpCompositeExtract %mat3v3float %params_0 5 + %105 = OpLoad %v3float %color + %106 = OpMatrixTimesVector %v3float %104 %105 + OpStore %color %106 %108 = OpLoad %v3float %color - %109 = OpCompositeExtract %float %108 0 - %110 = OpCompositeExtract %float %108 1 - %111 = OpCompositeExtract %float %108 2 - %112 = OpCompositeConstruct %v4float %109 %110 %111 %float_1 - OpReturnValue %112 + %109 = OpCompositeExtract %GammaTransferParams %params_0 4 + %107 = OpFunctionCall %v3float %gammaCorrection %108 %109 + OpStore %color %107 + OpBranch %99 + %99 = OpLabel + %110 = OpLoad %v3float %color + %111 = OpCompositeExtract %float %110 0 + %112 = OpCompositeExtract %float %110 1 + %113 = OpCompositeExtract %float %110 2 + %114 = OpCompositeConstruct %v4float %111 %112 %113 %float_1 + OpReturnValue %114 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %115 %val = OpFunctionParameter %ExternalTextureParams_std140 - %116 = OpLabel - %117 = OpCompositeExtract %uint %val 0 - %118 = OpCompositeExtract %uint %val 1 - %119 = OpCompositeExtract %mat3v4float %val 2 - %120 = OpCompositeExtract %GammaTransferParams %val 3 - %121 = OpCompositeExtract %GammaTransferParams %val 4 - %122 = OpCompositeExtract %mat3v3float %val 5 - %123 = OpCompositeExtract %v2float %val 6 - %124 = OpCompositeExtract %v2float %val 7 - %125 = OpCompositeExtract %v2float %val 8 - %126 = OpCompositeConstruct %mat3v2float %123 %124 %125 - %127 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %126 - OpReturnValue %127 + %118 = OpLabel + %119 = OpCompositeExtract %uint %val 0 + %120 = OpCompositeExtract %uint %val 1 + %121 = OpCompositeExtract %mat3v4float %val 2 + %122 = OpCompositeExtract %GammaTransferParams %val 3 + %123 = OpCompositeExtract %GammaTransferParams %val 4 + %124 = OpCompositeExtract %mat3v3float %val 5 + %125 = OpCompositeExtract %v2float %val 6 + %126 = OpCompositeExtract %v2float %val 7 + %127 = OpCompositeExtract %v2float %val 8 + %128 = OpCompositeConstruct %mat3v2float %125 %126 %127 + %129 = OpCompositeConstruct %ExternalTextureParams %119 %120 %121 %122 %123 %124 %128 + OpReturnValue %129 OpFunctionEnd -%textureLoad_1bfdfb = OpFunction %void None %128 - %131 = OpLabel - %arg_1 = OpVariable %_ptr_Function_v2uint Function %135 +%textureLoad_1bfdfb = OpFunction %void None %130 + %133 = OpLabel + %arg_1 = OpVariable %_ptr_Function_v2uint Function %136 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_1 %132 - %137 = OpLoad %11 %arg_0 - %138 = OpLoad %11 %ext_tex_plane_1 - %139 = OpLoad %v2uint %arg_1 - %143 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %144 = OpLoad %ExternalTextureParams_std140 %143 - %140 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %144 - %136 = OpFunctionCall %v4float %textureLoadExternal %137 %138 %139 %140 - OpStore %res %136 + OpStore %arg_1 %74 + %138 = OpLoad %11 %arg_0 + %139 = OpLoad %11 %ext_tex_plane_1 + %140 = OpLoad %v2uint %arg_1 + %144 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %145 = OpLoad %ExternalTextureParams_std140 %144 + %141 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %145 + %137 = OpFunctionCall %v4float %textureLoadExternal %138 %139 %140 %141 + OpStore %res %137 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %147 - %149 = OpLabel - %150 = OpFunctionCall %void %textureLoad_1bfdfb +%vertex_main_inner = OpFunction %v4float None %148 + %150 = OpLabel + %151 = OpFunctionCall %void %textureLoad_1bfdfb OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %128 - %152 = OpLabel - %153 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %153 +%vertex_main = OpFunction %void None %130 + %153 = OpLabel + %154 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %154 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %128 - %155 = OpLabel - %156 = OpFunctionCall %void %textureLoad_1bfdfb +%fragment_main = OpFunction %void None %130 + %156 = OpLabel + %157 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %128 - %158 = OpLabel - %159 = OpFunctionCall %void %textureLoad_1bfdfb +%compute_main = OpFunction %void None %130 + %159 = OpLabel + %160 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl index 062af5567d..f4f4be1af0 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.dxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl index 062af5567d..f4f4be1af0 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.fxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl index 772f15f9c3..a24d4fe83c 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl @@ -45,11 +45,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -131,11 +132,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -211,11 +213,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl index 79f2f00b47..b3cf4904fe 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl @@ -45,11 +45,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, int2 coord, ExternalTextureParams params) { + int2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm index 0e9786607d..c15aa870f9 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 161 +; Bound: 164 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -140,21 +140,23 @@ %mat3v2float = OpTypeMatrix %v2float 3 %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams + %v2uint = OpTypeVector %uint 2 %uint_1 = OpConstant %uint 1 - %82 = OpConstantNull %int + %76 = OpConstantComposite %v2uint %uint_1 %uint_1 + %85 = OpConstantNull %int %float_1 = OpConstant %float 1 - %95 = OpConstantNull %uint - %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %98 = OpConstantNull %uint + %116 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %128 = OpTypeFunction %void + %131 = OpTypeFunction %void %int_1 = OpConstant %int 1 - %133 = OpConstantComposite %v2int %int_1 %int_1 + %136 = OpConstantComposite %v2int %int_1 %int_1 %_ptr_Function_v2int = OpTypePointer Function %v2int - %136 = OpConstantNull %v2int + %139 = OpConstantNull %v2int %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %148 = OpTypeFunction %v4float + %151 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -198,104 +200,105 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %75 = OpCompositeExtract %uint %params_0 0 - %77 = OpIEqual %bool %75 %uint_1 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %80 - %79 = OpLabel - %81 = OpImageFetch %v4float %plane0 %coord Lod %82 - %83 = OpVectorShuffle %v3float %81 %81 0 1 2 - OpStore %color %83 - OpBranch %78 - %80 = OpLabel - %84 = OpImageFetch %v4float %plane0 %coord Lod %82 - %85 = OpCompositeExtract %float %84 0 - %86 = OpImageFetch %v4float %plane1 %coord Lod %82 - %87 = OpVectorShuffle %v2float %86 %86 0 1 + %77 = OpShiftRightArithmetic %v2int %coord %76 + %79 = OpCompositeExtract %uint %params_0 0 + %80 = OpIEqual %bool %79 %uint_1 + OpSelectionMerge %81 None + OpBranchConditional %80 %82 %83 + %82 = OpLabel + %84 = OpImageFetch %v4float %plane0 %coord Lod %85 + %86 = OpVectorShuffle %v3float %84 %84 0 1 2 + OpStore %color %86 + OpBranch %81 + %83 = OpLabel + %87 = OpImageFetch %v4float %plane0 %coord Lod %85 %88 = OpCompositeExtract %float %87 0 - %89 = OpCompositeExtract %float %87 1 - %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1 - %92 = OpCompositeExtract %mat3v4float %params_0 2 - %93 = OpVectorTimesMatrix %v3float %91 %92 - OpStore %color %93 - OpBranch %78 - %78 = OpLabel - %94 = OpCompositeExtract %uint %params_0 1 - %96 = OpIEqual %bool %94 %95 - OpSelectionMerge %97 None - OpBranchConditional %96 %98 %97 - %98 = OpLabel - %100 = OpLoad %v3float %color - %101 = OpCompositeExtract %GammaTransferParams %params_0 3 - %99 = OpFunctionCall %v3float %gammaCorrection %100 %101 - OpStore %color %99 - %102 = OpCompositeExtract %mat3v3float %params_0 5 + %89 = OpImageFetch %v4float %plane1 %77 Lod %85 + %90 = OpVectorShuffle %v2float %89 %89 0 1 + %91 = OpCompositeExtract %float %90 0 + %92 = OpCompositeExtract %float %90 1 + %94 = OpCompositeConstruct %v4float %88 %91 %92 %float_1 + %95 = OpCompositeExtract %mat3v4float %params_0 2 + %96 = OpVectorTimesMatrix %v3float %94 %95 + OpStore %color %96 + OpBranch %81 + %81 = OpLabel + %97 = OpCompositeExtract %uint %params_0 1 + %99 = OpIEqual %bool %97 %98 + OpSelectionMerge %100 None + OpBranchConditional %99 %101 %100 + %101 = OpLabel %103 = OpLoad %v3float %color - %104 = OpMatrixTimesVector %v3float %102 %103 - OpStore %color %104 + %104 = OpCompositeExtract %GammaTransferParams %params_0 3 + %102 = OpFunctionCall %v3float %gammaCorrection %103 %104 + OpStore %color %102 + %105 = OpCompositeExtract %mat3v3float %params_0 5 %106 = OpLoad %v3float %color - %107 = OpCompositeExtract %GammaTransferParams %params_0 4 - %105 = OpFunctionCall %v3float %gammaCorrection %106 %107 - OpStore %color %105 - OpBranch %97 - %97 = OpLabel - %108 = OpLoad %v3float %color - %109 = OpCompositeExtract %float %108 0 - %110 = OpCompositeExtract %float %108 1 - %111 = OpCompositeExtract %float %108 2 - %112 = OpCompositeConstruct %v4float %109 %110 %111 %float_1 - OpReturnValue %112 + %107 = OpMatrixTimesVector %v3float %105 %106 + OpStore %color %107 + %109 = OpLoad %v3float %color + %110 = OpCompositeExtract %GammaTransferParams %params_0 4 + %108 = OpFunctionCall %v3float %gammaCorrection %109 %110 + OpStore %color %108 + OpBranch %100 + %100 = OpLabel + %111 = OpLoad %v3float %color + %112 = OpCompositeExtract %float %111 0 + %113 = OpCompositeExtract %float %111 1 + %114 = OpCompositeExtract %float %111 2 + %115 = OpCompositeConstruct %v4float %112 %113 %114 %float_1 + OpReturnValue %115 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %116 %val = OpFunctionParameter %ExternalTextureParams_std140 - %116 = OpLabel - %117 = OpCompositeExtract %uint %val 0 - %118 = OpCompositeExtract %uint %val 1 - %119 = OpCompositeExtract %mat3v4float %val 2 - %120 = OpCompositeExtract %GammaTransferParams %val 3 - %121 = OpCompositeExtract %GammaTransferParams %val 4 - %122 = OpCompositeExtract %mat3v3float %val 5 - %123 = OpCompositeExtract %v2float %val 6 - %124 = OpCompositeExtract %v2float %val 7 - %125 = OpCompositeExtract %v2float %val 8 - %126 = OpCompositeConstruct %mat3v2float %123 %124 %125 - %127 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %126 - OpReturnValue %127 + %119 = OpLabel + %120 = OpCompositeExtract %uint %val 0 + %121 = OpCompositeExtract %uint %val 1 + %122 = OpCompositeExtract %mat3v4float %val 2 + %123 = OpCompositeExtract %GammaTransferParams %val 3 + %124 = OpCompositeExtract %GammaTransferParams %val 4 + %125 = OpCompositeExtract %mat3v3float %val 5 + %126 = OpCompositeExtract %v2float %val 6 + %127 = OpCompositeExtract %v2float %val 7 + %128 = OpCompositeExtract %v2float %val 8 + %129 = OpCompositeConstruct %mat3v2float %126 %127 %128 + %130 = OpCompositeConstruct %ExternalTextureParams %120 %121 %122 %123 %124 %125 %129 + OpReturnValue %130 OpFunctionEnd -%textureLoad_8acf41 = OpFunction %void None %128 - %131 = OpLabel - %arg_1 = OpVariable %_ptr_Function_v2int Function %136 +%textureLoad_8acf41 = OpFunction %void None %131 + %134 = OpLabel + %arg_1 = OpVariable %_ptr_Function_v2int Function %139 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_1 %133 - %138 = OpLoad %11 %arg_0 - %139 = OpLoad %11 %ext_tex_plane_1 - %140 = OpLoad %v2int %arg_1 - %144 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %145 = OpLoad %ExternalTextureParams_std140 %144 - %141 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %145 - %137 = OpFunctionCall %v4float %textureLoadExternal %138 %139 %140 %141 - OpStore %res %137 + OpStore %arg_1 %136 + %141 = OpLoad %11 %arg_0 + %142 = OpLoad %11 %ext_tex_plane_1 + %143 = OpLoad %v2int %arg_1 + %147 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %148 = OpLoad %ExternalTextureParams_std140 %147 + %144 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %148 + %140 = OpFunctionCall %v4float %textureLoadExternal %141 %142 %143 %144 + OpStore %res %140 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %148 - %150 = OpLabel - %151 = OpFunctionCall %void %textureLoad_8acf41 +%vertex_main_inner = OpFunction %v4float None %151 + %153 = OpLabel + %154 = OpFunctionCall %void %textureLoad_8acf41 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %128 - %153 = OpLabel - %154 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %154 +%vertex_main = OpFunction %void None %131 + %156 = OpLabel + %157 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %157 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %128 - %156 = OpLabel - %157 = OpFunctionCall %void %textureLoad_8acf41 - OpReturn - OpFunctionEnd -%compute_main = OpFunction %void None %128 +%fragment_main = OpFunction %void None %131 %159 = OpLabel %160 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd +%compute_main = OpFunction %void None %131 + %162 = OpLabel + %163 = OpFunctionCall %void %textureLoad_8acf41 + OpReturn + OpFunctionEnd diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl index c61c15ddc0..327f874123 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.dxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl index c61c15ddc0..327f874123 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl @@ -32,11 +32,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(Texture2D plane0, Texture2D plane1, int2 coord, ExternalTextureParams params) { + const int2 coord1 = (coord >> (1u).xx); float3 color = float3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = plane0.Load(int3(coord, 0)).rgb; } else { - color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f)); + color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord1, 0)).rg, 1.0f)); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl index f7349229ec..6cbc9c0836 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl @@ -45,11 +45,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -134,11 +135,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); @@ -217,11 +219,12 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { } vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ivec2 coord, ExternalTextureParams params) { + ivec2 coord1 = (coord >> uvec2(1u)); vec3 color = vec3(0.0f, 0.0f, 0.0f); if ((params.numPlanes == 1u)) { color = texelFetch(plane0_1, coord, 0).rgb; } else { - color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (vec4(texelFetch(plane0_1, coord, 0).r, texelFetch(plane1_1, coord1, 0).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl index bda7a402aa..0c67e8fbf0 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl @@ -45,11 +45,12 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureLoadExternal(texture2d plane0, texture2d plane1, int2 coord, ExternalTextureParams params) { + int2 const coord1 = (coord >> uint2(1u)); float3 color = 0.0f; if ((params.numPlanes == 1u)) { color = float4(plane0.read(uint2(coord), 0)).rgb; } else { - color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); + color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord1), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix); } if ((params.doYuvToRgbConversionOnly == 0u)) { color = gammaCorrection(color, params.gammaDecodeParams); diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm index f0e6ad2708..61528e5250 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 164 +; Bound: 167 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -144,19 +144,21 @@ %mat3v2float = OpTypeMatrix %v2float 3 %ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams + %v2uint = OpTypeVector %uint 2 %uint_1 = OpConstant %uint 1 - %82 = OpConstantNull %int + %76 = OpConstantComposite %v2uint %uint_1 %uint_1 + %85 = OpConstantNull %int %float_1 = OpConstant %float 1 - %95 = OpConstantNull %uint - %113 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int - %121 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 + %98 = OpConstantNull %uint + %116 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int + %124 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %136 = OpTypeFunction %void + %139 = OpTypeFunction %void %uint_0 = OpConstant %uint 0 %_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 - %148 = OpConstantNull %v2int + %151 = OpConstantNull %v2int %_ptr_Function_v4float = OpTypePointer Function %v4float - %151 = OpTypeFunction %v4float + %154 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -200,110 +202,111 @@ %params_0 = OpFunctionParameter %ExternalTextureParams %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %75 = OpCompositeExtract %uint %params_0 0 - %77 = OpIEqual %bool %75 %uint_1 - OpSelectionMerge %78 None - OpBranchConditional %77 %79 %80 - %79 = OpLabel - %81 = OpImageFetch %v4float %plane0 %coord Lod %82 - %83 = OpVectorShuffle %v3float %81 %81 0 1 2 - OpStore %color %83 - OpBranch %78 - %80 = OpLabel - %84 = OpImageFetch %v4float %plane0 %coord Lod %82 - %85 = OpCompositeExtract %float %84 0 - %86 = OpImageFetch %v4float %plane1 %coord Lod %82 - %87 = OpVectorShuffle %v2float %86 %86 0 1 + %77 = OpShiftRightArithmetic %v2int %coord %76 + %79 = OpCompositeExtract %uint %params_0 0 + %80 = OpIEqual %bool %79 %uint_1 + OpSelectionMerge %81 None + OpBranchConditional %80 %82 %83 + %82 = OpLabel + %84 = OpImageFetch %v4float %plane0 %coord Lod %85 + %86 = OpVectorShuffle %v3float %84 %84 0 1 2 + OpStore %color %86 + OpBranch %81 + %83 = OpLabel + %87 = OpImageFetch %v4float %plane0 %coord Lod %85 %88 = OpCompositeExtract %float %87 0 - %89 = OpCompositeExtract %float %87 1 - %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1 - %92 = OpCompositeExtract %mat3v4float %params_0 2 - %93 = OpVectorTimesMatrix %v3float %91 %92 - OpStore %color %93 - OpBranch %78 - %78 = OpLabel - %94 = OpCompositeExtract %uint %params_0 1 - %96 = OpIEqual %bool %94 %95 - OpSelectionMerge %97 None - OpBranchConditional %96 %98 %97 - %98 = OpLabel - %100 = OpLoad %v3float %color - %101 = OpCompositeExtract %GammaTransferParams %params_0 3 - %99 = OpFunctionCall %v3float %gammaCorrection %100 %101 - OpStore %color %99 - %102 = OpCompositeExtract %mat3v3float %params_0 5 + %89 = OpImageFetch %v4float %plane1 %77 Lod %85 + %90 = OpVectorShuffle %v2float %89 %89 0 1 + %91 = OpCompositeExtract %float %90 0 + %92 = OpCompositeExtract %float %90 1 + %94 = OpCompositeConstruct %v4float %88 %91 %92 %float_1 + %95 = OpCompositeExtract %mat3v4float %params_0 2 + %96 = OpVectorTimesMatrix %v3float %94 %95 + OpStore %color %96 + OpBranch %81 + %81 = OpLabel + %97 = OpCompositeExtract %uint %params_0 1 + %99 = OpIEqual %bool %97 %98 + OpSelectionMerge %100 None + OpBranchConditional %99 %101 %100 + %101 = OpLabel %103 = OpLoad %v3float %color - %104 = OpMatrixTimesVector %v3float %102 %103 - OpStore %color %104 + %104 = OpCompositeExtract %GammaTransferParams %params_0 3 + %102 = OpFunctionCall %v3float %gammaCorrection %103 %104 + OpStore %color %102 + %105 = OpCompositeExtract %mat3v3float %params_0 5 %106 = OpLoad %v3float %color - %107 = OpCompositeExtract %GammaTransferParams %params_0 4 - %105 = OpFunctionCall %v3float %gammaCorrection %106 %107 - OpStore %color %105 - OpBranch %97 - %97 = OpLabel - %108 = OpLoad %v3float %color - %109 = OpCompositeExtract %float %108 0 - %110 = OpCompositeExtract %float %108 1 - %111 = OpCompositeExtract %float %108 2 - %112 = OpCompositeConstruct %v4float %109 %110 %111 %float_1 - OpReturnValue %112 + %107 = OpMatrixTimesVector %v3float %105 %106 + OpStore %color %107 + %109 = OpLoad %v3float %color + %110 = OpCompositeExtract %GammaTransferParams %params_0 4 + %108 = OpFunctionCall %v3float %gammaCorrection %109 %110 + OpStore %color %108 + OpBranch %100 + %100 = OpLabel + %111 = OpLoad %v3float %color + %112 = OpCompositeExtract %float %111 0 + %113 = OpCompositeExtract %float %111 1 + %114 = OpCompositeExtract %float %111 2 + %115 = OpCompositeConstruct %v4float %112 %113 %114 %float_1 + OpReturnValue %115 OpFunctionEnd -%textureLoad2d = OpFunction %v4float None %113 +%textureLoad2d = OpFunction %v4float None %116 %texture = OpFunctionParameter %11 %ext_tex_plane_1_1 = OpFunctionParameter %11 %ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams %coords = OpFunctionParameter %v2int - %119 = OpLabel - %120 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1 - OpReturnValue %120 + %122 = OpLabel + %123 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1 + OpReturnValue %123 OpFunctionEnd -%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %121 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %124 %val = OpFunctionParameter %ExternalTextureParams_std140 - %124 = OpLabel - %125 = OpCompositeExtract %uint %val 0 - %126 = OpCompositeExtract %uint %val 1 - %127 = OpCompositeExtract %mat3v4float %val 2 - %128 = OpCompositeExtract %GammaTransferParams %val 3 - %129 = OpCompositeExtract %GammaTransferParams %val 4 - %130 = OpCompositeExtract %mat3v3float %val 5 - %131 = OpCompositeExtract %v2float %val 6 - %132 = OpCompositeExtract %v2float %val 7 - %133 = OpCompositeExtract %v2float %val 8 - %134 = OpCompositeConstruct %mat3v2float %131 %132 %133 - %135 = OpCompositeConstruct %ExternalTextureParams %125 %126 %127 %128 %129 %130 %134 - OpReturnValue %135 + %127 = OpLabel + %128 = OpCompositeExtract %uint %val 0 + %129 = OpCompositeExtract %uint %val 1 + %130 = OpCompositeExtract %mat3v4float %val 2 + %131 = OpCompositeExtract %GammaTransferParams %val 3 + %132 = OpCompositeExtract %GammaTransferParams %val 4 + %133 = OpCompositeExtract %mat3v3float %val 5 + %134 = OpCompositeExtract %v2float %val 6 + %135 = OpCompositeExtract %v2float %val 7 + %136 = OpCompositeExtract %v2float %val 8 + %137 = OpCompositeConstruct %mat3v2float %134 %135 %136 + %138 = OpCompositeConstruct %ExternalTextureParams %128 %129 %130 %131 %132 %133 %137 + OpReturnValue %138 OpFunctionEnd -%doTextureLoad = OpFunction %void None %136 - %139 = OpLabel +%doTextureLoad = OpFunction %void None %139 + %142 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %141 = OpLoad %11 %arg_0 - %142 = OpLoad %11 %ext_tex_plane_1 - %146 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 - %147 = OpLoad %ExternalTextureParams_std140 %146 - %143 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %147 - %140 = OpFunctionCall %v4float %textureLoad2d %141 %142 %143 %148 - OpStore %res %140 + %144 = OpLoad %11 %arg_0 + %145 = OpLoad %11 %ext_tex_plane_1 + %149 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %150 = OpLoad %ExternalTextureParams_std140 %149 + %146 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %150 + %143 = OpFunctionCall %v4float %textureLoad2d %144 %145 %146 %151 + OpStore %res %143 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %151 - %153 = OpLabel - %154 = OpFunctionCall %void %doTextureLoad +%vertex_main_inner = OpFunction %v4float None %154 + %156 = OpLabel + %157 = OpFunctionCall %void %doTextureLoad OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %136 - %156 = OpLabel - %157 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %157 +%vertex_main = OpFunction %void None %139 + %159 = OpLabel + %160 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %160 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %136 - %159 = OpLabel - %160 = OpFunctionCall %void %doTextureLoad - OpReturn - OpFunctionEnd -%compute_main = OpFunction %void None %136 +%fragment_main = OpFunction %void None %139 %162 = OpLabel %163 = OpFunctionCall %void %doTextureLoad OpReturn OpFunctionEnd +%compute_main = OpFunction %void None %139 + %165 = OpLabel + %166 = OpFunctionCall %void %doTextureLoad + OpReturn + OpFunctionEnd