Skip to content

Commit

Permalink
Fix WGSL usage in linear_memory:storageClass="uniform";* (#657)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
austinEng authored Jul 22, 2021
1 parent c9b72f0 commit f81a0e6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/webgpu/shader/execution/robust_access.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit f81a0e6

Please sign in to comment.