From 053926b67b7f2961fe65e5e471b03241011b1470 Mon Sep 17 00:00:00 2001 From: Peter McNeeley Date: Tue, 29 Oct 2024 12:02:29 -0400 Subject: [PATCH] Initial commit --- .../shader/validation/shader_io/align.spec.ts | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/webgpu/shader/validation/shader_io/align.spec.ts b/src/webgpu/shader/validation/shader_io/align.spec.ts index e65dfd4e3a24..b61a1c0f574c 100644 --- a/src/webgpu/shader/validation/shader_io/align.spec.ts +++ b/src/webgpu/shader/validation/shader_io/align.spec.ts @@ -13,7 +13,10 @@ const kTests = { }, one: { src: '@align(1)', - pass: true, + pass: false, + // EXCEPTION: Error: Unexpected validation error occurred: + // Error while parsing WGSL: :6:10 error: alignment must be a + // multiple of '4' bytes for the 'uniform' address space @align(1) a: i32, }, four_a: { src: '@align(4)', @@ -45,6 +48,14 @@ const kTests = { }, const_expr: { src: '@align(i_val + 4 - 6)', + pass: false, + // EXCEPTION: Error: Unexpected validation error occurred: + // Error while parsing WGSL: :6:10 error: alignment must be a + // multiple of '4' bytes for the 'uniform' address space + // @align(i_val + 4 - 6) a: i32 + }, + const_expr_2: { + src: '@align(i_val + 8 - 4)', pass: true, }, large: { @@ -185,7 +196,7 @@ g.test('required_alignment') { name: 'mat3x4', storage: 8, uniform: 8 }, { name: 'mat4x4', storage: 8, uniform: 8 }, { name: 'array, 2>', storage: 8, uniform: 16 }, - { name: 'array, 2>', storage: 8, uniform: 16 }, + { name: 'array, 2>', storage: 16, uniform: 16 }, { name: 'S', storage: 8, uniform: 16 }, ]) .beginSubcases() @@ -218,15 +229,12 @@ g.test('required_alignment') `; } - let align = t.params.align; - if (t.params.align === 'alignment') { - // Alignment value listed in the spec - if (t.params.address_space === 'storage') { - align = `${t.params.type.storage}`; - } else { - align = `${t.params.type.uniform}`; - } - } + // Alignment value listed in the spec + const min_align = + t.params.address_space === 'storage' + ? `${t.params.type.storage}` + : `${t.params.type.uniform}`; + const align = t.params.align === 'alignment' ? min_align : t.params.align; let address_space = 'uniform'; if (t.params.address_space === 'storage') { @@ -252,7 +260,8 @@ g.test('required_alignment') // requires that inner vec2 to have an align 16 which can only be done by specifying `vec4` // instead. const fails = - t.params.address_space === 'uniform' && t.params.type.name.startsWith('array