|
| 1 | +export const description = ` |
| 2 | +Tests using a destroyed texture on a queue. |
| 3 | +
|
| 4 | +TODO: |
| 5 | +- test renderPass/computePass (setBindGroup) |
| 6 | +- test beginRenderPass target |
| 7 | +`; |
| 8 | + |
| 9 | +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; |
| 10 | +import { ValidationTest } from '../../validation_test.js'; |
| 11 | + |
| 12 | +export const g = makeTestGroup(ValidationTest); |
| 13 | + |
| 14 | +g.test('writeTexture') |
| 15 | + .desc( |
| 16 | + ` |
| 17 | +Tests that using a destroyed texture in writeTexture fails. |
| 18 | +- x= {destroyed, not destroyed (control case)} |
| 19 | + ` |
| 20 | + ) |
| 21 | + .paramsSubcasesOnly(u => u.combine('destroyed', [false, true] as const)) |
| 22 | + .fn(t => { |
| 23 | + const { destroyed } = t.params; |
| 24 | + const texture = t.trackForCleanup( |
| 25 | + t.device.createTexture({ |
| 26 | + size: [1, 1, 1], |
| 27 | + format: 'rgba8unorm', |
| 28 | + usage: GPUTextureUsage.COPY_DST, |
| 29 | + }) |
| 30 | + ); |
| 31 | + |
| 32 | + if (destroyed) { |
| 33 | + texture.destroy(); |
| 34 | + } |
| 35 | + |
| 36 | + t.expectValidationError( |
| 37 | + () => t.queue.writeTexture({ texture }, new Uint8Array(4), { bytesPerRow: 4 }, [1, 1, 1]), |
| 38 | + destroyed |
| 39 | + ); |
| 40 | + }); |
| 41 | + |
| 42 | +g.test('copyTextureToTexture') |
| 43 | + .desc( |
| 44 | + ` |
| 45 | +Tests that using a destroyed texture in copyTextureToTexture fails. |
| 46 | +- x= {not destroyed (control case), src destroyed, dst destroyed} |
| 47 | + ` |
| 48 | + ) |
| 49 | + .paramsSubcasesOnly(u => u.combine('destroyed', ['none', 'src', 'dst', 'both'] as const)) |
| 50 | + .fn(t => { |
| 51 | + const src = t.trackForCleanup( |
| 52 | + t.device.createTexture({ |
| 53 | + size: [1, 1, 1], |
| 54 | + format: 'rgba8unorm', |
| 55 | + usage: GPUTextureUsage.COPY_SRC, |
| 56 | + }) |
| 57 | + ); |
| 58 | + const dst = t.trackForCleanup( |
| 59 | + t.device.createTexture({ |
| 60 | + size: [1, 1, 1], |
| 61 | + format: 'rgba8unorm', |
| 62 | + usage: GPUTextureUsage.COPY_DST, |
| 63 | + }) |
| 64 | + ); |
| 65 | + |
| 66 | + const encoder = t.device.createCommandEncoder(); |
| 67 | + encoder.copyTextureToTexture({ texture: src }, { texture: dst }, [1, 1, 1]); |
| 68 | + const commandBuffer = encoder.finish(); |
| 69 | + |
| 70 | + let shouldError = true; |
| 71 | + switch (t.params.destroyed) { |
| 72 | + case 'none': |
| 73 | + shouldError = false; |
| 74 | + break; |
| 75 | + case 'src': |
| 76 | + src.destroy(); |
| 77 | + break; |
| 78 | + case 'dst': |
| 79 | + dst.destroy(); |
| 80 | + break; |
| 81 | + case 'both': |
| 82 | + src.destroy(); |
| 83 | + dst.destroy(); |
| 84 | + break; |
| 85 | + } |
| 86 | + |
| 87 | + t.expectValidationError(() => { |
| 88 | + t.queue.submit([commandBuffer]); |
| 89 | + }, shouldError); |
| 90 | + }); |
| 91 | + |
| 92 | +g.test('copyBufferToTexture') |
| 93 | + .desc( |
| 94 | + ` |
| 95 | +Tests that using a destroyed texture in copyBufferToTexture fails. |
| 96 | +- x= {not destroyed (control case), dst destroyed} |
| 97 | + ` |
| 98 | + ) |
| 99 | + .paramsSubcasesOnly(u => u.combine('destroyed', [false, true] as const)) |
| 100 | + .fn(t => { |
| 101 | + const { destroyed } = t.params; |
| 102 | + const buffer = t.trackForCleanup( |
| 103 | + t.device.createBuffer({ size: 4, usage: GPUBufferUsage.COPY_SRC }) |
| 104 | + ); |
| 105 | + const texture = t.trackForCleanup( |
| 106 | + t.device.createTexture({ |
| 107 | + size: [1, 1, 1], |
| 108 | + format: 'rgba8unorm', |
| 109 | + usage: GPUTextureUsage.COPY_DST, |
| 110 | + }) |
| 111 | + ); |
| 112 | + |
| 113 | + const encoder = t.device.createCommandEncoder(); |
| 114 | + encoder.copyBufferToTexture({ buffer }, { texture }, [1, 1, 1]); |
| 115 | + const commandBuffer = encoder.finish(); |
| 116 | + |
| 117 | + if (destroyed) { |
| 118 | + texture.destroy(); |
| 119 | + } |
| 120 | + |
| 121 | + t.expectValidationError(() => { |
| 122 | + t.queue.submit([commandBuffer]); |
| 123 | + }, destroyed); |
| 124 | + }); |
| 125 | + |
| 126 | +g.test('copyTextureToBuffer') |
| 127 | + .desc( |
| 128 | + ` |
| 129 | +Tests that using a destroyed texture in copyTextureToBuffer fails. |
| 130 | +- x= {not destroyed (control case), src destroyed} |
| 131 | + ` |
| 132 | + ) |
| 133 | + .paramsSubcasesOnly(u => u.combine('destroyed', [false, true] as const)) |
| 134 | + .fn(t => { |
| 135 | + const { destroyed } = t.params; |
| 136 | + const texture = t.trackForCleanup( |
| 137 | + t.device.createTexture({ |
| 138 | + size: [1, 1, 1], |
| 139 | + format: 'rgba8unorm', |
| 140 | + usage: GPUTextureUsage.COPY_SRC, |
| 141 | + }) |
| 142 | + ); |
| 143 | + const buffer = t.trackForCleanup( |
| 144 | + t.device.createBuffer({ size: 4, usage: GPUBufferUsage.COPY_DST }) |
| 145 | + ); |
| 146 | + |
| 147 | + const encoder = t.device.createCommandEncoder(); |
| 148 | + encoder.copyTextureToBuffer({ texture }, { buffer }, [1, 1, 1]); |
| 149 | + const commandBuffer = encoder.finish(); |
| 150 | + |
| 151 | + if (destroyed) { |
| 152 | + texture.destroy(); |
| 153 | + } |
| 154 | + |
| 155 | + t.expectValidationError(() => { |
| 156 | + t.queue.submit([commandBuffer]); |
| 157 | + }, destroyed); |
| 158 | + }); |
0 commit comments