Add ExternalTexture Rotate and FlipY Functionality

Adds functionality to Dawn and Tint to rotate and flip-Y external
textures through the shader transform. Tests are included.

Bug: chromium:1316671
Change-Id: I40a6b67eaeb2a348f469e4879eeb585bc40537b2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/110181
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/dawn.json b/dawn.json
index 972d68d..115ccc5 100644
--- a/dawn.json
+++ b/dawn.json
@@ -1366,6 +1366,16 @@
             }
         ]
     },
+    "external texture rotation":{
+        "category": "enum",
+        "tags": ["dawn"],
+        "values": [
+            {"value": 0, "name": "rotate 0 degrees"},
+            {"value": 1, "name": "rotate 90 degrees"},
+            {"value": 2, "name": "rotate 180 degrees"},
+            {"value": 3, "name": "rotate 270 degrees"}
+        ]
+    },
     "external texture descriptor": {
         "category": "structure",
         "extensible": "in",
@@ -1384,7 +1394,9 @@
             {"name": "dst transfer function parameters", "type": "float", "annotation": "const*",
                 "length": 7},
             {"name": "gamut conversion matrix", "type": "float", "annotation": "const*",
-                "length": 9}
+                "length": 9},
+            {"name": "flip y", "type": "bool", "default": "false"},
+            {"name": "rotation", "type": "external texture rotation", "default": "rotate 0 degrees"}
         ]
     },
     "feature name": {
diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp
index edc9a35..33febcd 100644
--- a/src/dawn/native/ExternalTexture.cpp
+++ b/src/dawn/native/ExternalTexture.cpp
@@ -209,6 +209,28 @@
     const float* dstFn = descriptor->dstTransferFunctionParameters;
     std::copy(dstFn, dstFn + 7, params.gammaEncodingParams.begin());
 
+    float flipY = 1;
+    if (descriptor->flipY) {
+        flipY = -1;
+    }
+
+    // We can perform the flip-Y operation by multiplying the y-component portion of the matrix by
+    // -1.
+    switch (descriptor->rotation) {
+        case wgpu::ExternalTextureRotation::Rotate0Degrees:
+            params.coordTransformMatrix = {1.0, 0.0, 0.0, 1.0f * flipY};
+            break;
+        case wgpu::ExternalTextureRotation::Rotate90Degrees:
+            params.coordTransformMatrix = {0.0, 1.0f * flipY, -1.0, 0.0};
+            break;
+        case wgpu::ExternalTextureRotation::Rotate180Degrees:
+            params.coordTransformMatrix = {-1.0, 0.0, 0.0, -1.0f * flipY};
+            break;
+        case wgpu::ExternalTextureRotation::Rotate270Degrees:
+            params.coordTransformMatrix = {0.0, -1.0f * flipY, 1.0, 0.0};
+            break;
+    }
+
     DAWN_TRY(device->GetQueue()->WriteBuffer(mParamsBuffer.Get(), 0, &params,
                                              sizeof(ExternalTextureParams)));
 
diff --git a/src/dawn/native/ExternalTexture.h b/src/dawn/native/ExternalTexture.h
index d0d5a28..e387076 100644
--- a/src/dawn/native/ExternalTexture.h
+++ b/src/dawn/native/ExternalTexture.h
@@ -35,6 +35,7 @@
     std::array<float, 8> gammaDecodingParams = {};
     std::array<float, 8> gammaEncodingParams = {};
     std::array<float, 12> gamutConversionMatrix = {};
+    std::array<float, 4> coordTransformMatrix = {};
 };
 
 MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
diff --git a/src/dawn/tests/end2end/ExternalTextureTests.cpp b/src/dawn/tests/end2end/ExternalTextureTests.cpp
index 065836b..fe43933 100644
--- a/src/dawn/tests/end2end/ExternalTextureTests.cpp
+++ b/src/dawn/tests/end2end/ExternalTextureTests.cpp
@@ -37,6 +37,32 @@
 
 class ExternalTextureTests : public DawnTest {
   protected:
+    void SetUp() override {
+        DawnTest::SetUp();
+
+        vsModule = utils::CreateShaderModule(device, R"(
+            @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
+                var positions = array<vec4<f32>, 6>(
+                    vec4<f32>(-1.0, 1.0, 0.0, 1.0),
+                    vec4<f32>(-1.0, -1.0, 0.0, 1.0),
+                    vec4<f32>(1.0, 1.0, 0.0, 1.0),
+                    vec4<f32>(1.0, -1.0, 0.0, 1.0),
+                    vec4<f32>(-1.0, -1.0, 0.0, 1.0),
+                    vec4<f32>(1.0, 1.0, 0.0, 1.0)
+                );
+                return positions[VertexIndex];
+            })");
+
+        fsSampleExternalTextureModule = utils::CreateShaderModule(device, R"(
+            @group(0) @binding(0) var s : sampler;
+            @group(0) @binding(1) var t : texture_external;
+
+            @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
+                                     -> @location(0) vec4<f32> {
+                return textureSampleBaseClampToEdge(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
+            })");
+    }
+
     wgpu::ExternalTextureDescriptor CreateDefaultExternalTextureDescriptor() {
         wgpu::ExternalTextureDescriptor desc;
         desc.yuvToRgbConversionMatrix = yuvBT709ToRGBSRGB.yuvToRgbConversionMatrix.data();
@@ -47,12 +73,39 @@
         return desc;
     }
 
+    void RenderToSourceTexture(wgpu::ShaderModule fragmentShader, wgpu::Texture texture) {
+        {
+            utils::ComboRenderPipelineDescriptor descriptor;
+            descriptor.vertex.module = vsModule;
+            descriptor.cFragment.module = fragmentShader;
+            descriptor.cTargets[0].format = texture.GetFormat();
+            wgpu::RenderPipeline pipeline1 = device.CreateRenderPipeline(&descriptor);
+
+            wgpu::Sampler sampler = device.CreateSampler();
+
+            wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+            wgpu::TextureView renderView = texture.CreateView();
+            utils::ComboRenderPassDescriptor renderPass({renderView}, nullptr);
+            wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+            {
+                pass.SetPipeline(pipeline1);
+                pass.Draw(6);
+                pass.End();
+            }
+            wgpu::CommandBuffer copy = encoder.Finish();
+            queue.Submit(1, &copy);
+        }
+    }
+
     static constexpr uint32_t kWidth = 4;
     static constexpr uint32_t kHeight = 4;
     static constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::RGBA8Unorm;
     static constexpr wgpu::TextureUsage kSampledUsage = wgpu::TextureUsage::TextureBinding;
     utils::ColorSpaceConversionInfo yuvBT709ToRGBSRGB =
         utils::GetYUVBT709ToRGBSRGBColorSpaceConversionInfo();
+
+    wgpu::ShaderModule vsModule;
+    wgpu::ShaderModule fsSampleExternalTextureModule;
 };
 }  // anonymous namespace
 
@@ -73,29 +126,10 @@
 }
 
 TEST_P(ExternalTextureTests, SampleExternalTexture) {
-    // TODO(crbug.com/dawn/1263): SPIR-V has an issue compiling the output from Tint's external
-    // texture transform. Re-enable this test for OpenGL when the switch to Tint is complete.
+    // TODO(crbug.com/tint/1774): Tint has an issue compiling shaders that use external textures on
+    // OpenGL/OpenGLES.
     DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
 
-    const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
-        @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
-            var positions = array<vec4<f32>, 3>(
-                vec4<f32>(-1.0, 1.0, 0.0, 1.0),
-                vec4<f32>(-1.0, -1.0, 0.0, 1.0),
-                vec4<f32>(1.0, 1.0, 0.0, 1.0)
-            );
-            return positions[VertexIndex];
-        })");
-
-    const wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
-        @group(0) @binding(0) var s : sampler;
-        @group(0) @binding(1) var t : texture_external;
-
-        @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-                                 -> @location(0) vec4<f32> {
-            return textureSampleBaseClampToEdge(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
-        })");
-
     wgpu::Texture sampledTexture =
         Create2DTexture(device, kWidth, kHeight, kFormat,
                         wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment);
@@ -121,7 +155,7 @@
     // Pipeline Creation
     utils::ComboRenderPipelineDescriptor descriptor;
     descriptor.vertex.module = vsModule;
-    descriptor.cFragment.module = fsModule;
+    descriptor.cFragment.module = fsSampleExternalTextureModule;
     descriptor.cTargets[0].format = kFormat;
     wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
 
@@ -158,29 +192,10 @@
 }
 
 TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
-    // TODO(crbug.com/dawn/1263): SPIR-V has an issue compiling the output from Tint's external
-    // texture transform. Re-enable this test for OpenGL when the switch to Tint is complete.
+    // TODO(crbug.com/tint/1774): Tint has an issue compiling shaders that use external textures on
+    // OpenGL/OpenGLES.
     DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
 
-    const wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
-        @vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
-            var positions = array<vec4<f32>, 3>(
-                vec4<f32>(-1.0, 1.0, 0.0, 1.0),
-                vec4<f32>(-1.0, -1.0, 0.0, 1.0),
-                vec4<f32>(1.0, 1.0, 0.0, 1.0)
-            );
-            return positions[VertexIndex];
-        })");
-
-    const wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
-        @group(0) @binding(0) var s : sampler;
-        @group(0) @binding(1) var t : texture_external;
-
-        @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-                                 -> @location(0) vec4<f32> {
-            return textureSampleBaseClampToEdge(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
-        })");
-
     wgpu::Texture sampledTexturePlane0 =
         Create2DTexture(device, kWidth, kHeight, wgpu::TextureFormat::R8Unorm,
                         wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment);
@@ -213,7 +228,7 @@
          {0.5423, 0.5323, 0.4222, {120, 162, 169, 255}},
          {0.2345, 0.4383, 0.6342, {126, 53, 33, 255}}}};
 
-    for (ConversionExpectation expectation : expectations) {
+    for (const ConversionExpectation& expectation : expectations) {
         // Initialize the texture planes with YUV data
         {
             utils::ComboRenderPassDescriptor renderPass({externalViewPlane0, externalViewPlane1},
@@ -232,7 +247,7 @@
         utils::ComboRenderPipelineDescriptor descriptor;
         // descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
         descriptor.vertex.module = vsModule;
-        descriptor.cFragment.module = fsModule;
+        descriptor.cFragment.module = fsSampleExternalTextureModule;
         descriptor.cTargets[0].format = kFormat;
         wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
 
@@ -270,6 +285,346 @@
     }
 }
 
+// Test draws a green square in the upper left quadrant, a black square in the upper right, a red
+// square in the lower left and a blue square in the lower right. The image is then sampled as an
+// external texture and rotated 0, 90, 180, and 270 degrees with and without the y-axis flipped.
+TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) {
+    // TODO(crbug.com/tint/1774): Tint has an issue compiling shaders that use external textures on
+    // OpenGL/OpenGLES.
+    DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
+
+    const wgpu::ShaderModule sourceTextureFsModule = utils::CreateShaderModule(device, R"(
+        @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
+                                 -> @location(0) vec4<f32> {
+            if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
+               return vec4<f32>(0.0, 1.0, 0.0, 1.0);
+            }
+
+            if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(0.0, 0.0, 1.0, 1.0);
+            }
+
+            if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(0.0, 0.0, 0.0, 1.0);
+            }
+
+            return vec4<f32>(1.0, 0.0, 0.0, 1.0);
+        })");
+
+    wgpu::Texture sourceTexture =
+        Create2DTexture(device, kWidth, kHeight, kFormat,
+                        wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment);
+
+    RenderToSourceTexture(sourceTextureFsModule, sourceTexture);
+
+    wgpu::Texture renderTexture =
+        Create2DTexture(device, kWidth, kHeight, kFormat,
+                        wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment);
+
+    // Control case to verify flipY and rotation defaults
+    {
+        // Pipeline Creation
+        utils::ComboRenderPipelineDescriptor descriptor;
+        descriptor.vertex.module = vsModule;
+        descriptor.cFragment.module = fsSampleExternalTextureModule;
+        descriptor.cTargets[0].format = kFormat;
+        wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
+
+        // Create an ExternalTextureDescriptor from the texture view
+        wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
+        externalDesc.plane0 = sourceTexture.CreateView();
+
+        // Import the external texture
+        wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc);
+
+        // Create a sampler and bind group
+        wgpu::Sampler sampler = device.CreateSampler();
+
+        wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+                                                         {{0, sampler}, {1, externalTexture}});
+
+        // Run the shader, which should sample from the external texture and draw a triangle into
+        // the upper left corner of the render texture.
+        wgpu::TextureView renderView = renderTexture.CreateView();
+        utils::ComboRenderPassDescriptor renderPass({renderView}, nullptr);
+        wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+        wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+        {
+            pass.SetPipeline(pipeline);
+            pass.SetBindGroup(0, bindGroup);
+            pass.Draw(6);
+            pass.End();
+        }
+
+        wgpu::CommandBuffer commands = encoder.Finish();
+        queue.Submit(1, &commands);
+
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kGreen, renderTexture, 0, 0);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kBlack, renderTexture, 3, 0);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kRed, renderTexture, 0, 3);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kBlue, renderTexture, 3, 3);
+    }
+
+    struct RotationExpectation {
+        wgpu::ExternalTextureRotation rotation;
+        bool flipY;
+        utils::RGBA8 upperLeftColor;
+        utils::RGBA8 upperRightColor;
+        utils::RGBA8 lowerLeftColor;
+        utils::RGBA8 lowerRightColor;
+    };
+
+    std::array<RotationExpectation, 8> 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
+        utils::ComboRenderPipelineDescriptor descriptor;
+        descriptor.vertex.module = vsModule;
+        descriptor.cFragment.module = fsSampleExternalTextureModule;
+        descriptor.cTargets[0].format = kFormat;
+        wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
+
+        // Create an ExternalTextureDescriptor from the texture view
+        wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
+        externalDesc.plane0 = sourceTexture.CreateView();
+        externalDesc.rotation = exp.rotation;
+        externalDesc.flipY = exp.flipY;
+
+        // Import the external texture
+        wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc);
+
+        // Create a sampler and bind group
+        wgpu::Sampler sampler = device.CreateSampler();
+
+        wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+                                                         {{0, sampler}, {1, externalTexture}});
+
+        // Run the shader, which should sample from the external texture and draw a triangle into
+        // the upper left corner of the render texture.
+        wgpu::TextureView renderView = renderTexture.CreateView();
+        utils::ComboRenderPassDescriptor renderPass({renderView}, nullptr);
+        wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+        wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+        {
+            pass.SetPipeline(pipeline);
+            pass.SetBindGroup(0, bindGroup);
+            pass.Draw(6);
+            pass.End();
+        }
+
+        wgpu::CommandBuffer commands = encoder.Finish();
+        queue.Submit(1, &commands);
+
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperLeftColor, renderTexture, 0, 0);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperLeftColor, renderTexture, 1, 1);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperRightColor, renderTexture, 3, 0);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperRightColor, renderTexture, 2, 1);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerLeftColor, renderTexture, 0, 3);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerLeftColor, renderTexture, 1, 2);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerRightColor, renderTexture, 3, 3);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerRightColor, renderTexture, 2, 2);
+    }
+}
+
+// Test draws a green square in the upper left quadrant, a black square in the upper right, a red
+// square in the lower left and a blue square in the lower right. The image is then sampled as an
+// external texture and rotated 0, 90, 180, and 270 degrees with and without the y-axis flipped.
+TEST_P(ExternalTextureTests, RotateAndOrFlipMultiplanar) {
+    // TODO(crbug.com/tint/1774): Tint has an issue compiling shaders that use external textures on
+    // OpenGL/OpenGLES.
+    DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
+
+    const wgpu::ShaderModule sourceTexturePlane0FsModule = utils::CreateShaderModule(device, R"(
+        @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
+                                 -> @location(0) vec4<f32> {
+
+            if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
+               return vec4<f32>(0.7152, 0.0, 0.0, 0.0);
+            }
+
+            if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(0.0722, 0.0, 1.0, 1.0);
+            }
+
+            if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(0.0, 0.0, 0.0, 0.0);
+            }
+
+            return vec4<f32>(0.2126, 0.0, 0.0, 0.0);
+        })");
+
+    const wgpu::ShaderModule sourceTexturePlane1FsModule = utils::CreateShaderModule(device, R"(
+        @fragment fn main(@builtin(position) FragCoord : vec4<f32>)
+                                 -> @location(0) vec4<f32> {
+
+            if(FragCoord.x < 2.0 && FragCoord.y < 2.0) {
+               return vec4<f32>(0.1402, 0.0175, 0.0, 0.0);
+            }
+
+            if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(1.0, 0.4937, 0.0, 0.0);
+            }
+
+            if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
+               return vec4<f32>(0.5, 0.5, 0.0, 0.0);
+            }
+
+            return vec4<f32>(0.4172, 1.0, 0.0, 0.0);
+        })");
+
+    wgpu::Texture sourceTexturePlane0 =
+        Create2DTexture(device, kWidth, kHeight, wgpu::TextureFormat::R8Unorm,
+                        wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment);
+    wgpu::Texture sourceTexturePlane1 =
+        Create2DTexture(device, kWidth, kHeight, wgpu::TextureFormat::RG8Unorm,
+                        wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment);
+
+    RenderToSourceTexture(sourceTexturePlane0FsModule, sourceTexturePlane0);
+    RenderToSourceTexture(sourceTexturePlane1FsModule, sourceTexturePlane1);
+
+    wgpu::Texture renderTexture =
+        Create2DTexture(device, kWidth, kHeight, kFormat,
+                        wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::RenderAttachment);
+
+    // Control case to verify flipY and rotation defaults
+    {
+        // Pipeline Creation
+        utils::ComboRenderPipelineDescriptor descriptor;
+        descriptor.vertex.module = vsModule;
+        descriptor.cFragment.module = fsSampleExternalTextureModule;
+        descriptor.cTargets[0].format = kFormat;
+        wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
+
+        // Create an ExternalTextureDescriptor from the texture view
+        wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
+        externalDesc.plane0 = sourceTexturePlane0.CreateView();
+        externalDesc.plane1 = sourceTexturePlane1.CreateView();
+
+        // Import the external texture
+        wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc);
+
+        // Create a sampler and bind group
+        wgpu::Sampler sampler = device.CreateSampler();
+
+        wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+                                                         {{0, sampler}, {1, externalTexture}});
+
+        // Run the shader, which should sample from the external texture and draw a triangle into
+        // the upper left corner of the render texture.
+        wgpu::TextureView renderView = renderTexture.CreateView();
+        utils::ComboRenderPassDescriptor renderPass({renderView}, nullptr);
+        wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+        wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+        {
+            pass.SetPipeline(pipeline);
+            pass.SetBindGroup(0, bindGroup);
+            pass.Draw(6);
+            pass.End();
+        }
+
+        wgpu::CommandBuffer commands = encoder.Finish();
+        queue.Submit(1, &commands);
+
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kGreen, renderTexture, 0, 0);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kBlack, renderTexture, 3, 0);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kRed, renderTexture, 0, 3);
+        EXPECT_PIXEL_RGBA8_EQ(utils::RGBA8::kBlue, renderTexture, 3, 3);
+    }
+
+    struct RotationExpectation {
+        wgpu::ExternalTextureRotation rotation;
+        bool flipY;
+        utils::RGBA8 upperLeftColor;
+        utils::RGBA8 upperRightColor;
+        utils::RGBA8 lowerLeftColor;
+        utils::RGBA8 lowerRightColor;
+    };
+
+    std::array<RotationExpectation, 8> 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
+        utils::ComboRenderPipelineDescriptor descriptor;
+        descriptor.vertex.module = vsModule;
+        descriptor.cFragment.module = fsSampleExternalTextureModule;
+        descriptor.cTargets[0].format = kFormat;
+        wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
+
+        // Create an ExternalTextureDescriptor from the texture view
+        wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
+        externalDesc.plane0 = sourceTexturePlane0.CreateView();
+        externalDesc.plane1 = sourceTexturePlane1.CreateView();
+        externalDesc.rotation = exp.rotation;
+        externalDesc.flipY = exp.flipY;
+
+        // Import the external texture
+        wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc);
+
+        // Create a sampler and bind group
+        wgpu::Sampler sampler = device.CreateSampler();
+
+        wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
+                                                         {{0, sampler}, {1, externalTexture}});
+
+        // Run the shader, which should sample from the external texture and draw a triangle into
+        // the upper left corner of the render texture.
+        wgpu::TextureView renderView = renderTexture.CreateView();
+        utils::ComboRenderPassDescriptor renderPass({renderView}, nullptr);
+        wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
+        wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
+        {
+            pass.SetPipeline(pipeline);
+            pass.SetBindGroup(0, bindGroup);
+            pass.Draw(6);
+            pass.End();
+        }
+
+        wgpu::CommandBuffer commands = encoder.Finish();
+        queue.Submit(1, &commands);
+
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperLeftColor, renderTexture, 0, 0);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperLeftColor, renderTexture, 1, 1);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperRightColor, renderTexture, 3, 0);
+        EXPECT_PIXEL_RGBA8_EQ(exp.upperRightColor, renderTexture, 2, 1);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerLeftColor, renderTexture, 0, 3);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerLeftColor, renderTexture, 1, 2);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerRightColor, renderTexture, 3, 3);
+        EXPECT_PIXEL_RGBA8_EQ(exp.lowerRightColor, renderTexture, 2, 2);
+    }
+}
+
 DAWN_INSTANTIATE_TEST(ExternalTextureTests,
                       D3D12Backend(),
                       MetalBackend(),
diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc
index 0667ae9..63de1f4 100644
--- a/src/tint/transform/multiplanar_external_texture.cc
+++ b/src/tint/transform/multiplanar_external_texture.cc
@@ -258,10 +258,11 @@
         utils::Vector ext_tex_params_member_list{
             b.Member("numPlanes", b.ty.u32()),
             b.Member("doYuvToRgbConversionOnly", b.ty.u32()),
-            b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32())),
+            b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4<f32>()),
             b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
             b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
-            b.Member("gamutConversionMatrix", b.ty.mat3x3(b.ty.f32()))};
+            b.Member("gamutConversionMatrix", b.ty.mat3x3<f32>()),
+            b.Member("rotationMatrix", b.ty.mat2x2<f32>())};
 
         params_struct_sym = b.Symbols().New("ExternalTextureParams");
 
@@ -314,22 +315,27 @@
         const ast::CallExpression* plane_1_call = nullptr;
         switch (call_type) {
             case sem::BuiltinType::kTextureSampleBaseClampToEdge:
+                stmts.Push(b.Decl(b.Let("modifiedCoords",
+                                        b.Add(b.Mul(b.Sub("coord", f32(0.5)),
+                                                    b.MemberAccessor("params", "rotationMatrix")),
+                                              f32(0.5)))));
+
                 stmts.Push(b.Decl(b.Let(
                     "plane0_dims",
                     b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane0", 0_a)))));
                 stmts.Push(
                     b.Decl(b.Let("plane0_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane0_dims"))));
-                stmts.Push(
-                    b.Decl(b.Let("plane0_clamped", b.Call("clamp", "coord", "plane0_half_texel",
-                                                          b.Sub(1_a, "plane0_half_texel")))));
+                stmts.Push(b.Decl(
+                    b.Let("plane0_clamped", b.Call("clamp", "modifiedCoords", "plane0_half_texel",
+                                                   b.Sub(1_a, "plane0_half_texel")))));
                 stmts.Push(b.Decl(b.Let(
                     "plane1_dims",
                     b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane1", 0_a)))));
                 stmts.Push(
                     b.Decl(b.Let("plane1_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane1_dims"))));
-                stmts.Push(
-                    b.Decl(b.Let("plane1_clamped", b.Call("clamp", "coord", "plane1_half_texel",
-                                                          b.Sub(1_a, "plane1_half_texel")))));
+                stmts.Push(b.Decl(
+                    b.Let("plane1_clamped", b.Call("clamp", "modifiedCoords", "plane1_half_texel",
+                                                   b.Sub(1_a, "plane1_half_texel")))));
 
                 // textureSampleLevel(plane0, smp, plane0_clamped, 0.0);
                 single_plane_call =
diff --git a/src/tint/transform/multiplanar_external_texture_test.cc b/src/tint/transform/multiplanar_external_texture_test.cc
index dbfbc8d..b220447 100644
--- a/src/tint/transform/multiplanar_external_texture_test.cc
+++ b/src/tint/transform/multiplanar_external_texture_test.cc
@@ -138,6 +138,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
@@ -193,6 +194,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
@@ -247,6 +249,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -265,12 +268,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -329,6 +333,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -343,12 +348,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -412,6 +418,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
@@ -504,6 +511,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
@@ -595,6 +603,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -613,12 +622,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -692,6 +702,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -706,12 +717,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -795,6 +807,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
@@ -831,12 +844,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -904,6 +918,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -918,12 +933,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -995,6 +1011,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1014,12 +1031,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1086,6 +1104,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1100,12 +1119,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1179,6 +1199,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1197,12 +1218,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1281,6 +1303,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1304,12 +1327,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1384,6 +1408,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1398,12 +1423,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1483,6 +1509,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1497,12 +1524,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1570,6 +1598,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<u32> {
@@ -1621,6 +1650,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1637,12 +1667,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
@@ -1715,6 +1746,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
@@ -1734,12 +1766,13 @@
 }
 
 fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
+  let modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   let plane0_dims = vec2<f32>(textureDimensions(plane0, 0));
   let plane0_half_texel = (vec2<f32>(0.5) / plane0_dims);
-  let plane0_clamped = clamp(coord, plane0_half_texel, (1 - plane0_half_texel));
+  let plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1 - plane0_half_texel));
   let plane1_dims = vec2<f32>(textureDimensions(plane1, 0));
   let plane1_half_texel = (vec2<f32>(0.5) / plane1_dims);
-  let plane1_clamped = clamp(coord, plane1_half_texel, (1 - plane1_half_texel));
+  let plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1 - plane1_half_texel));
   var color : vec3<f32>;
   if ((params.numPlanes == 1)) {
     color = textureSampleLevel(plane0, smp, plane0_clamped, 0).rgb;
diff --git a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl
index a80ef5b..ca9e4d4 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl
+++ b/test/tint/bug/tint/1739.wgsl.expected.dxc.hlsl
@@ -19,11 +19,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space0);
 cbuffer cbuffer_ext_tex_params : register(b3, space0) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> t : register(t0, space0);
 RWTexture2D<float4> outImage : register(u1, space0);
@@ -50,14 +51,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_6(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_6(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_8(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_8(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -66,22 +67,30 @@
   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_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;
+  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[11], uint offset) {
+float3x3 tint_symbol_10(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_4(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_12(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_13 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_13;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_4(uint4 buffer[12], uint offset) {
+  const uint scalar_offset_16 = ((offset + 0u)) / 4;
+  const uint scalar_offset_17 = ((offset + 4u)) / 4;
+  const ExternalTextureParams tint_symbol_15 = {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_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 a80ef5b..ca9e4d4 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl
+++ b/test/tint/bug/tint/1739.wgsl.expected.fxc.hlsl
@@ -19,11 +19,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space0);
 cbuffer cbuffer_ext_tex_params : register(b3, space0) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> t : register(t0, space0);
 RWTexture2D<float4> outImage : register(u1, space0);
@@ -50,14 +51,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_6(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_6(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_8(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_8(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -66,22 +67,30 @@
   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_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;
+  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[11], uint offset) {
+float3x3 tint_symbol_10(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_4(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_12(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_13 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_13;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_4(uint4 buffer[12], uint offset) {
+  const uint scalar_offset_16 = ((offset + 0u)) / 4;
+  const uint scalar_offset_17 = ((offset + 4u)) / 4;
+  const ExternalTextureParams tint_symbol_15 = {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_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 913050b..f161025 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.glsl
+++ b/test/tint/bug/tint/1739.wgsl.expected.glsl
@@ -20,10 +20,24 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 layout(rgba8) uniform highp writeonly image2D outImage;
@@ -51,10 +65,14 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 ed7a995..195876b 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.msl
+++ b/test/tint/bug/tint/1739.wgsl.expected.msl
@@ -37,6 +37,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 2f01aa5..9bd661e 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.spvasm
+++ b/test/tint/bug/tint/1739.wgsl.expected.spvasm
@@ -1,22 +1,22 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 177
+; Bound: 195
 ; Schema: 0
                OpCapability Shader
                OpCapability ImageQuery
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                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,8 +26,10 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                OpName %ext_tex_params "ext_tex_params"
                OpName %t "t"
                OpName %outImage "outImage"
@@ -38,25 +40,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 "rotationMatrix"
                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
@@ -65,10 +77,12 @@
                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_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
                OpDecorate %ext_tex_params NonWritable
                OpDecorate %ext_tex_params DescriptorSet 0
                OpDecorate %ext_tex_params Binding 3
@@ -77,6 +91,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
@@ -87,186 +114,206 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %18 = OpTypeImage %float 2D 0 0 0 2 Rgba8
-%_ptr_UniformConstant_18 = OpTypePointer UniformConstant %18
-   %outImage = OpVariable %_ptr_UniformConstant_18 UniformConstant
+         %19 = OpTypeImage %float 2D 0 0 0 2 Rgba8
+%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19
+   %outImage = OpVariable %_ptr_UniformConstant_19 UniformConstant
         %int = OpTypeInt 32 1
       %v2int = OpTypeVector %int 2
-         %19 = OpTypeFunction %v2int %v2int %v2int %v2int
-         %30 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %20 = OpTypeFunction %v2int %v2int %v2int %v2int
+         %31 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %49 = OpConstantNull %v3float
-         %69 = OpTypeFunction %v4float %3 %3 %v2int %ExternalTextureParams
+         %50 = OpConstantNull %v3float
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %70 = OpTypeFunction %v4float %3 %3 %v2int %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
-         %84 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %87 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %98 = OpConstantNull %uint
+        %100 = OpConstantNull %uint
+        %118 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %116 = OpTypeFunction %void
+        %132 = OpTypeFunction %void
      %int_10 = OpConstant %int 10
-        %122 = OpConstantComposite %v2int %int_10 %int_10
-        %123 = OpConstantNull %v2int
+        %138 = OpConstantComposite %v2int %int_10 %int_10
+        %139 = OpConstantNull %v2int
      %v2uint = OpTypeVector %uint 2
       %int_0 = OpConstant %int 0
-        %130 = OpConstantComposite %v2uint %uint_1 %uint_1
+        %146 = 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
-        %141 = OpConstantNull %v4float
+        %158 = OpConstantNull %v4float
      %int_70 = OpConstant %int 70
     %int_118 = OpConstant %int 118
-        %154 = OpConstantComposite %v2int %int_70 %int_118
+        %171 = OpConstantComposite %v2int %int_70 %int_118
       %int_1 = OpConstant %int 1
-        %168 = OpConstantComposite %v2int %int_1 %84
- %tint_clamp = OpFunction %v2int None %19
+        %186 = OpConstantComposite %v2int %int_1 %87
+ %tint_clamp = OpFunction %v2int None %20
           %e = OpFunctionParameter %v2int
         %low = OpFunctionParameter %v2int
        %high = OpFunctionParameter %v2int
-         %26 = OpLabel
-         %29 = OpExtInst %v2int %28 SMax %e %low
-         %27 = OpExtInst %v2int %28 SMin %29 %high
-               OpReturnValue %27
+         %27 = OpLabel
+         %30 = OpExtInst %v2int %29 SMax %e %low
+         %28 = OpExtInst %v2int %29 SMin %30 %high
+               OpReturnValue %28
                OpFunctionEnd
-%gammaCorrection = OpFunction %v3float None %30
+%gammaCorrection = OpFunction %v3float None %31
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %34 = OpLabel
-         %47 = OpVariable %_ptr_Function_v3float Function %49
-         %59 = OpVariable %_ptr_Function_v3float Function %49
-         %65 = OpVariable %_ptr_Function_v3float Function %49
-         %35 = OpExtInst %v3float %28 FAbs %v
-         %36 = OpCompositeExtract %float %params 4
-         %37 = OpCompositeConstruct %v3float %36 %36 %36
-         %38 = OpFOrdLessThan %v3bool %35 %37
-         %41 = OpExtInst %v3float %28 FSign %v
-         %42 = OpCompositeExtract %float %params 3
-         %43 = OpExtInst %v3float %28 FAbs %v
-         %44 = OpVectorTimesScalar %v3float %43 %42
-         %45 = OpCompositeExtract %float %params 6
-         %50 = OpCompositeConstruct %v3float %45 %45 %45
-         %46 = OpFAdd %v3float %44 %50
-         %51 = OpFMul %v3float %41 %46
-         %52 = OpExtInst %v3float %28 FSign %v
-         %54 = OpCompositeExtract %float %params 1
-         %55 = OpExtInst %v3float %28 FAbs %v
-         %56 = OpVectorTimesScalar %v3float %55 %54
-         %57 = OpCompositeExtract %float %params 2
-         %60 = OpCompositeConstruct %v3float %57 %57 %57
-         %58 = OpFAdd %v3float %56 %60
-         %61 = OpCompositeExtract %float %params 0
-         %62 = OpCompositeConstruct %v3float %61 %61 %61
-         %53 = OpExtInst %v3float %28 Pow %58 %62
-         %63 = OpCompositeExtract %float %params 5
-         %66 = OpCompositeConstruct %v3float %63 %63 %63
-         %64 = OpFAdd %v3float %53 %66
-         %67 = OpFMul %v3float %52 %64
-         %68 = OpSelect %v3float %38 %51 %67
-               OpReturnValue %68
+         %35 = OpLabel
+         %48 = OpVariable %_ptr_Function_v3float Function %50
+         %60 = OpVariable %_ptr_Function_v3float Function %50
+         %66 = OpVariable %_ptr_Function_v3float Function %50
+         %36 = OpExtInst %v3float %29 FAbs %v
+         %37 = OpCompositeExtract %float %params 4
+         %38 = OpCompositeConstruct %v3float %37 %37 %37
+         %39 = OpFOrdLessThan %v3bool %36 %38
+         %42 = OpExtInst %v3float %29 FSign %v
+         %43 = OpCompositeExtract %float %params 3
+         %44 = OpExtInst %v3float %29 FAbs %v
+         %45 = OpVectorTimesScalar %v3float %44 %43
+         %46 = OpCompositeExtract %float %params 6
+         %51 = OpCompositeConstruct %v3float %46 %46 %46
+         %47 = OpFAdd %v3float %45 %51
+         %52 = OpFMul %v3float %42 %47
+         %53 = OpExtInst %v3float %29 FSign %v
+         %55 = OpCompositeExtract %float %params 1
+         %56 = OpExtInst %v3float %29 FAbs %v
+         %57 = OpVectorTimesScalar %v3float %56 %55
+         %58 = OpCompositeExtract %float %params 2
+         %61 = OpCompositeConstruct %v3float %58 %58 %58
+         %59 = OpFAdd %v3float %57 %61
+         %62 = OpCompositeExtract %float %params 0
+         %63 = OpCompositeConstruct %v3float %62 %62 %62
+         %54 = OpExtInst %v3float %29 Pow %59 %63
+         %64 = OpCompositeExtract %float %params 5
+         %67 = OpCompositeConstruct %v3float %64 %64 %64
+         %65 = OpFAdd %v3float %54 %67
+         %68 = OpFMul %v3float %53 %65
+         %69 = OpSelect %v3float %39 %52 %68
+               OpReturnValue %69
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %69
+%textureLoadExternal = OpFunction %v4float None %70
      %plane0 = OpFunctionParameter %3
      %plane1 = OpFunctionParameter %3
       %coord = OpFunctionParameter %v2int
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %75 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %49
-         %77 = OpCompositeExtract %uint %params_0 0
-         %79 = OpIEqual %bool %77 %uint_1
-               OpSelectionMerge %80 None
-               OpBranchConditional %79 %81 %82
-         %81 = OpLabel
-         %83 = OpImageFetch %v4float %plane0 %coord Lod %84
-         %85 = OpVectorShuffle %v3float %83 %83 0 1 2
-               OpStore %color %85
-               OpBranch %80
-         %82 = OpLabel
-         %86 = OpImageFetch %v4float %plane0 %coord Lod %84
-         %87 = OpCompositeExtract %float %86 0
-         %88 = OpImageFetch %v4float %plane1 %coord Lod %84
-         %90 = OpVectorShuffle %v2float %88 %88 0 1
-         %91 = OpCompositeExtract %float %90 0
-         %92 = OpCompositeExtract %float %90 1
-         %94 = OpCompositeConstruct %v4float %87 %91 %92 %float_1
-         %95 = OpCompositeExtract %mat3v4float %params_0 2
-         %96 = OpVectorTimesMatrix %v3float %94 %95
-               OpStore %color %96
-               OpBranch %80
-         %80 = OpLabel
-         %97 = OpCompositeExtract %uint %params_0 1
-         %99 = OpIEqual %bool %97 %98
-               OpSelectionMerge %100 None
-               OpBranchConditional %99 %101 %100
-        %101 = OpLabel
-        %103 = OpLoad %v3float %color
-        %104 = OpCompositeExtract %GammaTransferParams %params_0 3
-        %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
-               OpStore %color %102
-        %105 = OpCompositeExtract %mat3v3float %params_0 5
-        %106 = OpLoad %v3float %color
-        %107 = OpMatrixTimesVector %v3float %105 %106
-               OpStore %color %107
-        %109 = OpLoad %v3float %color
-        %110 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %108 = OpFunctionCall %v3float %gammaCorrection %109 %110
-               OpStore %color %108
-               OpBranch %100
-        %100 = OpLabel
+         %78 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %50
+         %80 = OpCompositeExtract %uint %params_0 0
+         %82 = OpIEqual %bool %80 %uint_1
+               OpSelectionMerge %83 None
+               OpBranchConditional %82 %84 %85
+         %84 = OpLabel
+         %86 = OpImageFetch %v4float %plane0 %coord Lod %87
+         %88 = OpVectorShuffle %v3float %86 %86 0 1 2
+               OpStore %color %88
+               OpBranch %83
+         %85 = OpLabel
+         %89 = OpImageFetch %v4float %plane0 %coord Lod %87
+         %90 = OpCompositeExtract %float %89 0
+         %91 = OpImageFetch %v4float %plane1 %coord Lod %87
+         %92 = OpVectorShuffle %v2float %91 %91 0 1
+         %93 = OpCompositeExtract %float %92 0
+         %94 = OpCompositeExtract %float %92 1
+         %96 = OpCompositeConstruct %v4float %90 %93 %94 %float_1
+         %97 = OpCompositeExtract %mat3v4float %params_0 2
+         %98 = OpVectorTimesMatrix %v3float %96 %97
+               OpStore %color %98
+               OpBranch %83
+         %83 = OpLabel
+         %99 = OpCompositeExtract %uint %params_0 1
+        %101 = OpIEqual %bool %99 %100
+               OpSelectionMerge %102 None
+               OpBranchConditional %101 %103 %102
+        %103 = OpLabel
+        %105 = OpLoad %v3float %color
+        %106 = OpCompositeExtract %GammaTransferParams %params_0 3
+        %104 = OpFunctionCall %v3float %gammaCorrection %105 %106
+               OpStore %color %104
+        %107 = OpCompositeExtract %mat3v3float %params_0 5
+        %108 = OpLoad %v3float %color
+        %109 = OpMatrixTimesVector %v3float %107 %108
+               OpStore %color %109
         %111 = OpLoad %v3float %color
-        %112 = OpCompositeExtract %float %111 0
-        %113 = OpCompositeExtract %float %111 1
-        %114 = OpCompositeExtract %float %111 2
-        %115 = OpCompositeConstruct %v4float %112 %113 %114 %float_1
-               OpReturnValue %115
+        %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 %116
-        %119 = OpLabel
-        %red = OpVariable %_ptr_Function_v4float Function %141
-      %green = OpVariable %_ptr_Function_v4float Function %141
-        %128 = OpLoad %3 %t
-        %127 = OpImageQuerySizeLod %v2uint %128 %int_0
-        %131 = OpISub %v2uint %127 %130
-        %124 = OpBitcast %v2int %131
-        %120 = OpFunctionCall %v2int %tint_clamp %122 %123 %124
-        %133 = OpLoad %3 %t
-        %134 = OpLoad %3 %ext_tex_plane_1
-        %137 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %138 = OpLoad %ExternalTextureParams %137
-        %132 = OpFunctionCall %v4float %textureLoadExternal %133 %134 %120 %138
-               OpStore %red %132
-        %146 = OpLoad %18 %outImage
-        %145 = OpImageQuerySize %v2uint %146
-        %147 = OpISub %v2uint %145 %130
-        %143 = OpBitcast %v2int %147
-        %142 = OpFunctionCall %v2int %tint_clamp %123 %123 %143
-        %149 = OpLoad %18 %outImage
-        %150 = OpLoad %v4float %red
-               OpImageWrite %149 %142 %150
-        %158 = OpLoad %3 %t
-        %157 = OpImageQuerySizeLod %v2uint %158 %int_0
-        %159 = OpISub %v2uint %157 %130
-        %155 = OpBitcast %v2int %159
-        %151 = OpFunctionCall %v2int %tint_clamp %154 %123 %155
-        %161 = OpLoad %3 %t
-        %162 = OpLoad %3 %ext_tex_plane_1
-        %163 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %164 = OpLoad %ExternalTextureParams %163
-        %160 = OpFunctionCall %v4float %textureLoadExternal %161 %162 %151 %164
-               OpStore %green %160
-        %172 = OpLoad %18 %outImage
-        %171 = OpImageQuerySize %v2uint %172
-        %173 = OpISub %v2uint %171 %130
-        %169 = OpBitcast %v2int %173
-        %166 = OpFunctionCall %v2int %tint_clamp %168 %123 %169
-        %175 = OpLoad %18 %outImage
-        %176 = OpLoad %v4float %green
-               OpImageWrite %175 %166 %176
+%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 = OpCompositeConstruct %mat2v2float %128 %129
+        %131 = OpCompositeConstruct %ExternalTextureParams %122 %123 %124 %125 %126 %127 %130
+               OpReturnValue %131
+               OpFunctionEnd
+       %main = OpFunction %void None %132
+        %135 = OpLabel
+        %red = OpVariable %_ptr_Function_v4float Function %158
+      %green = OpVariable %_ptr_Function_v4float Function %158
+        %144 = OpLoad %3 %t
+        %143 = OpImageQuerySizeLod %v2uint %144 %int_0
+        %147 = OpISub %v2uint %143 %146
+        %140 = OpBitcast %v2int %147
+        %136 = OpFunctionCall %v2int %tint_clamp %138 %139 %140
+        %149 = OpLoad %3 %t
+        %150 = OpLoad %3 %ext_tex_plane_1
+        %154 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %155 = OpLoad %ExternalTextureParams_std140 %154
+        %151 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %155
+        %148 = OpFunctionCall %v4float %textureLoadExternal %149 %150 %136 %151
+               OpStore %red %148
+        %163 = OpLoad %19 %outImage
+        %162 = OpImageQuerySize %v2uint %163
+        %164 = OpISub %v2uint %162 %146
+        %160 = OpBitcast %v2int %164
+        %159 = OpFunctionCall %v2int %tint_clamp %139 %139 %160
+        %166 = OpLoad %19 %outImage
+        %167 = OpLoad %v4float %red
+               OpImageWrite %166 %159 %167
+        %175 = OpLoad %3 %t
+        %174 = OpImageQuerySizeLod %v2uint %175 %int_0
+        %176 = OpISub %v2uint %174 %146
+        %172 = OpBitcast %v2int %176
+        %168 = OpFunctionCall %v2int %tint_clamp %171 %139 %172
+        %178 = OpLoad %3 %t
+        %179 = OpLoad %3 %ext_tex_plane_1
+        %181 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %182 = OpLoad %ExternalTextureParams_std140 %181
+        %180 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %182
+        %177 = OpFunctionCall %v4float %textureLoadExternal %178 %179 %168 %180
+               OpStore %green %177
+        %190 = OpLoad %19 %outImage
+        %189 = OpImageQuerySize %v2uint %190
+        %191 = OpISub %v2uint %189 %146
+        %187 = OpBitcast %v2int %191
+        %184 = OpFunctionCall %v2int %tint_clamp %186 %139 %187
+        %193 = OpLoad %19 %outImage
+        %194 = OpLoad %v4float %green
+               OpImageWrite %193 %184 %194
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/bug/tint/1739.wgsl.expected.wgsl b/test/tint/bug/tint/1739.wgsl.expected.wgsl
index d6bd056..f3d1c98 100644
--- a/test/tint/bug/tint/1739.wgsl.expected.wgsl
+++ b/test/tint/bug/tint/1739.wgsl.expected.wgsl
@@ -16,6 +16,7 @@
   gammaDecodeParams : GammaTransferParams,
   gammaEncodeParams : GammaTransferParams,
   gamutConversionMatrix : mat3x3<f32>,
+  rotationMatrix : mat2x2<f32>,
 }
 
 @group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
diff --git a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
index 092b79e..1f8d50c 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
@@ -1,6 +1,6 @@
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
diff --git a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
index 092b79e..1f8d50c 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
@@ -1,6 +1,6 @@
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
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 194a4bf..06f4c76 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 uniform highp sampler2D arg_0_1;
@@ -63,10 +75,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 uniform highp sampler2D arg_0_1;
@@ -102,10 +126,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+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 3808793..a997980 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.msl
@@ -19,6 +19,7 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 void textureDimensions_cdc6c9(texture2d<float, access::sample> 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 da1f2ab..12d1c58 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureDimensions/cdc6c9.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 48
+; Bound: 49
 ; Schema: 0
                OpCapability Shader
                OpCapability ImageQuery
@@ -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,8 +30,10 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                OpName %ext_tex_params "ext_tex_params"
                OpName %arg_0 "arg_0"
                OpName %textureDimensions_cdc6c9 "textureDimensions_cdc6c9"
@@ -44,14 +46,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
@@ -60,10 +62,12 @@
                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_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
                OpDecorate %ext_tex_params NonWritable
                OpDecorate %ext_tex_params DescriptorSet 1
                OpDecorate %ext_tex_params Binding 2
@@ -85,47 +89,48 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %void
+         %23 = OpTypeFunction %void
      %v2uint = OpTypeVector %uint 2
         %int = OpTypeInt 32 1
       %int_0 = OpConstant %int 0
 %_ptr_Function_v2uint = OpTypePointer Function %v2uint
-         %33 = OpConstantNull %v2uint
-         %34 = OpTypeFunction %v4float
+         %34 = OpConstantNull %v2uint
+         %35 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
-%textureDimensions_cdc6c9 = OpFunction %void None %22
-         %25 = OpLabel
-        %res = OpVariable %_ptr_Function_v2uint Function %33
-         %28 = OpLoad %11 %arg_0
-         %26 = OpImageQuerySizeLod %v2uint %28 %int_0
-               OpStore %res %26
+%textureDimensions_cdc6c9 = OpFunction %void None %23
+         %26 = OpLabel
+        %res = OpVariable %_ptr_Function_v2uint Function %34
+         %29 = OpLoad %11 %arg_0
+         %27 = OpImageQuerySizeLod %v2uint %29 %int_0
+               OpStore %res %27
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %34
-         %36 = OpLabel
-         %37 = OpFunctionCall %void %textureDimensions_cdc6c9
+%vertex_main_inner = OpFunction %v4float None %35
+         %37 = OpLabel
+         %38 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %22
-         %39 = OpLabel
-         %40 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %40
+%vertex_main = OpFunction %void None %23
+         %40 = OpLabel
+         %41 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %41
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %22
-         %43 = OpLabel
-         %44 = OpFunctionCall %void %textureDimensions_cdc6c9
+%fragment_main = OpFunction %void None %23
+         %44 = OpLabel
+         %45 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %22
-         %46 = OpLabel
-         %47 = OpFunctionCall %void %textureDimensions_cdc6c9
+%compute_main = OpFunction %void None %23
+         %47 = OpLabel
+         %48 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturn
                OpFunctionEnd
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 28536b3..7c4f973 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 28536b3..7c4f973 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 2c2df83..e9ad0a8 100644
--- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -48,8 +60,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -86,10 +102,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -116,8 +144,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -148,10 +180,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -178,8 +222,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 dfb5020..f4a8d7a 100644
--- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 72a5227..a8b4a3d 100644
--- a/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureLoad/1bfdfb.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 138
+; Bound: 155
 ; Schema: 0
                OpCapability Shader
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,19 +30,31 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                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"
@@ -53,14 +65,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
@@ -69,15 +81,30 @@
                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_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
                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 8
       %float = OpTypeFloat 32
     %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -94,152 +121,171 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %23 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %42 = OpConstantNull %v3float
+         %43 = OpConstantNull %v3float
      %v2uint = OpTypeVector %uint 2
-         %62 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
         %int = OpTypeInt 32 1
-         %79 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %82 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %93 = OpConstantNull %uint
+         %95 = OpConstantNull %uint
+        %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %111 = OpTypeFunction %void
-        %118 = OpConstantComposite %v2uint %uint_1 %uint_1
+        %127 = OpTypeFunction %void
+        %134 = 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
-        %125 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %22
+        %142 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %23
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %26 = OpLabel
-         %40 = OpVariable %_ptr_Function_v3float Function %42
-         %52 = OpVariable %_ptr_Function_v3float Function %42
-         %58 = OpVariable %_ptr_Function_v3float Function %42
-         %27 = OpExtInst %v3float %28 FAbs %v
-         %29 = OpCompositeExtract %float %params 4
-         %30 = OpCompositeConstruct %v3float %29 %29 %29
-         %31 = OpFOrdLessThan %v3bool %27 %30
-         %34 = OpExtInst %v3float %28 FSign %v
-         %35 = OpCompositeExtract %float %params 3
-         %36 = OpExtInst %v3float %28 FAbs %v
-         %37 = OpVectorTimesScalar %v3float %36 %35
-         %38 = OpCompositeExtract %float %params 6
-         %43 = OpCompositeConstruct %v3float %38 %38 %38
-         %39 = OpFAdd %v3float %37 %43
-         %44 = OpFMul %v3float %34 %39
-         %45 = OpExtInst %v3float %28 FSign %v
-         %47 = OpCompositeExtract %float %params 1
-         %48 = OpExtInst %v3float %28 FAbs %v
-         %49 = OpVectorTimesScalar %v3float %48 %47
-         %50 = OpCompositeExtract %float %params 2
-         %53 = OpCompositeConstruct %v3float %50 %50 %50
-         %51 = OpFAdd %v3float %49 %53
-         %54 = OpCompositeExtract %float %params 0
-         %55 = OpCompositeConstruct %v3float %54 %54 %54
-         %46 = OpExtInst %v3float %28 Pow %51 %55
-         %56 = OpCompositeExtract %float %params 5
-         %59 = OpCompositeConstruct %v3float %56 %56 %56
-         %57 = OpFAdd %v3float %46 %59
-         %60 = OpFMul %v3float %45 %57
-         %61 = OpSelect %v3float %31 %44 %60
-               OpReturnValue %61
+         %27 = OpLabel
+         %41 = OpVariable %_ptr_Function_v3float Function %43
+         %53 = OpVariable %_ptr_Function_v3float Function %43
+         %59 = OpVariable %_ptr_Function_v3float Function %43
+         %28 = OpExtInst %v3float %29 FAbs %v
+         %30 = OpCompositeExtract %float %params 4
+         %31 = OpCompositeConstruct %v3float %30 %30 %30
+         %32 = OpFOrdLessThan %v3bool %28 %31
+         %35 = OpExtInst %v3float %29 FSign %v
+         %36 = OpCompositeExtract %float %params 3
+         %37 = OpExtInst %v3float %29 FAbs %v
+         %38 = OpVectorTimesScalar %v3float %37 %36
+         %39 = OpCompositeExtract %float %params 6
+         %44 = OpCompositeConstruct %v3float %39 %39 %39
+         %40 = OpFAdd %v3float %38 %44
+         %45 = OpFMul %v3float %35 %40
+         %46 = OpExtInst %v3float %29 FSign %v
+         %48 = OpCompositeExtract %float %params 1
+         %49 = OpExtInst %v3float %29 FAbs %v
+         %50 = OpVectorTimesScalar %v3float %49 %48
+         %51 = OpCompositeExtract %float %params 2
+         %54 = OpCompositeConstruct %v3float %51 %51 %51
+         %52 = OpFAdd %v3float %50 %54
+         %55 = OpCompositeExtract %float %params 0
+         %56 = OpCompositeConstruct %v3float %55 %55 %55
+         %47 = OpExtInst %v3float %29 Pow %52 %56
+         %57 = OpCompositeExtract %float %params 5
+         %60 = OpCompositeConstruct %v3float %57 %57 %57
+         %58 = OpFAdd %v3float %47 %60
+         %61 = OpFMul %v3float %46 %58
+         %62 = OpSelect %v3float %32 %45 %61
+               OpReturnValue %62
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %62
+%textureLoadExternal = OpFunction %v4float None %63
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
       %coord = OpFunctionParameter %v2uint
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %69 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %42
-         %71 = OpCompositeExtract %uint %params_0 0
-         %73 = OpIEqual %bool %71 %uint_1
-               OpSelectionMerge %74 None
-               OpBranchConditional %73 %75 %76
-         %75 = OpLabel
-         %77 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %80 = OpVectorShuffle %v3float %77 %77 0 1 2
-               OpStore %color %80
-               OpBranch %74
-         %76 = OpLabel
-         %81 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %82 = OpCompositeExtract %float %81 0
-         %83 = OpImageFetch %v4float %plane1 %coord Lod %79
-         %85 = OpVectorShuffle %v2float %83 %83 0 1
-         %86 = OpCompositeExtract %float %85 0
-         %87 = OpCompositeExtract %float %85 1
-         %89 = OpCompositeConstruct %v4float %82 %86 %87 %float_1
-         %90 = OpCompositeExtract %mat3v4float %params_0 2
-         %91 = OpVectorTimesMatrix %v3float %89 %90
-               OpStore %color %91
-               OpBranch %74
-         %74 = OpLabel
-         %92 = OpCompositeExtract %uint %params_0 1
-         %94 = OpIEqual %bool %92 %93
-               OpSelectionMerge %95 None
-               OpBranchConditional %94 %96 %95
-         %96 = OpLabel
-         %98 = OpLoad %v3float %color
-         %99 = OpCompositeExtract %GammaTransferParams %params_0 3
-         %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
-               OpStore %color %97
-        %100 = OpCompositeExtract %mat3v3float %params_0 5
-        %101 = OpLoad %v3float %color
-        %102 = OpMatrixTimesVector %v3float %100 %101
-               OpStore %color %102
-        %104 = OpLoad %v3float %color
-        %105 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %103 = OpFunctionCall %v3float %gammaCorrection %104 %105
-               OpStore %color %103
-               OpBranch %95
-         %95 = OpLabel
+         %72 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %43
+         %74 = OpCompositeExtract %uint %params_0 0
+         %76 = OpIEqual %bool %74 %uint_1
+               OpSelectionMerge %77 None
+               OpBranchConditional %76 %78 %79
+         %78 = OpLabel
+         %80 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %83 = OpVectorShuffle %v3float %80 %80 0 1 2
+               OpStore %color %83
+               OpBranch %77
+         %79 = OpLabel
+         %84 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %85 = OpCompositeExtract %float %84 0
+         %86 = OpImageFetch %v4float %plane1 %coord Lod %82
+         %87 = OpVectorShuffle %v2float %86 %86 0 1
+         %88 = OpCompositeExtract %float %87 0
+         %89 = OpCompositeExtract %float %87 1
+         %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1
+         %92 = OpCompositeExtract %mat3v4float %params_0 2
+         %93 = OpVectorTimesMatrix %v3float %91 %92
+               OpStore %color %93
+               OpBranch %77
+         %77 = OpLabel
+         %94 = OpCompositeExtract %uint %params_0 1
+         %96 = OpIEqual %bool %94 %95
+               OpSelectionMerge %97 None
+               OpBranchConditional %96 %98 %97
+         %98 = OpLabel
+        %100 = OpLoad %v3float %color
+        %101 = OpCompositeExtract %GammaTransferParams %params_0 3
+         %99 = OpFunctionCall %v3float %gammaCorrection %100 %101
+               OpStore %color %99
+        %102 = OpCompositeExtract %mat3v3float %params_0 5
+        %103 = OpLoad %v3float %color
+        %104 = OpMatrixTimesVector %v3float %102 %103
+               OpStore %color %104
         %106 = OpLoad %v3float %color
-        %107 = OpCompositeExtract %float %106 0
-        %108 = OpCompositeExtract %float %106 1
-        %109 = OpCompositeExtract %float %106 2
-        %110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
-               OpReturnValue %110
+        %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 %111
-        %114 = 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 = OpCompositeConstruct %mat2v2float %123 %124
+        %126 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %125
+               OpReturnValue %126
+               OpFunctionEnd
+%textureLoad_1bfdfb = OpFunction %void None %127
+        %130 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-        %116 = OpLoad %11 %arg_0
-        %117 = OpLoad %11 %ext_tex_plane_1
-        %121 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %122 = OpLoad %ExternalTextureParams %121
-        %115 = OpFunctionCall %v4float %textureLoadExternal %116 %117 %118 %122
-               OpStore %res %115
+        %132 = OpLoad %11 %arg_0
+        %133 = OpLoad %11 %ext_tex_plane_1
+        %138 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %139 = OpLoad %ExternalTextureParams_std140 %138
+        %135 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %139
+        %131 = OpFunctionCall %v4float %textureLoadExternal %132 %133 %134 %135
+               OpStore %res %131
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %125
-        %127 = OpLabel
-        %128 = OpFunctionCall %void %textureLoad_1bfdfb
+%vertex_main_inner = OpFunction %v4float None %142
+        %144 = OpLabel
+        %145 = OpFunctionCall %void %textureLoad_1bfdfb
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %111
-        %130 = OpLabel
-        %131 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %131
+%vertex_main = OpFunction %void None %127
+        %147 = OpLabel
+        %148 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %148
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %111
-        %133 = OpLabel
-        %134 = OpFunctionCall %void %textureLoad_1bfdfb
+%fragment_main = OpFunction %void None %127
+        %150 = OpLabel
+        %151 = OpFunctionCall %void %textureLoad_1bfdfb
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %111
-        %136 = OpLabel
-        %137 = OpFunctionCall %void %textureLoad_1bfdfb
+%compute_main = OpFunction %void None %127
+        %153 = OpLabel
+        %154 = 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 ef621cb..224f88e 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 ef621cb..224f88e 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 88a7e3e..8295034 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -48,8 +60,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -86,10 +102,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -116,8 +144,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -148,10 +180,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -178,8 +222,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 93bf9c8..bcf4e6b 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 9929412..5b6a94a 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 139
+; Bound: 156
 ; Schema: 0
                OpCapability Shader
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,19 +30,31 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                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"
@@ -53,14 +65,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
@@ -69,15 +81,30 @@
                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_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
                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 8
       %float = OpTypeFloat 32
     %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -94,153 +121,172 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %23 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %42 = OpConstantNull %v3float
+         %43 = OpConstantNull %v3float
         %int = OpTypeInt 32 1
       %v2int = OpTypeVector %int 2
-         %62 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
-         %79 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %82 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %93 = OpConstantNull %uint
+         %95 = OpConstantNull %uint
+        %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %111 = OpTypeFunction %void
+        %127 = OpTypeFunction %void
       %int_1 = OpConstant %int 1
-        %119 = OpConstantComposite %v2int %int_1 %int_1
+        %135 = 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
-        %126 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %22
+        %143 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %23
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %26 = OpLabel
-         %40 = OpVariable %_ptr_Function_v3float Function %42
-         %52 = OpVariable %_ptr_Function_v3float Function %42
-         %58 = OpVariable %_ptr_Function_v3float Function %42
-         %27 = OpExtInst %v3float %28 FAbs %v
-         %29 = OpCompositeExtract %float %params 4
-         %30 = OpCompositeConstruct %v3float %29 %29 %29
-         %31 = OpFOrdLessThan %v3bool %27 %30
-         %34 = OpExtInst %v3float %28 FSign %v
-         %35 = OpCompositeExtract %float %params 3
-         %36 = OpExtInst %v3float %28 FAbs %v
-         %37 = OpVectorTimesScalar %v3float %36 %35
-         %38 = OpCompositeExtract %float %params 6
-         %43 = OpCompositeConstruct %v3float %38 %38 %38
-         %39 = OpFAdd %v3float %37 %43
-         %44 = OpFMul %v3float %34 %39
-         %45 = OpExtInst %v3float %28 FSign %v
-         %47 = OpCompositeExtract %float %params 1
-         %48 = OpExtInst %v3float %28 FAbs %v
-         %49 = OpVectorTimesScalar %v3float %48 %47
-         %50 = OpCompositeExtract %float %params 2
-         %53 = OpCompositeConstruct %v3float %50 %50 %50
-         %51 = OpFAdd %v3float %49 %53
-         %54 = OpCompositeExtract %float %params 0
-         %55 = OpCompositeConstruct %v3float %54 %54 %54
-         %46 = OpExtInst %v3float %28 Pow %51 %55
-         %56 = OpCompositeExtract %float %params 5
-         %59 = OpCompositeConstruct %v3float %56 %56 %56
-         %57 = OpFAdd %v3float %46 %59
-         %60 = OpFMul %v3float %45 %57
-         %61 = OpSelect %v3float %31 %44 %60
-               OpReturnValue %61
+         %27 = OpLabel
+         %41 = OpVariable %_ptr_Function_v3float Function %43
+         %53 = OpVariable %_ptr_Function_v3float Function %43
+         %59 = OpVariable %_ptr_Function_v3float Function %43
+         %28 = OpExtInst %v3float %29 FAbs %v
+         %30 = OpCompositeExtract %float %params 4
+         %31 = OpCompositeConstruct %v3float %30 %30 %30
+         %32 = OpFOrdLessThan %v3bool %28 %31
+         %35 = OpExtInst %v3float %29 FSign %v
+         %36 = OpCompositeExtract %float %params 3
+         %37 = OpExtInst %v3float %29 FAbs %v
+         %38 = OpVectorTimesScalar %v3float %37 %36
+         %39 = OpCompositeExtract %float %params 6
+         %44 = OpCompositeConstruct %v3float %39 %39 %39
+         %40 = OpFAdd %v3float %38 %44
+         %45 = OpFMul %v3float %35 %40
+         %46 = OpExtInst %v3float %29 FSign %v
+         %48 = OpCompositeExtract %float %params 1
+         %49 = OpExtInst %v3float %29 FAbs %v
+         %50 = OpVectorTimesScalar %v3float %49 %48
+         %51 = OpCompositeExtract %float %params 2
+         %54 = OpCompositeConstruct %v3float %51 %51 %51
+         %52 = OpFAdd %v3float %50 %54
+         %55 = OpCompositeExtract %float %params 0
+         %56 = OpCompositeConstruct %v3float %55 %55 %55
+         %47 = OpExtInst %v3float %29 Pow %52 %56
+         %57 = OpCompositeExtract %float %params 5
+         %60 = OpCompositeConstruct %v3float %57 %57 %57
+         %58 = OpFAdd %v3float %47 %60
+         %61 = OpFMul %v3float %46 %58
+         %62 = OpSelect %v3float %32 %45 %61
+               OpReturnValue %62
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %62
+%textureLoadExternal = OpFunction %v4float None %63
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
       %coord = OpFunctionParameter %v2int
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %70 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %42
-         %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 %79
-         %80 = OpVectorShuffle %v3float %78 %78 0 1 2
-               OpStore %color %80
-               OpBranch %75
-         %77 = OpLabel
-         %81 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %82 = OpCompositeExtract %float %81 0
-         %83 = OpImageFetch %v4float %plane1 %coord Lod %79
-         %85 = OpVectorShuffle %v2float %83 %83 0 1
-         %86 = OpCompositeExtract %float %85 0
-         %87 = OpCompositeExtract %float %85 1
-         %89 = OpCompositeConstruct %v4float %82 %86 %87 %float_1
-         %90 = OpCompositeExtract %mat3v4float %params_0 2
-         %91 = OpVectorTimesMatrix %v3float %89 %90
-               OpStore %color %91
-               OpBranch %75
-         %75 = OpLabel
-         %92 = OpCompositeExtract %uint %params_0 1
-         %94 = OpIEqual %bool %92 %93
-               OpSelectionMerge %95 None
-               OpBranchConditional %94 %96 %95
-         %96 = OpLabel
-         %98 = OpLoad %v3float %color
-         %99 = OpCompositeExtract %GammaTransferParams %params_0 3
-         %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
-               OpStore %color %97
-        %100 = OpCompositeExtract %mat3v3float %params_0 5
-        %101 = OpLoad %v3float %color
-        %102 = OpMatrixTimesVector %v3float %100 %101
-               OpStore %color %102
-        %104 = OpLoad %v3float %color
-        %105 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %103 = OpFunctionCall %v3float %gammaCorrection %104 %105
-               OpStore %color %103
-               OpBranch %95
-         %95 = OpLabel
+         %73 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %43
+         %75 = OpCompositeExtract %uint %params_0 0
+         %77 = OpIEqual %bool %75 %uint_1
+               OpSelectionMerge %78 None
+               OpBranchConditional %77 %79 %80
+         %79 = OpLabel
+         %81 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %83 = OpVectorShuffle %v3float %81 %81 0 1 2
+               OpStore %color %83
+               OpBranch %78
+         %80 = OpLabel
+         %84 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %85 = OpCompositeExtract %float %84 0
+         %86 = OpImageFetch %v4float %plane1 %coord Lod %82
+         %87 = OpVectorShuffle %v2float %86 %86 0 1
+         %88 = OpCompositeExtract %float %87 0
+         %89 = OpCompositeExtract %float %87 1
+         %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1
+         %92 = OpCompositeExtract %mat3v4float %params_0 2
+         %93 = OpVectorTimesMatrix %v3float %91 %92
+               OpStore %color %93
+               OpBranch %78
+         %78 = OpLabel
+         %94 = OpCompositeExtract %uint %params_0 1
+         %96 = OpIEqual %bool %94 %95
+               OpSelectionMerge %97 None
+               OpBranchConditional %96 %98 %97
+         %98 = OpLabel
+        %100 = OpLoad %v3float %color
+        %101 = OpCompositeExtract %GammaTransferParams %params_0 3
+         %99 = OpFunctionCall %v3float %gammaCorrection %100 %101
+               OpStore %color %99
+        %102 = OpCompositeExtract %mat3v3float %params_0 5
+        %103 = OpLoad %v3float %color
+        %104 = OpMatrixTimesVector %v3float %102 %103
+               OpStore %color %104
         %106 = OpLoad %v3float %color
-        %107 = OpCompositeExtract %float %106 0
-        %108 = OpCompositeExtract %float %106 1
-        %109 = OpCompositeExtract %float %106 2
-        %110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
-               OpReturnValue %110
+        %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 %111
-        %114 = 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 = OpCompositeConstruct %mat2v2float %123 %124
+        %126 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %125
+               OpReturnValue %126
+               OpFunctionEnd
+%textureLoad_8acf41 = OpFunction %void None %127
+        %130 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-        %116 = OpLoad %11 %arg_0
-        %117 = OpLoad %11 %ext_tex_plane_1
-        %122 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %123 = OpLoad %ExternalTextureParams %122
-        %115 = OpFunctionCall %v4float %textureLoadExternal %116 %117 %119 %123
-               OpStore %res %115
+        %132 = OpLoad %11 %arg_0
+        %133 = 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
+        %131 = OpFunctionCall %v4float %textureLoadExternal %132 %133 %135 %136
+               OpStore %res %131
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %126
-        %128 = OpLabel
-        %129 = OpFunctionCall %void %textureLoad_8acf41
+%vertex_main_inner = OpFunction %v4float None %143
+        %145 = OpLabel
+        %146 = OpFunctionCall %void %textureLoad_8acf41
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %111
-        %131 = OpLabel
-        %132 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %132
+%vertex_main = OpFunction %void None %127
+        %148 = OpLabel
+        %149 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %149
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %111
-        %134 = OpLabel
-        %135 = OpFunctionCall %void %textureLoad_8acf41
+%fragment_main = OpFunction %void None %127
+        %151 = OpLabel
+        %152 = OpFunctionCall %void %textureLoad_8acf41
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %111
-        %137 = OpLabel
-        %138 = OpFunctionCall %void %textureLoad_8acf41
+%compute_main = OpFunction %void None %127
+        %154 = OpLabel
+        %155 = 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 6bfa0cb..fb6084b 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
 cbuffer cbuffer_ext_tex_params : register(b3, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 SamplerState arg_1 : register(s1, space1);
@@ -32,16 +33,17 @@
 }
 
 float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  const float2 modifiedCoords = (mul(params.rotationMatrix, (coord - 0.5f)) + 0.5f);
   int3 tint_tmp;
   plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z);
   const float2 plane0_dims = float2(tint_tmp.xy);
   const float2 plane0_half_texel = ((0.5f).xx / plane0_dims);
-  const float2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  const float2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   int3 tint_tmp_1;
   plane1.GetDimensions(0, tint_tmp_1.x, tint_tmp_1.y, tint_tmp_1.z);
   const float2 plane1_dims = float2(tint_tmp_1.xy);
   const float2 plane1_half_texel = ((0.5f).xx / plane1_dims);
-  const float2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  const float2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = float3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = plane0.SampleLevel(smp, plane0_clamped, 0.0f).rgb;
@@ -56,14 +58,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -72,22 +74,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 6bfa0cb..fb6084b 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
 cbuffer cbuffer_ext_tex_params : register(b3, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 SamplerState arg_1 : register(s1, space1);
@@ -32,16 +33,17 @@
 }
 
 float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  const float2 modifiedCoords = (mul(params.rotationMatrix, (coord - 0.5f)) + 0.5f);
   int3 tint_tmp;
   plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z);
   const float2 plane0_dims = float2(tint_tmp.xy);
   const float2 plane0_half_texel = ((0.5f).xx / plane0_dims);
-  const float2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  const float2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   int3 tint_tmp_1;
   plane1.GetDimensions(0, tint_tmp_1.x, tint_tmp_1.y, tint_tmp_1.z);
   const float2 plane1_dims = float2(tint_tmp_1.xy);
   const float2 plane1_half_texel = ((0.5f).xx / plane1_dims);
-  const float2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  const float2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = float3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = plane0.SampleLevel(smp, plane0_clamped, 0.0f).rgb;
@@ -56,14 +58,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -72,22 +74,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 82b6a82..5a0d27b 100644
--- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -33,12 +45,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -57,8 +70,12 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -95,10 +112,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -110,12 +139,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -134,8 +164,12 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -166,10 +200,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -181,12 +227,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -205,8 +252,12 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 146503a..76ac2f5 100644
--- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 float3 gammaCorrection(float3 v, GammaTransferParams params) {
@@ -43,12 +44,13 @@
 }
 
 float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
+  float2 const modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   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(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  float2 const plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   float2 const plane1_dims = float2(uint2(plane1.get_width(0), plane1.get_height(0)));
   float2 const plane1_half_texel = (float2(0.5f) / plane1_dims);
-  float2 const plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  float2 const plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = 0.0f;
   if ((params.numPlanes == 1u)) {
     color = float4(plane0.sample(smp, plane0_clamped, level(0.0f))).rgb;
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 1597eb3..a51be75 100644
--- a/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm
@@ -1,11 +1,11 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 165
+; Bound: 190
 ; Schema: 0
                OpCapability Shader
                OpCapability ImageQuery
-         %31 = OpExtInstImport "GLSL.std.450"
+         %32 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,14 +31,24 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                OpName %textureSampleExternal "textureSampleExternal"
                OpName %plane0 "plane0"
                OpName %plane1 "plane1"
@@ -46,6 +56,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"
@@ -56,14 +68,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
@@ -72,10 +84,12 @@
                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_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
                OpDecorate %ext_tex_params NonWritable
                OpDecorate %ext_tex_params DescriptorSet 1
                OpDecorate %ext_tex_params Binding 3
@@ -83,6 +97,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
@@ -99,179 +126,206 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %24 = OpTypeSampler
-%_ptr_UniformConstant_24 = OpTypePointer UniformConstant %24
-      %arg_1 = OpVariable %_ptr_UniformConstant_24 UniformConstant
-         %25 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %25 = OpTypeSampler
+%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25
+      %arg_1 = OpVariable %_ptr_UniformConstant_25 UniformConstant
+         %26 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %45 = OpConstantNull %v3float
-    %v2float = OpTypeVector %float 2
-         %65 = OpTypeFunction %v4float %11 %11 %24 %v2float %ExternalTextureParams
+         %46 = OpConstantNull %v3float
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams
+  %float_0_5 = OpConstant %float 0.5
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %80 = OpConstantNull %v2float
      %v2uint = OpTypeVector %uint 2
         %int = OpTypeInt 32 1
-         %78 = OpConstantNull %int
-  %float_0_5 = OpConstant %float 0.5
-         %80 = OpConstantComposite %v2float %float_0_5 %float_0_5
+         %91 = OpConstantNull %int
+         %92 = OpConstantComposite %v2float %float_0_5 %float_0_5
     %float_1 = OpConstant %float 1
-%_ptr_Function_v2float = OpTypePointer Function %v2float
-         %87 = OpConstantNull %v2float
      %uint_1 = OpConstant %uint 1
-        %104 = OpTypeSampledImage %11
-        %119 = OpConstantNull %uint
+        %114 = OpTypeSampledImage %11
+        %129 = OpConstantNull %uint
+        %147 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %137 = OpTypeFunction %void
-        %145 = OpConstantComposite %v2float %float_1 %float_1
+        %161 = OpTypeFunction %void
+        %169 = 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
-        %152 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %25
+        %177 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %26
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %29 = OpLabel
-         %43 = OpVariable %_ptr_Function_v3float Function %45
-         %55 = OpVariable %_ptr_Function_v3float Function %45
-         %61 = OpVariable %_ptr_Function_v3float Function %45
-         %30 = OpExtInst %v3float %31 FAbs %v
-         %32 = OpCompositeExtract %float %params 4
-         %33 = OpCompositeConstruct %v3float %32 %32 %32
-         %34 = OpFOrdLessThan %v3bool %30 %33
-         %37 = OpExtInst %v3float %31 FSign %v
-         %38 = OpCompositeExtract %float %params 3
-         %39 = OpExtInst %v3float %31 FAbs %v
-         %40 = OpVectorTimesScalar %v3float %39 %38
-         %41 = OpCompositeExtract %float %params 6
-         %46 = OpCompositeConstruct %v3float %41 %41 %41
-         %42 = OpFAdd %v3float %40 %46
-         %47 = OpFMul %v3float %37 %42
-         %48 = OpExtInst %v3float %31 FSign %v
-         %50 = OpCompositeExtract %float %params 1
-         %51 = OpExtInst %v3float %31 FAbs %v
-         %52 = OpVectorTimesScalar %v3float %51 %50
-         %53 = OpCompositeExtract %float %params 2
-         %56 = OpCompositeConstruct %v3float %53 %53 %53
-         %54 = OpFAdd %v3float %52 %56
-         %57 = OpCompositeExtract %float %params 0
-         %58 = OpCompositeConstruct %v3float %57 %57 %57
-         %49 = OpExtInst %v3float %31 Pow %54 %58
-         %59 = OpCompositeExtract %float %params 5
-         %62 = OpCompositeConstruct %v3float %59 %59 %59
-         %60 = OpFAdd %v3float %49 %62
-         %63 = OpFMul %v3float %48 %60
-         %64 = OpSelect %v3float %34 %47 %63
-               OpReturnValue %64
+         %30 = OpLabel
+         %44 = OpVariable %_ptr_Function_v3float Function %46
+         %56 = OpVariable %_ptr_Function_v3float Function %46
+         %62 = OpVariable %_ptr_Function_v3float Function %46
+         %31 = OpExtInst %v3float %32 FAbs %v
+         %33 = OpCompositeExtract %float %params 4
+         %34 = OpCompositeConstruct %v3float %33 %33 %33
+         %35 = OpFOrdLessThan %v3bool %31 %34
+         %38 = OpExtInst %v3float %32 FSign %v
+         %39 = OpCompositeExtract %float %params 3
+         %40 = OpExtInst %v3float %32 FAbs %v
+         %41 = OpVectorTimesScalar %v3float %40 %39
+         %42 = OpCompositeExtract %float %params 6
+         %47 = OpCompositeConstruct %v3float %42 %42 %42
+         %43 = OpFAdd %v3float %41 %47
+         %48 = OpFMul %v3float %38 %43
+         %49 = OpExtInst %v3float %32 FSign %v
+         %51 = OpCompositeExtract %float %params 1
+         %52 = OpExtInst %v3float %32 FAbs %v
+         %53 = OpVectorTimesScalar %v3float %52 %51
+         %54 = OpCompositeExtract %float %params 2
+         %57 = OpCompositeConstruct %v3float %54 %54 %54
+         %55 = OpFAdd %v3float %53 %57
+         %58 = OpCompositeExtract %float %params 0
+         %59 = OpCompositeConstruct %v3float %58 %58 %58
+         %50 = OpExtInst %v3float %32 Pow %55 %59
+         %60 = OpCompositeExtract %float %params 5
+         %63 = OpCompositeConstruct %v3float %60 %60 %60
+         %61 = OpFAdd %v3float %50 %63
+         %64 = OpFMul %v3float %49 %61
+         %65 = OpSelect %v3float %35 %48 %64
+               OpReturnValue %65
                OpFunctionEnd
-%textureSampleExternal = OpFunction %v4float None %65
+%textureSampleExternal = OpFunction %v4float None %66
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
-        %smp = OpFunctionParameter %24
+        %smp = OpFunctionParameter %25
       %coord = OpFunctionParameter %v2float
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %73 = OpLabel
-         %85 = OpVariable %_ptr_Function_v2float Function %87
-         %94 = OpVariable %_ptr_Function_v2float Function %87
-      %color = OpVariable %_ptr_Function_v3float Function %45
-         %75 = OpImageQuerySizeLod %v2uint %plane0 %78
-         %74 = OpConvertUToF %v2float %75
-         %81 = OpFDiv %v2float %80 %74
-         %88 = OpCompositeConstruct %v2float %float_1 %float_1
-         %84 = OpFSub %v2float %88 %81
-         %82 = OpExtInst %v2float %31 NClamp %coord %81 %84
-         %90 = OpImageQuerySizeLod %v2uint %plane1 %78
-         %89 = OpConvertUToF %v2float %90
-         %91 = OpFDiv %v2float %80 %89
-         %95 = OpCompositeConstruct %v2float %float_1 %float_1
-         %93 = OpFSub %v2float %95 %91
-         %92 = OpExtInst %v2float %31 NClamp %coord %91 %93
-         %97 = OpCompositeExtract %uint %params_0 0
-         %99 = OpIEqual %bool %97 %uint_1
-               OpSelectionMerge %100 None
-               OpBranchConditional %99 %101 %102
-        %101 = OpLabel
-        %105 = OpSampledImage %104 %plane0 %smp
-        %103 = OpImageSampleExplicitLod %v4float %105 %82 Lod %8
-        %106 = OpVectorShuffle %v3float %103 %103 0 1 2
-               OpStore %color %106
-               OpBranch %100
-        %102 = OpLabel
-        %108 = OpSampledImage %104 %plane0 %smp
-        %107 = OpImageSampleExplicitLod %v4float %108 %82 Lod %8
-        %109 = OpCompositeExtract %float %107 0
-        %111 = OpSampledImage %104 %plane1 %smp
-        %110 = OpImageSampleExplicitLod %v4float %111 %92 Lod %8
-        %112 = OpVectorShuffle %v2float %110 %110 0 1
-        %113 = OpCompositeExtract %float %112 0
-        %114 = OpCompositeExtract %float %112 1
-        %115 = OpCompositeConstruct %v4float %109 %113 %114 %float_1
-        %116 = OpCompositeExtract %mat3v4float %params_0 2
-        %117 = OpVectorTimesMatrix %v3float %115 %116
-               OpStore %color %117
-               OpBranch %100
-        %100 = OpLabel
-        %118 = OpCompositeExtract %uint %params_0 1
-        %120 = OpIEqual %bool %118 %119
-               OpSelectionMerge %121 None
-               OpBranchConditional %120 %122 %121
-        %122 = OpLabel
-        %124 = OpLoad %v3float %color
-        %125 = OpCompositeExtract %GammaTransferParams %params_0 3
-        %123 = OpFunctionCall %v3float %gammaCorrection %124 %125
-               OpStore %color %123
-        %126 = OpCompositeExtract %mat3v3float %params_0 5
-        %127 = OpLoad %v3float %color
-        %128 = OpMatrixTimesVector %v3float %126 %127
-               OpStore %color %128
-        %130 = OpLoad %v3float %color
-        %131 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %129 = OpFunctionCall %v3float %gammaCorrection %130 %131
-               OpStore %color %129
-               OpBranch %121
-        %121 = OpLabel
-        %132 = OpLoad %v3float %color
-        %133 = OpCompositeExtract %float %132 0
-        %134 = OpCompositeExtract %float %132 1
-        %135 = OpCompositeExtract %float %132 2
-        %136 = OpCompositeConstruct %v4float %133 %134 %135 %float_1
-               OpReturnValue %136
+         %75 = OpLabel
+         %78 = OpVariable %_ptr_Function_v2float Function %80
+         %85 = OpVariable %_ptr_Function_v2float Function %80
+         %97 = OpVariable %_ptr_Function_v2float Function %80
+        %104 = OpVariable %_ptr_Function_v2float Function %80
+      %color = OpVariable %_ptr_Function_v3float Function %46
+         %81 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
+         %77 = OpFSub %v2float %coord %81
+         %82 = OpCompositeExtract %mat2v2float %params_0 6
+         %83 = OpVectorTimesMatrix %v2float %77 %82
+         %86 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
+         %84 = OpFAdd %v2float %83 %86
+         %88 = OpImageQuerySizeLod %v2uint %plane0 %91
+         %87 = OpConvertUToF %v2float %88
+         %93 = OpFDiv %v2float %92 %87
+         %98 = OpCompositeConstruct %v2float %float_1 %float_1
+         %96 = OpFSub %v2float %98 %93
+         %94 = OpExtInst %v2float %32 NClamp %84 %93 %96
+        %100 = OpImageQuerySizeLod %v2uint %plane1 %91
+         %99 = OpConvertUToF %v2float %100
+        %101 = OpFDiv %v2float %92 %99
+        %105 = OpCompositeConstruct %v2float %float_1 %float_1
+        %103 = OpFSub %v2float %105 %101
+        %102 = OpExtInst %v2float %32 NClamp %84 %101 %103
+        %107 = OpCompositeExtract %uint %params_0 0
+        %109 = OpIEqual %bool %107 %uint_1
+               OpSelectionMerge %110 None
+               OpBranchConditional %109 %111 %112
+        %111 = OpLabel
+        %115 = OpSampledImage %114 %plane0 %smp
+        %113 = OpImageSampleExplicitLod %v4float %115 %94 Lod %8
+        %116 = OpVectorShuffle %v3float %113 %113 0 1 2
+               OpStore %color %116
+               OpBranch %110
+        %112 = OpLabel
+        %118 = OpSampledImage %114 %plane0 %smp
+        %117 = OpImageSampleExplicitLod %v4float %118 %94 Lod %8
+        %119 = OpCompositeExtract %float %117 0
+        %121 = OpSampledImage %114 %plane1 %smp
+        %120 = OpImageSampleExplicitLod %v4float %121 %102 Lod %8
+        %122 = OpVectorShuffle %v2float %120 %120 0 1
+        %123 = OpCompositeExtract %float %122 0
+        %124 = OpCompositeExtract %float %122 1
+        %125 = OpCompositeConstruct %v4float %119 %123 %124 %float_1
+        %126 = OpCompositeExtract %mat3v4float %params_0 2
+        %127 = OpVectorTimesMatrix %v3float %125 %126
+               OpStore %color %127
+               OpBranch %110
+        %110 = OpLabel
+        %128 = OpCompositeExtract %uint %params_0 1
+        %130 = OpIEqual %bool %128 %129
+               OpSelectionMerge %131 None
+               OpBranchConditional %130 %132 %131
+        %132 = OpLabel
+        %134 = OpLoad %v3float %color
+        %135 = OpCompositeExtract %GammaTransferParams %params_0 3
+        %133 = OpFunctionCall %v3float %gammaCorrection %134 %135
+               OpStore %color %133
+        %136 = OpCompositeExtract %mat3v3float %params_0 5
+        %137 = OpLoad %v3float %color
+        %138 = OpMatrixTimesVector %v3float %136 %137
+               OpStore %color %138
+        %140 = OpLoad %v3float %color
+        %141 = OpCompositeExtract %GammaTransferParams %params_0 4
+        %139 = OpFunctionCall %v3float %gammaCorrection %140 %141
+               OpStore %color %139
+               OpBranch %131
+        %131 = OpLabel
+        %142 = OpLoad %v3float %color
+        %143 = OpCompositeExtract %float %142 0
+        %144 = OpCompositeExtract %float %142 1
+        %145 = OpCompositeExtract %float %142 2
+        %146 = OpCompositeConstruct %v4float %143 %144 %145 %float_1
+               OpReturnValue %146
                OpFunctionEnd
-%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %137
-        %140 = OpLabel
+%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %147
+        %val = OpFunctionParameter %ExternalTextureParams_std140
+        %150 = OpLabel
+        %151 = OpCompositeExtract %uint %val 0
+        %152 = OpCompositeExtract %uint %val 1
+        %153 = OpCompositeExtract %mat3v4float %val 2
+        %154 = OpCompositeExtract %GammaTransferParams %val 3
+        %155 = OpCompositeExtract %GammaTransferParams %val 4
+        %156 = OpCompositeExtract %mat3v3float %val 5
+        %157 = OpCompositeExtract %v2float %val 6
+        %158 = OpCompositeExtract %v2float %val 7
+        %159 = OpCompositeConstruct %mat2v2float %157 %158
+        %160 = OpCompositeConstruct %ExternalTextureParams %151 %152 %153 %154 %155 %156 %159
+               OpReturnValue %160
+               OpFunctionEnd
+%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %161
+        %164 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-        %142 = OpLoad %11 %arg_0
-        %143 = OpLoad %11 %ext_tex_plane_1
-        %144 = OpLoad %24 %arg_1
-        %148 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %149 = OpLoad %ExternalTextureParams %148
-        %141 = OpFunctionCall %v4float %textureSampleExternal %142 %143 %144 %145 %149
-               OpStore %res %141
+        %166 = OpLoad %11 %arg_0
+        %167 = OpLoad %11 %ext_tex_plane_1
+        %168 = OpLoad %25 %arg_1
+        %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 %152
-        %154 = OpLabel
-        %155 = 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 %137
-        %157 = OpLabel
-        %158 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %158
+%vertex_main = OpFunction %void None %161
+        %182 = OpLabel
+        %183 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %183
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %137
-        %160 = OpLabel
-        %161 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
+%fragment_main = OpFunction %void None %161
+        %185 = OpLabel
+        %186 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %137
-        %163 = OpLabel
-        %164 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
+%compute_main = OpFunction %void None %161
+        %188 = OpLabel
+        %189 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..d7de77a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.dxc.hlsl
@@ -0,0 +1,127 @@
+builtins/gen/literal/textureSampleLevel/979816.wgsl:28:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, vec2<f32>(1.f));
+                       ^^^^^^^^^^^^^^^^^^
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  float3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  float3x3 gamutConversionMatrix;
+  uint flipY;
+  float2x2 rotationMatrix;
+};
+
+Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
+cbuffer cbuffer_ext_tex_params : register(b3, space1) {
+  uint4 ext_tex_params[13];
+};
+Texture2D<float4> arg_0 : register(t0, space1);
+SamplerState arg_1 : register(s1, space1);
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  const bool3 cond = (abs(v) < float3((params.D).xxx));
+  const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
+  return (cond ? t : f);
+}
+
+float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  float3 color = float3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = plane0.SampleLevel(smp, coord, 0.0f).rgb;
+  } else {
+    color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = mul(color, params.gamutConversionMatrix);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+float3x4 tint_symbol_3(uint4 buffer[13], uint offset) {
+  const uint scalar_offset = ((offset + 0u)) / 4;
+  const uint scalar_offset_1 = ((offset + 16u)) / 4;
+  const uint scalar_offset_2 = ((offset + 32u)) / 4;
+  return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
+}
+
+GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_3 = ((offset + 0u)) / 4;
+  const uint scalar_offset_4 = ((offset + 4u)) / 4;
+  const uint scalar_offset_5 = ((offset + 8u)) / 4;
+  const uint scalar_offset_6 = ((offset + 12u)) / 4;
+  const uint scalar_offset_7 = ((offset + 16u)) / 4;
+  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;
+}
+
+float3x3 tint_symbol_7(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_11 = ((offset + 0u)) / 4;
+  const uint scalar_offset_12 = ((offset + 16u)) / 4;
+  const uint scalar_offset_13 = ((offset + 32u)) / 4;
+  return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
+}
+
+float2x2 tint_symbol_9(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_14 = ((offset + 0u)) / 4;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.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 uint scalar_offset_18 = ((offset + 176u)) / 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_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_9(buffer, (offset + 184u))};
+  return tint_symbol_12;
+}
+
+void textureSampleLevel_979816() {
+  float4 res = textureSampleExternal(arg_0, ext_tex_plane_1, arg_1, (1.0f).xx, tint_symbol_1(ext_tex_params, 0u));
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  textureSampleLevel_979816();
+  return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+  const float4 inner_result = vertex_main_inner();
+  tint_symbol wrapper_result = (tint_symbol)0;
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  textureSampleLevel_979816();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..d7de77a
--- /dev/null
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.fxc.hlsl
@@ -0,0 +1,127 @@
+builtins/gen/literal/textureSampleLevel/979816.wgsl:28:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, vec2<f32>(1.f));
+                       ^^^^^^^^^^^^^^^^^^
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  float3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  float3x3 gamutConversionMatrix;
+  uint flipY;
+  float2x2 rotationMatrix;
+};
+
+Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
+cbuffer cbuffer_ext_tex_params : register(b3, space1) {
+  uint4 ext_tex_params[13];
+};
+Texture2D<float4> arg_0 : register(t0, space1);
+SamplerState arg_1 : register(s1, space1);
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  const bool3 cond = (abs(v) < float3((params.D).xxx));
+  const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
+  return (cond ? t : f);
+}
+
+float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  float3 color = float3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = plane0.SampleLevel(smp, coord, 0.0f).rgb;
+  } else {
+    color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = mul(color, params.gamutConversionMatrix);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+float3x4 tint_symbol_3(uint4 buffer[13], uint offset) {
+  const uint scalar_offset = ((offset + 0u)) / 4;
+  const uint scalar_offset_1 = ((offset + 16u)) / 4;
+  const uint scalar_offset_2 = ((offset + 32u)) / 4;
+  return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
+}
+
+GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_3 = ((offset + 0u)) / 4;
+  const uint scalar_offset_4 = ((offset + 4u)) / 4;
+  const uint scalar_offset_5 = ((offset + 8u)) / 4;
+  const uint scalar_offset_6 = ((offset + 12u)) / 4;
+  const uint scalar_offset_7 = ((offset + 16u)) / 4;
+  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;
+}
+
+float3x3 tint_symbol_7(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_11 = ((offset + 0u)) / 4;
+  const uint scalar_offset_12 = ((offset + 16u)) / 4;
+  const uint scalar_offset_13 = ((offset + 32u)) / 4;
+  return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
+}
+
+float2x2 tint_symbol_9(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_14 = ((offset + 0u)) / 4;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.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 uint scalar_offset_18 = ((offset + 176u)) / 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_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_9(buffer, (offset + 184u))};
+  return tint_symbol_12;
+}
+
+void textureSampleLevel_979816() {
+  float4 res = textureSampleExternal(arg_0, ext_tex_plane_1, arg_1, (1.0f).xx, tint_symbol_1(ext_tex_params, 0u));
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  textureSampleLevel_979816();
+  return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+  const float4 inner_result = vertex_main_inner();
+  tint_symbol wrapper_result = (tint_symbol)0;
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  textureSampleLevel_979816();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.glsl
new file mode 100644
index 0000000..2a90360
--- /dev/null
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.glsl
@@ -0,0 +1,254 @@
+builtins/gen/literal/textureSampleLevel/979816.wgsl:28:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, vec2<f32>(1.f));
+                       ^^^^^^^^^^^^^^^^^^
+
+#version 310 es
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+vec4 vertex_main() {
+  textureSampleLevel_979816();
+  return vec4(0.0f);
+}
+
+void main() {
+  gl_PointSize = 1.0;
+  vec4 inner_result = vertex_main();
+  gl_Position = inner_result;
+  gl_Position.y = -(gl_Position.y);
+  gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+  return;
+}
+#version 310 es
+precision mediump float;
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, vec2(1.0f), conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+void compute_main() {
+  textureSampleLevel_979816();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+  compute_main();
+  return;
+}
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl
new file mode 100644
index 0000000..68cbca3
--- /dev/null
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl
@@ -0,0 +1,97 @@
+builtins/gen/literal/textureSampleLevel/979816.wgsl:28:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, vec2<f32>(1.f));
+                       ^^^^^^^^^^^^^^^^^^
+
+#include <metal_stdlib>
+
+using namespace metal;
+
+template<typename T, size_t N>
+struct tint_array {
+    const constant T& operator[](size_t i) const constant { return elements[i]; }
+    device T& operator[](size_t i) device { return elements[i]; }
+    const device T& operator[](size_t i) const device { return elements[i]; }
+    thread T& operator[](size_t i) thread { return elements[i]; }
+    const thread T& operator[](size_t i) const thread { return elements[i]; }
+    threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
+    const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
+    T elements[N];
+};
+
+struct GammaTransferParams {
+  /* 0x0000 */ float G;
+  /* 0x0004 */ float A;
+  /* 0x0008 */ float B;
+  /* 0x000c */ float C;
+  /* 0x0010 */ float D;
+  /* 0x0014 */ float E;
+  /* 0x0018 */ float F;
+  /* 0x001c */ uint padding;
+};
+
+struct ExternalTextureParams {
+  /* 0x0000 */ uint numPlanes;
+  /* 0x0004 */ uint doYuvToRgbConversionOnly;
+  /* 0x0008 */ tint_array<int8_t, 8> tint_pad;
+  /* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
+  /* 0x0040 */ GammaTransferParams gammaDecodeParams;
+  /* 0x0060 */ GammaTransferParams gammaEncodeParams;
+  /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ uint flipY;
+  /* 0x00b4 */ tint_array<int8_t, 4> tint_pad_1;
+  /* 0x00b8 */ float2x2 rotationMatrix;
+  /* 0x00c8 */ tint_array<int8_t, 8> tint_pad_2;
+};
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  bool3 const cond = (fabs(v) < float3(params.D));
+  float3 const t = (sign(v) * ((params.C * fabs(v)) + params.F));
+  float3 const f = (sign(v) * (pow(((params.A * fabs(v)) + params.B), float3(params.G)) + params.E));
+  return select(f, t, cond);
+}
+
+float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
+  float3 color = 0.0f;
+  if ((params.numPlanes == 1u)) {
+    color = float4(plane0.sample(smp, coord, level(0.0f))).rgb;
+  } else {
+    color = (float4(plane0.sample(smp, coord, level(0.0f))[0], float4(plane1.sample(smp, coord, level(0.0f))).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+void textureSampleLevel_979816(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, sampler tint_symbol_3, const constant ExternalTextureParams* const tint_symbol_4) {
+  float4 res = textureSampleExternal(tint_symbol_1, tint_symbol_2, tint_symbol_3, float2(1.0f), *(tint_symbol_4));
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner(texture2d<float, access::sample> tint_symbol_5, texture2d<float, access::sample> tint_symbol_6, sampler tint_symbol_7, const constant ExternalTextureParams* const tint_symbol_8) {
+  textureSampleLevel_979816(tint_symbol_5, tint_symbol_6, tint_symbol_7, tint_symbol_8);
+  return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main(texture2d<float, access::sample> tint_symbol_9 [[texture(0)]], texture2d<float, access::sample> tint_symbol_10 [[texture(1)]], sampler tint_symbol_11 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_12 [[buffer(2)]]) {
+  float4 const inner_result = vertex_main_inner(tint_symbol_9, tint_symbol_10, tint_symbol_11, tint_symbol_12);
+  tint_symbol wrapper_result = {};
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+fragment void fragment_main(texture2d<float, access::sample> tint_symbol_13 [[texture(0)]], texture2d<float, access::sample> tint_symbol_14 [[texture(1)]], sampler tint_symbol_15 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_16 [[buffer(2)]]) {
+  textureSampleLevel_979816(tint_symbol_13, tint_symbol_14, tint_symbol_15, tint_symbol_16);
+  return;
+}
+
+kernel void compute_main(texture2d<float, access::sample> tint_symbol_17 [[texture(0)]], texture2d<float, access::sample> tint_symbol_18 [[texture(1)]], sampler tint_symbol_19 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_20 [[buffer(2)]]) {
+  textureSampleLevel_979816(tint_symbol_17, tint_symbol_18, tint_symbol_19, tint_symbol_20);
+  return;
+}
+
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm
new file mode 100644
index 0000000..3519098
--- /dev/null
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm
@@ -0,0 +1,310 @@
+builtins/gen/literal/textureSampleLevel/979816.wgsl:28:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, vec2<f32>(1.f));
+                       ^^^^^^^^^^^^^^^^^^
+
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 162
+; Schema: 0
+               OpCapability Shader
+         %32 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+               OpEntryPoint Fragment %fragment_main "fragment_main"
+               OpEntryPoint GLCompute %compute_main "compute_main"
+               OpExecutionMode %fragment_main OriginUpperLeft
+               OpExecutionMode %compute_main LocalSize 1 1 1
+               OpName %value "value"
+               OpName %vertex_point_size "vertex_point_size"
+               OpName %ext_tex_plane_1 "ext_tex_plane_1"
+               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"
+               OpMemberName %GammaTransferParams 2 "B"
+               OpMemberName %GammaTransferParams 3 "C"
+               OpMemberName %GammaTransferParams 4 "D"
+               OpMemberName %GammaTransferParams 5 "E"
+               OpMemberName %GammaTransferParams 6 "F"
+               OpMemberName %GammaTransferParams 7 "padding"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "flipY"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 8 "rotationMatrix_1"
+               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 "flipY"
+               OpMemberName %ExternalTextureParams 7 "rotationMatrix"
+               OpName %textureSampleExternal "textureSampleExternal"
+               OpName %plane0 "plane0"
+               OpName %plane1 "plane1"
+               OpName %smp "smp"
+               OpName %coord "coord"
+               OpName %params_0 "params"
+               OpName %color "color"
+               OpName %conv_ExternalTextureParams "conv_ExternalTextureParams"
+               OpName %val "val"
+               OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               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_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
+               OpMemberDecorate %GammaTransferParams 3 Offset 12
+               OpMemberDecorate %GammaTransferParams 4 Offset 16
+               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 3
+               OpDecorate %arg_0 DescriptorSet 1
+               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 7 Offset 184
+               OpMemberDecorate %ExternalTextureParams 7 ColMajor
+               OpMemberDecorate %ExternalTextureParams 7 MatrixStride 8
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+         %11 = OpTypeImage %float 2D 0 0 0 1 Unknown
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
+       %uint = OpTypeInt 32 0
+%mat3v4float = OpTypeMatrix %v4float 3
+%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
+    %v3float = OpTypeVector %float 3
+%mat3v3float = OpTypeMatrix %v3float 3
+    %v2float = OpTypeVector %float 2
+%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %uint %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
+      %arg_1 = OpVariable %_ptr_UniformConstant_25 UniformConstant
+         %26 = OpTypeFunction %v3float %v3float %GammaTransferParams
+       %bool = OpTypeBool
+     %v3bool = OpTypeVector %bool 3
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %46 = OpConstantNull %v3float
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %uint %mat2v2float
+         %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams
+     %uint_1 = OpConstant %uint 1
+         %84 = OpTypeSampledImage %11
+    %float_1 = OpConstant %float 1
+        %100 = OpConstantNull %uint
+        %118 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
+       %void = OpTypeVoid
+        %133 = OpTypeFunction %void
+        %141 = OpConstantComposite %v2float %float_1 %float_1
+     %uint_0 = OpConstant %uint 0
+%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+        %149 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %26
+          %v = OpFunctionParameter %v3float
+     %params = OpFunctionParameter %GammaTransferParams
+         %30 = OpLabel
+         %44 = OpVariable %_ptr_Function_v3float Function %46
+         %56 = OpVariable %_ptr_Function_v3float Function %46
+         %62 = OpVariable %_ptr_Function_v3float Function %46
+         %31 = OpExtInst %v3float %32 FAbs %v
+         %33 = OpCompositeExtract %float %params 4
+         %34 = OpCompositeConstruct %v3float %33 %33 %33
+         %35 = OpFOrdLessThan %v3bool %31 %34
+         %38 = OpExtInst %v3float %32 FSign %v
+         %39 = OpCompositeExtract %float %params 3
+         %40 = OpExtInst %v3float %32 FAbs %v
+         %41 = OpVectorTimesScalar %v3float %40 %39
+         %42 = OpCompositeExtract %float %params 6
+         %47 = OpCompositeConstruct %v3float %42 %42 %42
+         %43 = OpFAdd %v3float %41 %47
+         %48 = OpFMul %v3float %38 %43
+         %49 = OpExtInst %v3float %32 FSign %v
+         %51 = OpCompositeExtract %float %params 1
+         %52 = OpExtInst %v3float %32 FAbs %v
+         %53 = OpVectorTimesScalar %v3float %52 %51
+         %54 = OpCompositeExtract %float %params 2
+         %57 = OpCompositeConstruct %v3float %54 %54 %54
+         %55 = OpFAdd %v3float %53 %57
+         %58 = OpCompositeExtract %float %params 0
+         %59 = OpCompositeConstruct %v3float %58 %58 %58
+         %50 = OpExtInst %v3float %32 Pow %55 %59
+         %60 = OpCompositeExtract %float %params 5
+         %63 = OpCompositeConstruct %v3float %60 %60 %60
+         %61 = OpFAdd %v3float %50 %63
+         %64 = OpFMul %v3float %49 %61
+         %65 = OpSelect %v3float %35 %48 %64
+               OpReturnValue %65
+               OpFunctionEnd
+%textureSampleExternal = OpFunction %v4float None %66
+     %plane0 = OpFunctionParameter %11
+     %plane1 = OpFunctionParameter %11
+        %smp = OpFunctionParameter %25
+      %coord = OpFunctionParameter %v2float
+   %params_0 = OpFunctionParameter %ExternalTextureParams
+         %75 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %46
+         %77 = OpCompositeExtract %uint %params_0 0
+         %79 = OpIEqual %bool %77 %uint_1
+               OpSelectionMerge %80 None
+               OpBranchConditional %79 %81 %82
+         %81 = OpLabel
+         %85 = OpSampledImage %84 %plane0 %smp
+         %83 = OpImageSampleExplicitLod %v4float %85 %coord Lod %8
+         %86 = OpVectorShuffle %v3float %83 %83 0 1 2
+               OpStore %color %86
+               OpBranch %80
+         %82 = OpLabel
+         %88 = OpSampledImage %84 %plane0 %smp
+         %87 = OpImageSampleExplicitLod %v4float %88 %coord Lod %8
+         %89 = OpCompositeExtract %float %87 0
+         %91 = OpSampledImage %84 %plane1 %smp
+         %90 = OpImageSampleExplicitLod %v4float %91 %coord Lod %8
+         %92 = OpVectorShuffle %v2float %90 %90 0 1
+         %93 = OpCompositeExtract %float %92 0
+         %94 = OpCompositeExtract %float %92 1
+         %96 = OpCompositeConstruct %v4float %89 %93 %94 %float_1
+         %97 = OpCompositeExtract %mat3v4float %params_0 2
+         %98 = OpVectorTimesMatrix %v3float %96 %97
+               OpStore %color %98
+               OpBranch %80
+         %80 = OpLabel
+         %99 = OpCompositeExtract %uint %params_0 1
+        %101 = OpIEqual %bool %99 %100
+               OpSelectionMerge %102 None
+               OpBranchConditional %101 %103 %102
+        %103 = OpLabel
+        %105 = OpLoad %v3float %color
+        %106 = OpCompositeExtract %GammaTransferParams %params_0 3
+        %104 = OpFunctionCall %v3float %gammaCorrection %105 %106
+               OpStore %color %104
+        %107 = OpCompositeExtract %mat3v3float %params_0 5
+        %108 = OpLoad %v3float %color
+        %109 = OpMatrixTimesVector %v3float %107 %108
+               OpStore %color %109
+        %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
+%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 %uint %val 6
+        %129 = OpCompositeExtract %v2float %val 7
+        %130 = OpCompositeExtract %v2float %val 8
+        %131 = OpCompositeConstruct %mat2v2float %129 %130
+        %132 = OpCompositeConstruct %ExternalTextureParams %122 %123 %124 %125 %126 %127 %128 %131
+               OpReturnValue %132
+               OpFunctionEnd
+%textureSampleLevel_979816 = OpFunction %void None %133
+        %136 = OpLabel
+        %res = OpVariable %_ptr_Function_v4float Function %5
+        %138 = OpLoad %11 %arg_0
+        %139 = OpLoad %11 %ext_tex_plane_1
+        %140 = OpLoad %25 %arg_1
+        %145 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %146 = OpLoad %ExternalTextureParams_std140 %145
+        %142 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %146
+        %137 = OpFunctionCall %v4float %textureSampleExternal %138 %139 %140 %141 %142
+               OpStore %res %137
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %149
+        %151 = OpLabel
+        %152 = OpFunctionCall %void %textureSampleLevel_979816
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %133
+        %154 = OpLabel
+        %155 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %155
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %133
+        %157 = OpLabel
+        %158 = OpFunctionCall %void %textureSampleLevel_979816
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %133
+        %160 = OpLabel
+        %161 = OpFunctionCall %void %textureSampleLevel_979816
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
index 092b79e..1f8d50c 100644
--- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
+++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.dxc.hlsl
@@ -1,6 +1,6 @@
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
diff --git a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
index 092b79e..1f8d50c 100644
--- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.fxc.hlsl
@@ -1,6 +1,6 @@
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
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 194a4bf..06f4c76 100644
--- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 uniform highp sampler2D arg_0_1;
@@ -63,10 +75,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 uniform highp sampler2D arg_0_1;
@@ -102,10 +126,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+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 3808793..a997980 100644
--- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.msl
@@ -19,6 +19,7 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 void textureDimensions_cdc6c9(texture2d<float, access::sample> 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 da1f2ab..12d1c58 100644
--- a/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureDimensions/cdc6c9.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 48
+; Bound: 49
 ; Schema: 0
                OpCapability Shader
                OpCapability ImageQuery
@@ -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,8 +30,10 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                OpName %ext_tex_params "ext_tex_params"
                OpName %arg_0 "arg_0"
                OpName %textureDimensions_cdc6c9 "textureDimensions_cdc6c9"
@@ -44,14 +46,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
@@ -60,10 +62,12 @@
                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_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
                OpDecorate %ext_tex_params NonWritable
                OpDecorate %ext_tex_params DescriptorSet 1
                OpDecorate %ext_tex_params Binding 2
@@ -85,47 +89,48 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %void
+         %23 = OpTypeFunction %void
      %v2uint = OpTypeVector %uint 2
         %int = OpTypeInt 32 1
       %int_0 = OpConstant %int 0
 %_ptr_Function_v2uint = OpTypePointer Function %v2uint
-         %33 = OpConstantNull %v2uint
-         %34 = OpTypeFunction %v4float
+         %34 = OpConstantNull %v2uint
+         %35 = OpTypeFunction %v4float
     %float_1 = OpConstant %float 1
-%textureDimensions_cdc6c9 = OpFunction %void None %22
-         %25 = OpLabel
-        %res = OpVariable %_ptr_Function_v2uint Function %33
-         %28 = OpLoad %11 %arg_0
-         %26 = OpImageQuerySizeLod %v2uint %28 %int_0
-               OpStore %res %26
+%textureDimensions_cdc6c9 = OpFunction %void None %23
+         %26 = OpLabel
+        %res = OpVariable %_ptr_Function_v2uint Function %34
+         %29 = OpLoad %11 %arg_0
+         %27 = OpImageQuerySizeLod %v2uint %29 %int_0
+               OpStore %res %27
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %34
-         %36 = OpLabel
-         %37 = OpFunctionCall %void %textureDimensions_cdc6c9
+%vertex_main_inner = OpFunction %v4float None %35
+         %37 = OpLabel
+         %38 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %22
-         %39 = OpLabel
-         %40 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %40
+%vertex_main = OpFunction %void None %23
+         %40 = OpLabel
+         %41 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %41
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %22
-         %43 = OpLabel
-         %44 = OpFunctionCall %void %textureDimensions_cdc6c9
+%fragment_main = OpFunction %void None %23
+         %44 = OpLabel
+         %45 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %22
-         %46 = OpLabel
-         %47 = OpFunctionCall %void %textureDimensions_cdc6c9
+%compute_main = OpFunction %void None %23
+         %47 = OpLabel
+         %48 = OpFunctionCall %void %textureDimensions_cdc6c9
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.dxc.hlsl
index dd7959d..4312f20 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 dd7959d..4312f20 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 4011eb4..fb5b151 100644
--- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -48,9 +60,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -87,10 +103,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -117,9 +145,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -150,10 +182,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -180,9 +224,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 2de6a9d..c4e100d 100644
--- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 d9c8b31..41e032e 100644
--- a/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureLoad/1bfdfb.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 142
+; Bound: 159
 ; Schema: 0
                OpCapability Shader
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,19 +30,31 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                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"
@@ -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,15 +82,30 @@
                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_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
                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 8
       %float = OpTypeFloat 32
     %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -95,157 +122,176 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %23 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %42 = OpConstantNull %v3float
+         %43 = OpConstantNull %v3float
      %v2uint = OpTypeVector %uint 2
-         %62 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %63 = OpTypeFunction %v4float %11 %11 %v2uint %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
         %int = OpTypeInt 32 1
-         %79 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %82 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %93 = OpConstantNull %uint
+         %95 = OpConstantNull %uint
+        %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %111 = OpTypeFunction %void
-        %115 = OpConstantComposite %v2uint %uint_1 %uint_1
+        %127 = OpTypeFunction %void
+        %131 = OpConstantComposite %v2uint %uint_1 %uint_1
 %_ptr_Function_v2uint = OpTypePointer Function %v2uint
-        %118 = OpConstantNull %v2uint
+        %134 = 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
-        %129 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %22
+        %146 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %23
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %26 = OpLabel
-         %40 = OpVariable %_ptr_Function_v3float Function %42
-         %52 = OpVariable %_ptr_Function_v3float Function %42
-         %58 = OpVariable %_ptr_Function_v3float Function %42
-         %27 = OpExtInst %v3float %28 FAbs %v
-         %29 = OpCompositeExtract %float %params 4
-         %30 = OpCompositeConstruct %v3float %29 %29 %29
-         %31 = OpFOrdLessThan %v3bool %27 %30
-         %34 = OpExtInst %v3float %28 FSign %v
-         %35 = OpCompositeExtract %float %params 3
-         %36 = OpExtInst %v3float %28 FAbs %v
-         %37 = OpVectorTimesScalar %v3float %36 %35
-         %38 = OpCompositeExtract %float %params 6
-         %43 = OpCompositeConstruct %v3float %38 %38 %38
-         %39 = OpFAdd %v3float %37 %43
-         %44 = OpFMul %v3float %34 %39
-         %45 = OpExtInst %v3float %28 FSign %v
-         %47 = OpCompositeExtract %float %params 1
-         %48 = OpExtInst %v3float %28 FAbs %v
-         %49 = OpVectorTimesScalar %v3float %48 %47
-         %50 = OpCompositeExtract %float %params 2
-         %53 = OpCompositeConstruct %v3float %50 %50 %50
-         %51 = OpFAdd %v3float %49 %53
-         %54 = OpCompositeExtract %float %params 0
-         %55 = OpCompositeConstruct %v3float %54 %54 %54
-         %46 = OpExtInst %v3float %28 Pow %51 %55
-         %56 = OpCompositeExtract %float %params 5
-         %59 = OpCompositeConstruct %v3float %56 %56 %56
-         %57 = OpFAdd %v3float %46 %59
-         %60 = OpFMul %v3float %45 %57
-         %61 = OpSelect %v3float %31 %44 %60
-               OpReturnValue %61
+         %27 = OpLabel
+         %41 = OpVariable %_ptr_Function_v3float Function %43
+         %53 = OpVariable %_ptr_Function_v3float Function %43
+         %59 = OpVariable %_ptr_Function_v3float Function %43
+         %28 = OpExtInst %v3float %29 FAbs %v
+         %30 = OpCompositeExtract %float %params 4
+         %31 = OpCompositeConstruct %v3float %30 %30 %30
+         %32 = OpFOrdLessThan %v3bool %28 %31
+         %35 = OpExtInst %v3float %29 FSign %v
+         %36 = OpCompositeExtract %float %params 3
+         %37 = OpExtInst %v3float %29 FAbs %v
+         %38 = OpVectorTimesScalar %v3float %37 %36
+         %39 = OpCompositeExtract %float %params 6
+         %44 = OpCompositeConstruct %v3float %39 %39 %39
+         %40 = OpFAdd %v3float %38 %44
+         %45 = OpFMul %v3float %35 %40
+         %46 = OpExtInst %v3float %29 FSign %v
+         %48 = OpCompositeExtract %float %params 1
+         %49 = OpExtInst %v3float %29 FAbs %v
+         %50 = OpVectorTimesScalar %v3float %49 %48
+         %51 = OpCompositeExtract %float %params 2
+         %54 = OpCompositeConstruct %v3float %51 %51 %51
+         %52 = OpFAdd %v3float %50 %54
+         %55 = OpCompositeExtract %float %params 0
+         %56 = OpCompositeConstruct %v3float %55 %55 %55
+         %47 = OpExtInst %v3float %29 Pow %52 %56
+         %57 = OpCompositeExtract %float %params 5
+         %60 = OpCompositeConstruct %v3float %57 %57 %57
+         %58 = OpFAdd %v3float %47 %60
+         %61 = OpFMul %v3float %46 %58
+         %62 = OpSelect %v3float %32 %45 %61
+               OpReturnValue %62
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %62
+%textureLoadExternal = OpFunction %v4float None %63
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
       %coord = OpFunctionParameter %v2uint
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %69 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %42
-         %71 = OpCompositeExtract %uint %params_0 0
-         %73 = OpIEqual %bool %71 %uint_1
-               OpSelectionMerge %74 None
-               OpBranchConditional %73 %75 %76
-         %75 = OpLabel
-         %77 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %80 = OpVectorShuffle %v3float %77 %77 0 1 2
-               OpStore %color %80
-               OpBranch %74
-         %76 = OpLabel
-         %81 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %82 = OpCompositeExtract %float %81 0
-         %83 = OpImageFetch %v4float %plane1 %coord Lod %79
-         %85 = OpVectorShuffle %v2float %83 %83 0 1
-         %86 = OpCompositeExtract %float %85 0
-         %87 = OpCompositeExtract %float %85 1
-         %89 = OpCompositeConstruct %v4float %82 %86 %87 %float_1
-         %90 = OpCompositeExtract %mat3v4float %params_0 2
-         %91 = OpVectorTimesMatrix %v3float %89 %90
-               OpStore %color %91
-               OpBranch %74
-         %74 = OpLabel
-         %92 = OpCompositeExtract %uint %params_0 1
-         %94 = OpIEqual %bool %92 %93
-               OpSelectionMerge %95 None
-               OpBranchConditional %94 %96 %95
-         %96 = OpLabel
-         %98 = OpLoad %v3float %color
-         %99 = OpCompositeExtract %GammaTransferParams %params_0 3
-         %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
-               OpStore %color %97
-        %100 = OpCompositeExtract %mat3v3float %params_0 5
-        %101 = OpLoad %v3float %color
-        %102 = OpMatrixTimesVector %v3float %100 %101
-               OpStore %color %102
-        %104 = OpLoad %v3float %color
-        %105 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %103 = OpFunctionCall %v3float %gammaCorrection %104 %105
-               OpStore %color %103
-               OpBranch %95
-         %95 = OpLabel
+         %72 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %43
+         %74 = OpCompositeExtract %uint %params_0 0
+         %76 = OpIEqual %bool %74 %uint_1
+               OpSelectionMerge %77 None
+               OpBranchConditional %76 %78 %79
+         %78 = OpLabel
+         %80 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %83 = OpVectorShuffle %v3float %80 %80 0 1 2
+               OpStore %color %83
+               OpBranch %77
+         %79 = OpLabel
+         %84 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %85 = OpCompositeExtract %float %84 0
+         %86 = OpImageFetch %v4float %plane1 %coord Lod %82
+         %87 = OpVectorShuffle %v2float %86 %86 0 1
+         %88 = OpCompositeExtract %float %87 0
+         %89 = OpCompositeExtract %float %87 1
+         %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1
+         %92 = OpCompositeExtract %mat3v4float %params_0 2
+         %93 = OpVectorTimesMatrix %v3float %91 %92
+               OpStore %color %93
+               OpBranch %77
+         %77 = OpLabel
+         %94 = OpCompositeExtract %uint %params_0 1
+         %96 = OpIEqual %bool %94 %95
+               OpSelectionMerge %97 None
+               OpBranchConditional %96 %98 %97
+         %98 = OpLabel
+        %100 = OpLoad %v3float %color
+        %101 = OpCompositeExtract %GammaTransferParams %params_0 3
+         %99 = OpFunctionCall %v3float %gammaCorrection %100 %101
+               OpStore %color %99
+        %102 = OpCompositeExtract %mat3v3float %params_0 5
+        %103 = OpLoad %v3float %color
+        %104 = OpMatrixTimesVector %v3float %102 %103
+               OpStore %color %104
         %106 = OpLoad %v3float %color
-        %107 = OpCompositeExtract %float %106 0
-        %108 = OpCompositeExtract %float %106 1
-        %109 = OpCompositeExtract %float %106 2
-        %110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
-               OpReturnValue %110
+        %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 %111
-        %114 = OpLabel
-      %arg_1 = OpVariable %_ptr_Function_v2uint Function %118
+%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 = OpCompositeConstruct %mat2v2float %123 %124
+        %126 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %125
+               OpReturnValue %126
+               OpFunctionEnd
+%textureLoad_1bfdfb = OpFunction %void None %127
+        %130 = OpLabel
+      %arg_1 = OpVariable %_ptr_Function_v2uint Function %134
         %res = OpVariable %_ptr_Function_v4float Function %5
-               OpStore %arg_1 %115
-        %120 = OpLoad %11 %arg_0
-        %121 = OpLoad %11 %ext_tex_plane_1
-        %122 = OpLoad %v2uint %arg_1
-        %125 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %126 = OpLoad %ExternalTextureParams %125
-        %119 = OpFunctionCall %v4float %textureLoadExternal %120 %121 %122 %126
-               OpStore %res %119
+               OpStore %arg_1 %131
+        %136 = OpLoad %11 %arg_0
+        %137 = OpLoad %11 %ext_tex_plane_1
+        %138 = OpLoad %v2uint %arg_1
+        %142 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %143 = OpLoad %ExternalTextureParams_std140 %142
+        %139 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %143
+        %135 = OpFunctionCall %v4float %textureLoadExternal %136 %137 %138 %139
+               OpStore %res %135
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %129
-        %131 = OpLabel
-        %132 = OpFunctionCall %void %textureLoad_1bfdfb
+%vertex_main_inner = OpFunction %v4float None %146
+        %148 = OpLabel
+        %149 = OpFunctionCall %void %textureLoad_1bfdfb
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %111
-        %134 = OpLabel
-        %135 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %135
+%vertex_main = OpFunction %void None %127
+        %151 = OpLabel
+        %152 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %152
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %111
-        %137 = OpLabel
-        %138 = OpFunctionCall %void %textureLoad_1bfdfb
+%fragment_main = OpFunction %void None %127
+        %154 = OpLabel
+        %155 = OpFunctionCall %void %textureLoad_1bfdfb
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %111
-        %140 = OpLabel
-        %141 = OpFunctionCall %void %textureLoad_1bfdfb
+%compute_main = OpFunction %void None %127
+        %157 = OpLabel
+        %158 = 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 6b42460..7a6564c 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 6b42460..7a6564c 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -45,14 +46,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -61,22 +62,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 0a17c67..abf9a70 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -48,9 +60,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -87,10 +103,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -117,9 +145,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -150,10 +182,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -180,9 +224,13 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 8806d2f..452877c 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 41ba458..95ed4c0 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 143
+; Bound: 160
 ; Schema: 0
                OpCapability Shader
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,19 +30,31 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                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"
@@ -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,15 +82,30 @@
                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_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
                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 8
       %float = OpTypeFloat 32
     %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -95,158 +122,177 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %23 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %42 = OpConstantNull %v3float
+         %43 = OpConstantNull %v3float
         %int = OpTypeInt 32 1
       %v2int = OpTypeVector %int 2
-         %62 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
-         %79 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %82 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %93 = OpConstantNull %uint
+         %95 = OpConstantNull %uint
+        %113 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %111 = OpTypeFunction %void
+        %127 = OpTypeFunction %void
       %int_1 = OpConstant %int 1
-        %116 = OpConstantComposite %v2int %int_1 %int_1
+        %132 = OpConstantComposite %v2int %int_1 %int_1
 %_ptr_Function_v2int = OpTypePointer Function %v2int
-        %119 = OpConstantNull %v2int
+        %135 = 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
-        %130 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %22
+        %147 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %23
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %26 = OpLabel
-         %40 = OpVariable %_ptr_Function_v3float Function %42
-         %52 = OpVariable %_ptr_Function_v3float Function %42
-         %58 = OpVariable %_ptr_Function_v3float Function %42
-         %27 = OpExtInst %v3float %28 FAbs %v
-         %29 = OpCompositeExtract %float %params 4
-         %30 = OpCompositeConstruct %v3float %29 %29 %29
-         %31 = OpFOrdLessThan %v3bool %27 %30
-         %34 = OpExtInst %v3float %28 FSign %v
-         %35 = OpCompositeExtract %float %params 3
-         %36 = OpExtInst %v3float %28 FAbs %v
-         %37 = OpVectorTimesScalar %v3float %36 %35
-         %38 = OpCompositeExtract %float %params 6
-         %43 = OpCompositeConstruct %v3float %38 %38 %38
-         %39 = OpFAdd %v3float %37 %43
-         %44 = OpFMul %v3float %34 %39
-         %45 = OpExtInst %v3float %28 FSign %v
-         %47 = OpCompositeExtract %float %params 1
-         %48 = OpExtInst %v3float %28 FAbs %v
-         %49 = OpVectorTimesScalar %v3float %48 %47
-         %50 = OpCompositeExtract %float %params 2
-         %53 = OpCompositeConstruct %v3float %50 %50 %50
-         %51 = OpFAdd %v3float %49 %53
-         %54 = OpCompositeExtract %float %params 0
-         %55 = OpCompositeConstruct %v3float %54 %54 %54
-         %46 = OpExtInst %v3float %28 Pow %51 %55
-         %56 = OpCompositeExtract %float %params 5
-         %59 = OpCompositeConstruct %v3float %56 %56 %56
-         %57 = OpFAdd %v3float %46 %59
-         %60 = OpFMul %v3float %45 %57
-         %61 = OpSelect %v3float %31 %44 %60
-               OpReturnValue %61
+         %27 = OpLabel
+         %41 = OpVariable %_ptr_Function_v3float Function %43
+         %53 = OpVariable %_ptr_Function_v3float Function %43
+         %59 = OpVariable %_ptr_Function_v3float Function %43
+         %28 = OpExtInst %v3float %29 FAbs %v
+         %30 = OpCompositeExtract %float %params 4
+         %31 = OpCompositeConstruct %v3float %30 %30 %30
+         %32 = OpFOrdLessThan %v3bool %28 %31
+         %35 = OpExtInst %v3float %29 FSign %v
+         %36 = OpCompositeExtract %float %params 3
+         %37 = OpExtInst %v3float %29 FAbs %v
+         %38 = OpVectorTimesScalar %v3float %37 %36
+         %39 = OpCompositeExtract %float %params 6
+         %44 = OpCompositeConstruct %v3float %39 %39 %39
+         %40 = OpFAdd %v3float %38 %44
+         %45 = OpFMul %v3float %35 %40
+         %46 = OpExtInst %v3float %29 FSign %v
+         %48 = OpCompositeExtract %float %params 1
+         %49 = OpExtInst %v3float %29 FAbs %v
+         %50 = OpVectorTimesScalar %v3float %49 %48
+         %51 = OpCompositeExtract %float %params 2
+         %54 = OpCompositeConstruct %v3float %51 %51 %51
+         %52 = OpFAdd %v3float %50 %54
+         %55 = OpCompositeExtract %float %params 0
+         %56 = OpCompositeConstruct %v3float %55 %55 %55
+         %47 = OpExtInst %v3float %29 Pow %52 %56
+         %57 = OpCompositeExtract %float %params 5
+         %60 = OpCompositeConstruct %v3float %57 %57 %57
+         %58 = OpFAdd %v3float %47 %60
+         %61 = OpFMul %v3float %46 %58
+         %62 = OpSelect %v3float %32 %45 %61
+               OpReturnValue %62
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %62
+%textureLoadExternal = OpFunction %v4float None %63
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
       %coord = OpFunctionParameter %v2int
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %70 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %42
-         %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 %79
-         %80 = OpVectorShuffle %v3float %78 %78 0 1 2
-               OpStore %color %80
-               OpBranch %75
-         %77 = OpLabel
-         %81 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %82 = OpCompositeExtract %float %81 0
-         %83 = OpImageFetch %v4float %plane1 %coord Lod %79
-         %85 = OpVectorShuffle %v2float %83 %83 0 1
-         %86 = OpCompositeExtract %float %85 0
-         %87 = OpCompositeExtract %float %85 1
-         %89 = OpCompositeConstruct %v4float %82 %86 %87 %float_1
-         %90 = OpCompositeExtract %mat3v4float %params_0 2
-         %91 = OpVectorTimesMatrix %v3float %89 %90
-               OpStore %color %91
-               OpBranch %75
-         %75 = OpLabel
-         %92 = OpCompositeExtract %uint %params_0 1
-         %94 = OpIEqual %bool %92 %93
-               OpSelectionMerge %95 None
-               OpBranchConditional %94 %96 %95
-         %96 = OpLabel
-         %98 = OpLoad %v3float %color
-         %99 = OpCompositeExtract %GammaTransferParams %params_0 3
-         %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
-               OpStore %color %97
-        %100 = OpCompositeExtract %mat3v3float %params_0 5
-        %101 = OpLoad %v3float %color
-        %102 = OpMatrixTimesVector %v3float %100 %101
-               OpStore %color %102
-        %104 = OpLoad %v3float %color
-        %105 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %103 = OpFunctionCall %v3float %gammaCorrection %104 %105
-               OpStore %color %103
-               OpBranch %95
-         %95 = OpLabel
+         %73 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %43
+         %75 = OpCompositeExtract %uint %params_0 0
+         %77 = OpIEqual %bool %75 %uint_1
+               OpSelectionMerge %78 None
+               OpBranchConditional %77 %79 %80
+         %79 = OpLabel
+         %81 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %83 = OpVectorShuffle %v3float %81 %81 0 1 2
+               OpStore %color %83
+               OpBranch %78
+         %80 = OpLabel
+         %84 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %85 = OpCompositeExtract %float %84 0
+         %86 = OpImageFetch %v4float %plane1 %coord Lod %82
+         %87 = OpVectorShuffle %v2float %86 %86 0 1
+         %88 = OpCompositeExtract %float %87 0
+         %89 = OpCompositeExtract %float %87 1
+         %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1
+         %92 = OpCompositeExtract %mat3v4float %params_0 2
+         %93 = OpVectorTimesMatrix %v3float %91 %92
+               OpStore %color %93
+               OpBranch %78
+         %78 = OpLabel
+         %94 = OpCompositeExtract %uint %params_0 1
+         %96 = OpIEqual %bool %94 %95
+               OpSelectionMerge %97 None
+               OpBranchConditional %96 %98 %97
+         %98 = OpLabel
+        %100 = OpLoad %v3float %color
+        %101 = OpCompositeExtract %GammaTransferParams %params_0 3
+         %99 = OpFunctionCall %v3float %gammaCorrection %100 %101
+               OpStore %color %99
+        %102 = OpCompositeExtract %mat3v3float %params_0 5
+        %103 = OpLoad %v3float %color
+        %104 = OpMatrixTimesVector %v3float %102 %103
+               OpStore %color %104
         %106 = OpLoad %v3float %color
-        %107 = OpCompositeExtract %float %106 0
-        %108 = OpCompositeExtract %float %106 1
-        %109 = OpCompositeExtract %float %106 2
-        %110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
-               OpReturnValue %110
+        %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 %111
-        %114 = OpLabel
-      %arg_1 = OpVariable %_ptr_Function_v2int 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 = OpCompositeConstruct %mat2v2float %123 %124
+        %126 = OpCompositeConstruct %ExternalTextureParams %117 %118 %119 %120 %121 %122 %125
+               OpReturnValue %126
+               OpFunctionEnd
+%textureLoad_8acf41 = OpFunction %void None %127
+        %130 = OpLabel
+      %arg_1 = OpVariable %_ptr_Function_v2int 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 %v2int %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 %v2int %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_8acf41
+%vertex_main_inner = OpFunction %v4float None %147
+        %149 = OpLabel
+        %150 = OpFunctionCall %void %textureLoad_8acf41
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %111
-        %135 = OpLabel
-        %136 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %136
+%vertex_main = OpFunction %void None %127
+        %152 = OpLabel
+        %153 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %153
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %111
-        %138 = OpLabel
-        %139 = OpFunctionCall %void %textureLoad_8acf41
+%fragment_main = OpFunction %void None %127
+        %155 = OpLabel
+        %156 = OpFunctionCall %void %textureLoad_8acf41
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %111
-        %141 = OpLabel
-        %142 = OpFunctionCall %void %textureLoad_8acf41
+%compute_main = OpFunction %void None %127
+        %158 = OpLabel
+        %159 = 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 c64a759..3d54873 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
 cbuffer cbuffer_ext_tex_params : register(b3, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 SamplerState arg_1 : register(s1, space1);
@@ -32,16 +33,17 @@
 }
 
 float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  const float2 modifiedCoords = (mul(params.rotationMatrix, (coord - 0.5f)) + 0.5f);
   int3 tint_tmp;
   plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z);
   const float2 plane0_dims = float2(tint_tmp.xy);
   const float2 plane0_half_texel = ((0.5f).xx / plane0_dims);
-  const float2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  const float2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   int3 tint_tmp_1;
   plane1.GetDimensions(0, tint_tmp_1.x, tint_tmp_1.y, tint_tmp_1.z);
   const float2 plane1_dims = float2(tint_tmp_1.xy);
   const float2 plane1_half_texel = ((0.5f).xx / plane1_dims);
-  const float2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  const float2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = float3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = plane0.SampleLevel(smp, plane0_clamped, 0.0f).rgb;
@@ -56,14 +58,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -72,22 +74,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 c64a759..3d54873 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
 cbuffer cbuffer_ext_tex_params : register(b3, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 SamplerState arg_1 : register(s1, space1);
@@ -32,16 +33,17 @@
 }
 
 float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  const float2 modifiedCoords = (mul(params.rotationMatrix, (coord - 0.5f)) + 0.5f);
   int3 tint_tmp;
   plane0.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z);
   const float2 plane0_dims = float2(tint_tmp.xy);
   const float2 plane0_half_texel = ((0.5f).xx / plane0_dims);
-  const float2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  const float2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   int3 tint_tmp_1;
   plane1.GetDimensions(0, tint_tmp_1.x, tint_tmp_1.y, tint_tmp_1.z);
   const float2 plane1_dims = float2(tint_tmp_1.xy);
   const float2 plane1_half_texel = ((0.5f).xx / plane1_dims);
-  const float2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  const float2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = float3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = plane0.SampleLevel(smp, plane0_clamped, 0.0f).rgb;
@@ -56,14 +58,14 @@
   return float4(color, 1.0f);
 }
 
-float3x4 tint_symbol_3(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_3(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_5(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -72,22 +74,30 @@
   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_9 = {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_9;
+  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[11], uint offset) {
+float3x3 tint_symbol_7(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_9(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_10;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_1(uint4 buffer[12], 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_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 a7c54d9..f94ff74 100644
--- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -33,12 +45,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -57,9 +70,13 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -96,10 +113,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -111,12 +140,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -135,9 +165,13 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -168,10 +202,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -183,12 +229,13 @@
 
 
 vec4 textureSampleExternal(highp sampler2D plane0_1, highp sampler2D plane1_1, highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec2 modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   vec2 plane0_dims = vec2(uvec2(textureSize(plane0_1, 0)));
   vec2 plane0_half_texel = (vec2(0.5f) / plane0_dims);
-  vec2 plane0_clamped = clamp(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  vec2 plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   vec2 plane1_dims = vec2(uvec2(textureSize(plane1_1, 0)));
   vec2 plane1_half_texel = (vec2(0.5f) / plane1_dims);
-  vec2 plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  vec2 plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   vec3 color = vec3(0.0f, 0.0f, 0.0f);
   if ((params.numPlanes == 1u)) {
     color = textureLod(plane0_smp, plane0_clamped, 0.0f).rgb;
@@ -207,9 +254,13 @@
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 33c183c..cc65f38 100644
--- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 float3 gammaCorrection(float3 v, GammaTransferParams params) {
@@ -43,12 +44,13 @@
 }
 
 float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
+  float2 const modifiedCoords = (((coord - 0.5f) * params.rotationMatrix) + 0.5f);
   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(coord, plane0_half_texel, (1.0f - plane0_half_texel));
+  float2 const plane0_clamped = clamp(modifiedCoords, plane0_half_texel, (1.0f - plane0_half_texel));
   float2 const plane1_dims = float2(uint2(plane1.get_width(0), plane1.get_height(0)));
   float2 const plane1_half_texel = (float2(0.5f) / plane1_dims);
-  float2 const plane1_clamped = clamp(coord, plane1_half_texel, (1.0f - plane1_half_texel));
+  float2 const plane1_clamped = clamp(modifiedCoords, plane1_half_texel, (1.0f - plane1_half_texel));
   float3 color = 0.0f;
   if ((params.numPlanes == 1u)) {
     color = float4(plane0.sample(smp, plane0_clamped, level(0.0f))).rgb;
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 ac6a1b9..1e24781 100644
--- a/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureSampleBaseClampToEdge/7c04e6.wgsl.expected.spvasm
@@ -1,11 +1,11 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 167
+; Bound: 192
 ; Schema: 0
                OpCapability Shader
                OpCapability ImageQuery
-         %31 = OpExtInstImport "GLSL.std.450"
+         %32 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,14 +31,24 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                OpName %textureSampleExternal "textureSampleExternal"
                OpName %plane0 "plane0"
                OpName %plane1 "plane1"
@@ -46,6 +56,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"
@@ -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,10 +85,12 @@
                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_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
                OpDecorate %ext_tex_params NonWritable
                OpDecorate %ext_tex_params DescriptorSet 1
                OpDecorate %ext_tex_params Binding 3
@@ -84,6 +98,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
@@ -100,182 +127,209 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %24 = OpTypeSampler
-%_ptr_UniformConstant_24 = OpTypePointer UniformConstant %24
-      %arg_1 = OpVariable %_ptr_UniformConstant_24 UniformConstant
-         %25 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %25 = OpTypeSampler
+%_ptr_UniformConstant_25 = OpTypePointer UniformConstant %25
+      %arg_1 = OpVariable %_ptr_UniformConstant_25 UniformConstant
+         %26 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %45 = OpConstantNull %v3float
-    %v2float = OpTypeVector %float 2
-         %65 = OpTypeFunction %v4float %11 %11 %24 %v2float %ExternalTextureParams
+         %46 = OpConstantNull %v3float
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams
+  %float_0_5 = OpConstant %float 0.5
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+         %80 = OpConstantNull %v2float
      %v2uint = OpTypeVector %uint 2
         %int = OpTypeInt 32 1
-         %78 = OpConstantNull %int
-  %float_0_5 = OpConstant %float 0.5
-         %80 = OpConstantComposite %v2float %float_0_5 %float_0_5
+         %91 = OpConstantNull %int
+         %92 = OpConstantComposite %v2float %float_0_5 %float_0_5
     %float_1 = OpConstant %float 1
-%_ptr_Function_v2float = OpTypePointer Function %v2float
-         %87 = OpConstantNull %v2float
      %uint_1 = OpConstant %uint 1
-        %104 = OpTypeSampledImage %11
-        %119 = OpConstantNull %uint
+        %114 = OpTypeSampledImage %11
+        %129 = OpConstantNull %uint
+        %147 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %137 = OpTypeFunction %void
-        %141 = OpConstantComposite %v2float %float_1 %float_1
+        %161 = OpTypeFunction %void
+        %165 = 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
-        %154 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %25
+        %179 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %26
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %29 = OpLabel
-         %43 = OpVariable %_ptr_Function_v3float Function %45
-         %55 = OpVariable %_ptr_Function_v3float Function %45
-         %61 = OpVariable %_ptr_Function_v3float Function %45
-         %30 = OpExtInst %v3float %31 FAbs %v
-         %32 = OpCompositeExtract %float %params 4
-         %33 = OpCompositeConstruct %v3float %32 %32 %32
-         %34 = OpFOrdLessThan %v3bool %30 %33
-         %37 = OpExtInst %v3float %31 FSign %v
-         %38 = OpCompositeExtract %float %params 3
-         %39 = OpExtInst %v3float %31 FAbs %v
-         %40 = OpVectorTimesScalar %v3float %39 %38
-         %41 = OpCompositeExtract %float %params 6
-         %46 = OpCompositeConstruct %v3float %41 %41 %41
-         %42 = OpFAdd %v3float %40 %46
-         %47 = OpFMul %v3float %37 %42
-         %48 = OpExtInst %v3float %31 FSign %v
-         %50 = OpCompositeExtract %float %params 1
-         %51 = OpExtInst %v3float %31 FAbs %v
-         %52 = OpVectorTimesScalar %v3float %51 %50
-         %53 = OpCompositeExtract %float %params 2
-         %56 = OpCompositeConstruct %v3float %53 %53 %53
-         %54 = OpFAdd %v3float %52 %56
-         %57 = OpCompositeExtract %float %params 0
-         %58 = OpCompositeConstruct %v3float %57 %57 %57
-         %49 = OpExtInst %v3float %31 Pow %54 %58
-         %59 = OpCompositeExtract %float %params 5
-         %62 = OpCompositeConstruct %v3float %59 %59 %59
-         %60 = OpFAdd %v3float %49 %62
-         %63 = OpFMul %v3float %48 %60
-         %64 = OpSelect %v3float %34 %47 %63
-               OpReturnValue %64
+         %30 = OpLabel
+         %44 = OpVariable %_ptr_Function_v3float Function %46
+         %56 = OpVariable %_ptr_Function_v3float Function %46
+         %62 = OpVariable %_ptr_Function_v3float Function %46
+         %31 = OpExtInst %v3float %32 FAbs %v
+         %33 = OpCompositeExtract %float %params 4
+         %34 = OpCompositeConstruct %v3float %33 %33 %33
+         %35 = OpFOrdLessThan %v3bool %31 %34
+         %38 = OpExtInst %v3float %32 FSign %v
+         %39 = OpCompositeExtract %float %params 3
+         %40 = OpExtInst %v3float %32 FAbs %v
+         %41 = OpVectorTimesScalar %v3float %40 %39
+         %42 = OpCompositeExtract %float %params 6
+         %47 = OpCompositeConstruct %v3float %42 %42 %42
+         %43 = OpFAdd %v3float %41 %47
+         %48 = OpFMul %v3float %38 %43
+         %49 = OpExtInst %v3float %32 FSign %v
+         %51 = OpCompositeExtract %float %params 1
+         %52 = OpExtInst %v3float %32 FAbs %v
+         %53 = OpVectorTimesScalar %v3float %52 %51
+         %54 = OpCompositeExtract %float %params 2
+         %57 = OpCompositeConstruct %v3float %54 %54 %54
+         %55 = OpFAdd %v3float %53 %57
+         %58 = OpCompositeExtract %float %params 0
+         %59 = OpCompositeConstruct %v3float %58 %58 %58
+         %50 = OpExtInst %v3float %32 Pow %55 %59
+         %60 = OpCompositeExtract %float %params 5
+         %63 = OpCompositeConstruct %v3float %60 %60 %60
+         %61 = OpFAdd %v3float %50 %63
+         %64 = OpFMul %v3float %49 %61
+         %65 = OpSelect %v3float %35 %48 %64
+               OpReturnValue %65
                OpFunctionEnd
-%textureSampleExternal = OpFunction %v4float None %65
+%textureSampleExternal = OpFunction %v4float None %66
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
-        %smp = OpFunctionParameter %24
+        %smp = OpFunctionParameter %25
       %coord = OpFunctionParameter %v2float
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %73 = OpLabel
-         %85 = OpVariable %_ptr_Function_v2float Function %87
-         %94 = OpVariable %_ptr_Function_v2float Function %87
-      %color = OpVariable %_ptr_Function_v3float Function %45
-         %75 = OpImageQuerySizeLod %v2uint %plane0 %78
-         %74 = OpConvertUToF %v2float %75
-         %81 = OpFDiv %v2float %80 %74
-         %88 = OpCompositeConstruct %v2float %float_1 %float_1
-         %84 = OpFSub %v2float %88 %81
-         %82 = OpExtInst %v2float %31 NClamp %coord %81 %84
-         %90 = OpImageQuerySizeLod %v2uint %plane1 %78
-         %89 = OpConvertUToF %v2float %90
-         %91 = OpFDiv %v2float %80 %89
-         %95 = OpCompositeConstruct %v2float %float_1 %float_1
-         %93 = OpFSub %v2float %95 %91
-         %92 = OpExtInst %v2float %31 NClamp %coord %91 %93
-         %97 = OpCompositeExtract %uint %params_0 0
-         %99 = OpIEqual %bool %97 %uint_1
-               OpSelectionMerge %100 None
-               OpBranchConditional %99 %101 %102
-        %101 = OpLabel
-        %105 = OpSampledImage %104 %plane0 %smp
-        %103 = OpImageSampleExplicitLod %v4float %105 %82 Lod %8
-        %106 = OpVectorShuffle %v3float %103 %103 0 1 2
-               OpStore %color %106
-               OpBranch %100
-        %102 = OpLabel
-        %108 = OpSampledImage %104 %plane0 %smp
-        %107 = OpImageSampleExplicitLod %v4float %108 %82 Lod %8
-        %109 = OpCompositeExtract %float %107 0
-        %111 = OpSampledImage %104 %plane1 %smp
-        %110 = OpImageSampleExplicitLod %v4float %111 %92 Lod %8
-        %112 = OpVectorShuffle %v2float %110 %110 0 1
-        %113 = OpCompositeExtract %float %112 0
-        %114 = OpCompositeExtract %float %112 1
-        %115 = OpCompositeConstruct %v4float %109 %113 %114 %float_1
-        %116 = OpCompositeExtract %mat3v4float %params_0 2
-        %117 = OpVectorTimesMatrix %v3float %115 %116
-               OpStore %color %117
-               OpBranch %100
-        %100 = OpLabel
-        %118 = OpCompositeExtract %uint %params_0 1
-        %120 = OpIEqual %bool %118 %119
-               OpSelectionMerge %121 None
-               OpBranchConditional %120 %122 %121
-        %122 = OpLabel
-        %124 = OpLoad %v3float %color
-        %125 = OpCompositeExtract %GammaTransferParams %params_0 3
-        %123 = OpFunctionCall %v3float %gammaCorrection %124 %125
-               OpStore %color %123
-        %126 = OpCompositeExtract %mat3v3float %params_0 5
-        %127 = OpLoad %v3float %color
-        %128 = OpMatrixTimesVector %v3float %126 %127
-               OpStore %color %128
-        %130 = OpLoad %v3float %color
-        %131 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %129 = OpFunctionCall %v3float %gammaCorrection %130 %131
-               OpStore %color %129
-               OpBranch %121
-        %121 = OpLabel
-        %132 = OpLoad %v3float %color
-        %133 = OpCompositeExtract %float %132 0
-        %134 = OpCompositeExtract %float %132 1
-        %135 = OpCompositeExtract %float %132 2
-        %136 = OpCompositeConstruct %v4float %133 %134 %135 %float_1
-               OpReturnValue %136
+         %75 = OpLabel
+         %78 = OpVariable %_ptr_Function_v2float Function %80
+         %85 = OpVariable %_ptr_Function_v2float Function %80
+         %97 = OpVariable %_ptr_Function_v2float Function %80
+        %104 = OpVariable %_ptr_Function_v2float Function %80
+      %color = OpVariable %_ptr_Function_v3float Function %46
+         %81 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
+         %77 = OpFSub %v2float %coord %81
+         %82 = OpCompositeExtract %mat2v2float %params_0 6
+         %83 = OpVectorTimesMatrix %v2float %77 %82
+         %86 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
+         %84 = OpFAdd %v2float %83 %86
+         %88 = OpImageQuerySizeLod %v2uint %plane0 %91
+         %87 = OpConvertUToF %v2float %88
+         %93 = OpFDiv %v2float %92 %87
+         %98 = OpCompositeConstruct %v2float %float_1 %float_1
+         %96 = OpFSub %v2float %98 %93
+         %94 = OpExtInst %v2float %32 NClamp %84 %93 %96
+        %100 = OpImageQuerySizeLod %v2uint %plane1 %91
+         %99 = OpConvertUToF %v2float %100
+        %101 = OpFDiv %v2float %92 %99
+        %105 = OpCompositeConstruct %v2float %float_1 %float_1
+        %103 = OpFSub %v2float %105 %101
+        %102 = OpExtInst %v2float %32 NClamp %84 %101 %103
+        %107 = OpCompositeExtract %uint %params_0 0
+        %109 = OpIEqual %bool %107 %uint_1
+               OpSelectionMerge %110 None
+               OpBranchConditional %109 %111 %112
+        %111 = OpLabel
+        %115 = OpSampledImage %114 %plane0 %smp
+        %113 = OpImageSampleExplicitLod %v4float %115 %94 Lod %8
+        %116 = OpVectorShuffle %v3float %113 %113 0 1 2
+               OpStore %color %116
+               OpBranch %110
+        %112 = OpLabel
+        %118 = OpSampledImage %114 %plane0 %smp
+        %117 = OpImageSampleExplicitLod %v4float %118 %94 Lod %8
+        %119 = OpCompositeExtract %float %117 0
+        %121 = OpSampledImage %114 %plane1 %smp
+        %120 = OpImageSampleExplicitLod %v4float %121 %102 Lod %8
+        %122 = OpVectorShuffle %v2float %120 %120 0 1
+        %123 = OpCompositeExtract %float %122 0
+        %124 = OpCompositeExtract %float %122 1
+        %125 = OpCompositeConstruct %v4float %119 %123 %124 %float_1
+        %126 = OpCompositeExtract %mat3v4float %params_0 2
+        %127 = OpVectorTimesMatrix %v3float %125 %126
+               OpStore %color %127
+               OpBranch %110
+        %110 = OpLabel
+        %128 = OpCompositeExtract %uint %params_0 1
+        %130 = OpIEqual %bool %128 %129
+               OpSelectionMerge %131 None
+               OpBranchConditional %130 %132 %131
+        %132 = OpLabel
+        %134 = OpLoad %v3float %color
+        %135 = OpCompositeExtract %GammaTransferParams %params_0 3
+        %133 = OpFunctionCall %v3float %gammaCorrection %134 %135
+               OpStore %color %133
+        %136 = OpCompositeExtract %mat3v3float %params_0 5
+        %137 = OpLoad %v3float %color
+        %138 = OpMatrixTimesVector %v3float %136 %137
+               OpStore %color %138
+        %140 = OpLoad %v3float %color
+        %141 = OpCompositeExtract %GammaTransferParams %params_0 4
+        %139 = OpFunctionCall %v3float %gammaCorrection %140 %141
+               OpStore %color %139
+               OpBranch %131
+        %131 = OpLabel
+        %142 = OpLoad %v3float %color
+        %143 = OpCompositeExtract %float %142 0
+        %144 = OpCompositeExtract %float %142 1
+        %145 = OpCompositeExtract %float %142 2
+        %146 = OpCompositeConstruct %v4float %143 %144 %145 %float_1
+               OpReturnValue %146
                OpFunctionEnd
-%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %137
-        %140 = OpLabel
-      %arg_2 = OpVariable %_ptr_Function_v2float Function %87
+%conv_ExternalTextureParams = OpFunction %ExternalTextureParams None %147
+        %val = OpFunctionParameter %ExternalTextureParams_std140
+        %150 = OpLabel
+        %151 = OpCompositeExtract %uint %val 0
+        %152 = OpCompositeExtract %uint %val 1
+        %153 = OpCompositeExtract %mat3v4float %val 2
+        %154 = OpCompositeExtract %GammaTransferParams %val 3
+        %155 = OpCompositeExtract %GammaTransferParams %val 4
+        %156 = OpCompositeExtract %mat3v3float %val 5
+        %157 = OpCompositeExtract %v2float %val 6
+        %158 = OpCompositeExtract %v2float %val 7
+        %159 = OpCompositeConstruct %mat2v2float %157 %158
+        %160 = OpCompositeConstruct %ExternalTextureParams %151 %152 %153 %154 %155 %156 %159
+               OpReturnValue %160
+               OpFunctionEnd
+%textureSampleBaseClampToEdge_7c04e6 = OpFunction %void None %161
+        %164 = OpLabel
+      %arg_2 = OpVariable %_ptr_Function_v2float Function %80
         %res = OpVariable %_ptr_Function_v4float Function %5
-               OpStore %arg_2 %141
-        %144 = OpLoad %11 %arg_0
-        %145 = OpLoad %11 %ext_tex_plane_1
-        %146 = OpLoad %24 %arg_1
-        %147 = OpLoad %v2float %arg_2
-        %150 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %151 = OpLoad %ExternalTextureParams %150
-        %143 = OpFunctionCall %v4float %textureSampleExternal %144 %145 %146 %147 %151
-               OpStore %res %143
+               OpStore %arg_2 %165
+        %168 = OpLoad %11 %arg_0
+        %169 = OpLoad %11 %ext_tex_plane_1
+        %170 = OpLoad %25 %arg_1
+        %171 = OpLoad %v2float %arg_2
+        %175 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %176 = OpLoad %ExternalTextureParams_std140 %175
+        %172 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %176
+        %167 = OpFunctionCall %v4float %textureSampleExternal %168 %169 %170 %171 %172
+               OpStore %res %167
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %154
-        %156 = OpLabel
-        %157 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
+%vertex_main_inner = OpFunction %v4float None %179
+        %181 = OpLabel
+        %182 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %137
-        %159 = OpLabel
-        %160 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %160
+%vertex_main = OpFunction %void None %161
+        %184 = OpLabel
+        %185 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %185
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %137
-        %162 = OpLabel
-        %163 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
+%fragment_main = OpFunction %void None %161
+        %187 = OpLabel
+        %188 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %137
-        %165 = OpLabel
-        %166 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
+%compute_main = OpFunction %void None %161
+        %190 = OpLabel
+        %191 = OpFunctionCall %void %textureSampleBaseClampToEdge_7c04e6
                OpReturn
                OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.dxc.hlsl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..a1d2c00
--- /dev/null
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.dxc.hlsl
@@ -0,0 +1,128 @@
+builtins/gen/var/textureSampleLevel/979816.wgsl:29:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2);
+                       ^^^^^^^^^^^^^^^^^^
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  float3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  float3x3 gamutConversionMatrix;
+  uint flipY;
+  float2x2 rotationMatrix;
+};
+
+Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
+cbuffer cbuffer_ext_tex_params : register(b3, space1) {
+  uint4 ext_tex_params[13];
+};
+Texture2D<float4> arg_0 : register(t0, space1);
+SamplerState arg_1 : register(s1, space1);
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  const bool3 cond = (abs(v) < float3((params.D).xxx));
+  const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
+  return (cond ? t : f);
+}
+
+float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  float3 color = float3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = plane0.SampleLevel(smp, coord, 0.0f).rgb;
+  } else {
+    color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = mul(color, params.gamutConversionMatrix);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+float3x4 tint_symbol_3(uint4 buffer[13], uint offset) {
+  const uint scalar_offset = ((offset + 0u)) / 4;
+  const uint scalar_offset_1 = ((offset + 16u)) / 4;
+  const uint scalar_offset_2 = ((offset + 32u)) / 4;
+  return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
+}
+
+GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_3 = ((offset + 0u)) / 4;
+  const uint scalar_offset_4 = ((offset + 4u)) / 4;
+  const uint scalar_offset_5 = ((offset + 8u)) / 4;
+  const uint scalar_offset_6 = ((offset + 12u)) / 4;
+  const uint scalar_offset_7 = ((offset + 16u)) / 4;
+  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;
+}
+
+float3x3 tint_symbol_7(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_11 = ((offset + 0u)) / 4;
+  const uint scalar_offset_12 = ((offset + 16u)) / 4;
+  const uint scalar_offset_13 = ((offset + 32u)) / 4;
+  return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
+}
+
+float2x2 tint_symbol_9(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_14 = ((offset + 0u)) / 4;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.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 uint scalar_offset_18 = ((offset + 176u)) / 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_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_9(buffer, (offset + 184u))};
+  return tint_symbol_12;
+}
+
+void textureSampleLevel_979816() {
+  float2 arg_2 = (1.0f).xx;
+  float4 res = textureSampleExternal(arg_0, ext_tex_plane_1, arg_1, arg_2, tint_symbol_1(ext_tex_params, 0u));
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  textureSampleLevel_979816();
+  return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+  const float4 inner_result = vertex_main_inner();
+  tint_symbol wrapper_result = (tint_symbol)0;
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  textureSampleLevel_979816();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.fxc.hlsl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..a1d2c00
--- /dev/null
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.fxc.hlsl
@@ -0,0 +1,128 @@
+builtins/gen/var/textureSampleLevel/979816.wgsl:29:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2);
+                       ^^^^^^^^^^^^^^^^^^
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  float3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  float3x3 gamutConversionMatrix;
+  uint flipY;
+  float2x2 rotationMatrix;
+};
+
+Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
+cbuffer cbuffer_ext_tex_params : register(b3, space1) {
+  uint4 ext_tex_params[13];
+};
+Texture2D<float4> arg_0 : register(t0, space1);
+SamplerState arg_1 : register(s1, space1);
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  const bool3 cond = (abs(v) < float3((params.D).xxx));
+  const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
+  return (cond ? t : f);
+}
+
+float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
+  float3 color = float3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = plane0.SampleLevel(smp, coord, 0.0f).rgb;
+  } else {
+    color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = mul(color, params.gamutConversionMatrix);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+float3x4 tint_symbol_3(uint4 buffer[13], uint offset) {
+  const uint scalar_offset = ((offset + 0u)) / 4;
+  const uint scalar_offset_1 = ((offset + 16u)) / 4;
+  const uint scalar_offset_2 = ((offset + 32u)) / 4;
+  return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
+}
+
+GammaTransferParams tint_symbol_5(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_3 = ((offset + 0u)) / 4;
+  const uint scalar_offset_4 = ((offset + 4u)) / 4;
+  const uint scalar_offset_5 = ((offset + 8u)) / 4;
+  const uint scalar_offset_6 = ((offset + 12u)) / 4;
+  const uint scalar_offset_7 = ((offset + 16u)) / 4;
+  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;
+}
+
+float3x3 tint_symbol_7(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_11 = ((offset + 0u)) / 4;
+  const uint scalar_offset_12 = ((offset + 16u)) / 4;
+  const uint scalar_offset_13 = ((offset + 32u)) / 4;
+  return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
+}
+
+float2x2 tint_symbol_9(uint4 buffer[13], uint offset) {
+  const uint scalar_offset_14 = ((offset + 0u)) / 4;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.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 uint scalar_offset_18 = ((offset + 176u)) / 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_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u)), buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_9(buffer, (offset + 184u))};
+  return tint_symbol_12;
+}
+
+void textureSampleLevel_979816() {
+  float2 arg_2 = (1.0f).xx;
+  float4 res = textureSampleExternal(arg_0, ext_tex_plane_1, arg_1, arg_2, tint_symbol_1(ext_tex_params, 0u));
+}
+
+struct tint_symbol {
+  float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+  textureSampleLevel_979816();
+  return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+  const float4 inner_result = vertex_main_inner();
+  tint_symbol wrapper_result = (tint_symbol)0;
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+  return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  textureSampleLevel_979816();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.glsl
new file mode 100644
index 0000000..e1d2dce
--- /dev/null
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.glsl
@@ -0,0 +1,257 @@
+builtins/gen/var/textureSampleLevel/979816.wgsl:29:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2);
+                       ^^^^^^^^^^^^^^^^^^
+
+#version 310 es
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec2 arg_2 = vec2(1.0f);
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+vec4 vertex_main() {
+  textureSampleLevel_979816();
+  return vec4(0.0f);
+}
+
+void main() {
+  gl_PointSize = 1.0;
+  vec4 inner_result = vertex_main();
+  gl_Position = inner_result;
+  gl_Position.y = -(gl_Position.y);
+  gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+  return;
+}
+#version 310 es
+precision mediump float;
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec2 arg_2 = vec2(1.0f);
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+void fragment_main() {
+  textureSampleLevel_979816();
+}
+
+void main() {
+  fragment_main();
+  return;
+}
+#version 310 es
+
+struct GammaTransferParams {
+  float G;
+  float A;
+  float B;
+  float C;
+  float D;
+  float E;
+  float F;
+  uint padding;
+};
+
+struct ExternalTextureParams {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  mat2 rotationMatrix;
+};
+
+struct ExternalTextureParams_std140 {
+  uint numPlanes;
+  uint doYuvToRgbConversionOnly;
+  mat3x4 yuvToRgbConversionMatrix;
+  GammaTransferParams gammaDecodeParams;
+  GammaTransferParams gammaEncodeParams;
+  mat3 gamutConversionMatrix;
+  uint flipY;
+  vec2 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 3, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
+} ext_tex_params;
+
+vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
+  bvec3 cond = lessThan(abs(v), vec3(params.D));
+  vec3 t = (sign(v) * ((params.C * abs(v)) + params.F));
+  vec3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3(params.G)) + params.E));
+  return mix(f, t, cond);
+}
+
+
+vec4 textureSampleExternal(highp sampler2D plane0_smp, highp sampler2D plane1_smp, vec2 coord, ExternalTextureParams params) {
+  vec3 color = vec3(0.0f, 0.0f, 0.0f);
+  if ((params.numPlanes == 1u)) {
+    color = textureLod(plane0_smp, coord, 0.0f).rgb;
+  } else {
+    color = (vec4(textureLod(plane0_smp, coord, 0.0f).r, textureLod(plane1_smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return vec4(color, 1.0f);
+}
+
+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, val.flipY, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
+void textureSampleLevel_979816() {
+  vec2 arg_2 = vec2(1.0f);
+  vec4 res = textureSampleExternal(arg_0_arg_1, ext_tex_plane_1_arg_1, arg_2, conv_ExternalTextureParams(ext_tex_params.inner));
+}
+
+void compute_main() {
+  textureSampleLevel_979816();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+  compute_main();
+  return;
+}
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl
new file mode 100644
index 0000000..cd0fe73
--- /dev/null
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl
@@ -0,0 +1,98 @@
+builtins/gen/var/textureSampleLevel/979816.wgsl:29:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2);
+                       ^^^^^^^^^^^^^^^^^^
+
+#include <metal_stdlib>
+
+using namespace metal;
+
+template<typename T, size_t N>
+struct tint_array {
+    const constant T& operator[](size_t i) const constant { return elements[i]; }
+    device T& operator[](size_t i) device { return elements[i]; }
+    const device T& operator[](size_t i) const device { return elements[i]; }
+    thread T& operator[](size_t i) thread { return elements[i]; }
+    const thread T& operator[](size_t i) const thread { return elements[i]; }
+    threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
+    const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
+    T elements[N];
+};
+
+struct GammaTransferParams {
+  /* 0x0000 */ float G;
+  /* 0x0004 */ float A;
+  /* 0x0008 */ float B;
+  /* 0x000c */ float C;
+  /* 0x0010 */ float D;
+  /* 0x0014 */ float E;
+  /* 0x0018 */ float F;
+  /* 0x001c */ uint padding;
+};
+
+struct ExternalTextureParams {
+  /* 0x0000 */ uint numPlanes;
+  /* 0x0004 */ uint doYuvToRgbConversionOnly;
+  /* 0x0008 */ tint_array<int8_t, 8> tint_pad;
+  /* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
+  /* 0x0040 */ GammaTransferParams gammaDecodeParams;
+  /* 0x0060 */ GammaTransferParams gammaEncodeParams;
+  /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ uint flipY;
+  /* 0x00b4 */ tint_array<int8_t, 4> tint_pad_1;
+  /* 0x00b8 */ float2x2 rotationMatrix;
+  /* 0x00c8 */ tint_array<int8_t, 8> tint_pad_2;
+};
+
+float3 gammaCorrection(float3 v, GammaTransferParams params) {
+  bool3 const cond = (fabs(v) < float3(params.D));
+  float3 const t = (sign(v) * ((params.C * fabs(v)) + params.F));
+  float3 const f = (sign(v) * (pow(((params.A * fabs(v)) + params.B), float3(params.G)) + params.E));
+  return select(f, t, cond);
+}
+
+float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
+  float3 color = 0.0f;
+  if ((params.numPlanes == 1u)) {
+    color = float4(plane0.sample(smp, coord, level(0.0f))).rgb;
+  } else {
+    color = (float4(plane0.sample(smp, coord, level(0.0f))[0], float4(plane1.sample(smp, coord, level(0.0f))).rg, 1.0f) * params.yuvToRgbConversionMatrix);
+  }
+  if ((params.doYuvToRgbConversionOnly == 0u)) {
+    color = gammaCorrection(color, params.gammaDecodeParams);
+    color = (params.gamutConversionMatrix * color);
+    color = gammaCorrection(color, params.gammaEncodeParams);
+  }
+  return float4(color, 1.0f);
+}
+
+void textureSampleLevel_979816(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, sampler tint_symbol_3, const constant ExternalTextureParams* const tint_symbol_4) {
+  float2 arg_2 = float2(1.0f);
+  float4 res = textureSampleExternal(tint_symbol_1, tint_symbol_2, tint_symbol_3, arg_2, *(tint_symbol_4));
+}
+
+struct tint_symbol {
+  float4 value [[position]];
+};
+
+float4 vertex_main_inner(texture2d<float, access::sample> tint_symbol_5, texture2d<float, access::sample> tint_symbol_6, sampler tint_symbol_7, const constant ExternalTextureParams* const tint_symbol_8) {
+  textureSampleLevel_979816(tint_symbol_5, tint_symbol_6, tint_symbol_7, tint_symbol_8);
+  return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main(texture2d<float, access::sample> tint_symbol_9 [[texture(0)]], texture2d<float, access::sample> tint_symbol_10 [[texture(1)]], sampler tint_symbol_11 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_12 [[buffer(2)]]) {
+  float4 const inner_result = vertex_main_inner(tint_symbol_9, tint_symbol_10, tint_symbol_11, tint_symbol_12);
+  tint_symbol wrapper_result = {};
+  wrapper_result.value = inner_result;
+  return wrapper_result;
+}
+
+fragment void fragment_main(texture2d<float, access::sample> tint_symbol_13 [[texture(0)]], texture2d<float, access::sample> tint_symbol_14 [[texture(1)]], sampler tint_symbol_15 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_16 [[buffer(2)]]) {
+  textureSampleLevel_979816(tint_symbol_13, tint_symbol_14, tint_symbol_15, tint_symbol_16);
+  return;
+}
+
+kernel void compute_main(texture2d<float, access::sample> tint_symbol_17 [[texture(0)]], texture2d<float, access::sample> tint_symbol_18 [[texture(1)]], sampler tint_symbol_19 [[sampler(0)]], const constant ExternalTextureParams* tint_symbol_20 [[buffer(2)]]) {
+  textureSampleLevel_979816(tint_symbol_17, tint_symbol_18, tint_symbol_19, tint_symbol_20);
+  return;
+}
+
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm
new file mode 100644
index 0000000..ebdb9a6
--- /dev/null
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm
@@ -0,0 +1,316 @@
+builtins/gen/var/textureSampleLevel/979816.wgsl:29:24 warning: use of deprecated builtin
+  var res: vec4<f32> = textureSampleLevel(arg_0, arg_1, arg_2);
+                       ^^^^^^^^^^^^^^^^^^
+
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 166
+; Schema: 0
+               OpCapability Shader
+         %32 = OpExtInstImport "GLSL.std.450"
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+               OpEntryPoint Fragment %fragment_main "fragment_main"
+               OpEntryPoint GLCompute %compute_main "compute_main"
+               OpExecutionMode %fragment_main OriginUpperLeft
+               OpExecutionMode %compute_main LocalSize 1 1 1
+               OpName %value "value"
+               OpName %vertex_point_size "vertex_point_size"
+               OpName %ext_tex_plane_1 "ext_tex_plane_1"
+               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"
+               OpMemberName %GammaTransferParams 2 "B"
+               OpMemberName %GammaTransferParams 3 "C"
+               OpMemberName %GammaTransferParams 4 "D"
+               OpMemberName %GammaTransferParams 5 "E"
+               OpMemberName %GammaTransferParams 6 "F"
+               OpMemberName %GammaTransferParams 7 "padding"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "flipY"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 8 "rotationMatrix_1"
+               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 "flipY"
+               OpMemberName %ExternalTextureParams 7 "rotationMatrix"
+               OpName %textureSampleExternal "textureSampleExternal"
+               OpName %plane0 "plane0"
+               OpName %plane1 "plane1"
+               OpName %smp "smp"
+               OpName %coord "coord"
+               OpName %params_0 "params"
+               OpName %color "color"
+               OpName %conv_ExternalTextureParams "conv_ExternalTextureParams"
+               OpName %val "val"
+               OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
+               OpName %arg_2 "arg_2"
+               OpName %res "res"
+               OpName %vertex_main_inner "vertex_main_inner"
+               OpName %vertex_main "vertex_main"
+               OpName %fragment_main "fragment_main"
+               OpName %compute_main "compute_main"
+               OpDecorate %value BuiltIn Position
+               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_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
+               OpMemberDecorate %GammaTransferParams 3 Offset 12
+               OpMemberDecorate %GammaTransferParams 4 Offset 16
+               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 3
+               OpDecorate %arg_0 DescriptorSet 1
+               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 7 Offset 184
+               OpMemberDecorate %ExternalTextureParams 7 ColMajor
+               OpMemberDecorate %ExternalTextureParams 7 MatrixStride 8
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+          %5 = OpConstantNull %v4float
+      %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+          %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+         %11 = OpTypeImage %float 2D 0 0 0 1 Unknown
+%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
+%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
+       %uint = OpTypeInt 32 0
+%mat3v4float = OpTypeMatrix %v4float 3
+%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
+    %v3float = OpTypeVector %float 3
+%mat3v3float = OpTypeMatrix %v3float 3
+    %v2float = OpTypeVector %float 2
+%ExternalTextureParams_std140 = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %uint %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
+      %arg_1 = OpVariable %_ptr_UniformConstant_25 UniformConstant
+         %26 = OpTypeFunction %v3float %v3float %GammaTransferParams
+       %bool = OpTypeBool
+     %v3bool = OpTypeVector %bool 3
+%_ptr_Function_v3float = OpTypePointer Function %v3float
+         %46 = OpConstantNull %v3float
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %uint %mat2v2float
+         %66 = OpTypeFunction %v4float %11 %11 %25 %v2float %ExternalTextureParams
+     %uint_1 = OpConstant %uint 1
+         %84 = OpTypeSampledImage %11
+    %float_1 = OpConstant %float 1
+        %100 = OpConstantNull %uint
+        %118 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
+       %void = OpTypeVoid
+        %133 = OpTypeFunction %void
+        %137 = OpConstantComposite %v2float %float_1 %float_1
+%_ptr_Function_v2float = OpTypePointer Function %v2float
+        %140 = OpConstantNull %v2float
+     %uint_0 = OpConstant %uint 0
+%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+        %153 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %26
+          %v = OpFunctionParameter %v3float
+     %params = OpFunctionParameter %GammaTransferParams
+         %30 = OpLabel
+         %44 = OpVariable %_ptr_Function_v3float Function %46
+         %56 = OpVariable %_ptr_Function_v3float Function %46
+         %62 = OpVariable %_ptr_Function_v3float Function %46
+         %31 = OpExtInst %v3float %32 FAbs %v
+         %33 = OpCompositeExtract %float %params 4
+         %34 = OpCompositeConstruct %v3float %33 %33 %33
+         %35 = OpFOrdLessThan %v3bool %31 %34
+         %38 = OpExtInst %v3float %32 FSign %v
+         %39 = OpCompositeExtract %float %params 3
+         %40 = OpExtInst %v3float %32 FAbs %v
+         %41 = OpVectorTimesScalar %v3float %40 %39
+         %42 = OpCompositeExtract %float %params 6
+         %47 = OpCompositeConstruct %v3float %42 %42 %42
+         %43 = OpFAdd %v3float %41 %47
+         %48 = OpFMul %v3float %38 %43
+         %49 = OpExtInst %v3float %32 FSign %v
+         %51 = OpCompositeExtract %float %params 1
+         %52 = OpExtInst %v3float %32 FAbs %v
+         %53 = OpVectorTimesScalar %v3float %52 %51
+         %54 = OpCompositeExtract %float %params 2
+         %57 = OpCompositeConstruct %v3float %54 %54 %54
+         %55 = OpFAdd %v3float %53 %57
+         %58 = OpCompositeExtract %float %params 0
+         %59 = OpCompositeConstruct %v3float %58 %58 %58
+         %50 = OpExtInst %v3float %32 Pow %55 %59
+         %60 = OpCompositeExtract %float %params 5
+         %63 = OpCompositeConstruct %v3float %60 %60 %60
+         %61 = OpFAdd %v3float %50 %63
+         %64 = OpFMul %v3float %49 %61
+         %65 = OpSelect %v3float %35 %48 %64
+               OpReturnValue %65
+               OpFunctionEnd
+%textureSampleExternal = OpFunction %v4float None %66
+     %plane0 = OpFunctionParameter %11
+     %plane1 = OpFunctionParameter %11
+        %smp = OpFunctionParameter %25
+      %coord = OpFunctionParameter %v2float
+   %params_0 = OpFunctionParameter %ExternalTextureParams
+         %75 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %46
+         %77 = OpCompositeExtract %uint %params_0 0
+         %79 = OpIEqual %bool %77 %uint_1
+               OpSelectionMerge %80 None
+               OpBranchConditional %79 %81 %82
+         %81 = OpLabel
+         %85 = OpSampledImage %84 %plane0 %smp
+         %83 = OpImageSampleExplicitLod %v4float %85 %coord Lod %8
+         %86 = OpVectorShuffle %v3float %83 %83 0 1 2
+               OpStore %color %86
+               OpBranch %80
+         %82 = OpLabel
+         %88 = OpSampledImage %84 %plane0 %smp
+         %87 = OpImageSampleExplicitLod %v4float %88 %coord Lod %8
+         %89 = OpCompositeExtract %float %87 0
+         %91 = OpSampledImage %84 %plane1 %smp
+         %90 = OpImageSampleExplicitLod %v4float %91 %coord Lod %8
+         %92 = OpVectorShuffle %v2float %90 %90 0 1
+         %93 = OpCompositeExtract %float %92 0
+         %94 = OpCompositeExtract %float %92 1
+         %96 = OpCompositeConstruct %v4float %89 %93 %94 %float_1
+         %97 = OpCompositeExtract %mat3v4float %params_0 2
+         %98 = OpVectorTimesMatrix %v3float %96 %97
+               OpStore %color %98
+               OpBranch %80
+         %80 = OpLabel
+         %99 = OpCompositeExtract %uint %params_0 1
+        %101 = OpIEqual %bool %99 %100
+               OpSelectionMerge %102 None
+               OpBranchConditional %101 %103 %102
+        %103 = OpLabel
+        %105 = OpLoad %v3float %color
+        %106 = OpCompositeExtract %GammaTransferParams %params_0 3
+        %104 = OpFunctionCall %v3float %gammaCorrection %105 %106
+               OpStore %color %104
+        %107 = OpCompositeExtract %mat3v3float %params_0 5
+        %108 = OpLoad %v3float %color
+        %109 = OpMatrixTimesVector %v3float %107 %108
+               OpStore %color %109
+        %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
+%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 %uint %val 6
+        %129 = OpCompositeExtract %v2float %val 7
+        %130 = OpCompositeExtract %v2float %val 8
+        %131 = OpCompositeConstruct %mat2v2float %129 %130
+        %132 = OpCompositeConstruct %ExternalTextureParams %122 %123 %124 %125 %126 %127 %128 %131
+               OpReturnValue %132
+               OpFunctionEnd
+%textureSampleLevel_979816 = OpFunction %void None %133
+        %136 = OpLabel
+      %arg_2 = OpVariable %_ptr_Function_v2float Function %140
+        %res = OpVariable %_ptr_Function_v4float Function %5
+               OpStore %arg_2 %137
+        %142 = OpLoad %11 %arg_0
+        %143 = OpLoad %11 %ext_tex_plane_1
+        %144 = OpLoad %25 %arg_1
+        %145 = OpLoad %v2float %arg_2
+        %149 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %150 = OpLoad %ExternalTextureParams_std140 %149
+        %146 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %150
+        %141 = OpFunctionCall %v4float %textureSampleExternal %142 %143 %144 %145 %146
+               OpStore %res %141
+               OpReturn
+               OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %153
+        %155 = OpLabel
+        %156 = OpFunctionCall %void %textureSampleLevel_979816
+               OpReturnValue %5
+               OpFunctionEnd
+%vertex_main = OpFunction %void None %133
+        %158 = OpLabel
+        %159 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %159
+               OpStore %vertex_point_size %float_1
+               OpReturn
+               OpFunctionEnd
+%fragment_main = OpFunction %void None %133
+        %161 = OpLabel
+        %162 = OpFunctionCall %void %textureSampleLevel_979816
+               OpReturn
+               OpFunctionEnd
+%compute_main = OpFunction %void None %133
+        %164 = OpLabel
+        %165 = OpFunctionCall %void %textureSampleLevel_979816
+               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 b2f84d9..c12d811 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -49,14 +50,14 @@
   return textureLoadExternal(tint_symbol, ext_tex_plane_1_1, coords, ext_tex_params_1);
 }
 
-float3x4 tint_symbol_4(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_4(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_6(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_6(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -65,22 +66,30 @@
   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_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[11], uint offset) {
+float3x3 tint_symbol_8(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_2(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_10(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_11;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_2(uint4 buffer[12], uint offset) {
+  const uint scalar_offset_16 = ((offset + 0u)) / 4;
+  const uint scalar_offset_17 = ((offset + 4u)) / 4;
+  const ExternalTextureParams tint_symbol_13 = {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_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 b2f84d9..c12d811 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,11 +15,12 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   float3x3 gamutConversionMatrix;
+  float2x2 rotationMatrix;
 };
 
 Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
 cbuffer cbuffer_ext_tex_params : register(b2, space1) {
-  uint4 ext_tex_params[11];
+  uint4 ext_tex_params[12];
 };
 Texture2D<float4> arg_0 : register(t0, space1);
 
@@ -49,14 +50,14 @@
   return textureLoadExternal(tint_symbol, ext_tex_plane_1_1, coords, ext_tex_params_1);
 }
 
-float3x4 tint_symbol_4(uint4 buffer[11], uint offset) {
+float3x4 tint_symbol_4(uint4 buffer[12], uint offset) {
   const uint scalar_offset = ((offset + 0u)) / 4;
   const uint scalar_offset_1 = ((offset + 16u)) / 4;
   const uint scalar_offset_2 = ((offset + 32u)) / 4;
   return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
 }
 
-GammaTransferParams tint_symbol_6(uint4 buffer[11], uint offset) {
+GammaTransferParams tint_symbol_6(uint4 buffer[12], uint offset) {
   const uint scalar_offset_3 = ((offset + 0u)) / 4;
   const uint scalar_offset_4 = ((offset + 4u)) / 4;
   const uint scalar_offset_5 = ((offset + 8u)) / 4;
@@ -65,22 +66,30 @@
   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_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[11], uint offset) {
+float3x3 tint_symbol_8(uint4 buffer[12], uint offset) {
   const uint scalar_offset_11 = ((offset + 0u)) / 4;
   const uint scalar_offset_12 = ((offset + 16u)) / 4;
   const uint scalar_offset_13 = ((offset + 32u)) / 4;
   return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
 }
 
-ExternalTextureParams tint_symbol_2(uint4 buffer[11], uint offset) {
+float2x2 tint_symbol_10(uint4 buffer[12], uint offset) {
   const uint scalar_offset_14 = ((offset + 0u)) / 4;
-  const uint scalar_offset_15 = ((offset + 4u)) / 4;
-  const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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))};
-  return tint_symbol_11;
+  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];
+  return float2x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)));
+}
+
+ExternalTextureParams tint_symbol_2(uint4 buffer[12], uint offset) {
+  const uint scalar_offset_16 = ((offset + 0u)) / 4;
+  const uint scalar_offset_17 = ((offset + 4u)) / 4;
+  const ExternalTextureParams tint_symbol_13 = {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_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 2a7cdf6..87e3260 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.glsl
@@ -18,10 +18,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -52,8 +64,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -90,10 +106,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -124,8 +152,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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() {
@@ -156,10 +188,22 @@
   GammaTransferParams gammaDecodeParams;
   GammaTransferParams gammaEncodeParams;
   mat3 gamutConversionMatrix;
+  mat2 rotationMatrix;
 };
 
-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 rotationMatrix_0;
+  vec2 rotationMatrix_1;
+};
+
+layout(binding = 2, std140) uniform ext_tex_params_block_std140_ubo {
+  ExternalTextureParams_std140 inner;
 } ext_tex_params;
 
 vec3 gammaCorrection(vec3 v, GammaTransferParams params) {
@@ -190,8 +234,12 @@
 
 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, mat2(val.rotationMatrix_0, val.rotationMatrix_1));
+}
+
 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 2afc801..cef47ca 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl
@@ -33,6 +33,7 @@
   /* 0x0040 */ GammaTransferParams gammaDecodeParams;
   /* 0x0060 */ GammaTransferParams gammaEncodeParams;
   /* 0x0080 */ float3x3 gamutConversionMatrix;
+  /* 0x00b0 */ float2x2 rotationMatrix;
 };
 
 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 e0ff7dd..75d20ad 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm
@@ -1,10 +1,10 @@
 ; SPIR-V
 ; Version: 1.3
 ; Generator: Google Tint Compiler; 0
-; Bound: 146
+; Bound: 163
 ; Schema: 0
                OpCapability Shader
-         %28 = OpExtInstImport "GLSL.std.450"
+         %29 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
                OpEntryPoint Fragment %fragment_main "fragment_main"
@@ -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,13 +30,23 @@
                OpMemberName %GammaTransferParams 5 "E"
                OpMemberName %GammaTransferParams 6 "F"
                OpMemberName %GammaTransferParams 7 "padding"
-               OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
-               OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 4 "gammaEncodeParams"
+               OpMemberName %ExternalTextureParams_std140 5 "gamutConversionMatrix"
+               OpMemberName %ExternalTextureParams_std140 6 "rotationMatrix_0"
+               OpMemberName %ExternalTextureParams_std140 7 "rotationMatrix_1"
                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 "rotationMatrix"
                OpName %textureLoadExternal "textureLoadExternal"
                OpName %plane0 "plane0"
                OpName %plane1 "plane1"
@@ -48,6 +58,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"
@@ -58,14 +70,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
@@ -74,15 +86,30 @@
                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_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
                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 8
       %float = OpTypeFloat 32
     %v4float = OpTypeVector %float 4
 %_ptr_Output_v4float = OpTypePointer Output %v4float
@@ -99,162 +126,181 @@
 %GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
     %v3float = OpTypeVector %float 3
 %mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
-%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
+%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
-         %22 = OpTypeFunction %v3float %v3float %GammaTransferParams
+         %23 = OpTypeFunction %v3float %v3float %GammaTransferParams
        %bool = OpTypeBool
      %v3bool = OpTypeVector %bool 3
 %_ptr_Function_v3float = OpTypePointer Function %v3float
-         %42 = OpConstantNull %v3float
+         %43 = OpConstantNull %v3float
         %int = OpTypeInt 32 1
       %v2int = OpTypeVector %int 2
-         %62 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
+%mat2v2float = OpTypeMatrix %v2float 2
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float %mat2v2float
+         %63 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
      %uint_1 = OpConstant %uint 1
-         %79 = OpConstantNull %int
-    %v2float = OpTypeVector %float 2
+         %82 = OpConstantNull %int
     %float_1 = OpConstant %float 1
-         %93 = OpConstantNull %uint
-        %111 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
+         %95 = OpConstantNull %uint
+        %113 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
+        %121 = OpTypeFunction %ExternalTextureParams %ExternalTextureParams_std140
        %void = OpTypeVoid
-        %119 = OpTypeFunction %void
+        %135 = OpTypeFunction %void
      %uint_0 = OpConstant %uint 0
-%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
-        %130 = OpConstantNull %v2int
+%_ptr_Uniform_ExternalTextureParams_std140 = OpTypePointer Uniform %ExternalTextureParams_std140
+        %147 = OpConstantNull %v2int
 %_ptr_Function_v4float = OpTypePointer Function %v4float
-        %133 = OpTypeFunction %v4float
-%gammaCorrection = OpFunction %v3float None %22
+        %150 = OpTypeFunction %v4float
+%gammaCorrection = OpFunction %v3float None %23
           %v = OpFunctionParameter %v3float
      %params = OpFunctionParameter %GammaTransferParams
-         %26 = OpLabel
-         %40 = OpVariable %_ptr_Function_v3float Function %42
-         %52 = OpVariable %_ptr_Function_v3float Function %42
-         %58 = OpVariable %_ptr_Function_v3float Function %42
-         %27 = OpExtInst %v3float %28 FAbs %v
-         %29 = OpCompositeExtract %float %params 4
-         %30 = OpCompositeConstruct %v3float %29 %29 %29
-         %31 = OpFOrdLessThan %v3bool %27 %30
-         %34 = OpExtInst %v3float %28 FSign %v
-         %35 = OpCompositeExtract %float %params 3
-         %36 = OpExtInst %v3float %28 FAbs %v
-         %37 = OpVectorTimesScalar %v3float %36 %35
-         %38 = OpCompositeExtract %float %params 6
-         %43 = OpCompositeConstruct %v3float %38 %38 %38
-         %39 = OpFAdd %v3float %37 %43
-         %44 = OpFMul %v3float %34 %39
-         %45 = OpExtInst %v3float %28 FSign %v
-         %47 = OpCompositeExtract %float %params 1
-         %48 = OpExtInst %v3float %28 FAbs %v
-         %49 = OpVectorTimesScalar %v3float %48 %47
-         %50 = OpCompositeExtract %float %params 2
-         %53 = OpCompositeConstruct %v3float %50 %50 %50
-         %51 = OpFAdd %v3float %49 %53
-         %54 = OpCompositeExtract %float %params 0
-         %55 = OpCompositeConstruct %v3float %54 %54 %54
-         %46 = OpExtInst %v3float %28 Pow %51 %55
-         %56 = OpCompositeExtract %float %params 5
-         %59 = OpCompositeConstruct %v3float %56 %56 %56
-         %57 = OpFAdd %v3float %46 %59
-         %60 = OpFMul %v3float %45 %57
-         %61 = OpSelect %v3float %31 %44 %60
-               OpReturnValue %61
+         %27 = OpLabel
+         %41 = OpVariable %_ptr_Function_v3float Function %43
+         %53 = OpVariable %_ptr_Function_v3float Function %43
+         %59 = OpVariable %_ptr_Function_v3float Function %43
+         %28 = OpExtInst %v3float %29 FAbs %v
+         %30 = OpCompositeExtract %float %params 4
+         %31 = OpCompositeConstruct %v3float %30 %30 %30
+         %32 = OpFOrdLessThan %v3bool %28 %31
+         %35 = OpExtInst %v3float %29 FSign %v
+         %36 = OpCompositeExtract %float %params 3
+         %37 = OpExtInst %v3float %29 FAbs %v
+         %38 = OpVectorTimesScalar %v3float %37 %36
+         %39 = OpCompositeExtract %float %params 6
+         %44 = OpCompositeConstruct %v3float %39 %39 %39
+         %40 = OpFAdd %v3float %38 %44
+         %45 = OpFMul %v3float %35 %40
+         %46 = OpExtInst %v3float %29 FSign %v
+         %48 = OpCompositeExtract %float %params 1
+         %49 = OpExtInst %v3float %29 FAbs %v
+         %50 = OpVectorTimesScalar %v3float %49 %48
+         %51 = OpCompositeExtract %float %params 2
+         %54 = OpCompositeConstruct %v3float %51 %51 %51
+         %52 = OpFAdd %v3float %50 %54
+         %55 = OpCompositeExtract %float %params 0
+         %56 = OpCompositeConstruct %v3float %55 %55 %55
+         %47 = OpExtInst %v3float %29 Pow %52 %56
+         %57 = OpCompositeExtract %float %params 5
+         %60 = OpCompositeConstruct %v3float %57 %57 %57
+         %58 = OpFAdd %v3float %47 %60
+         %61 = OpFMul %v3float %46 %58
+         %62 = OpSelect %v3float %32 %45 %61
+               OpReturnValue %62
                OpFunctionEnd
-%textureLoadExternal = OpFunction %v4float None %62
+%textureLoadExternal = OpFunction %v4float None %63
      %plane0 = OpFunctionParameter %11
      %plane1 = OpFunctionParameter %11
       %coord = OpFunctionParameter %v2int
    %params_0 = OpFunctionParameter %ExternalTextureParams
-         %70 = OpLabel
-      %color = OpVariable %_ptr_Function_v3float Function %42
-         %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 %79
-         %80 = OpVectorShuffle %v3float %78 %78 0 1 2
-               OpStore %color %80
-               OpBranch %75
-         %77 = OpLabel
-         %81 = OpImageFetch %v4float %plane0 %coord Lod %79
-         %82 = OpCompositeExtract %float %81 0
-         %83 = OpImageFetch %v4float %plane1 %coord Lod %79
-         %85 = OpVectorShuffle %v2float %83 %83 0 1
-         %86 = OpCompositeExtract %float %85 0
-         %87 = OpCompositeExtract %float %85 1
-         %89 = OpCompositeConstruct %v4float %82 %86 %87 %float_1
-         %90 = OpCompositeExtract %mat3v4float %params_0 2
-         %91 = OpVectorTimesMatrix %v3float %89 %90
-               OpStore %color %91
-               OpBranch %75
-         %75 = OpLabel
-         %92 = OpCompositeExtract %uint %params_0 1
-         %94 = OpIEqual %bool %92 %93
-               OpSelectionMerge %95 None
-               OpBranchConditional %94 %96 %95
-         %96 = OpLabel
-         %98 = OpLoad %v3float %color
-         %99 = OpCompositeExtract %GammaTransferParams %params_0 3
-         %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
-               OpStore %color %97
-        %100 = OpCompositeExtract %mat3v3float %params_0 5
-        %101 = OpLoad %v3float %color
-        %102 = OpMatrixTimesVector %v3float %100 %101
-               OpStore %color %102
-        %104 = OpLoad %v3float %color
-        %105 = OpCompositeExtract %GammaTransferParams %params_0 4
-        %103 = OpFunctionCall %v3float %gammaCorrection %104 %105
-               OpStore %color %103
-               OpBranch %95
-         %95 = OpLabel
+         %73 = OpLabel
+      %color = OpVariable %_ptr_Function_v3float Function %43
+         %75 = OpCompositeExtract %uint %params_0 0
+         %77 = OpIEqual %bool %75 %uint_1
+               OpSelectionMerge %78 None
+               OpBranchConditional %77 %79 %80
+         %79 = OpLabel
+         %81 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %83 = OpVectorShuffle %v3float %81 %81 0 1 2
+               OpStore %color %83
+               OpBranch %78
+         %80 = OpLabel
+         %84 = OpImageFetch %v4float %plane0 %coord Lod %82
+         %85 = OpCompositeExtract %float %84 0
+         %86 = OpImageFetch %v4float %plane1 %coord Lod %82
+         %87 = OpVectorShuffle %v2float %86 %86 0 1
+         %88 = OpCompositeExtract %float %87 0
+         %89 = OpCompositeExtract %float %87 1
+         %91 = OpCompositeConstruct %v4float %85 %88 %89 %float_1
+         %92 = OpCompositeExtract %mat3v4float %params_0 2
+         %93 = OpVectorTimesMatrix %v3float %91 %92
+               OpStore %color %93
+               OpBranch %78
+         %78 = OpLabel
+         %94 = OpCompositeExtract %uint %params_0 1
+         %96 = OpIEqual %bool %94 %95
+               OpSelectionMerge %97 None
+               OpBranchConditional %96 %98 %97
+         %98 = OpLabel
+        %100 = OpLoad %v3float %color
+        %101 = OpCompositeExtract %GammaTransferParams %params_0 3
+         %99 = OpFunctionCall %v3float %gammaCorrection %100 %101
+               OpStore %color %99
+        %102 = OpCompositeExtract %mat3v3float %params_0 5
+        %103 = OpLoad %v3float %color
+        %104 = OpMatrixTimesVector %v3float %102 %103
+               OpStore %color %104
         %106 = OpLoad %v3float %color
-        %107 = OpCompositeExtract %float %106 0
-        %108 = OpCompositeExtract %float %106 1
-        %109 = OpCompositeExtract %float %106 2
-        %110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
-               OpReturnValue %110
+        %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 %111
+%textureLoad2d = OpFunction %v4float None %113
     %texture = OpFunctionParameter %11
 %ext_tex_plane_1_1 = OpFunctionParameter %11
 %ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams
      %coords = OpFunctionParameter %v2int
-        %117 = OpLabel
-        %118 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
-               OpReturnValue %118
+        %119 = OpLabel
+        %120 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
+               OpReturnValue %120
                OpFunctionEnd
-%doTextureLoad = OpFunction %void None %119
-        %122 = 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 = OpCompositeConstruct %mat2v2float %131 %132
+        %134 = OpCompositeConstruct %ExternalTextureParams %125 %126 %127 %128 %129 %130 %133
+               OpReturnValue %134
+               OpFunctionEnd
+%doTextureLoad = OpFunction %void None %135
+        %138 = OpLabel
         %res = OpVariable %_ptr_Function_v4float Function %5
-        %124 = OpLoad %11 %arg_0
-        %125 = OpLoad %11 %ext_tex_plane_1
-        %128 = OpAccessChain %_ptr_Uniform_ExternalTextureParams %ext_tex_params %uint_0
-        %129 = OpLoad %ExternalTextureParams %128
-        %123 = OpFunctionCall %v4float %textureLoad2d %124 %125 %129 %130
-               OpStore %res %123
+        %140 = OpLoad %11 %arg_0
+        %141 = OpLoad %11 %ext_tex_plane_1
+        %145 = OpAccessChain %_ptr_Uniform_ExternalTextureParams_std140 %ext_tex_params %uint_0
+        %146 = OpLoad %ExternalTextureParams_std140 %145
+        %142 = OpFunctionCall %ExternalTextureParams %conv_ExternalTextureParams %146
+        %139 = OpFunctionCall %v4float %textureLoad2d %140 %141 %142 %147
+               OpStore %res %139
                OpReturn
                OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %133
-        %135 = OpLabel
-        %136 = OpFunctionCall %void %doTextureLoad
+%vertex_main_inner = OpFunction %v4float None %150
+        %152 = OpLabel
+        %153 = OpFunctionCall %void %doTextureLoad
                OpReturnValue %5
                OpFunctionEnd
-%vertex_main = OpFunction %void None %119
-        %138 = OpLabel
-        %139 = OpFunctionCall %v4float %vertex_main_inner
-               OpStore %value %139
+%vertex_main = OpFunction %void None %135
+        %155 = OpLabel
+        %156 = OpFunctionCall %v4float %vertex_main_inner
+               OpStore %value %156
                OpStore %vertex_point_size %float_1
                OpReturn
                OpFunctionEnd
-%fragment_main = OpFunction %void None %119
-        %141 = OpLabel
-        %142 = OpFunctionCall %void %doTextureLoad
+%fragment_main = OpFunction %void None %135
+        %158 = OpLabel
+        %159 = OpFunctionCall %void %doTextureLoad
                OpReturn
                OpFunctionEnd
-%compute_main = OpFunction %void None %119
-        %144 = OpLabel
-        %145 = OpFunctionCall %void %doTextureLoad
+%compute_main = OpFunction %void None %135
+        %161 = OpLabel
+        %162 = OpFunctionCall %void %doTextureLoad
                OpReturn
                OpFunctionEnd