From f81a0e6b0f6b34d21a9c77ea1ba429ab8ff4eec8 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Thu, 22 Jul 2021 13:39:51 -0700 Subject: [PATCH] Fix WGSL usage in linear_memory:storageClass="uniform";* (#657) * Fix WGSL usage in linear_memory:storageClass="uniform";* Arrays in the uniform storage class must have elements aligned to 16 bytes. Bug: crbug.com/dawn/1012 * Update src/webgpu/shader/execution/robust_access.spec.ts --- .../shader/execution/robust_access.spec.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/webgpu/shader/execution/robust_access.spec.ts b/src/webgpu/shader/execution/robust_access.spec.ts index b76e71957c4d..1f6f92818145 100644 --- a/src/webgpu/shader/execution/robust_access.spec.ts +++ b/src/webgpu/shader/execution/robust_access.spec.ts @@ -162,12 +162,25 @@ function* generateIndexableTypes({ layout: scalarInfo.layout ? { alignment: scalarInfo.layout.alignment, - size: kArrayLength * arrayStride(scalarInfo.layout), + size: + storageClass === 'uniform' + ? // Uniform storage class must have array elements aligned to 16. + kArrayLength * + arrayStride({ + ...scalarInfo.layout, + alignment: 16, + }) + : kArrayLength * arrayStride(scalarInfo.layout), } : undefined, }; + // Sized array - yield { type: `array<${scalarType},${kArrayLength}>`, _typeInfo: arrayTypeInfo }; + if (storageClass === 'uniform') { + yield { type: `[[stride(16)]] array<${scalarType},${kArrayLength}>`, _typeInfo: arrayTypeInfo }; + } else { + yield { type: `array<${scalarType},${kArrayLength}>`, _typeInfo: arrayTypeInfo }; + } // Unsized array if (storageClass === 'storage') { yield { type: `array<${scalarType}>`, _typeInfo: arrayTypeInfo };