diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index d472bd5e01..b2b4c50290 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -1561,6 +1561,7 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, return false; bool pack_mip_in_coords = false; + uint32_t hlsl_ret_width = 4u; switch (intrinsic->Type()) { case sem::IntrinsicType::kTextureSample: @@ -1577,9 +1578,11 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, break; case sem::IntrinsicType::kTextureSampleCompare: out << ".SampleCmp("; + hlsl_ret_width = 1; break; case sem::IntrinsicType::kTextureSampleCompareLevel: out << ".SampleCmpLevelZero("; + hlsl_ret_width = 1; break; case sem::IntrinsicType::kTextureLoad: out << ".Load("; @@ -1630,28 +1633,52 @@ bool GeneratorImpl::EmitTextureCall(std::ostream& pre, } } else if (pack_mip_in_coords) { // Mip level needs to be appended to the coordinates, but is always zero. - if (!emit_vector_appended_with_i32_zero(param_coords)) + if (!emit_vector_appended_with_i32_zero(param_coords)) { return false; + } } else { - if (!EmitExpression(pre, out, param_coords)) + if (!EmitExpression(pre, out, param_coords)) { return false; + } } for (auto usage : {Usage::kDepthRef, Usage::kBias, Usage::kLevel, Usage::kDdx, Usage::kDdy, Usage::kSampleIndex, Usage::kOffset}) { if (auto* e = arg(usage)) { out << ", "; - if (!EmitExpression(pre, out, e)) + if (!EmitExpression(pre, out, e)) { return false; + } } } if (intrinsic->Type() == sem::IntrinsicType::kTextureStore) { out << "] = "; - if (!EmitExpression(pre, out, arg(Usage::kValue))) + if (!EmitExpression(pre, out, arg(Usage::kValue))) { return false; + } } else { out << ")"; + + // If the intrinsic return type does not match the number of elements of the + // HLSL intrinsic, we need to swizzle the expression to generate the correct + // number of components. + uint32_t wgsl_ret_width = 1; + if (auto* vec = intrinsic->ReturnType()->As()) { + wgsl_ret_width = vec->size(); + } + if (wgsl_ret_width < hlsl_ret_width) { + out << "."; + for (uint32_t i = 0; i < wgsl_ret_width; i++) { + out << "xyz"[i]; + } + } + if (wgsl_ret_width > hlsl_ret_width) { + TINT_ICE(diagnostics_) << "WGSL return width (" << wgsl_ret_width + << ") is wider than HLSL return width (" + << hlsl_ret_width << ") for " << intrinsic->Type(); + return false; + } } return true; diff --git a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc index e35e50315f..82475fcf2e 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_texture_test.cc @@ -44,7 +44,7 @@ ExpectedResult expected_texture_overload( R"(int tint_tmp; tint_symbol.GetDimensions(tint_tmp); )", - "tint_tmp", + "tint_tmp;", }; case ValidTextureOverload::kDimensions2d: case ValidTextureOverload::kDimensionsDepth2d: @@ -54,14 +54,14 @@ ExpectedResult expected_texture_overload( R"(int2 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y); )", - "tint_tmp", + "tint_tmp;", }; case ValidTextureOverload::kDimensionsMultisampled2d: return { R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensions2dArray: @@ -72,7 +72,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensions3d: case ValidTextureOverload::kDimensionsStorageRO3d: @@ -81,7 +81,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp", + "tint_tmp;", }; case ValidTextureOverload::kDimensionsCube: case ValidTextureOverload::kDimensionsDepthCube: @@ -89,7 +89,7 @@ ExpectedResult expected_texture_overload( R"(int2 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y); )", - "tint_tmp", + "tint_tmp;", }; case ValidTextureOverload::kDimensionsCubeArray: case ValidTextureOverload::kDimensionsDepthCubeArray: @@ -97,7 +97,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensions2dLevel: case ValidTextureOverload::kDimensionsDepth2dLevel: @@ -105,7 +105,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(1, tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensions2dArrayLevel: case ValidTextureOverload::kDimensionsDepth2dArrayLevel: @@ -113,14 +113,14 @@ ExpectedResult expected_texture_overload( R"(int4 tint_tmp; tint_symbol.GetDimensions(1, tint_tmp.x, tint_tmp.y, tint_tmp.z, tint_tmp.w); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensions3dLevel: return { R"(int4 tint_tmp; tint_symbol.GetDimensions(1, tint_tmp.x, tint_tmp.y, tint_tmp.z, tint_tmp.w); )", - "tint_tmp.xyz", + "tint_tmp.xyz;", }; case ValidTextureOverload::kDimensionsCubeLevel: case ValidTextureOverload::kDimensionsDepthCubeLevel: @@ -128,7 +128,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(1, tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kDimensionsCubeArrayLevel: case ValidTextureOverload::kDimensionsDepthCubeArrayLevel: @@ -136,7 +136,7 @@ ExpectedResult expected_texture_overload( R"(int4 tint_tmp; tint_symbol.GetDimensions(1, tint_tmp.x, tint_tmp.y, tint_tmp.z, tint_tmp.w); )", - "tint_tmp.xy", + "tint_tmp.xy;", }; case ValidTextureOverload::kNumLayers2dArray: case ValidTextureOverload::kNumLayersDepth2dArray: @@ -147,7 +147,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.z", + "tint_tmp.z;", }; case ValidTextureOverload::kNumLevels2d: case ValidTextureOverload::kNumLevelsCube: @@ -157,7 +157,7 @@ ExpectedResult expected_texture_overload( R"(int3 tint_tmp; tint_symbol.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.z", + "tint_tmp.z;", }; case ValidTextureOverload::kNumLevels2dArray: case ValidTextureOverload::kNumLevels3d: @@ -168,165 +168,165 @@ ExpectedResult expected_texture_overload( R"(int4 tint_tmp; tint_symbol.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z, tint_tmp.w); )", - "tint_tmp.w", + "tint_tmp.w;", }; case ValidTextureOverload::kNumSamplesMultisampled2d: return { R"(int3 tint_tmp; tint_symbol.GetDimensions(tint_tmp.x, tint_tmp.y, tint_tmp.z); )", - "tint_tmp.z", + "tint_tmp.z;", }; case ValidTextureOverload::kSample1dF32: - return R"(tint_symbol.Sample(tint_symbol_1, 1.0f))"; + return R"(tint_symbol.Sample(tint_symbol_1, 1.0f);)"; case ValidTextureOverload::kSample2dF32: - return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f));)"; case ValidTextureOverload::kSample2dOffsetF32: - return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f), int2(3, 4)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f), int2(3, 4));)"; case ValidTextureOverload::kSample2dArrayF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3))))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3)));)"; case ValidTextureOverload::kSample2dArrayOffsetF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3)), int2(4, 5)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3)), int2(4, 5));)"; case ValidTextureOverload::kSample3dF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSample3dOffsetF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), int3(4, 5, 6));)"; case ValidTextureOverload::kSampleCubeF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f));)"; case ValidTextureOverload::kSampleCubeArrayF32: - return R"(tint_symbol.Sample(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4))))"; + return R"(tint_symbol.Sample(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)));)"; case ValidTextureOverload::kSampleDepth2dF32: - return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f)).x;)"; case ValidTextureOverload::kSampleDepth2dOffsetF32: - return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f), int2(3, 4)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float2(1.0f, 2.0f), int2(3, 4)).x;)"; case ValidTextureOverload::kSampleDepth2dArrayF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3))))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3))).x;)"; case ValidTextureOverload::kSampleDepth2dArrayOffsetF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3)), int2(4, 5)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, float(3)), int2(4, 5)).x;)"; case ValidTextureOverload::kSampleDepthCubeF32: - return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f)))"; + return R"(tint_symbol.Sample(tint_symbol_1, float3(1.0f, 2.0f, 3.0f)).x;)"; case ValidTextureOverload::kSampleDepthCubeArrayF32: - return R"(tint_symbol.Sample(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4))))"; + return R"(tint_symbol.Sample(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4))).x;)"; case ValidTextureOverload::kSampleBias2dF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float2(1.0f, 2.0f), 3.0f))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleBias2dOffsetF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5));)"; case ValidTextureOverload::kSampleBias2dArrayF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f);)"; case ValidTextureOverload::kSampleBias2dArrayOffsetF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f, int2(5, 6)))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f, int2(5, 6));)"; case ValidTextureOverload::kSampleBias3dF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleBias3dOffsetF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f, int3(5, 6, 7)))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f, int3(5, 6, 7));)"; case ValidTextureOverload::kSampleBiasCubeF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleBiasCubeArrayF32: - return R"(tint_symbol.SampleBias(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(3)), 4.0f))"; + return R"(tint_symbol.SampleBias(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(3)), 4.0f);)"; case ValidTextureOverload::kSampleLevel2dF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3.0f))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleLevel2dOffsetF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5));)"; case ValidTextureOverload::kSampleLevel2dArrayF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f);)"; case ValidTextureOverload::kSampleLevel2dArrayOffsetF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f, int2(5, 6)))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4.0f, int2(5, 6));)"; case ValidTextureOverload::kSampleLevel3dF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleLevel3dOffsetF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f, int3(5, 6, 7)))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f, int3(5, 6, 7));)"; case ValidTextureOverload::kSampleLevelCubeF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleLevelCubeArrayF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kSampleLevelDepth2dF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3).x;)"; case ValidTextureOverload::kSampleLevelDepth2dOffsetF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3, int2(4, 5)))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float2(1.0f, 2.0f), 3, int2(4, 5)).x;)"; case ValidTextureOverload::kSampleLevelDepth2dArrayF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4).x;)"; case ValidTextureOverload::kSampleLevelDepth2dArrayOffsetF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4, int2(5, 6)))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, float(3)), 4, int2(5, 6)).x;)"; case ValidTextureOverload::kSampleLevelDepthCubeF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4).x;)"; case ValidTextureOverload::kSampleLevelDepthCubeArrayF32: - return R"(tint_symbol.SampleLevel(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5))"; + return R"(tint_symbol.SampleLevel(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5).x;)"; case ValidTextureOverload::kSampleGrad2dF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float2(1.0f, 2.0f), float2(3.0f, 4.0f), float2(5.0f, 6.0f)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float2(1.0f, 2.0f), float2(3.0f, 4.0f), float2(5.0f, 6.0f));)"; case ValidTextureOverload::kSampleGrad2dOffsetF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float2(1.0f, 2.0f), float2(3.0f, 4.0f), float2(5.0f, 6.0f), int2(7, 8)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float2(1.0f, 2.0f), float2(3.0f, 4.0f), float2(5.0f, 6.0f), int2(7, 8));)"; case ValidTextureOverload::kSampleGrad2dArrayF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, float(3)), float2(4.0f, 5.0f), float2(6.0f, 7.0f)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, float(3)), float2(4.0f, 5.0f), float2(6.0f, 7.0f));)"; case ValidTextureOverload::kSampleGrad2dArrayOffsetF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, float(3)), float2(4.0f, 5.0f), float2(6.0f, 7.0f), int2(8, 9)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, float(3)), float2(4.0f, 5.0f), float2(6.0f, 7.0f), int2(8, 9));)"; case ValidTextureOverload::kSampleGrad3dF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));)"; case ValidTextureOverload::kSampleGrad3dOffsetF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f), int3(10, 11, 12)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f), int3(10, 11, 12));)"; case ValidTextureOverload::kSampleGradCubeF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));)"; case ValidTextureOverload::kSampleGradCubeArrayF32: - return R"(tint_symbol.SampleGrad(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f)))"; + return R"(tint_symbol.SampleGrad(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), float3(5.0f, 6.0f, 7.0f), float3(8.0f, 9.0f, 10.0f));)"; case ValidTextureOverload::kSampleCompareDepth2dF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float2(1.0f, 2.0f), 3.0f))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleCompareDepth2dOffsetF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5));)"; case ValidTextureOverload::kSampleCompareDepth2dArrayF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f);)"; case ValidTextureOverload::kSampleCompareDepth2dArrayOffsetF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6)))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6));)"; case ValidTextureOverload::kSampleCompareDepthCubeF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleCompareDepthCubeArrayF32: - return R"(tint_symbol.SampleCmp(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f))"; + return R"(tint_symbol.SampleCmp(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kSampleCompareLevelDepth2dF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float2(1.0f, 2.0f), 3.0f))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float2(1.0f, 2.0f), 3.0f);)"; case ValidTextureOverload::kSampleCompareLevelDepth2dOffsetF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5)))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float2(1.0f, 2.0f), 3.0f, int2(4, 5));)"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f);)"; case ValidTextureOverload::kSampleCompareLevelDepth2dArrayOffsetF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6)))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, float(4)), 3.0f, int2(5, 6));)"; case ValidTextureOverload::kSampleCompareLevelDepthCubeF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float3(1.0f, 2.0f, 3.0f), 4.0f);)"; case ValidTextureOverload::kSampleCompareLevelDepthCubeArrayF32: - return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f))"; + return R"(tint_symbol.SampleCmpLevelZero(tint_symbol_1, float4(1.0f, 2.0f, 3.0f, float(4)), 5.0f);)"; case ValidTextureOverload::kLoad1dLevelF32: - return R"(tint_symbol.Load(int2(1, 0), 3))"; + return R"(tint_symbol.Load(int2(1, 0), 3);)"; case ValidTextureOverload::kLoad1dLevelU32: - return R"(tint_symbol.Load(int2(1, 0), 3))"; + return R"(tint_symbol.Load(int2(1, 0), 3);)"; case ValidTextureOverload::kLoad1dLevelI32: - return R"(tint_symbol.Load(int2(1, 0), 3))"; + return R"(tint_symbol.Load(int2(1, 0), 3);)"; case ValidTextureOverload::kLoad2dLevelF32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoad2dLevelU32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoad2dLevelI32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoad2dArrayLevelF32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoad2dArrayLevelU32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoad2dArrayLevelI32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoad3dLevelF32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoad3dLevelU32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoad3dLevelI32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4);)"; case ValidTextureOverload::kLoadMultisampled2dF32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoadMultisampled2dU32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoadMultisampled2dI32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3);)"; case ValidTextureOverload::kLoadDepth2dLevelF32: - return R"(tint_symbol.Load(int3(1, 2, 0), 3))"; + return R"(tint_symbol.Load(int3(1, 2, 0), 3).x;)"; case ValidTextureOverload::kLoadDepth2dArrayLevelF32: - return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0), 4).x;)"; case ValidTextureOverload::kLoadStorageRO1dRgba32float: - return R"(tint_symbol.Load(int2(1, 0)))"; + return R"(tint_symbol.Load(int2(1, 0));)"; case ValidTextureOverload::kLoadStorageRO2dRgba8unorm: case ValidTextureOverload::kLoadStorageRO2dRgba8snorm: case ValidTextureOverload::kLoadStorageRO2dRgba8uint: @@ -343,19 +343,19 @@ ExpectedResult expected_texture_overload( case ValidTextureOverload::kLoadStorageRO2dRgba32uint: case ValidTextureOverload::kLoadStorageRO2dRgba32sint: case ValidTextureOverload::kLoadStorageRO2dRgba32float: - return R"(tint_symbol.Load(int3(1, 2, 0)))"; + return R"(tint_symbol.Load(int3(1, 2, 0));)"; case ValidTextureOverload::kLoadStorageRO2dArrayRgba32float: - return R"(tint_symbol.Load(int4(1, 2, 3, 0)))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0));)"; case ValidTextureOverload::kLoadStorageRO3dRgba32float: - return R"(tint_symbol.Load(int4(1, 2, 3, 0)))"; + return R"(tint_symbol.Load(int4(1, 2, 3, 0));)"; case ValidTextureOverload::kStoreWO1dRgba32float: - return R"(tint_symbol[1] = float4(2.0f, 3.0f, 4.0f, 5.0f))"; + return R"(tint_symbol[1] = float4(2.0f, 3.0f, 4.0f, 5.0f);)"; case ValidTextureOverload::kStoreWO2dRgba32float: - return R"(tint_symbol[int2(1, 2)] = float4(3.0f, 4.0f, 5.0f, 6.0f))"; + return R"(tint_symbol[int2(1, 2)] = float4(3.0f, 4.0f, 5.0f, 6.0f);)"; case ValidTextureOverload::kStoreWO2dArrayRgba32float: - return R"(tint_symbol[int3(1, 2, 3)] = float4(4.0f, 5.0f, 6.0f, 7.0f))"; + return R"(tint_symbol[int3(1, 2, 3)] = float4(4.0f, 5.0f, 6.0f, 7.0f);)"; case ValidTextureOverload::kStoreWO3dRgba32float: - return R"(tint_symbol[int3(1, 2, 3)] = float4(4.0f, 5.0f, 6.0f, 7.0f))"; + return R"(tint_symbol[int3(1, 2, 3)] = float4(4.0f, 5.0f, 6.0f, 7.0f);)"; } return ""; } // NOLINT - Ignore the length of this function diff --git a/test/bug/tint/827.wgsl.expected.hlsl b/test/bug/tint/827.wgsl.expected.hlsl index bb53157412..b3581d6196 100644 --- a/test/bug/tint/827.wgsl.expected.hlsl +++ b/test/bug/tint/827.wgsl.expected.hlsl @@ -9,6 +9,6 @@ struct tint_symbol_1 { [numthreads(1, 1, 1)] void main(tint_symbol_1 tint_symbol) { const uint3 GlobalInvocationId = tint_symbol.GlobalInvocationId; - result.Store((4u * ((GlobalInvocationId.y * width) + GlobalInvocationId.x)), asuint(tex.Load(int3(int(GlobalInvocationId.x), int(GlobalInvocationId.y), 0), 0))); + result.Store((4u * ((GlobalInvocationId.y * width) + GlobalInvocationId.x)), asuint(tex.Load(int3(int(GlobalInvocationId.x), int(GlobalInvocationId.y), 0), 0).x)); return; } diff --git a/test/intrinsics/gen/textureLoad/19cf87.wgsl.expected.hlsl b/test/intrinsics/gen/textureLoad/19cf87.wgsl.expected.hlsl index 2f11c738cd..b4d522185c 100644 --- a/test/intrinsics/gen/textureLoad/19cf87.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureLoad/19cf87.wgsl.expected.hlsl @@ -1,7 +1,7 @@ Texture2D arg_0 : register(t0, space1); void textureLoad_19cf87() { - float res = arg_0.Load(int3(0, 0, 0), 1); + float res = arg_0.Load(int3(0, 0, 0), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureLoad/9b2667.wgsl.expected.hlsl b/test/intrinsics/gen/textureLoad/9b2667.wgsl.expected.hlsl index d41bf8b9b8..e513119df2 100644 --- a/test/intrinsics/gen/textureLoad/9b2667.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureLoad/9b2667.wgsl.expected.hlsl @@ -1,7 +1,7 @@ Texture2DArray arg_0 : register(t0, space1); void textureLoad_9b2667() { - float res = arg_0.Load(int4(0, 0, 1, 0), 1); + float res = arg_0.Load(int4(0, 0, 1, 0), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSample/38bbb9.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/38bbb9.wgsl.expected.hlsl index 1804b92726..eed7099604 100644 --- a/test/intrinsics/gen/textureSample/38bbb9.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/38bbb9.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2D arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_38bbb9() { - float res = arg_0.Sample(arg_1, float2(0.0f, 0.0f)); + float res = arg_0.Sample(arg_1, float2(0.0f, 0.0f)).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSample/667d76.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/667d76.wgsl.expected.hlsl index b47fa1a99d..6f582e3460 100644 --- a/test/intrinsics/gen/textureSample/667d76.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/667d76.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2D arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_667d76() { - float res = arg_0.Sample(arg_1, float2(0.0f, 0.0f), int2(0, 0)); + float res = arg_0.Sample(arg_1, float2(0.0f, 0.0f), int2(0, 0)).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSample/7e9ffd.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/7e9ffd.wgsl.expected.hlsl index 4a3fcf2744..b3167130ed 100644 --- a/test/intrinsics/gen/textureSample/7e9ffd.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/7e9ffd.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2DArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_7e9ffd() { - float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, float(1))); + float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, float(1))).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSample/8522e7.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/8522e7.wgsl.expected.hlsl index 2e1b6234d4..a47e848497 100644 --- a/test/intrinsics/gen/textureSample/8522e7.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/8522e7.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2DArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_8522e7() { - float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, float(1)), int2(0, 0)); + float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, float(1)), int2(0, 0)).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSample/c2f4e8.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/c2f4e8.wgsl.expected.hlsl index d201d1f471..c2eee5aed8 100644 --- a/test/intrinsics/gen/textureSample/c2f4e8.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/c2f4e8.wgsl.expected.hlsl @@ -2,7 +2,7 @@ TextureCubeArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_c2f4e8() { - float res = arg_0.Sample(arg_1, float4(0.0f, 0.0f, 0.0f, float(1))); + float res = arg_0.Sample(arg_1, float4(0.0f, 0.0f, 0.0f, float(1))).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSample/ea7030.wgsl.expected.hlsl b/test/intrinsics/gen/textureSample/ea7030.wgsl.expected.hlsl index 730837fd2b..f01c286204 100644 --- a/test/intrinsics/gen/textureSample/ea7030.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSample/ea7030.wgsl.expected.hlsl @@ -2,7 +2,7 @@ TextureCube arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSample_ea7030() { - float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, 0.0f)); + float res = arg_0.Sample(arg_1, float3(0.0f, 0.0f, 0.0f)).x; } void fragment_main() { diff --git a/test/intrinsics/gen/textureSampleLevel/02be59.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/02be59.wgsl.expected.hlsl index 13c3f119cd..91b31b046f 100644 --- a/test/intrinsics/gen/textureSampleLevel/02be59.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/02be59.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2D arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_02be59() { - float res = arg_0.SampleLevel(arg_1, float2(0.0f, 0.0f), 1); + float res = arg_0.SampleLevel(arg_1, float2(0.0f, 0.0f), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSampleLevel/1b0291.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/1b0291.wgsl.expected.hlsl index a2b0752913..b74acd61a0 100644 --- a/test/intrinsics/gen/textureSampleLevel/1b0291.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/1b0291.wgsl.expected.hlsl @@ -2,7 +2,7 @@ TextureCube arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_1b0291() { - float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, 0.0f), 1); + float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, 0.0f), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSampleLevel/1bf73e.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/1bf73e.wgsl.expected.hlsl index 7a18e0c7a6..ec16c2ab43 100644 --- a/test/intrinsics/gen/textureSampleLevel/1bf73e.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/1bf73e.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2DArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_1bf73e() { - float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, float(1)), 1); + float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, float(1)), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSampleLevel/47daa4.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/47daa4.wgsl.expected.hlsl index 3e841fc8b6..25843068e0 100644 --- a/test/intrinsics/gen/textureSampleLevel/47daa4.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/47daa4.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2D arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_47daa4() { - float res = arg_0.SampleLevel(arg_1, float2(0.0f, 0.0f), 1, int2(0, 0)); + float res = arg_0.SampleLevel(arg_1, float2(0.0f, 0.0f), 1, int2(0, 0)).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSampleLevel/ae5e39.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/ae5e39.wgsl.expected.hlsl index 6cfb1d5918..f9cabecf7e 100644 --- a/test/intrinsics/gen/textureSampleLevel/ae5e39.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/ae5e39.wgsl.expected.hlsl @@ -2,7 +2,7 @@ TextureCubeArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_ae5e39() { - float res = arg_0.SampleLevel(arg_1, float4(0.0f, 0.0f, 0.0f, float(1)), 1); + float res = arg_0.SampleLevel(arg_1, float4(0.0f, 0.0f, 0.0f, float(1)), 1).x; } struct tint_symbol { diff --git a/test/intrinsics/gen/textureSampleLevel/ba93b3.wgsl.expected.hlsl b/test/intrinsics/gen/textureSampleLevel/ba93b3.wgsl.expected.hlsl index b48b267444..9a7073d363 100644 --- a/test/intrinsics/gen/textureSampleLevel/ba93b3.wgsl.expected.hlsl +++ b/test/intrinsics/gen/textureSampleLevel/ba93b3.wgsl.expected.hlsl @@ -2,7 +2,7 @@ Texture2DArray arg_0 : register(t0, space1); SamplerState arg_1 : register(s1, space1); void textureSampleLevel_ba93b3() { - float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, float(1)), 1, int2(0, 0)); + float res = arg_0.SampleLevel(arg_1, float3(0.0f, 0.0f, float(1)), 1, int2(0, 0)).x; } struct tint_symbol {