diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp index 9a0a91975a..f24043aa62 100644 --- a/src/dawn/native/ExternalTexture.cpp +++ b/src/dawn/native/ExternalTexture.cpp @@ -209,67 +209,106 @@ MaybeError ExternalTextureBase::Initialize(DeviceBase* device, const float* dstFn = descriptor->dstTransferFunctionParameters; std::copy(dstFn, dstFn + 7, params.gammaEncodingParams.begin()); - // These scale factors perform part of the cropping operation. These default to 1, so we can use - // them directly for performing rotation in the matrix later. - float xScale = descriptor->visibleRect.width; - float yScale = descriptor->visibleRect.height; + // Unlike WGSL, which stores matrices in column vectors, the following arithmetic uses row + // vectors, so elements are stored in the following order: + // ┌ ┐ + // │ 0, 1, 2 │ + // │ 3, 4, 5 │ + // └ ┘ + // The matrix is transposed at the end. + using mat2x3 = std::array; - // In the shader, we must convert UV coordinates from the {0, 1} space to the {-0.5, 0.5} space - // to do rotation. Ideally, we want to combine the rotate, flip-Y operations in a single matrix - // operation - but this is complicated because scaling most easily occurs in the {0, 1} space. - // We can work around this and perform scaling in the {-0.5, 0.5} space by multiplying the - // needed conversion constant "+ 0.5" by the scale factor. We then can do this all within a - // single matrix operation by calculating and adding this value to the offset specified in the - // matrix. For reference, this is the entire operation needed is: - // - // newCoords = vec3((coord - 0.5f), 1.0f) * coordTransformationMatrix) + (scaleFactor * - // 0.5) - // - // Because we combine the ending (scaleFactor * 0.5) into the crop offset within the matrix, the - // shader is actually: - // - // newCoords = vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix; - // - // TODO(dawn:1614): Incorporate the "- 0.5f" into the matrix. - float xOffset = descriptor->visibleRect.x + 0.5f * xScale; - float yOffset = descriptor->visibleRect.y + 0.5f * yScale; + // Multiplies the two mat2x3 matrices, by treating the RHS matrix as a mat3x3 where the last row + // is [0, 0, 1]. + auto Mul = [&](const mat2x3& lhs, const mat2x3& rhs) { + auto& a = lhs[0]; + auto& b = lhs[1]; + auto& c = lhs[2]; + auto& d = lhs[3]; + auto& e = lhs[4]; + auto& f = lhs[5]; + auto& g = rhs[0]; + auto& h = rhs[1]; + auto& i = rhs[2]; + auto& j = rhs[3]; + auto& k = rhs[4]; + auto& l = rhs[5]; + // ┌ ┐ ┌ ┐ + // │ a, b, c │ │ g, h, i │ + // │ d, e, f │ x │ j, k, l │ + // └ ┘ │ 0, 0, 1 │ + // └ ┘ + return mat2x3{ + a * g + b * j, // + a * h + b * k, // + a * i + b * l + c, // + d * g + e * j, // + d * h + e * k, // + d * i + e * l + f, // + }; + }; - // Flip-Y can be done by simply negating the scaling factor in the y-plane. The position of the - // y-plane scaling factor in the matrix can be different depending on the rotation. - float flipY = 1; + auto Scale = [&](const mat2x3& m, float x, float y) { + return Mul(mat2x3{x, 0, 0, 0, y, 0}, m); + }; + + auto Translate = [&](const mat2x3& m, float x, float y) { + return Mul(mat2x3{1, 0, x, 0, 1, y}, m); + }; + + mat2x3 coordTransformMatrix = { + 1, 0, 0, // + 0, 1, 0, // + }; + + // Offset the coordinates so the center texel is at the origin, so we can apply rotations and + // y-flips. After translation, coordinates range from [-0.5 .. +0.5] in both U and V. + coordTransformMatrix = Translate(coordTransformMatrix, -0.5, -0.5); + + // If the texture needs flipping, mirror in Y. if (descriptor->flipY) { - flipY = -1; + coordTransformMatrix = Scale(coordTransformMatrix, 1, -1); } - // This block creates a 2x3 matrix which when multiplied by UV coordinates in a shader performs - // rotation, flip-Y and cropping operations. + // Apply rotations as needed. switch (descriptor->rotation) { case wgpu::ExternalTextureRotation::Rotate0Degrees: - params.coordTransformMatrix = {xScale, 0.0, // - xOffset, 0.0, // - 0.0, flipY * yScale, // - yOffset, 0.0}; break; case wgpu::ExternalTextureRotation::Rotate90Degrees: - params.coordTransformMatrix = {0.0, flipY * yScale, // - xOffset, 0.0, // - -xScale, 0.0, // - yOffset, 0.0}; + coordTransformMatrix = Mul(mat2x3{0, +1, 0, // x' = y + -1, 0, 0}, // y' = -x + coordTransformMatrix); break; case wgpu::ExternalTextureRotation::Rotate180Degrees: - params.coordTransformMatrix = {-xScale, 0.0, // - xOffset, 0.0, // - 0.0, flipY * -yScale, // - yOffset, 0.0}; + coordTransformMatrix = Mul(mat2x3{-1, 0, 0, // x' = -x + 0, -1, 0}, // y' = -y + coordTransformMatrix); break; case wgpu::ExternalTextureRotation::Rotate270Degrees: - params.coordTransformMatrix = {0.0, flipY * -yScale, // - xOffset, 0.0, // - xScale, 0.0, // - yOffset, 0.0}; + coordTransformMatrix = Mul(mat2x3{0, -1, 0, // x' = -y + +1, 0, 0}, // y' = x + coordTransformMatrix); break; } + // Offset the coordinates so the bottom-left texel is at origin. + // After translation, coordinates range from [0 .. 1] in both U and V. + coordTransformMatrix = Translate(coordTransformMatrix, 0.5, 0.5); + + // Finally, scale and translate based on the visible rect. This applies cropping. + coordTransformMatrix = + Scale(coordTransformMatrix, descriptor->visibleRect.width, descriptor->visibleRect.height); + coordTransformMatrix = + Translate(coordTransformMatrix, descriptor->visibleRect.x, descriptor->visibleRect.y); + + // Transpose the mat2x3 into column vectors for use by WGSL. + params.coordTransformMatrix[0] = coordTransformMatrix[0]; + params.coordTransformMatrix[1] = coordTransformMatrix[3]; + params.coordTransformMatrix[2] = coordTransformMatrix[1]; + params.coordTransformMatrix[3] = coordTransformMatrix[4]; + params.coordTransformMatrix[4] = coordTransformMatrix[2]; + params.coordTransformMatrix[5] = coordTransformMatrix[5]; + DAWN_TRY(device->GetQueue()->WriteBuffer(mParamsBuffer.Get(), 0, ¶ms, sizeof(ExternalTextureParams))); diff --git a/src/dawn/native/ExternalTexture.h b/src/dawn/native/ExternalTexture.h index 9570451fcd..1e637b3c51 100644 --- a/src/dawn/native/ExternalTexture.h +++ b/src/dawn/native/ExternalTexture.h @@ -35,7 +35,7 @@ struct ExternalTextureParams { std::array gammaDecodingParams = {}; std::array gammaEncodingParams = {}; std::array gamutConversionMatrix = {}; - std::array coordTransformMatrix = {}; + std::array coordTransformMatrix = {}; }; MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device, diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp index b3a833cd2a..316dfc3654 100644 --- a/src/dawn/tests/end2end/ExternalTextureTests.cpp +++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp @@ -374,23 +374,24 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) { utils::RGBA8 lowerRightColor; }; - std::array expectations = { - {{wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen, - utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed, - utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, - {wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue, - utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack, - utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, - {wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed, - utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack}, - {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue, - utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}, - {wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack, - utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed}, - {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen, - utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}}}; + std::array expectations = {{ + {wgpu::ExternalTextureRotation::Rotate0Degrees, false, utils::RGBA8::kGreen, + utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kBlue}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, false, utils::RGBA8::kRed, + utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kBlack}, + {wgpu::ExternalTextureRotation::Rotate180Degrees, false, utils::RGBA8::kBlue, + utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kGreen}, + {wgpu::ExternalTextureRotation::Rotate270Degrees, false, utils::RGBA8::kBlack, + utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kRed}, + {wgpu::ExternalTextureRotation::Rotate0Degrees, true, utils::RGBA8::kRed, + utils::RGBA8::kBlue, utils::RGBA8::kGreen, utils::RGBA8::kBlack}, + {wgpu::ExternalTextureRotation::Rotate90Degrees, true, utils::RGBA8::kBlue, + utils::RGBA8::kBlack, utils::RGBA8::kRed, utils::RGBA8::kGreen}, + {wgpu::ExternalTextureRotation::Rotate180Degrees, true, utils::RGBA8::kBlack, + utils::RGBA8::kGreen, utils::RGBA8::kBlue, utils::RGBA8::kRed}, + {wgpu::ExternalTextureRotation::Rotate270Degrees, true, utils::RGBA8::kGreen, + utils::RGBA8::kRed, utils::RGBA8::kBlack, utils::RGBA8::kBlue}, + }}; for (const RotationExpectation& exp : expectations) { // Pipeline Creation diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index f8c927b174..f5770fb6a8 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -263,7 +263,7 @@ struct MultiplanarExternalTexture::State { b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")), b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")), b.Member("gamutConversionMatrix", b.ty.mat3x3()), - b.Member("coordTransformationMatrix", b.ty.mat2x3())}; + b.Member("coordTransformationMatrix", b.ty.mat3x2())}; params_struct_sym = b.Symbols().New("ExternalTextureParams"); @@ -316,12 +316,9 @@ struct MultiplanarExternalTexture::State { const ast::CallExpression* plane_1_call = nullptr; switch (call_type) { case sem::BuiltinType::kTextureSampleBaseClampToEdge: - // TODO(dawn:1614): Change this statement to incorporate the "- 0.5" into the - // matrix. - stmts.Push( - b.Decl(b.Let("modifiedCoords", - b.Mul(b.vec3(b.Sub("coord", f32(0.5)), f32(1.0f)), - b.MemberAccessor("params", "coordTransformationMatrix"))))); + stmts.Push(b.Decl(b.Let( + "modifiedCoords", b.Mul(b.MemberAccessor("params", "coordTransformationMatrix"), + b.vec3("coord", 1_a))))); stmts.Push(b.Decl(b.Let( "plane0_dims", diff --git a/src/tint/transform/multiplanar_external_texture_test.cc b/src/tint/transform/multiplanar_external_texture_test.cc index 15fa48e032..c76e3e39e0 100644 --- a/src/tint/transform/multiplanar_external_texture_test.cc +++ b/src/tint/transform/multiplanar_external_texture_test.cc @@ -138,7 +138,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(1) var ext_tex_plane_1 : texture_2d; @@ -194,7 +194,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(1) var ext_tex_plane_1 : texture_2d; @@ -249,7 +249,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -268,7 +268,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -333,7 +333,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -348,7 +348,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -418,7 +418,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(1) var ext_tex_plane_1 : texture_2d; @@ -511,7 +511,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(1) var ext_tex_plane_1 : texture_2d; @@ -603,7 +603,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -622,7 +622,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -702,7 +702,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -717,7 +717,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -807,7 +807,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(4) var ext_tex_plane_1 : texture_2d; @@ -844,7 +844,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -918,7 +918,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -933,7 +933,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1011,7 +1011,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1031,7 +1031,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1104,7 +1104,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1119,7 +1119,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1199,7 +1199,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(3) var ext_tex_plane_1 : texture_2d; @@ -1218,7 +1218,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1303,7 +1303,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(3) var ext_tex_plane_1 : texture_2d; @@ -1327,7 +1327,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1408,7 +1408,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1423,7 +1423,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1509,7 +1509,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1524,7 +1524,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1598,7 +1598,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } fn f(ext_tex : texture_2d, ext_tex_plane_1 : texture_2d, ext_tex_params : ExternalTextureParams) -> vec2 { @@ -1650,7 +1650,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1667,7 +1667,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); @@ -1746,7 +1746,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; @@ -1766,7 +1766,7 @@ fn gammaCorrection(v : vec3, params : GammaTransferParams) -> vec3 { } fn textureSampleExternal(plane0 : texture_2d, plane1 : texture_2d, smp : sampler, coord : vec2, params : ExternalTextureParams) -> vec4 { - let modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + let modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1)); let plane0_dims = vec2(textureDimensions(plane0, 0)); let plane0_half_texel = (vec2(0.5) / plane0_dims); let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel)); diff --git a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl index 4e5d1946c5..8f9f2ce525 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl @@ -19,7 +19,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space0); @@ -67,8 +67,8 @@ GammaTransferParams tint_symbol_8(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_13 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_13; + const GammaTransferParams tint_symbol_14 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_14; } float3x3 tint_symbol_10(uint4 buffer[13], uint offset) { @@ -78,17 +78,21 @@ float3x3 tint_symbol_10(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_12(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_12(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_4(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_14 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_6(buffer, (offset + 16u)), tint_symbol_8(buffer, (offset + 64u)), tint_symbol_8(buffer, (offset + 96u)), tint_symbol_10(buffer, (offset + 128u)), tint_symbol_12(buffer, (offset + 176u))}; - return tint_symbol_14; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_15 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_6(buffer, (offset + 16u)), tint_symbol_8(buffer, (offset + 64u)), tint_symbol_8(buffer, (offset + 96u)), tint_symbol_10(buffer, (offset + 128u)), tint_symbol_12(buffer, (offset + 176u))}; + return tint_symbol_15; } [numthreads(1, 1, 1)] diff --git a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl index 4e5d1946c5..8f9f2ce525 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl +++ b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl @@ -19,7 +19,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space0); @@ -67,8 +67,8 @@ GammaTransferParams tint_symbol_8(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_13 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_13; + const GammaTransferParams tint_symbol_14 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_14; } float3x3 tint_symbol_10(uint4 buffer[13], uint offset) { @@ -78,17 +78,21 @@ float3x3 tint_symbol_10(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_12(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_12(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_4(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_14 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_6(buffer, (offset + 16u)), tint_symbol_8(buffer, (offset + 64u)), tint_symbol_8(buffer, (offset + 96u)), tint_symbol_10(buffer, (offset + 128u)), tint_symbol_12(buffer, (offset + 176u))}; - return tint_symbol_14; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_15 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_6(buffer, (offset + 16u)), tint_symbol_8(buffer, (offset + 64u)), tint_symbol_8(buffer, (offset + 96u)), tint_symbol_10(buffer, (offset + 128u)), tint_symbol_12(buffer, (offset + 176u))}; + return tint_symbol_15; } [numthreads(1, 1, 1)] diff --git a/test/tint/bug/tint/1739.wgsl.expected.glsl b/test/tint/bug/tint/1739.wgsl.expected.glsl index 6f48f14fd1..2e0bcd3f6a 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.glsl +++ b/test/tint/bug/tint/1739.wgsl.expected.glsl @@ -20,11 +20,29 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; + uint pad_2; + uint pad_3; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + uint pad; + uint pad_1; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; + uint pad_2; + uint pad_3; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; layout(rgba8) uniform highp writeonly image2D outImage; @@ -52,10 +70,14 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D t_2; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.pad, val.pad_1, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2), val.pad_2, val.pad_3); +} + void tint_symbol() { - vec4 red = textureLoadExternal(t_2, ext_tex_plane_1_1, clamp(ivec2(10), ivec2(0), ivec2((uvec2(uvec2(textureSize(t_2, 0))) - uvec2(1u)))), ext_tex_params.inner); + vec4 red = textureLoadExternal(t_2, ext_tex_plane_1_1, clamp(ivec2(10), ivec2(0), ivec2((uvec2(uvec2(textureSize(t_2, 0))) - uvec2(1u)))), conv_ExternalTextureParams(ext_tex_params.inner)); imageStore(outImage, clamp(ivec2(0), ivec2(0), ivec2((uvec2(uvec2(imageSize(outImage))) - uvec2(1u)))), red); - vec4 green = textureLoadExternal(t_2, ext_tex_plane_1_1, clamp(ivec2(70, 118), ivec2(0), ivec2((uvec2(uvec2(textureSize(t_2, 0))) - uvec2(1u)))), ext_tex_params.inner); + vec4 green = textureLoadExternal(t_2, ext_tex_plane_1_1, clamp(ivec2(70, 118), ivec2(0), ivec2((uvec2(uvec2(textureSize(t_2, 0))) - uvec2(1u)))), conv_ExternalTextureParams(ext_tex_params.inner)); imageStore(outImage, clamp(ivec2(1, 0), ivec2(0), ivec2((uvec2(uvec2(imageSize(outImage))) - uvec2(1u)))), green); return; } diff --git a/test/tint/bug/tint/1739.wgsl.expected.msl b/test/tint/bug/tint/1739.wgsl.expected.msl index 267f97adc1..834c6d5c9e 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.msl +++ b/test/tint/bug/tint/1739.wgsl.expected.msl @@ -37,7 +37,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { diff --git a/test/tint/bug/tint/1739.wgsl.expected.spvasm b/test/tint/bug/tint/1739.wgsl.expected.spvasm index 92f0b5bc37..35659d8341 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: 178 +; Bound: 196 ; Schema: 0 OpCapability Shader OpCapability ImageQuery @@ -10,13 +10,13 @@ OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -26,9 +26,11 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %t "t" OpName %outImage "outImage" @@ -39,25 +41,35 @@ OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %main "main" OpName %red "red" OpName %green "green" OpDecorate %ext_tex_plane_1 DescriptorSet 0 OpDecorate %ext_tex_plane_1 Binding 2 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -66,13 +78,13 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 - OpMemberDecorate %ExternalTextureParams 4 Offset 96 - OpMemberDecorate %ExternalTextureParams 5 Offset 128 - OpMemberDecorate %ExternalTextureParams 5 ColMajor - OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 6 Offset 176 - OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 OpDecorate %ext_tex_params NonWritable OpDecorate %ext_tex_params DescriptorSet 0 OpDecorate %ext_tex_params Binding 3 @@ -81,6 +93,19 @@ OpDecorate %outImage NonReadable OpDecorate %outImage DescriptorSet 0 OpDecorate %outImage Binding 1 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpMemberDecorate %ExternalTextureParams 4 Offset 96 + OpMemberDecorate %ExternalTextureParams 5 Offset 128 + OpMemberDecorate %ExternalTextureParams 5 ColMajor + OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 6 Offset 176 + OpMemberDecorate %ExternalTextureParams 6 ColMajor + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %3 = OpTypeImage %float 2D 0 0 0 1 Unknown %_ptr_UniformConstant_3 = OpTypePointer UniformConstant %3 @@ -91,11 +116,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %t = OpVariable %_ptr_UniformConstant_3 UniformConstant %19 = OpTypeImage %float 2D 0 0 0 2 Rgba8 %_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19 @@ -108,29 +133,31 @@ %v3bool = OpTypeVector %bool 3 %_ptr_Function_v3float = OpTypePointer Function %v3float %50 = OpConstantNull %v3float +%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 - %85 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %87 = OpConstantNull %int %float_1 = OpConstant %float 1 - %99 = OpConstantNull %uint + %100 = OpConstantNull %uint + %118 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %117 = OpTypeFunction %void + %133 = OpTypeFunction %void %int_10 = OpConstant %int 10 - %123 = OpConstantComposite %v2int %int_10 %int_10 - %124 = OpConstantNull %v2int + %139 = OpConstantComposite %v2int %int_10 %int_10 + %140 = OpConstantNull %v2int %v2uint = OpTypeVector %uint 2 %int_0 = OpConstant %int 0 - %131 = OpConstantComposite %v2uint %uint_1 %uint_1 + %147 = OpConstantComposite %v2uint %uint_1 %uint_1 %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %142 = OpConstantNull %v4float + %159 = OpConstantNull %v4float %int_70 = OpConstant %int 70 %int_118 = OpConstant %int 118 - %155 = OpConstantComposite %v2int %int_70 %int_118 + %172 = OpConstantComposite %v2int %int_70 %int_118 %int_1 = OpConstant %int 1 - %169 = OpConstantComposite %v2int %int_1 %85 + %187 = OpConstantComposite %v2int %int_1 %87 %tint_clamp = OpFunction %v2int None %20 %e = OpFunctionParameter %v2int %low = OpFunctionParameter %v2int @@ -181,97 +208,115 @@ %plane1 = OpFunctionParameter %3 %coord = OpFunctionParameter %v2int %params_0 = OpFunctionParameter %ExternalTextureParams - %76 = OpLabel + %78 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %50 - %78 = OpCompositeExtract %uint %params_0 0 - %80 = OpIEqual %bool %78 %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 + %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 + %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 - %87 = OpImageFetch %v4float %plane0 %coord Lod %85 - %88 = OpCompositeExtract %float %87 0 - %89 = OpImageFetch %v4float %plane1 %coord Lod %85 - %91 = OpVectorShuffle %v2float %89 %89 0 1 - %92 = OpCompositeExtract %float %91 0 - %93 = OpCompositeExtract %float %91 1 - %95 = OpCompositeConstruct %v4float %88 %92 %93 %float_1 - %96 = OpCompositeExtract %mat3v4float %params_0 2 - %97 = OpVectorTimesMatrix %v3float %95 %96 - OpStore %color %97 - OpBranch %81 - %81 = OpLabel - %98 = OpCompositeExtract %uint %params_0 1 - %100 = OpIEqual %bool %98 %99 - OpSelectionMerge %101 None - OpBranchConditional %100 %102 %101 - %102 = OpLabel - %104 = OpLoad %v3float %color - %105 = OpCompositeExtract %GammaTransferParams %params_0 3 - %103 = OpFunctionCall %v3float %gammaCorrection %104 %105 - OpStore %color %103 - %106 = OpCompositeExtract %mat3v3float %params_0 5 - %107 = OpLoad %v3float %color - %108 = OpMatrixTimesVector %v3float %106 %107 - OpStore %color %108 - %110 = OpLoad %v3float %color - %111 = OpCompositeExtract %GammaTransferParams %params_0 4 - %109 = OpFunctionCall %v3float %gammaCorrection %110 %111 + %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 + %108 = OpLoad %v3float %color + %109 = OpMatrixTimesVector %v3float %107 %108 OpStore %color %109 - OpBranch %101 - %101 = OpLabel - %112 = OpLoad %v3float %color - %113 = OpCompositeExtract %float %112 0 - %114 = OpCompositeExtract %float %112 1 - %115 = OpCompositeExtract %float %112 2 - %116 = OpCompositeConstruct %v4float %113 %114 %115 %float_1 - OpReturnValue %116 + %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 OpFunctionEnd - %main = OpFunction %void None %117 - %120 = OpLabel - %red = OpVariable %_ptr_Function_v4float Function %142 - %green = OpVariable %_ptr_Function_v4float Function %142 - %129 = OpLoad %3 %t - %128 = OpImageQuerySizeLod %v2uint %129 %int_0 - %132 = OpISub %v2uint %128 %131 - %125 = OpBitcast %v2int %132 - %121 = OpFunctionCall %v2int %tint_clamp %123 %124 %125 - %134 = OpLoad %3 %t - %135 = OpLoad %3 %ext_tex_plane_1 - %138 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %139 = OpLoad %ExternalTextureParams %138 - %133 = OpFunctionCall %v4float %textureLoadExternal %134 %135 %121 %139 - OpStore %red %133 - %147 = OpLoad %19 %outImage - %146 = OpImageQuerySize %v2uint %147 - %148 = OpISub %v2uint %146 %131 - %144 = OpBitcast %v2int %148 - %143 = OpFunctionCall %v2int %tint_clamp %124 %124 %144 - %150 = OpLoad %19 %outImage - %151 = OpLoad %v4float %red - OpImageWrite %150 %143 %151 - %159 = OpLoad %3 %t - %158 = OpImageQuerySizeLod %v2uint %159 %int_0 - %160 = OpISub %v2uint %158 %131 - %156 = OpBitcast %v2int %160 - %152 = OpFunctionCall %v2int %tint_clamp %155 %124 %156 - %162 = OpLoad %3 %t - %163 = OpLoad %3 %ext_tex_plane_1 - %164 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %165 = OpLoad %ExternalTextureParams %164 - %161 = OpFunctionCall %v4float %textureLoadExternal %162 %163 %152 %165 - OpStore %green %161 - %173 = OpLoad %19 %outImage - %172 = OpImageQuerySize %v2uint %173 - %174 = OpISub %v2uint %172 %131 - %170 = OpBitcast %v2int %174 - %167 = OpFunctionCall %v2int %tint_clamp %169 %124 %170 - %176 = OpLoad %19 %outImage - %177 = OpLoad %v4float %green - OpImageWrite %176 %167 %177 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %118 + %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 + 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 OpReturn OpFunctionEnd diff --git a/test/tint/bug/tint/1739.wgsl.expected.wgsl b/test/tint/bug/tint/1739.wgsl.expected.wgsl index b3e9613f3f..f4c25e6d40 100644 --- a/test/tint/bug/tint/1739.wgsl.expected.wgsl +++ b/test/tint/bug/tint/1739.wgsl.expected.wgsl @@ -16,7 +16,7 @@ struct ExternalTextureParams { gammaDecodeParams : GammaTransferParams, gammaEncodeParams : GammaTransferParams, gamutConversionMatrix : mat3x3, - coordTransformationMatrix : mat2x3, + coordTransformationMatrix : mat3x2, } @group(0) @binding(2) var ext_tex_plane_1 : texture_2d; diff --git a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl index 166425ef81..f358a0993e 100644 --- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; @@ -64,11 +76,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; @@ -104,11 +128,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; diff --git a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl index b15ada1217..ec4f00621d 100644 --- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl @@ -19,7 +19,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; void textureDimensions_cdc6c9(texture2d tint_symbol_1) { diff --git a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm index 5cb8e1ce1c..920b2b5c0c 100644 --- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,9 +30,11 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %textureDimensions_cdc6c9 "textureDimensions_cdc6c9" @@ -45,14 +47,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -61,13 +63,13 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 - OpMemberDecorate %ExternalTextureParams 4 Offset 96 - OpMemberDecorate %ExternalTextureParams 5 Offset 128 - OpMemberDecorate %ExternalTextureParams 5 ColMajor - OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 6 Offset 176 - OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 OpDecorate %ext_tex_params NonWritable OpDecorate %ext_tex_params DescriptorSet 1 OpDecorate %ext_tex_params Binding 2 @@ -89,11 +91,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %void = OpTypeVoid %23 = OpTypeFunction %void 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 f85afb725f..17bf1dd4dc 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_1bfdfb() { 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 f85afb725f..17bf1dd4dc 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_1bfdfb() { 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 f86097c524..f20ac3428b 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -49,8 +61,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -87,11 +103,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -118,8 +146,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -150,11 +182,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -181,8 +225,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, uvec2(1u), conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { 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 193efc6609..b96779516d 100644 --- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { 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 8e3400af99..97b8218b77 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: 139 +; Bound: 156 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,20 +30,32 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureLoad_1bfdfb "textureLoad_1bfdfb" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -54,14 +66,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -70,18 +82,31 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 + OpDecorate %ext_tex_params NonWritable + OpDecorate %ext_tex_params DescriptorSet 1 + OpDecorate %ext_tex_params Binding 2 + OpDecorate %arg_0 DescriptorSet 1 + OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 OpMemberDecorate %ExternalTextureParams 4 Offset 96 OpMemberDecorate %ExternalTextureParams 5 Offset 128 OpMemberDecorate %ExternalTextureParams 5 ColMajor OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 OpMemberDecorate %ExternalTextureParams 6 Offset 176 OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 - OpDecorate %ext_tex_params NonWritable - OpDecorate %ext_tex_params DescriptorSet 1 - OpDecorate %ext_tex_params Binding 2 - OpDecorate %arg_0 DescriptorSet 1 - OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -98,11 +123,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %23 = OpTypeFunction %v3float %v3float %GammaTransferParams %bool = OpTypeBool @@ -110,20 +135,22 @@ %_ptr_Function_v3float = OpTypePointer Function %v3float %43 = OpConstantNull %v3float %v2uint = OpTypeVector %uint 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams %uint_1 = OpConstant %uint 1 %int = OpTypeInt 32 1 - %80 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %82 = OpConstantNull %int %float_1 = OpConstant %float 1 - %94 = OpConstantNull %uint + %95 = OpConstantNull %uint + %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %112 = OpTypeFunction %void - %119 = OpConstantComposite %v2uint %uint_1 %uint_1 + %128 = OpTypeFunction %void + %135 = OpConstantComposite %v2uint %uint_1 %uint_1 %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %126 = OpTypeFunction %v4float + %143 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -165,86 +192,103 @@ %plane1 = OpFunctionParameter %11 %coord = OpFunctionParameter %v2uint %params_0 = OpFunctionParameter %ExternalTextureParams - %70 = OpLabel + %72 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %72 = OpCompositeExtract %uint %params_0 0 - %74 = OpIEqual %bool %72 %uint_1 - OpSelectionMerge %75 None - OpBranchConditional %74 %76 %77 - %76 = OpLabel - %78 = OpImageFetch %v4float %plane0 %coord Lod %80 - %81 = OpVectorShuffle %v3float %78 %78 0 1 2 - OpStore %color %81 - OpBranch %75 + %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 + %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 - %82 = OpImageFetch %v4float %plane0 %coord Lod %80 - %83 = OpCompositeExtract %float %82 0 - %84 = OpImageFetch %v4float %plane1 %coord Lod %80 - %86 = OpVectorShuffle %v2float %84 %84 0 1 - %87 = OpCompositeExtract %float %86 0 - %88 = OpCompositeExtract %float %86 1 - %90 = OpCompositeConstruct %v4float %83 %87 %88 %float_1 - %91 = OpCompositeExtract %mat3v4float %params_0 2 - %92 = OpVectorTimesMatrix %v3float %90 %91 - OpStore %color %92 - OpBranch %75 - %75 = OpLabel - %93 = OpCompositeExtract %uint %params_0 1 - %95 = OpIEqual %bool %93 %94 - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - %99 = OpLoad %v3float %color - %100 = OpCompositeExtract %GammaTransferParams %params_0 3 - %98 = OpFunctionCall %v3float %gammaCorrection %99 %100 - OpStore %color %98 - %101 = OpCompositeExtract %mat3v3float %params_0 5 - %102 = OpLoad %v3float %color - %103 = OpMatrixTimesVector %v3float %101 %102 - OpStore %color %103 - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 4 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 + %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 - OpBranch %96 - %96 = OpLabel - %107 = OpLoad %v3float %color - %108 = OpCompositeExtract %float %107 0 - %109 = OpCompositeExtract %float %107 1 - %110 = OpCompositeExtract %float %107 2 - %111 = OpCompositeConstruct %v4float %108 %109 %110 %float_1 - OpReturnValue %111 + %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 OpFunctionEnd -%textureLoad_1bfdfb = OpFunction %void None %112 - %115 = OpLabel +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 + %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 + OpFunctionEnd +%textureLoad_1bfdfb = OpFunction %void None %128 + %131 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %117 = OpLoad %11 %arg_0 - %118 = OpLoad %11 %ext_tex_plane_1 - %122 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %123 = OpLoad %ExternalTextureParams %122 - %116 = OpFunctionCall %v4float %textureLoadExternal %117 %118 %119 %123 - OpStore %res %116 + %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 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %126 - %128 = OpLabel - %129 = OpFunctionCall %void %textureLoad_1bfdfb +%vertex_main_inner = OpFunction %v4float None %143 + %145 = OpLabel + %146 = OpFunctionCall %void %textureLoad_1bfdfb OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %112 - %131 = OpLabel - %132 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %132 +%vertex_main = OpFunction %void None %128 + %148 = OpLabel + %149 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %149 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %112 - %134 = OpLabel - %135 = OpFunctionCall %void %textureLoad_1bfdfb +%fragment_main = OpFunction %void None %128 + %151 = OpLabel + %152 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %112 - %137 = OpLabel - %138 = OpFunctionCall %void %textureLoad_1bfdfb +%compute_main = OpFunction %void None %128 + %154 = OpLabel + %155 = 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 c48e41af00..fd0e466b1e 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_8acf41() { 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 c48e41af00..fd0e466b1e 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_8acf41() { 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 c01f77903d..93f5c75009 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -49,8 +61,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -87,11 +103,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -118,8 +146,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -150,11 +182,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -181,8 +225,12 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, ivec2(1), conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { 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 67fdf13f1f..467303ea69 100644 --- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { 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 1c3c4e2282..a6467db281 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: 140 +; Bound: 157 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,20 +30,32 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureLoad_8acf41 "textureLoad_8acf41" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -54,14 +66,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -70,18 +82,31 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 + OpDecorate %ext_tex_params NonWritable + OpDecorate %ext_tex_params DescriptorSet 1 + OpDecorate %ext_tex_params Binding 2 + OpDecorate %arg_0 DescriptorSet 1 + OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 OpMemberDecorate %ExternalTextureParams 4 Offset 96 OpMemberDecorate %ExternalTextureParams 5 Offset 128 OpMemberDecorate %ExternalTextureParams 5 ColMajor OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 OpMemberDecorate %ExternalTextureParams 6 Offset 176 OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 - OpDecorate %ext_tex_params NonWritable - OpDecorate %ext_tex_params DescriptorSet 1 - OpDecorate %ext_tex_params Binding 2 - OpDecorate %arg_0 DescriptorSet 1 - OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -98,11 +123,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %23 = OpTypeFunction %v3float %v3float %GammaTransferParams %bool = OpTypeBool @@ -111,20 +136,22 @@ %43 = OpConstantNull %v3float %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams %uint_1 = OpConstant %uint 1 - %80 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %82 = OpConstantNull %int %float_1 = OpConstant %float 1 - %94 = OpConstantNull %uint + %95 = OpConstantNull %uint + %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %112 = OpTypeFunction %void + %128 = OpTypeFunction %void %int_1 = OpConstant %int 1 - %120 = OpConstantComposite %v2int %int_1 %int_1 + %136 = OpConstantComposite %v2int %int_1 %int_1 %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %127 = OpTypeFunction %v4float + %144 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -166,86 +193,103 @@ %plane1 = OpFunctionParameter %11 %coord = OpFunctionParameter %v2int %params_0 = OpFunctionParameter %ExternalTextureParams - %71 = OpLabel + %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %73 = OpCompositeExtract %uint %params_0 0 - %75 = OpIEqual %bool %73 %uint_1 - OpSelectionMerge %76 None - OpBranchConditional %75 %77 %78 - %77 = OpLabel - %79 = OpImageFetch %v4float %plane0 %coord Lod %80 - %81 = OpVectorShuffle %v3float %79 %79 0 1 2 - OpStore %color %81 - OpBranch %76 + %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 + %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 - %82 = OpImageFetch %v4float %plane0 %coord Lod %80 - %83 = OpCompositeExtract %float %82 0 - %84 = OpImageFetch %v4float %plane1 %coord Lod %80 - %86 = OpVectorShuffle %v2float %84 %84 0 1 - %87 = OpCompositeExtract %float %86 0 - %88 = OpCompositeExtract %float %86 1 - %90 = OpCompositeConstruct %v4float %83 %87 %88 %float_1 - %91 = OpCompositeExtract %mat3v4float %params_0 2 - %92 = OpVectorTimesMatrix %v3float %90 %91 - OpStore %color %92 - OpBranch %76 - %76 = OpLabel - %93 = OpCompositeExtract %uint %params_0 1 - %95 = OpIEqual %bool %93 %94 - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - %99 = OpLoad %v3float %color - %100 = OpCompositeExtract %GammaTransferParams %params_0 3 - %98 = OpFunctionCall %v3float %gammaCorrection %99 %100 - OpStore %color %98 - %101 = OpCompositeExtract %mat3v3float %params_0 5 - %102 = OpLoad %v3float %color - %103 = OpMatrixTimesVector %v3float %101 %102 - OpStore %color %103 - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 4 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 + %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 - OpBranch %96 - %96 = OpLabel - %107 = OpLoad %v3float %color - %108 = OpCompositeExtract %float %107 0 - %109 = OpCompositeExtract %float %107 1 - %110 = OpCompositeExtract %float %107 2 - %111 = OpCompositeConstruct %v4float %108 %109 %110 %float_1 - OpReturnValue %111 + %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 OpFunctionEnd -%textureLoad_8acf41 = OpFunction %void None %112 - %115 = OpLabel +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 + %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 + OpFunctionEnd +%textureLoad_8acf41 = OpFunction %void None %128 + %131 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %117 = OpLoad %11 %arg_0 - %118 = OpLoad %11 %ext_tex_plane_1 - %123 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %124 = OpLoad %ExternalTextureParams %123 - %116 = OpFunctionCall %v4float %textureLoadExternal %117 %118 %120 %124 - OpStore %res %116 + %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 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %127 - %129 = OpLabel - %130 = OpFunctionCall %void %textureLoad_8acf41 +%vertex_main_inner = OpFunction %v4float None %144 + %146 = OpLabel + %147 = OpFunctionCall %void %textureLoad_8acf41 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %112 - %132 = OpLabel - %133 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %133 +%vertex_main = OpFunction %void None %128 + %149 = OpLabel + %150 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %150 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %112 - %135 = OpLabel - %136 = OpFunctionCall %void %textureLoad_8acf41 +%fragment_main = OpFunction %void None %128 + %152 = OpLabel + %153 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %112 - %138 = OpLabel - %139 = OpFunctionCall %void %textureLoad_8acf41 +%compute_main = OpFunction %void None %128 + %155 = OpLabel + %156 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl index 1cf5c8dfdc..b6bbc70b37 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space1); @@ -33,7 +33,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(Texture2D plane0, Texture2D plane1, SamplerState smp, float2 coord, ExternalTextureParams params) { - const float2 modifiedCoords = mul(params.coordTransformationMatrix, float3((coord - 0.5f), 1.0f)); + const float2 modifiedCoords = mul(float3(coord, 1.0f), params.coordTransformationMatrix); int3 tint_tmp; plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z); const float2 plane0_dims = float2(tint_tmp.xy); @@ -74,8 +74,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -85,17 +85,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureSampleBaseClampToEdge_7c04e6() { diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl index 1cf5c8dfdc..b6bbc70b37 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space1); @@ -33,7 +33,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(Texture2D plane0, Texture2D plane1, SamplerState smp, float2 coord, ExternalTextureParams params) { - const float2 modifiedCoords = mul(params.coordTransformationMatrix, float3((coord - 0.5f), 1.0f)); + const float2 modifiedCoords = mul(float3(coord, 1.0f), params.coordTransformationMatrix); int3 tint_tmp; plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z); const float2 plane0_dims = float2(tint_tmp.xy); @@ -74,8 +74,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -85,17 +85,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureSampleBaseClampToEdge_7c04e6() { diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl index e76d774c26..b12b3d8502 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -34,7 +46,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -59,8 +71,12 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -97,11 +113,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -113,7 +141,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -138,8 +166,12 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -170,11 +202,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -186,7 +230,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -211,8 +255,12 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl index 381d6ab0fb..b06119d1fe 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { @@ -44,7 +45,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(texture2d plane0, texture2d plane1, sampler smp, float2 coord, ExternalTextureParams params) { - float2 const modifiedCoords = (float3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + float2 const modifiedCoords = (params.coordTransformationMatrix * float3(coord, 1.0f)); float2 const plane0_dims = float2(uint2(plane0.get_width(0), plane0.get_height(0))); float2 const plane0_half_texel = (float2(0.5f) / plane0_dims); float2 const plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); diff --git a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm index 313856018c..76ed4d14cb 100644 --- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 174 +; Bound: 188 ; Schema: 0 OpCapability Shader OpCapability ImageQuery @@ -15,13 +15,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -31,15 +31,25 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %arg_1 "arg_1" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureSampleExternal "textureSampleExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" @@ -47,6 +57,8 @@ OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureSampleBaseClampToEdge_7c04e6 "textureSampleBaseClampToEdge_7c04e6" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -57,14 +69,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 2 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -73,13 +85,13 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 - OpMemberDecorate %ExternalTextureParams 4 Offset 96 - OpMemberDecorate %ExternalTextureParams 5 Offset 128 - OpMemberDecorate %ExternalTextureParams 5 ColMajor - OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 6 Offset 176 - OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 OpDecorate %ext_tex_params NonWritable OpDecorate %ext_tex_params DescriptorSet 1 OpDecorate %ext_tex_params Binding 3 @@ -87,6 +99,19 @@ OpDecorate %arg_0 Binding 0 OpDecorate %arg_1 DescriptorSet 1 OpDecorate %arg_1 Binding 1 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpMemberDecorate %ExternalTextureParams 4 Offset 96 + OpMemberDecorate %ExternalTextureParams 5 Offset 128 + OpMemberDecorate %ExternalTextureParams 5 ColMajor + OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 6 Offset 176 + OpMemberDecorate %ExternalTextureParams 6 ColMajor + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -103,11 +128,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %25 = OpTypeSampler %_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 @@ -117,26 +142,28 @@ %v3bool = OpTypeVector %bool 3 %_ptr_Function_v3float = OpTypePointer Function %v3float %46 = OpConstantNull %v3float - %v2float = OpTypeVector %float 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams - %float_0_5 = OpConstant %float 0.5 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %79 = OpConstantNull %v2float %float_1 = OpConstant %float 1 %v2uint = OpTypeVector %uint 2 %int = OpTypeInt 32 1 - %91 = OpConstantNull %int - %92 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %86 = OpConstantNull %int + %float_0_5 = OpConstant %float 0.5 + %88 = OpConstantComposite %v2float %float_0_5 %float_0_5 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %94 = OpConstantNull %v2float %uint_1 = OpConstant %uint 1 - %113 = OpTypeSampledImage %11 - %128 = OpConstantNull %uint + %111 = OpTypeSampledImage %11 + %126 = OpConstantNull %uint + %144 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %146 = OpTypeFunction %void - %154 = OpConstantComposite %v2float %float_1 %float_1 + %159 = OpTypeFunction %void + %167 = OpConstantComposite %v2float %float_1 %float_1 %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %161 = OpTypeFunction %v4float + %175 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %26 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -179,112 +206,126 @@ %smp = OpFunctionParameter %25 %coord = OpFunctionParameter %v2float %params_0 = OpFunctionParameter %ExternalTextureParams - %74 = OpLabel - %77 = OpVariable %_ptr_Function_v2float Function %79 - %96 = OpVariable %_ptr_Function_v2float Function %79 - %103 = OpVariable %_ptr_Function_v2float Function %79 + %75 = OpLabel + %92 = OpVariable %_ptr_Function_v2float Function %94 + %101 = OpVariable %_ptr_Function_v2float Function %94 %color = OpVariable %_ptr_Function_v3float Function %46 - %80 = OpCompositeConstruct %v2float %float_0_5 %float_0_5 - %76 = OpFSub %v2float %coord %80 - %81 = OpCompositeExtract %float %76 0 - %82 = OpCompositeExtract %float %76 1 - %84 = OpCompositeConstruct %v3float %81 %82 %float_1 - %85 = OpCompositeExtract %mat2v3float %params_0 6 - %86 = OpVectorTimesMatrix %v2float %84 %85 - %88 = OpImageQuerySizeLod %v2uint %plane0 %91 - %87 = OpConvertUToF %v2float %88 - %93 = OpFDiv %v2float %92 %87 - %97 = OpCompositeConstruct %v2float %float_1 %float_1 - %95 = OpFSub %v2float %97 %93 - %94 = OpExtInst %v2float %32 NClamp %86 %93 %95 - %99 = OpImageQuerySizeLod %v2uint %plane1 %91 - %98 = OpConvertUToF %v2float %99 - %100 = OpFDiv %v2float %92 %98 - %104 = OpCompositeConstruct %v2float %float_1 %float_1 - %102 = OpFSub %v2float %104 %100 - %101 = OpExtInst %v2float %32 NClamp %86 %100 %102 - %106 = OpCompositeExtract %uint %params_0 0 - %108 = OpIEqual %bool %106 %uint_1 - OpSelectionMerge %109 None - OpBranchConditional %108 %110 %111 - %110 = OpLabel - %114 = OpSampledImage %113 %plane0 %smp - %112 = OpImageSampleExplicitLod %v4float %114 %94 Lod %8 - %115 = OpVectorShuffle %v3float %112 %112 0 1 2 - OpStore %color %115 - OpBranch %109 - %111 = OpLabel - %117 = OpSampledImage %113 %plane0 %smp - %116 = OpImageSampleExplicitLod %v4float %117 %94 Lod %8 - %118 = OpCompositeExtract %float %116 0 - %120 = OpSampledImage %113 %plane1 %smp - %119 = OpImageSampleExplicitLod %v4float %120 %101 Lod %8 - %121 = OpVectorShuffle %v2float %119 %119 0 1 - %122 = OpCompositeExtract %float %121 0 - %123 = OpCompositeExtract %float %121 1 - %124 = OpCompositeConstruct %v4float %118 %122 %123 %float_1 - %125 = OpCompositeExtract %mat3v4float %params_0 2 - %126 = OpVectorTimesMatrix %v3float %124 %125 - OpStore %color %126 - OpBranch %109 + %76 = OpCompositeExtract %mat3v2float %params_0 6 + %77 = OpCompositeExtract %float %coord 0 + %78 = OpCompositeExtract %float %coord 1 + %80 = OpCompositeConstruct %v3float %77 %78 %float_1 + %81 = OpMatrixTimesVector %v2float %76 %80 + %83 = OpImageQuerySizeLod %v2uint %plane0 %86 + %82 = OpConvertUToF %v2float %83 + %89 = OpFDiv %v2float %88 %82 + %95 = OpCompositeConstruct %v2float %float_1 %float_1 + %91 = OpFSub %v2float %95 %89 + %90 = OpExtInst %v2float %32 NClamp %81 %89 %91 + %97 = OpImageQuerySizeLod %v2uint %plane1 %86 + %96 = OpConvertUToF %v2float %97 + %98 = OpFDiv %v2float %88 %96 + %102 = OpCompositeConstruct %v2float %float_1 %float_1 + %100 = OpFSub %v2float %102 %98 + %99 = OpExtInst %v2float %32 NClamp %81 %98 %100 + %104 = OpCompositeExtract %uint %params_0 0 + %106 = OpIEqual %bool %104 %uint_1 + OpSelectionMerge %107 None + OpBranchConditional %106 %108 %109 + %108 = OpLabel + %112 = OpSampledImage %111 %plane0 %smp + %110 = OpImageSampleExplicitLod %v4float %112 %90 Lod %8 + %113 = OpVectorShuffle %v3float %110 %110 0 1 2 + OpStore %color %113 + OpBranch %107 %109 = OpLabel - %127 = OpCompositeExtract %uint %params_0 1 - %129 = OpIEqual %bool %127 %128 - OpSelectionMerge %130 None - OpBranchConditional %129 %131 %130 - %131 = OpLabel - %133 = OpLoad %v3float %color - %134 = OpCompositeExtract %GammaTransferParams %params_0 3 - %132 = OpFunctionCall %v3float %gammaCorrection %133 %134 - OpStore %color %132 - %135 = OpCompositeExtract %mat3v3float %params_0 5 - %136 = OpLoad %v3float %color - %137 = OpMatrixTimesVector %v3float %135 %136 - OpStore %color %137 + %115 = OpSampledImage %111 %plane0 %smp + %114 = OpImageSampleExplicitLod %v4float %115 %90 Lod %8 + %116 = OpCompositeExtract %float %114 0 + %118 = OpSampledImage %111 %plane1 %smp + %117 = OpImageSampleExplicitLod %v4float %118 %99 Lod %8 + %119 = OpVectorShuffle %v2float %117 %117 0 1 + %120 = OpCompositeExtract %float %119 0 + %121 = OpCompositeExtract %float %119 1 + %122 = OpCompositeConstruct %v4float %116 %120 %121 %float_1 + %123 = OpCompositeExtract %mat3v4float %params_0 2 + %124 = OpVectorTimesMatrix %v3float %122 %123 + OpStore %color %124 + OpBranch %107 + %107 = OpLabel + %125 = OpCompositeExtract %uint %params_0 1 + %127 = OpIEqual %bool %125 %126 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + %131 = OpLoad %v3float %color + %132 = OpCompositeExtract %GammaTransferParams %params_0 3 + %130 = OpFunctionCall %v3float %gammaCorrection %131 %132 + OpStore %color %130 + %133 = OpCompositeExtract %mat3v3float %params_0 5 + %134 = OpLoad %v3float %color + %135 = OpMatrixTimesVector %v3float %133 %134 + OpStore %color %135 + %137 = OpLoad %v3float %color + %138 = OpCompositeExtract %GammaTransferParams %params_0 4 + %136 = OpFunctionCall %v3float %gammaCorrection %137 %138 + OpStore %color %136 + OpBranch %128 + %128 = OpLabel %139 = OpLoad %v3float %color - %140 = OpCompositeExtract %GammaTransferParams %params_0 4 - %138 = OpFunctionCall %v3float %gammaCorrection %139 %140 - OpStore %color %138 - OpBranch %130 - %130 = OpLabel - %141 = OpLoad %v3float %color - %142 = OpCompositeExtract %float %141 0 - %143 = OpCompositeExtract %float %141 1 - %144 = OpCompositeExtract %float %141 2 - %145 = OpCompositeConstruct %v4float %142 %143 %144 %float_1 - OpReturnValue %145 + %140 = OpCompositeExtract %float %139 0 + %141 = OpCompositeExtract %float %139 1 + %142 = OpCompositeExtract %float %139 2 + %143 = OpCompositeConstruct %v4float %140 %141 %142 %float_1 + OpReturnValue %143 OpFunctionEnd -%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %146 - %149 = OpLabel +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %144 + %val = OpFunctionParameter %ExternalTextureParams_std140 + %147 = OpLabel + %148 = OpCompositeExtract %uint %val 0 + %149 = OpCompositeExtract %uint %val 1 + %150 = OpCompositeExtract %mat3v4float %val 2 + %151 = OpCompositeExtract %GammaTransferParams %val 3 + %152 = OpCompositeExtract %GammaTransferParams %val 4 + %153 = OpCompositeExtract %mat3v3float %val 5 + %154 = OpCompositeExtract %v2float %val 6 + %155 = OpCompositeExtract %v2float %val 7 + %156 = OpCompositeExtract %v2float %val 8 + %157 = OpCompositeConstruct %mat3v2float %154 %155 %156 + %158 = OpCompositeConstruct %ExternalTextureParams %148 %149 %150 %151 %152 %153 %157 + OpReturnValue %158 + OpFunctionEnd +%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %159 + %162 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %151 = OpLoad %11 %arg_0 - %152 = OpLoad %11 %ext_tex_plane_1 - %153 = OpLoad %25 %arg_1 - %157 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %158 = OpLoad %ExternalTextureParams %157 - %150 = OpFunctionCall %v4float %textureSampleExternal %151 %152 %153 %154 %158 - OpStore %res %150 + %164 = OpLoad %11 %arg_0 + %165 = OpLoad %11 %ext_tex_plane_1 + %166 = OpLoad %25 %arg_1 + %171 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %172 = OpLoad %ExternalTextureParams_std140 %171 + %168 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %172 + %163 = OpFunctionCall %v4float %textureSampleExternal %164 %165 %166 %167 %168 + OpStore %res %163 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %161 - %163 = OpLabel - %164 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%vertex_main_inner = OpFunction %v4float None %175 + %177 = OpLabel + %178 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %146 - %166 = OpLabel - %167 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %167 +%vertex_main = OpFunction %void None %159 + %180 = OpLabel + %181 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %181 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %146 - %169 = OpLabel - %170 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%fragment_main = OpFunction %void None %159 + %183 = OpLabel + %184 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %146 - %172 = OpLabel - %173 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%compute_main = OpFunction %void None %159 + %186 = OpLabel + %187 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl index 166425ef81..f358a0993e 100644 --- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; @@ -64,11 +76,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; @@ -104,11 +128,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; uniform highp sampler2D arg_0_1; diff --git a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl index b15ada1217..ec4f00621d 100644 --- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl @@ -19,7 +19,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; void textureDimensions_cdc6c9(texture2d tint_symbol_1) { diff --git a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm index 5cb8e1ce1c..920b2b5c0c 100644 --- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,9 +30,11 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %textureDimensions_cdc6c9 "textureDimensions_cdc6c9" @@ -45,14 +47,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -61,13 +63,13 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 - OpMemberDecorate %ExternalTextureParams 4 Offset 96 - OpMemberDecorate %ExternalTextureParams 5 Offset 128 - OpMemberDecorate %ExternalTextureParams 5 ColMajor - OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 6 Offset 176 - OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 OpDecorate %ext_tex_params NonWritable OpDecorate %ext_tex_params DescriptorSet 1 OpDecorate %ext_tex_params Binding 2 @@ -89,11 +91,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %void = OpTypeVoid %23 = OpTypeFunction %void 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 ce6b28f506..a90f55cb12 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_1bfdfb() { 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 ce6b28f506..a90f55cb12 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_1bfdfb() { 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 9954096907..64681a8540 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -49,9 +61,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { uvec2 arg_1 = uvec2(1u); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -88,11 +104,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -119,9 +147,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { uvec2 arg_1 = uvec2(1u); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -152,11 +184,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -183,9 +227,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, uve uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_1bfdfb() { uvec2 arg_1 = uvec2(1u); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { 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 7531106a3c..a8df5b26dc 100644 --- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { 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 3fdb7b461a..64a3bcd2cf 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: 143 +; Bound: 160 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,20 +30,32 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureLoad_1bfdfb "textureLoad_1bfdfb" OpName %arg_1 "arg_1" OpName %res "res" @@ -55,14 +67,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -71,18 +83,31 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 + OpDecorate %ext_tex_params NonWritable + OpDecorate %ext_tex_params DescriptorSet 1 + OpDecorate %ext_tex_params Binding 2 + OpDecorate %arg_0 DescriptorSet 1 + OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 OpMemberDecorate %ExternalTextureParams 4 Offset 96 OpMemberDecorate %ExternalTextureParams 5 Offset 128 OpMemberDecorate %ExternalTextureParams 5 ColMajor OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 OpMemberDecorate %ExternalTextureParams 6 Offset 176 OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 - OpDecorate %ext_tex_params NonWritable - OpDecorate %ext_tex_params DescriptorSet 1 - OpDecorate %ext_tex_params Binding 2 - OpDecorate %arg_0 DescriptorSet 1 - OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -99,11 +124,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %23 = OpTypeFunction %v3float %v3float %GammaTransferParams %bool = OpTypeBool @@ -111,22 +136,24 @@ %_ptr_Function_v3float = OpTypePointer Function %v3float %43 = OpConstantNull %v3float %v2uint = OpTypeVector %uint 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams %uint_1 = OpConstant %uint 1 %int = OpTypeInt 32 1 - %80 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %82 = OpConstantNull %int %float_1 = OpConstant %float 1 - %94 = OpConstantNull %uint + %95 = OpConstantNull %uint + %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %112 = OpTypeFunction %void - %116 = OpConstantComposite %v2uint %uint_1 %uint_1 + %128 = OpTypeFunction %void + %132 = OpConstantComposite %v2uint %uint_1 %uint_1 %_ptr_Function_v2uint = OpTypePointer Function %v2uint - %119 = OpConstantNull %v2uint + %135 = OpConstantNull %v2uint %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %130 = OpTypeFunction %v4float + %147 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -168,89 +195,106 @@ %plane1 = OpFunctionParameter %11 %coord = OpFunctionParameter %v2uint %params_0 = OpFunctionParameter %ExternalTextureParams - %70 = OpLabel + %72 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %72 = OpCompositeExtract %uint %params_0 0 - %74 = OpIEqual %bool %72 %uint_1 - OpSelectionMerge %75 None - OpBranchConditional %74 %76 %77 - %76 = OpLabel - %78 = OpImageFetch %v4float %plane0 %coord Lod %80 - %81 = OpVectorShuffle %v3float %78 %78 0 1 2 - OpStore %color %81 - OpBranch %75 + %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 + %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 - %82 = OpImageFetch %v4float %plane0 %coord Lod %80 - %83 = OpCompositeExtract %float %82 0 - %84 = OpImageFetch %v4float %plane1 %coord Lod %80 - %86 = OpVectorShuffle %v2float %84 %84 0 1 - %87 = OpCompositeExtract %float %86 0 - %88 = OpCompositeExtract %float %86 1 - %90 = OpCompositeConstruct %v4float %83 %87 %88 %float_1 - %91 = OpCompositeExtract %mat3v4float %params_0 2 - %92 = OpVectorTimesMatrix %v3float %90 %91 - OpStore %color %92 - OpBranch %75 - %75 = OpLabel - %93 = OpCompositeExtract %uint %params_0 1 - %95 = OpIEqual %bool %93 %94 - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - %99 = OpLoad %v3float %color - %100 = OpCompositeExtract %GammaTransferParams %params_0 3 - %98 = OpFunctionCall %v3float %gammaCorrection %99 %100 - OpStore %color %98 - %101 = OpCompositeExtract %mat3v3float %params_0 5 - %102 = OpLoad %v3float %color - %103 = OpMatrixTimesVector %v3float %101 %102 - OpStore %color %103 - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 4 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 + %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 - OpBranch %96 - %96 = OpLabel - %107 = OpLoad %v3float %color - %108 = OpCompositeExtract %float %107 0 - %109 = OpCompositeExtract %float %107 1 - %110 = OpCompositeExtract %float %107 2 - %111 = OpCompositeConstruct %v4float %108 %109 %110 %float_1 - OpReturnValue %111 + %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 OpFunctionEnd -%textureLoad_1bfdfb = OpFunction %void None %112 - %115 = OpLabel - %arg_1 = OpVariable %_ptr_Function_v2uint Function %119 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 + %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 + OpFunctionEnd +%textureLoad_1bfdfb = OpFunction %void None %128 + %131 = OpLabel + %arg_1 = OpVariable %_ptr_Function_v2uint Function %135 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_1 %116 - %121 = OpLoad %11 %arg_0 - %122 = OpLoad %11 %ext_tex_plane_1 - %123 = OpLoad %v2uint %arg_1 - %126 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %127 = OpLoad %ExternalTextureParams %126 - %120 = OpFunctionCall %v4float %textureLoadExternal %121 %122 %123 %127 - OpStore %res %120 + 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 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %130 - %132 = OpLabel - %133 = OpFunctionCall %void %textureLoad_1bfdfb +%vertex_main_inner = OpFunction %v4float None %147 + %149 = OpLabel + %150 = OpFunctionCall %void %textureLoad_1bfdfb OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %112 - %135 = OpLabel - %136 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %136 +%vertex_main = OpFunction %void None %128 + %152 = OpLabel + %153 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %153 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %112 - %138 = OpLabel - %139 = OpFunctionCall %void %textureLoad_1bfdfb +%fragment_main = OpFunction %void None %128 + %155 = OpLabel + %156 = OpFunctionCall %void %textureLoad_1bfdfb OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %112 - %141 = OpLabel - %142 = OpFunctionCall %void %textureLoad_1bfdfb +%compute_main = OpFunction %void None %128 + %158 = OpLabel + %159 = 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 81fc2e996e..55e0aa30b9 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_8acf41() { 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 81fc2e996e..55e0aa30b9 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -62,8 +62,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -73,17 +73,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureLoad_8acf41() { 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 dc56310374..772f15f9c3 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -49,9 +61,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { ivec2 arg_1 = ivec2(1); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -88,11 +104,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -119,9 +147,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { ivec2 arg_1 = ivec2(1); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -152,11 +184,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -183,9 +227,13 @@ vec4 textureLoadExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, ive uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureLoad_8acf41() { ivec2 arg_1 = ivec2(1); - vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, ext_tex_params.inner); + vec4 res = textureLoadExternal(arg_0_1, ext_tex_plane_1_1, arg_1, conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { 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 ce4e96b0b6..79f2f00b47 100644 --- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { 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 eb3098b7a9..0e9786607d 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: 144 +; Bound: 161 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,20 +30,32 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureLoad_8acf41 "textureLoad_8acf41" OpName %arg_1 "arg_1" OpName %res "res" @@ -55,14 +67,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -71,18 +83,31 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 + OpDecorate %ext_tex_params NonWritable + OpDecorate %ext_tex_params DescriptorSet 1 + OpDecorate %ext_tex_params Binding 2 + OpDecorate %arg_0 DescriptorSet 1 + OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 OpMemberDecorate %ExternalTextureParams 4 Offset 96 OpMemberDecorate %ExternalTextureParams 5 Offset 128 OpMemberDecorate %ExternalTextureParams 5 ColMajor OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 OpMemberDecorate %ExternalTextureParams 6 Offset 176 OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 - OpDecorate %ext_tex_params NonWritable - OpDecorate %ext_tex_params DescriptorSet 1 - OpDecorate %ext_tex_params Binding 2 - OpDecorate %arg_0 DescriptorSet 1 - OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -99,11 +124,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %23 = OpTypeFunction %v3float %v3float %GammaTransferParams %bool = OpTypeBool @@ -112,22 +137,24 @@ %43 = OpConstantNull %v3float %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams %uint_1 = OpConstant %uint 1 - %80 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %82 = OpConstantNull %int %float_1 = OpConstant %float 1 - %94 = OpConstantNull %uint + %95 = OpConstantNull %uint + %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %112 = OpTypeFunction %void + %128 = OpTypeFunction %void %int_1 = OpConstant %int 1 - %117 = OpConstantComposite %v2int %int_1 %int_1 + %133 = OpConstantComposite %v2int %int_1 %int_1 %_ptr_Function_v2int = OpTypePointer Function %v2int - %120 = OpConstantNull %v2int + %136 = OpConstantNull %v2int %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %131 = OpTypeFunction %v4float + %148 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -169,89 +196,106 @@ %plane1 = OpFunctionParameter %11 %coord = OpFunctionParameter %v2int %params_0 = OpFunctionParameter %ExternalTextureParams - %71 = OpLabel + %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %73 = OpCompositeExtract %uint %params_0 0 - %75 = OpIEqual %bool %73 %uint_1 - OpSelectionMerge %76 None - OpBranchConditional %75 %77 %78 - %77 = OpLabel - %79 = OpImageFetch %v4float %plane0 %coord Lod %80 - %81 = OpVectorShuffle %v3float %79 %79 0 1 2 - OpStore %color %81 - OpBranch %76 + %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 + %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 - %82 = OpImageFetch %v4float %plane0 %coord Lod %80 - %83 = OpCompositeExtract %float %82 0 - %84 = OpImageFetch %v4float %plane1 %coord Lod %80 - %86 = OpVectorShuffle %v2float %84 %84 0 1 - %87 = OpCompositeExtract %float %86 0 - %88 = OpCompositeExtract %float %86 1 - %90 = OpCompositeConstruct %v4float %83 %87 %88 %float_1 - %91 = OpCompositeExtract %mat3v4float %params_0 2 - %92 = OpVectorTimesMatrix %v3float %90 %91 - OpStore %color %92 - OpBranch %76 - %76 = OpLabel - %93 = OpCompositeExtract %uint %params_0 1 - %95 = OpIEqual %bool %93 %94 - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - %99 = OpLoad %v3float %color - %100 = OpCompositeExtract %GammaTransferParams %params_0 3 - %98 = OpFunctionCall %v3float %gammaCorrection %99 %100 - OpStore %color %98 - %101 = OpCompositeExtract %mat3v3float %params_0 5 - %102 = OpLoad %v3float %color - %103 = OpMatrixTimesVector %v3float %101 %102 - OpStore %color %103 - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 4 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 + %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 - OpBranch %96 - %96 = OpLabel - %107 = OpLoad %v3float %color - %108 = OpCompositeExtract %float %107 0 - %109 = OpCompositeExtract %float %107 1 - %110 = OpCompositeExtract %float %107 2 - %111 = OpCompositeConstruct %v4float %108 %109 %110 %float_1 - OpReturnValue %111 + %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 OpFunctionEnd -%textureLoad_8acf41 = OpFunction %void None %112 - %115 = OpLabel - %arg_1 = OpVariable %_ptr_Function_v2int Function %120 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %113 + %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 + OpFunctionEnd +%textureLoad_8acf41 = OpFunction %void None %128 + %131 = OpLabel + %arg_1 = OpVariable %_ptr_Function_v2int Function %136 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_1 %117 - %122 = OpLoad %11 %arg_0 - %123 = OpLoad %11 %ext_tex_plane_1 - %124 = OpLoad %v2int %arg_1 - %127 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %128 = OpLoad %ExternalTextureParams %127 - %121 = OpFunctionCall %v4float %textureLoadExternal %122 %123 %124 %128 - OpStore %res %121 + 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 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %131 - %133 = OpLabel - %134 = OpFunctionCall %void %textureLoad_8acf41 +%vertex_main_inner = OpFunction %v4float None %148 + %150 = OpLabel + %151 = OpFunctionCall %void %textureLoad_8acf41 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %112 - %136 = OpLabel - %137 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %137 +%vertex_main = OpFunction %void None %128 + %153 = OpLabel + %154 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %154 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %112 - %139 = OpLabel - %140 = OpFunctionCall %void %textureLoad_8acf41 +%fragment_main = OpFunction %void None %128 + %156 = OpLabel + %157 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %112 - %142 = OpLabel - %143 = OpFunctionCall %void %textureLoad_8acf41 +%compute_main = OpFunction %void None %128 + %159 = OpLabel + %160 = OpFunctionCall %void %textureLoad_8acf41 OpReturn OpFunctionEnd diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl index 3f8ffd10ee..9322a94fc4 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.dxc.hlsl @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space1); @@ -33,7 +33,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(Texture2D plane0, Texture2D plane1, SamplerState smp, float2 coord, ExternalTextureParams params) { - const float2 modifiedCoords = mul(params.coordTransformationMatrix, float3((coord - 0.5f), 1.0f)); + const float2 modifiedCoords = mul(float3(coord, 1.0f), params.coordTransformationMatrix); int3 tint_tmp; plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z); const float2 plane0_dims = float2(tint_tmp.xy); @@ -74,8 +74,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -85,17 +85,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureSampleBaseClampToEdge_7c04e6() { diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl index 3f8ffd10ee..9322a94fc4 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.fxc.hlsl @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t2, space1); @@ -33,7 +33,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(Texture2D plane0, Texture2D plane1, SamplerState smp, float2 coord, ExternalTextureParams params) { - const float2 modifiedCoords = mul(params.coordTransformationMatrix, float3((coord - 0.5f), 1.0f)); + const float2 modifiedCoords = mul(float3(coord, 1.0f), params.coordTransformationMatrix); int3 tint_tmp; plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z); const float2 plane0_dims = float2(tint_tmp.xy); @@ -74,8 +74,8 @@ GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_10; + const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_11; } float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { @@ -85,17 +85,21 @@ float3x3 tint_symbol_7(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_9(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_9(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_1(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; - return tint_symbol_11; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), tint_symbol_9(buffer, (offset + 176u))}; + return tint_symbol_12; } void textureSampleBaseClampToEdge_7c04e6() { diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl index 800424cc88..9824423f94 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -34,7 +46,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -59,9 +71,13 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { vec2 arg_2 = vec2(1.0f); - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner)); } vec4 vertex_main() { @@ -98,11 +114,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -114,7 +142,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -139,9 +167,13 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { vec2 arg_2 = vec2(1.0f); - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner)); } void fragment_main() { @@ -172,11 +204,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 3, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -188,7 +232,7 @@ vec3 gammaCorrection(vec3 v, GammaTransferParams params) { vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) { - vec2 modifiedCoords = (vec3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + vec2 modifiedCoords = (params.coordTransformationMatrix * vec3(coord, 1.0f)); vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0))); vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims); vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); @@ -213,9 +257,13 @@ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_1; uniform highp sampler2D arg_0_arg_1; uniform highp sampler2D ext_tex_plane_1_arg_1; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void textureSampleBaseClampToEdge_7c04e6() { vec2 arg_2 = vec2(1.0f); - vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, ext_tex_params.inner); + vec4 res = textureSampleExternal(arg_0_1, ext_tex_plane_1_1, arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner)); } void compute_main() { diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl index 0fa91649a9..822c1b200f 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { @@ -44,7 +45,7 @@ float3 gammaCorrection(float3 v, GammaTransferParams params) { } float4 textureSampleExternal(texture2d plane0, texture2d plane1, sampler smp, float2 coord, ExternalTextureParams params) { - float2 const modifiedCoords = (float3((coord - 0.5f), 1.0f) * params.coordTransformationMatrix); + float2 const modifiedCoords = (params.coordTransformationMatrix * float3(coord, 1.0f)); float2 const plane0_dims = float2(uint2(plane0.get_width(0), plane0.get_height(0))); float2 const plane0_half_texel = (float2(0.5f) / plane0_dims); float2 const plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel)); diff --git a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm index a1e3535dbc..1abcb63122 100644 --- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm +++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 176 +; Bound: 190 ; Schema: 0 OpCapability Shader OpCapability ImageQuery @@ -15,13 +15,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -31,15 +31,25 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %arg_1 "arg_1" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureSampleExternal "textureSampleExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" @@ -47,6 +57,8 @@ OpName %coord "coord" OpName %params_0 "params" OpName %color "color" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %textureSampleBaseClampToEdge_7c04e6 "textureSampleBaseClampToEdge_7c04e6" OpName %arg_2 "arg_2" OpName %res "res" @@ -58,14 +70,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 2 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -74,13 +86,13 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 - OpMemberDecorate %ExternalTextureParams 4 Offset 96 - OpMemberDecorate %ExternalTextureParams 5 Offset 128 - OpMemberDecorate %ExternalTextureParams 5 ColMajor - OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 6 Offset 176 - OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 OpDecorate %ext_tex_params NonWritable OpDecorate %ext_tex_params DescriptorSet 1 OpDecorate %ext_tex_params Binding 3 @@ -88,6 +100,19 @@ OpDecorate %arg_0 Binding 0 OpDecorate %arg_1 DescriptorSet 1 OpDecorate %arg_1 Binding 1 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpMemberDecorate %ExternalTextureParams 4 Offset 96 + OpMemberDecorate %ExternalTextureParams 5 Offset 128 + OpMemberDecorate %ExternalTextureParams 5 ColMajor + OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 6 Offset 176 + OpMemberDecorate %ExternalTextureParams 6 ColMajor + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -104,11 +129,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %25 = OpTypeSampler %_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25 @@ -118,26 +143,28 @@ %v3bool = OpTypeVector %bool 3 %_ptr_Function_v3float = OpTypePointer Function %v3float %46 = OpConstantNull %v3float - %v2float = OpTypeVector %float 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams - %float_0_5 = OpConstant %float 0.5 -%_ptr_Function_v2float = OpTypePointer Function %v2float - %79 = OpConstantNull %v2float %float_1 = OpConstant %float 1 %v2uint = OpTypeVector %uint 2 %int = OpTypeInt 32 1 - %91 = OpConstantNull %int - %92 = OpConstantComposite %v2float %float_0_5 %float_0_5 + %86 = OpConstantNull %int + %float_0_5 = OpConstant %float 0.5 + %88 = OpConstantComposite %v2float %float_0_5 %float_0_5 +%_ptr_Function_v2float = OpTypePointer Function %v2float + %94 = OpConstantNull %v2float %uint_1 = OpConstant %uint 1 - %113 = OpTypeSampledImage %11 - %128 = OpConstantNull %uint + %111 = OpTypeSampledImage %11 + %126 = OpConstantNull %uint + %144 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %146 = OpTypeFunction %void - %150 = OpConstantComposite %v2float %float_1 %float_1 + %159 = OpTypeFunction %void + %163 = OpConstantComposite %v2float %float_1 %float_1 %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 %_ptr_Function_v4float = OpTypePointer Function %v4float - %163 = OpTypeFunction %v4float + %177 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %26 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -180,115 +207,129 @@ %smp = OpFunctionParameter %25 %coord = OpFunctionParameter %v2float %params_0 = OpFunctionParameter %ExternalTextureParams - %74 = OpLabel - %77 = OpVariable %_ptr_Function_v2float Function %79 - %96 = OpVariable %_ptr_Function_v2float Function %79 - %103 = OpVariable %_ptr_Function_v2float Function %79 + %75 = OpLabel + %92 = OpVariable %_ptr_Function_v2float Function %94 + %101 = OpVariable %_ptr_Function_v2float Function %94 %color = OpVariable %_ptr_Function_v3float Function %46 - %80 = OpCompositeConstruct %v2float %float_0_5 %float_0_5 - %76 = OpFSub %v2float %coord %80 - %81 = OpCompositeExtract %float %76 0 - %82 = OpCompositeExtract %float %76 1 - %84 = OpCompositeConstruct %v3float %81 %82 %float_1 - %85 = OpCompositeExtract %mat2v3float %params_0 6 - %86 = OpVectorTimesMatrix %v2float %84 %85 - %88 = OpImageQuerySizeLod %v2uint %plane0 %91 - %87 = OpConvertUToF %v2float %88 - %93 = OpFDiv %v2float %92 %87 - %97 = OpCompositeConstruct %v2float %float_1 %float_1 - %95 = OpFSub %v2float %97 %93 - %94 = OpExtInst %v2float %32 NClamp %86 %93 %95 - %99 = OpImageQuerySizeLod %v2uint %plane1 %91 - %98 = OpConvertUToF %v2float %99 - %100 = OpFDiv %v2float %92 %98 - %104 = OpCompositeConstruct %v2float %float_1 %float_1 - %102 = OpFSub %v2float %104 %100 - %101 = OpExtInst %v2float %32 NClamp %86 %100 %102 - %106 = OpCompositeExtract %uint %params_0 0 - %108 = OpIEqual %bool %106 %uint_1 - OpSelectionMerge %109 None - OpBranchConditional %108 %110 %111 - %110 = OpLabel - %114 = OpSampledImage %113 %plane0 %smp - %112 = OpImageSampleExplicitLod %v4float %114 %94 Lod %8 - %115 = OpVectorShuffle %v3float %112 %112 0 1 2 - OpStore %color %115 - OpBranch %109 - %111 = OpLabel - %117 = OpSampledImage %113 %plane0 %smp - %116 = OpImageSampleExplicitLod %v4float %117 %94 Lod %8 - %118 = OpCompositeExtract %float %116 0 - %120 = OpSampledImage %113 %plane1 %smp - %119 = OpImageSampleExplicitLod %v4float %120 %101 Lod %8 - %121 = OpVectorShuffle %v2float %119 %119 0 1 - %122 = OpCompositeExtract %float %121 0 - %123 = OpCompositeExtract %float %121 1 - %124 = OpCompositeConstruct %v4float %118 %122 %123 %float_1 - %125 = OpCompositeExtract %mat3v4float %params_0 2 - %126 = OpVectorTimesMatrix %v3float %124 %125 - OpStore %color %126 - OpBranch %109 + %76 = OpCompositeExtract %mat3v2float %params_0 6 + %77 = OpCompositeExtract %float %coord 0 + %78 = OpCompositeExtract %float %coord 1 + %80 = OpCompositeConstruct %v3float %77 %78 %float_1 + %81 = OpMatrixTimesVector %v2float %76 %80 + %83 = OpImageQuerySizeLod %v2uint %plane0 %86 + %82 = OpConvertUToF %v2float %83 + %89 = OpFDiv %v2float %88 %82 + %95 = OpCompositeConstruct %v2float %float_1 %float_1 + %91 = OpFSub %v2float %95 %89 + %90 = OpExtInst %v2float %32 NClamp %81 %89 %91 + %97 = OpImageQuerySizeLod %v2uint %plane1 %86 + %96 = OpConvertUToF %v2float %97 + %98 = OpFDiv %v2float %88 %96 + %102 = OpCompositeConstruct %v2float %float_1 %float_1 + %100 = OpFSub %v2float %102 %98 + %99 = OpExtInst %v2float %32 NClamp %81 %98 %100 + %104 = OpCompositeExtract %uint %params_0 0 + %106 = OpIEqual %bool %104 %uint_1 + OpSelectionMerge %107 None + OpBranchConditional %106 %108 %109 + %108 = OpLabel + %112 = OpSampledImage %111 %plane0 %smp + %110 = OpImageSampleExplicitLod %v4float %112 %90 Lod %8 + %113 = OpVectorShuffle %v3float %110 %110 0 1 2 + OpStore %color %113 + OpBranch %107 %109 = OpLabel - %127 = OpCompositeExtract %uint %params_0 1 - %129 = OpIEqual %bool %127 %128 - OpSelectionMerge %130 None - OpBranchConditional %129 %131 %130 - %131 = OpLabel - %133 = OpLoad %v3float %color - %134 = OpCompositeExtract %GammaTransferParams %params_0 3 - %132 = OpFunctionCall %v3float %gammaCorrection %133 %134 - OpStore %color %132 - %135 = OpCompositeExtract %mat3v3float %params_0 5 - %136 = OpLoad %v3float %color - %137 = OpMatrixTimesVector %v3float %135 %136 - OpStore %color %137 + %115 = OpSampledImage %111 %plane0 %smp + %114 = OpImageSampleExplicitLod %v4float %115 %90 Lod %8 + %116 = OpCompositeExtract %float %114 0 + %118 = OpSampledImage %111 %plane1 %smp + %117 = OpImageSampleExplicitLod %v4float %118 %99 Lod %8 + %119 = OpVectorShuffle %v2float %117 %117 0 1 + %120 = OpCompositeExtract %float %119 0 + %121 = OpCompositeExtract %float %119 1 + %122 = OpCompositeConstruct %v4float %116 %120 %121 %float_1 + %123 = OpCompositeExtract %mat3v4float %params_0 2 + %124 = OpVectorTimesMatrix %v3float %122 %123 + OpStore %color %124 + OpBranch %107 + %107 = OpLabel + %125 = OpCompositeExtract %uint %params_0 1 + %127 = OpIEqual %bool %125 %126 + OpSelectionMerge %128 None + OpBranchConditional %127 %129 %128 + %129 = OpLabel + %131 = OpLoad %v3float %color + %132 = OpCompositeExtract %GammaTransferParams %params_0 3 + %130 = OpFunctionCall %v3float %gammaCorrection %131 %132 + OpStore %color %130 + %133 = OpCompositeExtract %mat3v3float %params_0 5 + %134 = OpLoad %v3float %color + %135 = OpMatrixTimesVector %v3float %133 %134 + OpStore %color %135 + %137 = OpLoad %v3float %color + %138 = OpCompositeExtract %GammaTransferParams %params_0 4 + %136 = OpFunctionCall %v3float %gammaCorrection %137 %138 + OpStore %color %136 + OpBranch %128 + %128 = OpLabel %139 = OpLoad %v3float %color - %140 = OpCompositeExtract %GammaTransferParams %params_0 4 - %138 = OpFunctionCall %v3float %gammaCorrection %139 %140 - OpStore %color %138 - OpBranch %130 - %130 = OpLabel - %141 = OpLoad %v3float %color - %142 = OpCompositeExtract %float %141 0 - %143 = OpCompositeExtract %float %141 1 - %144 = OpCompositeExtract %float %141 2 - %145 = OpCompositeConstruct %v4float %142 %143 %144 %float_1 - OpReturnValue %145 + %140 = OpCompositeExtract %float %139 0 + %141 = OpCompositeExtract %float %139 1 + %142 = OpCompositeExtract %float %139 2 + %143 = OpCompositeConstruct %v4float %140 %141 %142 %float_1 + OpReturnValue %143 OpFunctionEnd -%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %146 - %149 = OpLabel - %arg_2 = OpVariable %_ptr_Function_v2float Function %79 +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %144 + %val = OpFunctionParameter %ExternalTextureParams_std140 + %147 = OpLabel + %148 = OpCompositeExtract %uint %val 0 + %149 = OpCompositeExtract %uint %val 1 + %150 = OpCompositeExtract %mat3v4float %val 2 + %151 = OpCompositeExtract %GammaTransferParams %val 3 + %152 = OpCompositeExtract %GammaTransferParams %val 4 + %153 = OpCompositeExtract %mat3v3float %val 5 + %154 = OpCompositeExtract %v2float %val 6 + %155 = OpCompositeExtract %v2float %val 7 + %156 = OpCompositeExtract %v2float %val 8 + %157 = OpCompositeConstruct %mat3v2float %154 %155 %156 + %158 = OpCompositeConstruct %ExternalTextureParams %148 %149 %150 %151 %152 %153 %157 + OpReturnValue %158 + OpFunctionEnd +%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %159 + %162 = OpLabel + %arg_2 = OpVariable %_ptr_Function_v2float Function %94 %res = OpVariable %_ptr_Function_v4float Function %5 - OpStore %arg_2 %150 - %153 = OpLoad %11 %arg_0 - %154 = OpLoad %11 %ext_tex_plane_1 - %155 = OpLoad %25 %arg_1 - %156 = OpLoad %v2float %arg_2 - %159 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %160 = OpLoad %ExternalTextureParams %159 - %152 = OpFunctionCall %v4float %textureSampleExternal %153 %154 %155 %156 %160 - OpStore %res %152 + OpStore %arg_2 %163 + %166 = OpLoad %11 %arg_0 + %167 = OpLoad %11 %ext_tex_plane_1 + %168 = OpLoad %25 %arg_1 + %169 = OpLoad %v2float %arg_2 + %173 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0 + %174 = OpLoad %ExternalTextureParams_std140 %173 + %170 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %174 + %165 = OpFunctionCall %v4float %textureSampleExternal %166 %167 %168 %169 %170 + OpStore %res %165 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %163 - %165 = OpLabel - %166 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%vertex_main_inner = OpFunction %v4float None %177 + %179 = OpLabel + %180 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %146 - %168 = OpLabel - %169 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %169 +%vertex_main = OpFunction %void None %159 + %182 = OpLabel + %183 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %183 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %146 - %171 = OpLabel - %172 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%fragment_main = OpFunction %void None %159 + %185 = OpLabel + %186 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %146 - %174 = OpLabel - %175 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 +%compute_main = OpFunction %void None %159 + %188 = OpLabel + %189 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6 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 794293aac1..ca1acb36b7 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -66,8 +66,8 @@ GammaTransferParams tint_symbol_6(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_11; + const GammaTransferParams tint_symbol_12 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_12; } float3x3 tint_symbol_8(uint4 buffer[13], uint offset) { @@ -77,17 +77,21 @@ float3x3 tint_symbol_8(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_10(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_10(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_2(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))}; - return tint_symbol_12; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_13 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))}; + return tint_symbol_13; } void doTextureLoad() { 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 794293aac1..ca1acb36b7 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 @@ -15,7 +15,7 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; float3x3 gamutConversionMatrix; - float2x3 coordTransformationMatrix; + float3x2 coordTransformationMatrix; }; Texture2D ext_tex_plane_1 : register(t1, space1); @@ -66,8 +66,8 @@ GammaTransferParams tint_symbol_6(uint4 buffer[13], uint offset) { const uint scalar_offset_8 = ((offset + 20u)) / 4; const uint scalar_offset_9 = ((offset + 24u)) / 4; const uint scalar_offset_10 = ((offset + 28u)) / 4; - const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; - return tint_symbol_11; + const GammaTransferParams tint_symbol_12 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]}; + return tint_symbol_12; } float3x3 tint_symbol_8(uint4 buffer[13], uint offset) { @@ -77,17 +77,21 @@ float3x3 tint_symbol_8(uint4 buffer[13], uint offset) { return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz)); } -float2x3 tint_symbol_10(uint4 buffer[13], uint offset) { +float3x2 tint_symbol_10(uint4 buffer[13], uint offset) { const uint scalar_offset_14 = ((offset + 0u)) / 4; - const uint scalar_offset_15 = ((offset + 16u)) / 4; - return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz)); + uint4 ubo_load = buffer[scalar_offset_14 / 4]; + const uint scalar_offset_15 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_15 / 4]; + const uint scalar_offset_16 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_16 / 4]; + return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); } ExternalTextureParams tint_symbol_2(uint4 buffer[13], uint offset) { - const uint scalar_offset_16 = ((offset + 0u)) / 4; - const uint scalar_offset_17 = ((offset + 4u)) / 4; - const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))}; - return tint_symbol_12; + const uint scalar_offset_17 = ((offset + 0u)) / 4; + const uint scalar_offset_18 = ((offset + 4u)) / 4; + const ExternalTextureParams tint_symbol_13 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))}; + return tint_symbol_13; } void doTextureLoad() { 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 230fb2e055..f7349229ec 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl @@ -18,11 +18,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -53,8 +65,12 @@ vec4 textureLoad2d(highp sampler2D tint_symbol_1, highp sampler2D ext_tex_plane_ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_2; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void doTextureLoad() { - vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, ext_tex_params.inner, ivec2(0)); + vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, conv_ExternalTextureParams(ext_tex_params.inner), ivec2(0)); } vec4 vertex_main() { @@ -91,11 +107,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -126,8 +154,12 @@ vec4 textureLoad2d(highp sampler2D tint_symbol_1, highp sampler2D ext_tex_plane_ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_2; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void doTextureLoad() { - vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, ext_tex_params.inner, ivec2(0)); + vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, conv_ExternalTextureParams(ext_tex_params.inner), ivec2(0)); } void fragment_main() { @@ -158,11 +190,23 @@ struct ExternalTextureParams { GammaTransferParams gammaDecodeParams; GammaTransferParams gammaEncodeParams; mat3 gamutConversionMatrix; - mat2x3 coordTransformationMatrix; + mat3x2 coordTransformationMatrix; }; -layout(binding = 2, std140) uniform ext_tex_params_block_ubo { - ExternalTextureParams inner; +struct ExternalTextureParams_std140 { + uint numPlanes; + uint doYuvToRgbConversionOnly; + mat3x4 yuvToRgbConversionMatrix; + GammaTransferParams gammaDecodeParams; + GammaTransferParams gammaEncodeParams; + mat3 gamutConversionMatrix; + vec2 coordTransformationMatrix_0; + vec2 coordTransformationMatrix_1; + vec2 coordTransformationMatrix_2; +}; + +layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo { + ExternalTextureParams_std140 inner; } ext_tex_params; vec3 gammaCorrection(vec3 v, GammaTransferParams params) { @@ -193,8 +237,12 @@ vec4 textureLoad2d(highp sampler2D tint_symbol_1, highp sampler2D ext_tex_plane_ uniform highp sampler2D arg_0_1; uniform highp sampler2D ext_tex_plane_1_2; +ExternalTextureParams conv_ExternalTextureParams(ExternalTextureParams_std140 val) { + return ExternalTextureParams(val.numPlanes, val.doYuvToRgbConversionOnly, val.yuvToRgbConversionMatrix, val.gammaDecodeParams, val.gammaEncodeParams, val.gamutConversionMatrix, mat3x2(val.coordTransformationMatrix_0, val.coordTransformationMatrix_1, val.coordTransformationMatrix_2)); +} + void doTextureLoad() { - vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, ext_tex_params.inner, ivec2(0)); + vec4 res = textureLoad2d(arg_0_1, ext_tex_plane_1_2, conv_ExternalTextureParams(ext_tex_params.inner), ivec2(0)); } void compute_main() { 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 7c1b1c6a26..bda7a402aa 100644 --- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl +++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl @@ -33,7 +33,8 @@ struct ExternalTextureParams { /* 0x0040 */ GammaTransferParams gammaDecodeParams; /* 0x0060 */ GammaTransferParams gammaEncodeParams; /* 0x0080 */ float3x3 gamutConversionMatrix; - /* 0x00b0 */ float2x3 coordTransformationMatrix; + /* 0x00b0 */ float3x2 coordTransformationMatrix; + /* 0x00c8 */ tint_array tint_pad_1; }; float3 gammaCorrection(float3 v, GammaTransferParams params) { 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 3bdf36dddf..f0e6ad2708 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: 147 +; Bound: 164 ; Schema: 0 OpCapability Shader %29 = OpExtInstImport "GLSL.std.450" @@ -14,13 +14,13 @@ OpName %value "value" OpName %vertex_point_size "vertex_point_size" OpName %ext_tex_plane_1 "ext_tex_plane_1" - OpName %ext_tex_params_block "ext_tex_params_block" - OpMemberName %ext_tex_params_block 0 "inner" - OpName %ExternalTextureParams "ExternalTextureParams" - OpMemberName %ExternalTextureParams 0 "numPlanes" - OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" - OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" - OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpName %ext_tex_params_block_std140 "ext_tex_params_block_std140" + OpMemberName %ext_tex_params_block_std140 0 "inner" + OpName %ExternalTextureParams_std140 "ExternalTextureParams_std140" + OpMemberName %ExternalTextureParams_std140 0 "numPlanes" + OpMemberName %ExternalTextureParams_std140 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams_std140 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams_std140 3 "gammaDecodeParams" OpName %GammaTransferParams "GammaTransferParams" OpMemberName %GammaTransferParams 0 "G" OpMemberName %GammaTransferParams 1 "A" @@ -30,14 +30,24 @@ OpMemberName %GammaTransferParams 5 "E" OpMemberName %GammaTransferParams 6 "F" OpMemberName %GammaTransferParams 7 "padding" - OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" - OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" - OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" + OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams_std140 6 "coordTransformationMatrix_0" + OpMemberName %ExternalTextureParams_std140 7 "coordTransformationMatrix_1" + OpMemberName %ExternalTextureParams_std140 8 "coordTransformationMatrix_2" OpName %ext_tex_params "ext_tex_params" OpName %arg_0 "arg_0" OpName %gammaCorrection "gammaCorrection" OpName %v "v" OpName %params "params" + OpName %ExternalTextureParams "ExternalTextureParams" + OpMemberName %ExternalTextureParams 0 "numPlanes" + OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly" + OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix" + OpMemberName %ExternalTextureParams 3 "gammaDecodeParams" + OpMemberName %ExternalTextureParams 4 "gammaEncodeParams" + OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix" + OpMemberName %ExternalTextureParams 6 "coordTransformationMatrix" OpName %textureLoadExternal "textureLoadExternal" OpName %plane0 "plane0" OpName %plane1 "plane1" @@ -49,6 +59,8 @@ OpName %ext_tex_plane_1_1 "ext_tex_plane_1_1" OpName %ext_tex_params_1 "ext_tex_params_1" OpName %coords "coords" + OpName %conv_ExternalTextureParams "conv_ExternalTextureParams" + OpName %val "val" OpName %doTextureLoad "doTextureLoad" OpName %res "res" OpName %vertex_main_inner "vertex_main_inner" @@ -59,14 +71,14 @@ OpDecorate %vertex_point_size BuiltIn PointSize OpDecorate %ext_tex_plane_1 DescriptorSet 1 OpDecorate %ext_tex_plane_1 Binding 1 - OpDecorate %ext_tex_params_block Block - OpMemberDecorate %ext_tex_params_block 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 0 Offset 0 - OpMemberDecorate %ExternalTextureParams 1 Offset 4 - OpMemberDecorate %ExternalTextureParams 2 Offset 16 - OpMemberDecorate %ExternalTextureParams 2 ColMajor - OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 - OpMemberDecorate %ExternalTextureParams 3 Offset 64 + OpDecorate %ext_tex_params_block_std140 Block + OpMemberDecorate %ext_tex_params_block_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 0 Offset 0 + OpMemberDecorate %ExternalTextureParams_std140 1 Offset 4 + OpMemberDecorate %ExternalTextureParams_std140 2 Offset 16 + OpMemberDecorate %ExternalTextureParams_std140 2 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 3 Offset 64 OpMemberDecorate %GammaTransferParams 0 Offset 0 OpMemberDecorate %GammaTransferParams 1 Offset 4 OpMemberDecorate %GammaTransferParams 2 Offset 8 @@ -75,18 +87,31 @@ OpMemberDecorate %GammaTransferParams 5 Offset 20 OpMemberDecorate %GammaTransferParams 6 Offset 24 OpMemberDecorate %GammaTransferParams 7 Offset 28 + OpMemberDecorate %ExternalTextureParams_std140 4 Offset 96 + OpMemberDecorate %ExternalTextureParams_std140 5 Offset 128 + OpMemberDecorate %ExternalTextureParams_std140 5 ColMajor + OpMemberDecorate %ExternalTextureParams_std140 5 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams_std140 6 Offset 176 + OpMemberDecorate %ExternalTextureParams_std140 7 Offset 184 + OpMemberDecorate %ExternalTextureParams_std140 8 Offset 192 + OpDecorate %ext_tex_params NonWritable + OpDecorate %ext_tex_params DescriptorSet 1 + OpDecorate %ext_tex_params Binding 2 + OpDecorate %arg_0 DescriptorSet 1 + OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 0 Offset 0 + OpMemberDecorate %ExternalTextureParams 1 Offset 4 + OpMemberDecorate %ExternalTextureParams 2 Offset 16 + OpMemberDecorate %ExternalTextureParams 2 ColMajor + OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16 + OpMemberDecorate %ExternalTextureParams 3 Offset 64 OpMemberDecorate %ExternalTextureParams 4 Offset 96 OpMemberDecorate %ExternalTextureParams 5 Offset 128 OpMemberDecorate %ExternalTextureParams 5 ColMajor OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16 OpMemberDecorate %ExternalTextureParams 6 Offset 176 OpMemberDecorate %ExternalTextureParams 6 ColMajor - OpMemberDecorate %ExternalTextureParams 6 MatrixStride 16 - OpDecorate %ext_tex_params NonWritable - OpDecorate %ext_tex_params DescriptorSet 1 - OpDecorate %ext_tex_params Binding 2 - OpDecorate %arg_0 DescriptorSet 1 - OpDecorate %arg_0 Binding 0 + OpMemberDecorate %ExternalTextureParams 6 MatrixStride 8 %float = OpTypeFloat 32 %v4float = OpTypeVector %float 4 %_ptr_Output_v4float = OpTypePointer Output %v4float @@ -103,11 +128,11 @@ %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint %v3float = OpTypeVector %float 3 %mat3v3float = OpTypeMatrix %v3float 3 -%mat2v3float = OpTypeMatrix %v3float 2 -%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v3float -%ext_tex_params_block = OpTypeStruct %ExternalTextureParams -%_ptr_Uniform_ext_tex_params_block = OpTypePointer Uniform %ext_tex_params_block -%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block Uniform + %v2float = OpTypeVector %float 2 +%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %v2float %v2float %v2float +%ext_tex_params_block_std140 = OpTypeStruct %ExternalTextureParams_std140 +%_ptr_Uniform_ext_tex_params_block_std140 = OpTypePointer Uniform %ext_tex_params_block_std140 +%ext_tex_params = OpVariable %_ptr_Uniform_ext_tex_params_block_std140 Uniform %arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant %23 = OpTypeFunction %v3float %v3float %GammaTransferParams %bool = OpTypeBool @@ -116,20 +141,22 @@ %43 = OpConstantNull %v3float %int = OpTypeInt 32 1 %v2int = OpTypeVector %int 2 +%mat3v2float = OpTypeMatrix %v2float 3 +%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat3v2float %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams %uint_1 = OpConstant %uint 1 - %80 = OpConstantNull %int - %v2float = OpTypeVector %float 2 + %82 = OpConstantNull %int %float_1 = OpConstant %float 1 - %94 = OpConstantNull %uint - %112 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int + %95 = OpConstantNull %uint + %113 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int + %121 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140 %void = OpTypeVoid - %120 = OpTypeFunction %void + %136 = OpTypeFunction %void %uint_0 = OpConstant %uint 0 -%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams - %131 = OpConstantNull %v2int +%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140 + %148 = OpConstantNull %v2int %_ptr_Function_v4float = OpTypePointer Function %v4float - %134 = OpTypeFunction %v4float + %151 = OpTypeFunction %v4float %gammaCorrection = OpFunction %v3float None %23 %v = OpFunctionParameter %v3float %params = OpFunctionParameter %GammaTransferParams @@ -171,95 +198,112 @@ %plane1 = OpFunctionParameter %11 %coord = OpFunctionParameter %v2int %params_0 = OpFunctionParameter %ExternalTextureParams - %71 = OpLabel + %73 = OpLabel %color = OpVariable %_ptr_Function_v3float Function %43 - %73 = OpCompositeExtract %uint %params_0 0 - %75 = OpIEqual %bool %73 %uint_1 - OpSelectionMerge %76 None - OpBranchConditional %75 %77 %78 - %77 = OpLabel - %79 = OpImageFetch %v4float %plane0 %coord Lod %80 - %81 = OpVectorShuffle %v3float %79 %79 0 1 2 - OpStore %color %81 - OpBranch %76 + %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 + %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 - %82 = OpImageFetch %v4float %plane0 %coord Lod %80 - %83 = OpCompositeExtract %float %82 0 - %84 = OpImageFetch %v4float %plane1 %coord Lod %80 - %86 = OpVectorShuffle %v2float %84 %84 0 1 - %87 = OpCompositeExtract %float %86 0 - %88 = OpCompositeExtract %float %86 1 - %90 = OpCompositeConstruct %v4float %83 %87 %88 %float_1 - %91 = OpCompositeExtract %mat3v4float %params_0 2 - %92 = OpVectorTimesMatrix %v3float %90 %91 - OpStore %color %92 - OpBranch %76 - %76 = OpLabel - %93 = OpCompositeExtract %uint %params_0 1 - %95 = OpIEqual %bool %93 %94 - OpSelectionMerge %96 None - OpBranchConditional %95 %97 %96 - %97 = OpLabel - %99 = OpLoad %v3float %color - %100 = OpCompositeExtract %GammaTransferParams %params_0 3 - %98 = OpFunctionCall %v3float %gammaCorrection %99 %100 - OpStore %color %98 - %101 = OpCompositeExtract %mat3v3float %params_0 5 - %102 = OpLoad %v3float %color - %103 = OpMatrixTimesVector %v3float %101 %102 - OpStore %color %103 - %105 = OpLoad %v3float %color - %106 = OpCompositeExtract %GammaTransferParams %params_0 4 - %104 = OpFunctionCall %v3float %gammaCorrection %105 %106 + %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 - OpBranch %96 - %96 = OpLabel - %107 = OpLoad %v3float %color - %108 = OpCompositeExtract %float %107 0 - %109 = OpCompositeExtract %float %107 1 - %110 = OpCompositeExtract %float %107 2 - %111 = OpCompositeConstruct %v4float %108 %109 %110 %float_1 - OpReturnValue %111 + %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 OpFunctionEnd -%textureLoad2d = OpFunction %v4float None %112 +%textureLoad2d = OpFunction %v4float None %113 %texture = OpFunctionParameter %11 %ext_tex_plane_1_1 = OpFunctionParameter %11 %ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams %coords = OpFunctionParameter %v2int - %118 = OpLabel - %119 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1 - OpReturnValue %119 + %119 = OpLabel + %120 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1 + OpReturnValue %120 OpFunctionEnd -%doTextureLoad = OpFunction %void None %120 - %123 = OpLabel +%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %121 + %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 + OpFunctionEnd +%doTextureLoad = OpFunction %void None %136 + %139 = OpLabel %res = OpVariable %_ptr_Function_v4float Function %5 - %125 = OpLoad %11 %arg_0 - %126 = OpLoad %11 %ext_tex_plane_1 - %129 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0 - %130 = OpLoad %ExternalTextureParams %129 - %124 = OpFunctionCall %v4float %textureLoad2d %125 %126 %130 %131 - OpStore %res %124 + %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 OpReturn OpFunctionEnd -%vertex_main_inner = OpFunction %v4float None %134 - %136 = OpLabel - %137 = OpFunctionCall %void %doTextureLoad +%vertex_main_inner = OpFunction %v4float None %151 + %153 = OpLabel + %154 = OpFunctionCall %void %doTextureLoad OpReturnValue %5 OpFunctionEnd -%vertex_main = OpFunction %void None %120 - %139 = OpLabel - %140 = OpFunctionCall %v4float %vertex_main_inner - OpStore %value %140 +%vertex_main = OpFunction %void None %136 + %156 = OpLabel + %157 = OpFunctionCall %v4float %vertex_main_inner + OpStore %value %157 OpStore %vertex_point_size %float_1 OpReturn OpFunctionEnd -%fragment_main = OpFunction %void None %120 - %142 = OpLabel - %143 = OpFunctionCall %void %doTextureLoad +%fragment_main = OpFunction %void None %136 + %159 = OpLabel + %160 = OpFunctionCall %void %doTextureLoad OpReturn OpFunctionEnd -%compute_main = OpFunction %void None %120 - %145 = OpLabel - %146 = OpFunctionCall %void %doTextureLoad +%compute_main = OpFunction %void None %136 + %162 = OpLabel + %163 = OpFunctionCall %void %doTextureLoad OpReturn OpFunctionEnd