summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/texture/rg11b10ufloat_renderable.spec.ts
blob: 3b9b58ffa7ea2c23ee33bd3e79056f881a443a95 (plain)
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
export const description = `
Tests for capabilities added by rg11b10ufloat-renderable flag.
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { GPUConst } from '../../../constants.js';
import { ValidationTest } from '../validation_test.js';

export const g = makeTestGroup(ValidationTest);

g.test('create_texture')
  .desc(
    `
Test that it is valid to create rg11b10ufloat texture with RENDER_ATTACHMENT usage and/or
sampleCount > 1, iff rg11b10ufloat-renderable feature is enabled.
Note, the createTexture tests cover these validation cases where this feature is not enabled.
`
  )
  .params(u => u.combine('sampleCount', [1, 4]))
  .beforeAllSubcases(t => {
    t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
  })
  .fn(async t => {
    const { sampleCount } = t.params;
    const descriptor = {
      size: [1, 1, 1],
      format: 'rg11b10ufloat' as const,
      sampleCount,
      usage: GPUConst.TextureUsage.RENDER_ATTACHMENT,
    };
    t.device.createTexture(descriptor);
  });

g.test('begin_render_pass')
  .desc(
    `
Test that it is valid to begin render pass with rg11b10ufloat texture format
iff rg11b10ufloat-renderable feature is enabled.
`
  )
  .beforeAllSubcases(t => {
    t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
  })
  .fn(async t => {
    const texture = t.device.createTexture({
      size: [1, 1, 1],
      format: 'rg11b10ufloat',
      sampleCount: 1,
      usage: GPUConst.TextureUsage.RENDER_ATTACHMENT,
    });
    const encoder = t.device.createCommandEncoder();
    encoder.beginRenderPass({
      colorAttachments: [
        {
          view: texture.createView(),
          clearValue: { r: 1.0, g: 0.0, b: 0.0, a: 1.0 },
          loadOp: 'clear',
          storeOp: 'store',
        },
      ],
    });
  });

g.test('begin_render_bundle_encoder')
  .desc(
    `
Test that it is valid to begin render bundle encoder with rg11b10ufloat texture
format iff rg11b10ufloat-renderable feature is enabled.
`
  )
  .beforeAllSubcases(t => {
    t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
  })
  .fn(async t => {
    t.device.createRenderBundleEncoder({
      colorFormats: ['rg11b10ufloat'],
    });
  });

g.test('create_render_pipeline')
  .desc(
    `
Test that it is valid to create render pipeline with rg11b10ufloat texture format
in descriptor.fragment.targets iff rg11b10ufloat-renderable feature is enabled.
`
  )
  .beforeAllSubcases(t => {
    t.selectDeviceOrSkipTestCase('rg11b10ufloat-renderable');
  })
  .fn(async t => {
    t.device.createRenderPipeline({
      layout: 'auto',
      vertex: {
        module: t.device.createShaderModule({
          code: t.getNoOpShaderCode('VERTEX'),
        }),
        entryPoint: 'main',
      },
      fragment: {
        module: t.device.createShaderModule({
          code: t.getNoOpShaderCode('FRAGMENT'),
        }),
        entryPoint: 'main',
        targets: [{ format: 'rg11b10ufloat', writeMask: 0 }],
      },
      primitive: { topology: 'triangle-list' },
    });
  });