From 8085671ed2a710a696488ff1d112a773be38121a Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 17 Nov 2021 14:54:07 +0000 Subject: [PATCH] test: Add missing cases for UBO dynamic loads Looks like a typo in the test cases I wrote. Change-Id: Ieb4d8ce28827e47ab0baef7b1178395d97f90ace Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69841 Kokoro: Kokoro Commit-Queue: Antonio Maiorano Auto-Submit: Ben Clayton Reviewed-by: Antonio Maiorano --- test/buffer/uniform/dynamic_index/read.wgsl | 2 + .../dynamic_index/read.wgsl.expected.hlsl | 60 +++++++++++++------ .../dynamic_index/read.wgsl.expected.msl | 2 + .../dynamic_index/read.wgsl.expected.spvasm | 20 +++++-- .../dynamic_index/read.wgsl.expected.wgsl | 2 + 5 files changed, 62 insertions(+), 24 deletions(-) diff --git a/test/buffer/uniform/dynamic_index/read.wgsl b/test/buffer/uniform/dynamic_index/read.wgsl index 12cc0c0895..f1612ea8b2 100644 --- a/test/buffer/uniform/dynamic_index/read.wgsl +++ b/test/buffer/uniform/dynamic_index/read.wgsl @@ -30,4 +30,6 @@ fn main([[builtin(local_invocation_index)]] idx : u32) { let g = s.arr[idx].g; let h = s.arr[idx].h; let i = s.arr[idx].i; + let j = s.arr[idx].j; + let k = s.arr[idx].k; } diff --git a/test/buffer/uniform/dynamic_index/read.wgsl.expected.hlsl b/test/buffer/uniform/dynamic_index/read.wgsl.expected.hlsl index 351446d745..b110fb71d8 100644 --- a/test/buffer/uniform/dynamic_index/read.wgsl.expected.hlsl +++ b/test/buffer/uniform/dynamic_index/read.wgsl.expected.hlsl @@ -12,26 +12,50 @@ float2x3 tint_symbol_9(uint4 buffer[96], uint offset) { return float2x3(asfloat(buffer[scalar_offset / 4].xyz), asfloat(buffer[scalar_offset_1 / 4].xyz)); } +float3x2 tint_symbol_10(uint4 buffer[96], uint offset) { + const uint scalar_offset_2 = ((offset + 0u)) / 4; + uint4 ubo_load = buffer[scalar_offset_2 / 4]; + const uint scalar_offset_3 = ((offset + 8u)) / 4; + uint4 ubo_load_1 = buffer[scalar_offset_3 / 4]; + const uint scalar_offset_4 = ((offset + 16u)) / 4; + uint4 ubo_load_2 = buffer[scalar_offset_4 / 4]; + return float3x2(asfloat(((scalar_offset_2 & 2) ? ubo_load.zw : ubo_load.xy)), asfloat(((scalar_offset_3 & 2) ? ubo_load_1.zw : ubo_load_1.xy)), asfloat(((scalar_offset_4 & 2) ? ubo_load_2.zw : ubo_load_2.xy))); +} + +typedef int4 tint_symbol_12_ret[4]; +tint_symbol_12_ret tint_symbol_12(uint4 buffer[96], uint offset) { + int4 arr_1[4] = (int4[4])0; + { + for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) { + const uint scalar_offset_5 = ((offset + (i_1 * 16u))) / 4; + arr_1[i_1] = asint(buffer[scalar_offset_5 / 4]); + } + } + return arr_1; +} + void main_inner(uint idx) { - const uint scalar_offset_2 = ((192u * idx)) / 4; - const int3 a = asint(s[scalar_offset_2 / 4].xyz); - const uint scalar_offset_3 = (((192u * idx) + 12u)) / 4; - const int b = asint(s[scalar_offset_3 / 4][scalar_offset_3 % 4]); - const uint scalar_offset_4 = (((192u * idx) + 16u)) / 4; - const uint3 c = s[scalar_offset_4 / 4].xyz; - const uint scalar_offset_5 = (((192u * idx) + 28u)) / 4; - const uint d = s[scalar_offset_5 / 4][scalar_offset_5 % 4]; - const uint scalar_offset_6 = (((192u * idx) + 32u)) / 4; - const float3 e = asfloat(s[scalar_offset_6 / 4].xyz); - const uint scalar_offset_7 = (((192u * idx) + 44u)) / 4; - const float f = asfloat(s[scalar_offset_7 / 4][scalar_offset_7 % 4]); - const uint scalar_offset_8 = (((192u * idx) + 48u)) / 4; - uint4 ubo_load = s[scalar_offset_8 / 4]; - const int2 g = asint(((scalar_offset_8 & 2) ? ubo_load.zw : ubo_load.xy)); - const uint scalar_offset_9 = (((192u * idx) + 56u)) / 4; - uint4 ubo_load_1 = s[scalar_offset_9 / 4]; - const int2 h = asint(((scalar_offset_9 & 2) ? ubo_load_1.zw : ubo_load_1.xy)); + const uint scalar_offset_6 = ((192u * idx)) / 4; + const int3 a = asint(s[scalar_offset_6 / 4].xyz); + const uint scalar_offset_7 = (((192u * idx) + 12u)) / 4; + const int b = asint(s[scalar_offset_7 / 4][scalar_offset_7 % 4]); + const uint scalar_offset_8 = (((192u * idx) + 16u)) / 4; + const uint3 c = s[scalar_offset_8 / 4].xyz; + const uint scalar_offset_9 = (((192u * idx) + 28u)) / 4; + const uint d = s[scalar_offset_9 / 4][scalar_offset_9 % 4]; + const uint scalar_offset_10 = (((192u * idx) + 32u)) / 4; + const float3 e = asfloat(s[scalar_offset_10 / 4].xyz); + const uint scalar_offset_11 = (((192u * idx) + 44u)) / 4; + const float f = asfloat(s[scalar_offset_11 / 4][scalar_offset_11 % 4]); + const uint scalar_offset_12 = (((192u * idx) + 48u)) / 4; + uint4 ubo_load_3 = s[scalar_offset_12 / 4]; + const int2 g = asint(((scalar_offset_12 & 2) ? ubo_load_3.zw : ubo_load_3.xy)); + const uint scalar_offset_13 = (((192u * idx) + 56u)) / 4; + uint4 ubo_load_4 = s[scalar_offset_13 / 4]; + const int2 h = asint(((scalar_offset_13 & 2) ? ubo_load_4.zw : ubo_load_4.xy)); const float2x3 i = tint_symbol_9(s, ((192u * idx) + 64u)); + const float3x2 j = tint_symbol_10(s, ((192u * idx) + 96u)); + const int4 k[4] = tint_symbol_12(s, ((192u * idx) + 128u)); } [numthreads(1, 1, 1)] diff --git a/test/buffer/uniform/dynamic_index/read.wgsl.expected.msl b/test/buffer/uniform/dynamic_index/read.wgsl.expected.msl index 16e6ca2f50..0b2cafef7f 100644 --- a/test/buffer/uniform/dynamic_index/read.wgsl.expected.msl +++ b/test/buffer/uniform/dynamic_index/read.wgsl.expected.msl @@ -46,6 +46,8 @@ void tint_symbol_inner(uint idx, const constant S* const tint_symbol_1) { int2 const g = (*(tint_symbol_1)).arr.arr[idx].g; int2 const h = (*(tint_symbol_1)).arr.arr[idx].h; float2x3 const i = (*(tint_symbol_1)).arr.arr[idx].i; + float3x2 const j = (*(tint_symbol_1)).arr.arr[idx].j; + tint_array_wrapper const k = (*(tint_symbol_1)).arr.arr[idx].k; } kernel void tint_symbol(const constant S* tint_symbol_2 [[buffer(0)]], uint idx [[thread_index_in_threadgroup]]) { diff --git a/test/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm b/test/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm index e00a927675..9f34e036f3 100644 --- a/test/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm +++ b/test/buffer/uniform/dynamic_index/read.wgsl.expected.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.3 ; Generator: Google Tint Compiler; 0 -; Bound: 65 +; Bound: 73 ; Schema: 0 OpCapability Shader OpMemoryModel Logical GLSL450 @@ -87,7 +87,11 @@ %_ptr_Uniform_v2int = OpTypePointer Uniform %v2int %uint_7 = OpConstant %uint 7 %_ptr_Uniform_mat2v3float = OpTypePointer Uniform %mat2v3float - %60 = OpTypeFunction %void + %uint_9 = OpConstant %uint 9 +%_ptr_Uniform_mat3v2float = OpTypePointer Uniform %mat3v2float + %uint_10 = OpConstant %uint 10 +%_ptr_Uniform__arr_v4int_uint_4 = OpTypePointer Uniform %_arr_v4int_uint_4 + %68 = OpTypeFunction %void %main_inner = OpFunction %void None %22 %idx = OpFunctionParameter %uint %26 = OpLabel @@ -109,11 +113,15 @@ %56 = OpLoad %v2int %55 %58 = OpAccessChain %_ptr_Uniform_mat2v3float %s %uint_0 %idx %uint_8 %59 = OpLoad %mat2v3float %58 + %62 = OpAccessChain %_ptr_Uniform_mat3v2float %s %uint_0 %idx %uint_9 + %63 = OpLoad %mat3v2float %62 + %66 = OpAccessChain %_ptr_Uniform__arr_v4int_uint_4 %s %uint_0 %idx %uint_10 + %67 = OpLoad %_arr_v4int_uint_4 %66 OpReturn OpFunctionEnd - %main = OpFunction %void None %60 - %62 = OpLabel - %64 = OpLoad %uint %idx_1 - %63 = OpFunctionCall %void %main_inner %64 + %main = OpFunction %void None %68 + %70 = OpLabel + %72 = OpLoad %uint %idx_1 + %71 = OpFunctionCall %void %main_inner %72 OpReturn OpFunctionEnd diff --git a/test/buffer/uniform/dynamic_index/read.wgsl.expected.wgsl b/test/buffer/uniform/dynamic_index/read.wgsl.expected.wgsl index 7377f9e315..017eb39103 100644 --- a/test/buffer/uniform/dynamic_index/read.wgsl.expected.wgsl +++ b/test/buffer/uniform/dynamic_index/read.wgsl.expected.wgsl @@ -32,4 +32,6 @@ fn main([[builtin(local_invocation_index)]] idx : u32) { let g = s.arr[idx].g; let h = s.arr[idx].h; let i = s.arr[idx].i; + let j = s.arr[idx].j; + let k = s.arr[idx].k; }