Skip to content

Commit d6613a5

Browse files
authored
Detect invalid end() in "pass_end_invalid_order" (gpuweb#4501)
Calling end() on an already ended or invalid pass should generate a device error. Detect these cases in pass_end_invalid_order and expect a validation error in these cases.
1 parent c62b162 commit d6613a5

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/webgpu/api/validation/encoding/encoder_state.spec.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ TODO:
1717
`;
1818

1919
import { makeTestGroup } from '../../../../common/framework/test_group.js';
20-
import { objectEquals } from '../../../../common/util/util.js';
2120
import { AllFeaturesMaxLimitsGPUTest } from '../../../gpu_test.js';
2221

2322
class F extends AllFeaturesMaxLimitsGPUTest {
@@ -51,9 +50,6 @@ g.test('pass_end_invalid_order')
5150
`
5251
Test that beginning a {compute,render} pass before ending the previous {compute,render} pass
5352
causes an error.
54-
55-
TODO(https://github.com/gpuweb/gpuweb/issues/5207): Resolve whether a validation error
56-
should be raised immediately if '!firstPassEnd && endPasses = [1, 0]'.
5753
`
5854
)
5955
.params(u =>
@@ -63,8 +59,6 @@ g.test('pass_end_invalid_order')
6359
.beginSubcases()
6460
.combine('firstPassEnd', [true, false])
6561
.combine('endPasses', [[], [0], [1], [0, 1], [1, 0]])
66-
// Don't end the first pass multiple times (that generates a validation error but doesn't invalidate the encoder)
67-
.unless(p => p.firstPassEnd && p.endPasses.includes(0))
6862
)
6963
.fn(t => {
7064
const { pass0Type, pass1Type, firstPassEnd, endPasses } = t.params;
@@ -83,15 +77,16 @@ g.test('pass_end_invalid_order')
8377

8478
const passes = [firstPass, secondPass];
8579
for (const index of endPasses) {
86-
passes[index].end();
80+
const validEnd = (index === 0 && !firstPassEnd) || (index === 1 && firstPassEnd);
81+
t.expectValidationError(() => {
82+
passes[index].end();
83+
}, !validEnd);
8784
}
8885

89-
// If {endPasses} is '[1]' and {firstPass} ends, it's a control case.
90-
const valid = firstPassEnd && objectEquals(endPasses, [1]);
91-
86+
const validFinish = firstPassEnd && endPasses.includes(1);
9287
t.expectValidationError(() => {
9388
encoder.finish();
94-
}, !valid);
89+
}, !validFinish);
9590
});
9691

9792
g.test('call_after_successful_finish')

0 commit comments

Comments
 (0)