Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ g.test('swizzle_assignment_vars')
kSwizzleAssignmentCases[t.params.case];

t.skipIf(t.params.address_space === 'storage' && elemType === 'bool');
if (t.params.memory_view === 'ptr') {
t.skipIfLanguageFeatureNotSupported('pointer_composite_access');
}

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

const wgsl = `
requires swizzle_assignment;
${t.params.memory_view === 'ptr' ? 'requires pointer_composite_access;' : ''}
${elemType === 'f16' ? 'enable f16;' : ''}

struct Outputs {
Expand Down Expand Up @@ -380,6 +384,10 @@ g.test('swizzle_compound_assignment')
const { elemType, vecSize, initial, swizzle, op, rhs, expected } =
kSwizzleCompoundAssignmentCases[t.params.case];

if (t.params.memory_view === 'ptr') {
t.skipIfLanguageFeatureNotSupported('pointer_composite_access');
}

const vecType = `vec${vecSize}<${elemType}>`;
const initialValues = initial.join(', ');

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

const wgsl = `
requires swizzle_assignment;
${t.params.memory_view === 'ptr' ? 'requires pointer_composite_access;' : ''}
${elemType === 'f16' ? 'enable f16;' : ''}

struct Outputs {
Expand Down
35 changes: 35 additions & 0 deletions src/webgpu/shader/validation/statement/swizzle_assignment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,38 @@ fn main() {
`;
t.expectCompileResult(false, code);
});

g.test('pointer_swizzle_assignment')
.desc('Validate swizzle assignments on pointers')
.params(u =>
u
.combine('use_pointer', [true, false] as const)
.combine('requires_pointer_composite_access', [true, false] as const)
.combine('use_compound', [true, false] as const)
)
.fn(t => {
t.skipIfLanguageFeatureNotSupported('swizzle_assignment');
const { use_pointer, requires_pointer_composite_access, use_compound } = t.params;

const requires_directive = requires_pointer_composite_access
? 'requires pointer_composite_access;'
: '';

const lhs = use_pointer ? 'p.xy' : '(*p).xy';
const op = use_compound ? '+=' : '=';

const code = `
${requires_directive}
@fragment
fn main() {
var v = vec4f();
let p = &v;
${lhs} ${op} vec2f(1.0);
}
`;

const has_feature = t.hasLanguageFeature('pointer_composite_access');
const expected = !use_pointer || has_feature;

t.expectCompileResult(expected, code);
});
Loading