Skip to content
Open
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
3 changes: 3 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@
"webgpu:shader,execution,stage:basic_compute:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,stage:basic_render:*": { "subcaseMS": 1.000 },
"webgpu:shader,execution,statement,compound:decl:*": { "subcaseMS": 29.767 },
"webgpu:shader,execution,statement,compound:eval_order:*": { "subcaseMS": 54.311 },
"webgpu:shader,execution,statement,discard:all:*": { "subcaseMS": 36.094 },
"webgpu:shader,execution,statement,discard:continuing:*": { "subcaseMS": 276.268 },
"webgpu:shader,execution,statement,discard:derivatives:*": { "subcaseMS": 15.287 },
Expand All @@ -2065,6 +2066,8 @@
"webgpu:shader,execution,statement,increment_decrement:vec4_element_decrement:*": { "subcaseMS": 5.300 },
"webgpu:shader,execution,statement,increment_decrement:vec4_element_increment:*": { "subcaseMS": 6.300 },
"webgpu:shader,execution,statement,phony:executes:*": { "subcaseMS": 129.949 },
"webgpu:shader,execution,statement,swizzle_assignment:compound_eval_order:*": { "subcaseMS": 16.651 },
"webgpu:shader,execution,statement,swizzle_assignment:eval_order:*": { "subcaseMS": 17.193 },
"webgpu:shader,execution,statement,swizzle_assignment:swizzle_assignment_vars:*": { "subcaseMS": 1200.970 },
"webgpu:shader,execution,statement,swizzle_assignment:swizzle_compound_assignment:*": { "subcaseMS": 0.091 },
"webgpu:shader,execution,value_init:array,nested:*": { "subcaseMS": 3004.523 },
Expand Down
31 changes: 31 additions & 0 deletions src/webgpu/shader/execution/statement/compound.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { keysOf } from '../../../../common/util/data_tables.js';
import { TypedArrayBufferView } from '../../../../common/util/util.js';
import { AllFeaturesMaxLimitsGPUTest, GPUTest } from '../../../gpu_test.js';
import { runFlowControlTest } from '../flow_control/harness.js';

export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

Expand Down Expand Up @@ -135,3 +136,33 @@ g.test('decl')
kTests[t.params.case].src
);
});

g.test('eval_order')
.desc('Tests evaluation order of compound assignment, lhs is evaluated before rhs')
.fn(t => {
runFlowControlTest(t, f => ({
entrypoint: `
arr[0] = 41;
${f.expect_order(0)}
arr[idx()] += foo();
${f.expect_order(3)}
if (arr[0] == 42) {
${f.expect_order(4)}
} else {
${f.expect_not_reached()}
}
`,
extra: `
var<private> arr : array<u32, 1>;
fn idx() -> u32 {
${f.expect_order(1)}
return 0;
}
fn foo() -> u32 {
${f.expect_order(2)}
arr[0] = 10;
return 1;
}
`,
}));
});
74 changes: 74 additions & 0 deletions src/webgpu/shader/execution/statement/swizzle_assignment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { keysOf } from '../../../../common/util/data_tables.js';
import { TypedArrayBufferView } from '../../../../common/util/util.js';
import { Float16Array } from '../../../../external/petamoriken/float16/float16.js';
import { AllFeaturesMaxLimitsGPUTest, GPUTest } from '../../../gpu_test.js';
import { runFlowControlTest } from '../flow_control/harness.js';

export const g = makeTestGroup(AllFeaturesMaxLimitsGPUTest);

Expand Down Expand Up @@ -420,3 +421,76 @@ fn main() {
}`;
runSwizzleAssignmentTest(t, elemType, expected, wgsl);
});

g.test('eval_order')
.desc(
'Tests that the vec pointer on the lhs of a swizzle assignment is evaluated before the rhs, and the load of the lhs vec happens after rhs.'
)
.fn(t => {
t.skipIfLanguageFeatureNotSupported('swizzle_assignment');
runFlowControlTest(t, f => ({
entrypoint: `
arr[0] = vec4u(1, 1, 1, 1);
${f.expect_order(0)}
arr[foo()].xy = bar();
${f.expect_order(3)}
if (all(arr[0] == vec4u(4, 5, 3, 8))) {
${f.expect_order(4)}
} else {
${f.expect_not_reached()}
}
`,
extra: `
var<private> arr : array<vec4u, 1>;
fn foo() -> u32 {
${f.expect_order(1)}
arr[0].x = 6; // overwritten by swizzle
arr[0].z = 7; // overwritten by bar()
arr[0].w = 8; // persists
return 0;
}
fn bar() -> vec2u {
${f.expect_order(2)}
arr[0].z = 3; // persists
return vec2u(4, 5); // will set x,y
}
`,
}));
});

g.test('compound_eval_order')
.desc(
'Tests that the lhs of a swizzle compound assignment is evaluated before the rhs, and another load of the lhs vec happens after rhs evaluation, without re-evaluating the pointer to the lhs vec.'
)
.fn(t => {
t.skipIfLanguageFeatureNotSupported('swizzle_assignment');
runFlowControlTest(t, f => ({
entrypoint: `
arr[0] = vec4u(1, 1, 1, 1);
${f.expect_order(0)}
arr[foo()].xy += bar();
${f.expect_order(3)}
if (all(arr[0] == vec4u(10, 6, 3, 8))) {
${f.expect_order(4)}
} else {
${f.expect_not_reached()}
}
`,
extra: `
var<private> arr : array<vec4u, 1>;
fn foo() -> u32 {
${f.expect_order(1)}
arr[0].x = 6; // modifies x before add
arr[0].z = 7; // overwritten by bar()
arr[0].w = 8; // persists
return 0;
}
fn bar() -> vec2u {
${f.expect_order(2)}
arr[0].x = 2; // no visible effect
arr[0].z = 3; // persists
return vec2u(4, 5); // will add to x,y
}
`,
}));
});