Reduce shader complexity for external textures
Do more math on the CPU to avoid per-fragment ALU operations.
Use a mat3x2 instead of mat2x3 to avoid padding.
Fixed: dawn:1614
Change-Id: Ib0e0f7d44ed9aa16eaca712f6553214fad141feb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon1 Jones <brandon1.jones@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
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 794293a..ca1acb3 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.fxc.hlsl
@@ -15,7 +15,7 @@
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
float3x3 gamutConversionMatrix;
- float2x3 coordTransformationMatrix;
+ float3x2 coordTransformationMatrix;
};
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
@@ -66,8 +66,8 @@
const uint scalar_offset_8 = ((offset + 20u)) / 4;
const uint scalar_offset_9 = ((offset + 24u)) / 4;
const uint scalar_offset_10 = ((offset + 28u)) / 4;
- const GammaTransferParams tint_symbol_11 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]};
- return tint_symbol_11;
+ const GammaTransferParams tint_symbol_12 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]};
+ return tint_symbol_12;
}
float3x3 tint_symbol_8(uint4 buffer[13], uint offset) {
@@ -77,17 +77,21 @@
return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
}
-float2x3 tint_symbol_10(uint4 buffer[13], uint offset) {
+float3x2 tint_symbol_10(uint4 buffer[13], uint offset) {
const uint scalar_offset_14 = ((offset + 0u)) / 4;
- const uint scalar_offset_15 = ((offset + 16u)) / 4;
- return float2x3(asfloat(buffer[scalar_offset_14 / 4].xyz), asfloat(buffer[scalar_offset_15 / 4].xyz));
+ uint4 ubo_load = buffer[scalar_offset_14 / 4];
+ const uint scalar_offset_15 = ((offset + 8u)) / 4;
+ uint4 ubo_load_1 = buffer[scalar_offset_15 / 4];
+ const uint scalar_offset_16 = ((offset + 16u)) / 4;
+ uint4 ubo_load_2 = buffer[scalar_offset_16 / 4];
+ return float3x2(asfloat(((scalar_offset_14 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_15 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_16 & 2) ? ubo_load_2.zw : ubo_load_2.xy)));
}
ExternalTextureParams tint_symbol_2(uint4 buffer[13], uint offset) {
- const uint scalar_offset_16 = ((offset + 0u)) / 4;
- const uint scalar_offset_17 = ((offset + 4u)) / 4;
- const ExternalTextureParams tint_symbol_12 = {buffer[scalar_offset_16 / 4][scalar_offset_16 % 4], buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))};
- return tint_symbol_12;
+ const uint scalar_offset_17 = ((offset + 0u)) / 4;
+ const uint scalar_offset_18 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_13 = {buffer[scalar_offset_17 / 4][scalar_offset_17 % 4], buffer[scalar_offset_18 / 4][scalar_offset_18 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u)), tint_symbol_10(buffer, (offset + 176u))};
+ return tint_symbol_13;
}
void doTextureLoad() {