Skip to content

Commit 9fb8ce6

Browse files
authored
Correct swizzle assignment on pointer tests (#4682)
The swizzle assignment spec was updated so that creating a SwizzleView from pointer requires support for pointer_composite_access, so CTS tests here are updated to correctly handle the interaction between swizzle_assignment and pointer_composite_access. Execution tests for swizzle assignment via pointer are now skipped if the pointer_composite_access language feature is not available, and validation tests are added to validate both cases. Bug: crbug.com/534329233
1 parent af9a578 commit 9fb8ce6

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎src/webgpu/shader/execution/statement/swizzle_assignment.spec.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ g.test('swizzle_assignment_vars')
265265
kSwizzleAssignmentCases[t.params.case];
266266

267267
t.skipIf(t.params.address_space === 'storage' && elemType === 'bool');
268+
if (t.params.memory_view === 'ptr') {
269+
t.skipIfLanguageFeatureNotSupported('pointer_composite_access');
270+
}
268271

269272
const vecType = `vec${vecSize}<${elemType}>`;
270273
const initialValues =
@@ -282,6 +285,7 @@ g.test('swizzle_assignment_vars')
282285

283286
const wgsl = `
284287
requires swizzle_assignment;
288+
${t.params.memory_view === 'ptr' ? 'requires pointer_composite_access;' : ''}
285289
${elemType === 'f16' ? 'enable f16;' : ''}
286290
287291
struct Outputs {
@@ -380,6 +384,10 @@ g.test('swizzle_compound_assignment')
380384
const { elemType, vecSize, initial, swizzle, op, rhs, expected } =
381385
kSwizzleCompoundAssignmentCases[t.params.case];
382386

387+
if (t.params.memory_view === 'ptr') {
388+
t.skipIfLanguageFeatureNotSupported('pointer_composite_access');
389+
}
390+
383391
const vecType = `vec${vecSize}<${elemType}>`;
384392
const initialValues = initial.join(', ');
385393

@@ -392,6 +400,7 @@ g.test('swizzle_compound_assignment')
392400

393401
const wgsl = `
394402
requires swizzle_assignment;
403+
${t.params.memory_view === 'ptr' ? 'requires pointer_composite_access;' : ''}
395404
${elemType === 'f16' ? 'enable f16;' : ''}
396405
397406
struct Outputs {

‎src/webgpu/shader/validation/statement/swizzle_assignment.spec.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,38 @@ fn main() {
144144
`;
145145
t.expectCompileResult(false, code);
146146
});
147+
148+
g.test('pointer_swizzle_assignment')
149+
.desc('Validate swizzle assignments on pointers')
150+
.params(u =>
151+
u
152+
.combine('use_pointer', [true, false] as const)
153+
.combine('requires_pointer_composite_access', [true, false] as const)
154+
.combine('use_compound', [true, false] as const)
155+
)
156+
.fn(t => {
157+
t.skipIfLanguageFeatureNotSupported('swizzle_assignment');
158+
const { use_pointer, requires_pointer_composite_access, use_compound } = t.params;
159+
160+
const requires_directive = requires_pointer_composite_access
161+
? 'requires pointer_composite_access;'
162+
: '';
163+
164+
const lhs = use_pointer ? 'p.xy' : '(*p).xy';
165+
const op = use_compound ? '+=' : '=';
166+
167+
const code = `
168+
${requires_directive}
169+
@fragment
170+
fn main() {
171+
var v = vec4f();
172+
let p = &v;
173+
${lhs} ${op} vec2f(1.0);
174+
}
175+
`;
176+
177+
const has_feature = t.hasLanguageFeature('pointer_composite_access');
178+
const expected = !use_pointer || has_feature;
179+
180+
t.expectCompileResult(expected, code);
181+
});

0 commit comments

Comments
 (0)