1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
export const description = `Tests writeTexture validation.`;
import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { GPUConst } from '../../../constants.js';
import { kResourceStates } from '../../../gpu_test.js';
import { ValidationTest } from '../validation_test.js';
export const g = makeTestGroup(ValidationTest);
g.test('texture_state')
.desc(
`
Test that the texture used for GPUQueue.writeTexture() must be valid. Tests calling writeTexture
with {valid, invalid, destroyed} texture.
`
)
.params(u => u.combine('textureState', kResourceStates))
.fn(async t => {
const { textureState } = t.params;
const texture = t.createTextureWithState(textureState);
const data = new Uint8Array(16);
const size = [1, 1];
const isValid = textureState === 'valid';
t.expectValidationError(() => {
t.device.queue.writeTexture({ texture }, data, {}, size);
}, !isValid);
});
g.test('usages')
.desc(
`
Tests calling writeTexture with the texture missed COPY_DST usage.
- texture {with, without} COPY DST usage
`
)
.paramsSubcasesOnly([
{ usage: GPUConst.TextureUsage.COPY_DST }, // control case
{ usage: GPUConst.TextureUsage.STORAGE_BINDING },
{ usage: GPUConst.TextureUsage.STORAGE_BINDING | GPUConst.TextureUsage.COPY_SRC },
{ usage: GPUConst.TextureUsage.STORAGE_BINDING | GPUConst.TextureUsage.COPY_DST },
])
.fn(async t => {
const { usage } = t.params;
const texture = t.device.createTexture({
size: { width: 16, height: 16 },
usage,
format: 'rgba8unorm' as const,
});
const data = new Uint8Array(16);
const size = [1, 1];
const isValid = usage & GPUConst.TextureUsage.COPY_DST ? true : false;
t.expectValidationError(() => {
t.device.queue.writeTexture({ texture }, data, {}, size);
}, !isValid);
});
g.test('sample_count')
.desc(
`
Test that the texture sample count. Check that a validation error is generated if sample count is
not 1.
`
)
.params(u => u.combine('sampleCount', [1, 4]))
.fn(async t => {
const { sampleCount } = t.params;
const texture = t.device.createTexture({
size: { width: 16, height: 16 },
sampleCount,
format: 'bgra8unorm',
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,
});
const data = new Uint8Array(16);
const size = [1, 1];
const isValid = sampleCount === 1;
t.expectValidationError(() => {
t.device.queue.writeTexture({ texture }, data, {}, size);
}, !isValid);
});
g.test('texture,device_mismatch')
.desc('Tests writeTexture cannot be called with a texture created from another device.')
.paramsSubcasesOnly(u => u.combine('mismatched', [true, false]))
.beforeAllSubcases(t => {
t.selectMismatchedDeviceOrSkipTestCase(undefined);
})
.fn(async t => {
const { mismatched } = t.params;
const sourceDevice = mismatched ? t.mismatchedDevice : t.device;
const texture = sourceDevice.createTexture({
size: { width: 16, height: 16 },
format: 'bgra8unorm',
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,
});
t.trackForCleanup(texture);
const data = new Uint8Array(16);
const size = [1, 1];
t.expectValidationError(() => {
t.device.queue.writeTexture({ texture }, data, {}, size);
}, mismatched);
});
|