|
| 1 | +export const description = ` |
| 2 | +Tests for capability checking for the 'texture-formats-tier1' feature. |
| 3 | +
|
| 4 | +Test that enabling texture-formats-tier1 also enables rg11b10ufloat-renderable |
| 5 | +
|
| 6 | +Tests that abilities enabled by 'texture-formats-tier1' correctly generate validation errors |
| 7 | +when the feature is not enabled. This includes: |
| 8 | +- RENDER_ATTACHMENT usage for formats gaining this capability. |
| 9 | +- Multisample usage for formats gaining this capability. |
| 10 | +- Blendability for formats gaining this capability. |
| 11 | +- Resolvability for formats gaining this capability. |
| 12 | +- STORAGE_BINDING usage for formats gaining this capability. |
| 13 | +`; |
| 14 | + |
| 15 | +import { makeTestGroup } from '../../../../../common/framework/test_group.js'; |
| 16 | +import { |
| 17 | + kTextureFormatTier1AllowsRenderAttachmentBlendableMultisampleResolve, |
| 18 | + kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly, |
| 19 | +} from '../../../../format_info.js'; |
| 20 | +import { UniqueFeaturesOrLimitsGPUTest } from '../../../../gpu_test.js'; |
| 21 | +import * as vtu from '../../validation_test_utils.js'; |
| 22 | + |
| 23 | +export const g = makeTestGroup(UniqueFeaturesOrLimitsGPUTest); |
| 24 | + |
| 25 | +g.test('enables_rg11b10ufloat_renderable') |
| 26 | + .desc( |
| 27 | + ` |
| 28 | + Test that enabling texture-formats-tier1 also enables rg11b10ufloat-renderable |
| 29 | + ` |
| 30 | + ) |
| 31 | + .beforeAllSubcases(t => t.selectDeviceOrSkipTestCase('texture-formats-tier1')) |
| 32 | + .fn(t => { |
| 33 | + t.expect(() => t.device.features.has('rg11b10ufloat-renderable')); |
| 34 | + }); |
| 35 | + |
| 36 | +g.test('texture_usage,render_attachment') |
| 37 | + .desc( |
| 38 | + ` |
| 39 | + Test creating a texture with RENDER_ATTACHMENT usage and a format enabled by |
| 40 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 41 | + ` |
| 42 | + ) |
| 43 | + .params(u => |
| 44 | + u |
| 45 | + .combine('format', kTextureFormatTier1AllowsRenderAttachmentBlendableMultisampleResolve) |
| 46 | + .combine('enable_feature', [true, false]) |
| 47 | + ) |
| 48 | + .beforeAllSubcases(t => { |
| 49 | + const { enable_feature } = t.params; |
| 50 | + if (enable_feature) { |
| 51 | + t.selectDeviceOrSkipTestCase('texture-formats-tier1'); |
| 52 | + } |
| 53 | + }) |
| 54 | + .fn(t => { |
| 55 | + const { format, enable_feature } = t.params; |
| 56 | + |
| 57 | + t.expectValidationError(() => { |
| 58 | + t.createTextureTracked({ |
| 59 | + format, |
| 60 | + size: [1, 1, 1], |
| 61 | + usage: GPUTextureUsage.RENDER_ATTACHMENT, |
| 62 | + }); |
| 63 | + }, !enable_feature); |
| 64 | + }); |
| 65 | + |
| 66 | +g.test('texture_usage,multisample') |
| 67 | + .desc( |
| 68 | + ` |
| 69 | + Test creating a multisampled texture with a format enabled by |
| 70 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 71 | + ` |
| 72 | + ) |
| 73 | + .params(u => |
| 74 | + u |
| 75 | + .combine('format', kTextureFormatTier1AllowsRenderAttachmentBlendableMultisampleResolve) |
| 76 | + .combine('enable_feature', [true, false]) |
| 77 | + ) |
| 78 | + .beforeAllSubcases(t => { |
| 79 | + const { enable_feature } = t.params; |
| 80 | + if (enable_feature) { |
| 81 | + t.selectDeviceOrSkipTestCase('texture-formats-tier1'); |
| 82 | + } |
| 83 | + }) |
| 84 | + .fn(t => { |
| 85 | + const { format, enable_feature } = t.params; |
| 86 | + |
| 87 | + t.expectValidationError(() => { |
| 88 | + t.createTextureTracked({ |
| 89 | + format, |
| 90 | + size: [1, 1, 1], |
| 91 | + usage: GPUTextureUsage.RENDER_ATTACHMENT, |
| 92 | + sampleCount: 4, |
| 93 | + }); |
| 94 | + }, !enable_feature); |
| 95 | + }); |
| 96 | + |
| 97 | +g.test('texture_usage,storage_binding') |
| 98 | + .desc( |
| 99 | + ` |
| 100 | + Test creating a texture with STORAGE_BINDING usage and a format enabled by |
| 101 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 102 | + ` |
| 103 | + ) |
| 104 | + .params(u => |
| 105 | + u |
| 106 | + .combine('format', kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly) |
| 107 | + .combine('enable_feature', [true, false]) |
| 108 | + ) |
| 109 | + .beforeAllSubcases(t => { |
| 110 | + const { enable_feature } = t.params; |
| 111 | + if (enable_feature) { |
| 112 | + t.selectDeviceOrSkipTestCase('texture-formats-tier1'); |
| 113 | + } |
| 114 | + }) |
| 115 | + .fn(t => { |
| 116 | + const { format, enable_feature } = t.params; |
| 117 | + |
| 118 | + t.expectValidationError(() => { |
| 119 | + t.createTextureTracked({ |
| 120 | + format, |
| 121 | + size: [1, 1, 1], |
| 122 | + usage: GPUTextureUsage.STORAGE_BINDING, |
| 123 | + }); |
| 124 | + }, !enable_feature); |
| 125 | + }); |
| 126 | + |
| 127 | +g.test('render_pipeline,color_target') |
| 128 | + .desc( |
| 129 | + ` |
| 130 | + Test creating a render pipeline with a color target format enabled by |
| 131 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 132 | + This covers RENDER_ATTACHMENT, blendable, and multisample capabilities. |
| 133 | +
|
| 134 | + Note: it's not clear it's possible to check blendable and multisample |
| 135 | + as most likely there will be an error for RENDER_ATTACHMENT first. |
| 136 | + ` |
| 137 | + ) |
| 138 | + .params(u => |
| 139 | + u |
| 140 | + .combine('isAsync', [false, true]) |
| 141 | + .combine('format', [ |
| 142 | + 'rgba8unorm', |
| 143 | + ...kTextureFormatTier1AllowsRenderAttachmentBlendableMultisampleResolve, |
| 144 | + ] as const) |
| 145 | + .combine('enable_feature', [true, false]) |
| 146 | + .combine('check', ['RENDER_ATTACHMENT', 'blendable', 'multisample'] as const) |
| 147 | + ) |
| 148 | + .beforeAllSubcases(t => { |
| 149 | + const { enable_feature } = t.params; |
| 150 | + if (enable_feature) { |
| 151 | + t.selectDeviceOrSkipTestCase('texture-formats-tier1'); |
| 152 | + } |
| 153 | + }) |
| 154 | + .fn(t => { |
| 155 | + const { isAsync, format, enable_feature, check } = t.params; |
| 156 | + |
| 157 | + const pipelineDescriptor: GPURenderPipelineDescriptor = { |
| 158 | + layout: 'auto', |
| 159 | + vertex: { |
| 160 | + module: t.device.createShaderModule({ |
| 161 | + code: ` |
| 162 | + @vertex |
| 163 | + fn main()-> @builtin(position) vec4<f32> { |
| 164 | + return vec4<f32>(0.0, 0.0, 0.0, 1.0); |
| 165 | + }`, |
| 166 | + }), |
| 167 | + entryPoint: 'main', |
| 168 | + }, |
| 169 | + fragment: { |
| 170 | + module: t.device.createShaderModule({ |
| 171 | + code: ` |
| 172 | + @fragment |
| 173 | + fn main() -> @location(0) vec4<f32> { |
| 174 | + return vec4<f32>(0.0, 1.0, 0.0, 1.0); |
| 175 | + }`, |
| 176 | + }), |
| 177 | + entryPoint: 'main', |
| 178 | + targets: [{ format }], |
| 179 | + }, |
| 180 | + }; |
| 181 | + const target0 = (pipelineDescriptor.fragment!.targets as GPUColorTargetState[])[0]; |
| 182 | + |
| 183 | + if (check === 'multisample') { |
| 184 | + pipelineDescriptor.multisample = { count: 4 }; |
| 185 | + } |
| 186 | + |
| 187 | + if (check === 'blendable') { |
| 188 | + target0.blend = { |
| 189 | + color: { operation: 'add', srcFactor: 'one', dstFactor: 'zero' }, |
| 190 | + alpha: { operation: 'add', srcFactor: 'one', dstFactor: 'zero' }, |
| 191 | + }; |
| 192 | + } |
| 193 | + |
| 194 | + vtu.doCreateRenderPipelineTest( |
| 195 | + t, |
| 196 | + isAsync, |
| 197 | + enable_feature || format === 'rgba8unorm', |
| 198 | + pipelineDescriptor, |
| 199 | + 'GPUPipelineError' |
| 200 | + ); |
| 201 | + }); |
| 202 | + |
| 203 | +g.test('render_pass,resolvable') |
| 204 | + .desc( |
| 205 | + ` |
| 206 | + Test creating a render pass with resolve with a color target format enabled by |
| 207 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 208 | +
|
| 209 | + It's not clear this can be tested because you won't be able to create a render pipeline |
| 210 | + that passes validation which you need before you can create a render pass that resolves. |
| 211 | + ` |
| 212 | + ) |
| 213 | + .unimplemented(); |
| 214 | + |
| 215 | +g.test('bind_group_layout,storage_texture') |
| 216 | + .desc( |
| 217 | + ` |
| 218 | + Test creating a bind group layout with a storage texture binding format enabled by |
| 219 | + 'texture-formats-tier1' fails if the feature is not enabled. |
| 220 | + ` |
| 221 | + ) |
| 222 | + .params(u => |
| 223 | + u |
| 224 | + .combine('format', kTextureFormatsTier1EnablesStorageReadOnlyWriteOnly) |
| 225 | + .combine('access', ['read-only', 'write-only'] as const) // Tier1 enables read-only/write-only for these |
| 226 | + .combine('enable_feature', [true, false]) |
| 227 | + ) |
| 228 | + .beforeAllSubcases(t => { |
| 229 | + const { enable_feature } = t.params; |
| 230 | + if (enable_feature) { |
| 231 | + t.selectDeviceOrSkipTestCase('texture-formats-tier1'); |
| 232 | + } |
| 233 | + }) |
| 234 | + .fn(t => { |
| 235 | + const { format, access, enable_feature } = t.params; |
| 236 | + |
| 237 | + t.expectValidationError(() => { |
| 238 | + t.device.createBindGroupLayout({ |
| 239 | + entries: [ |
| 240 | + { |
| 241 | + binding: 0, |
| 242 | + visibility: GPUShaderStage.COMPUTE, |
| 243 | + storageTexture: { |
| 244 | + format, |
| 245 | + access, |
| 246 | + }, |
| 247 | + }, |
| 248 | + ], |
| 249 | + }); |
| 250 | + }, !enable_feature); |
| 251 | + }); |
0 commit comments