summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/vertex_state/index_format.spec.ts
blob: 3815e0cd575ec09c328e7a31f7e3143c7b786e10 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
export const description = `
Test indexing, index format and primitive restart.
`;

import { makeTestGroup } from '../../../../common/framework/test_group.js';
import { GPUTest } from '../../../gpu_test.js';
import { getTextureCopyLayout } from '../../../util/texture/layout.js';

const kHeight = 4;
const kWidth = 8;
const kTextureFormat = 'r8uint' as const;

/** 4x4 grid of r8uint values (each 0 or 1). */
type Raster8x4 = readonly [
  readonly [0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1],
  readonly [0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1],
  readonly [0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1],
  readonly [0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1, 0 | 1]
];

/** Expected 4x4 rasterization of a bottom-left triangle. */
const kBottomLeftTriangle: Raster8x4 = [
  [0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 1, 0, 0, 0],
  [0, 0, 0, 0, 1, 1, 0, 0],
  [0, 0, 0, 0, 1, 1, 1, 0],
];

/** Expected 4x4 rasterization filling the whole quad. */
const kSquare: Raster8x4 = [
  [0, 0, 0, 0, 1, 1, 1, 1],
  [0, 0, 0, 0, 1, 1, 1, 1],
  [0, 0, 0, 0, 1, 1, 1, 1],
  [0, 0, 0, 0, 1, 1, 1, 1],
];

/** Expected 4x4 rasterization with no pixels. */
const kNothing: Raster8x4 = [
  [0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0],
];

const { byteLength, bytesPerRow, rowsPerImage } = getTextureCopyLayout(kTextureFormat, '2d', [
  kWidth,
  kHeight,
  1,
]);

class IndexFormatTest extends GPUTest {
  MakeRenderPipeline(
    topology: GPUPrimitiveTopology,
    stripIndexFormat?: GPUIndexFormat
  ): GPURenderPipeline {
    const vertexModule = this.device.createShaderModule({
      // NOTE: These positions will create triangles that cut right through pixel centers. If this
      // results in different rasterization results on different hardware, tweak to avoid this.
      code: `
        @vertex
        fn main(@builtin(vertex_index) VertexIndex : u32)
             -> @builtin(position) vec4<f32> {
          var pos = array<vec2<f32>, 4>(
            vec2<f32>(0.01,  0.98),
            vec2<f32>(0.99, -0.98),
            vec2<f32>(0.99,  0.98),
            vec2<f32>(0.01, -0.98));

          if (VertexIndex == 0xFFFFu || VertexIndex == 0xFFFFFFFFu) {
            return vec4<f32>(-0.99, -0.98, 0.0, 1.0);
          }
          return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
        }
      `,
    });

    const fragmentModule = this.device.createShaderModule({
      code: `
        @fragment
        fn main() -> @location(0) u32 {
          return 1u;
        }
      `,
    });

    return this.device.createRenderPipeline({
      layout: this.device.createPipelineLayout({ bindGroupLayouts: [] }),
      vertex: { module: vertexModule, entryPoint: 'main' },
      fragment: {
        module: fragmentModule,
        entryPoint: 'main',
        targets: [{ format: kTextureFormat }],
      },
      primitive: {
        topology,
        stripIndexFormat,
      },
    });
  }

  CreateIndexBuffer(indices: readonly number[], indexFormat: GPUIndexFormat): GPUBuffer {
    const typedArrayConstructor = { uint16: Uint16Array, uint32: Uint32Array }[indexFormat];
    return this.makeBufferWithContents(new typedArrayConstructor(indices), GPUBufferUsage.INDEX);
  }

  run(
    indexBuffer: GPUBuffer,
    indexCount: number,
    indexFormat: GPUIndexFormat,
    indexOffset: number = 0,
    primitiveTopology: GPUPrimitiveTopology = 'triangle-list'
  ): GPUBuffer {
    let pipeline: GPURenderPipeline;
    // The indexFormat must be set in render pipeline descriptor that specifies a strip primitive
    // topology for primitive restart testing
    if (primitiveTopology === 'line-strip' || primitiveTopology === 'triangle-strip') {
      pipeline = this.MakeRenderPipeline(primitiveTopology, indexFormat);
    } else {
      pipeline = this.MakeRenderPipeline(primitiveTopology);
    }

    const colorAttachment = this.device.createTexture({
      format: kTextureFormat,
      size: { width: kWidth, height: kHeight, depthOrArrayLayers: 1 },
      usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
    });

    const result = this.device.createBuffer({
      size: byteLength,
      usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
    });

    const encoder = this.device.createCommandEncoder();
    const pass = encoder.beginRenderPass({
      colorAttachments: [
        {
          view: colorAttachment.createView(),
          clearValue: [0, 0, 0, 0],
          loadOp: 'clear',
          storeOp: 'store',
        },
      ],
    });
    pass.setPipeline(pipeline);
    pass.setIndexBuffer(indexBuffer, indexFormat, indexOffset);
    pass.drawIndexed(indexCount);
    pass.end();
    encoder.copyTextureToBuffer(
      { texture: colorAttachment },
      { buffer: result, bytesPerRow, rowsPerImage },
      [kWidth, kHeight]
    );
    this.device.queue.submit([encoder.finish()]);

    return result;
  }

  CreateExpectedUint8Array(renderShape: Raster8x4): Uint8Array {
    const arrayBuffer = new Uint8Array(byteLength);
    for (let row = 0; row < renderShape.length; row++) {
      for (let col = 0; col < renderShape[row].length; col++) {
        const texel: 0 | 1 = renderShape[row][col];

        const kBytesPerTexel = 1; // r8uint
        const byteOffset = row * bytesPerRow + col * kBytesPerTexel;
        arrayBuffer[byteOffset] = texel;
      }
    }
    return arrayBuffer;
  }
}

export const g = makeTestGroup(IndexFormatTest);

g.test('index_format,uint16')
  .desc('Test rendering result of indexed draw with index format of uint16.')
  .paramsSubcasesOnly([
    { indexOffset: 0, _indexCount: 10, _expectedShape: kSquare },
    { indexOffset: 6, _indexCount: 6, _expectedShape: kBottomLeftTriangle },
    { indexOffset: 18, _indexCount: 0, _expectedShape: kNothing },
  ])
  .fn(t => {
    const { indexOffset, _indexCount, _expectedShape } = t.params;

    // If this is written as uint16 but interpreted as uint32, it will have index 1 and 2 be both 0
    // and render nothing.
    // And the index buffer size - offset must be not less than the size required by triangle
    // list, otherwise it also render nothing.
    const indices: number[] = [1, 2, 0, 0, 0, 0, 0, 1, 3, 0];
    const indexBuffer = t.CreateIndexBuffer(indices, 'uint16');
    const result = t.run(indexBuffer, _indexCount, 'uint16', indexOffset);

    const expectedTextureValues = t.CreateExpectedUint8Array(_expectedShape);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });

g.test('index_format,uint32')
  .desc('Test rendering result of indexed draw with index format of uint32.')
  .paramsSubcasesOnly([
    { indexOffset: 0, _indexCount: 10, _expectedShape: kSquare },
    { indexOffset: 12, _indexCount: 7, _expectedShape: kBottomLeftTriangle },
    { indexOffset: 36, _indexCount: 0, _expectedShape: kNothing },
  ])
  .fn(t => {
    const { indexOffset, _indexCount, _expectedShape } = t.params;

    // If this is interpreted as uint16, then it would be 0, 1, 0, ... and would draw nothing.
    // And the index buffer size - offset must be not less than the size required by triangle
    // list, otherwise it also render nothing.
    const indices: number[] = [1, 2, 0, 0, 0, 0, 0, 1, 3, 0];
    const indexBuffer = t.CreateIndexBuffer(indices, 'uint32');
    const result = t.run(indexBuffer, _indexCount, 'uint32', indexOffset);

    const expectedTextureValues = t.CreateExpectedUint8Array(_expectedShape);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });

g.test('index_format,change_pipeline_after_setIndexBuffer')
  .desc('Test that setting the index buffer before the pipeline works correctly.')
  .params(u => u.combine('setPipelineBeforeSetIndexBuffer', [false, true]))
  .fn(t => {
    const indexOffset = 12;
    const indexCount = 7;
    const expectedShape = kBottomLeftTriangle;

    const indexFormat16 = 'uint16';
    const indexFormat32 = 'uint32';

    const indices: number[] = [1, 2, 0, 0, 0, 0, 0, 1, 3, 0];
    const indexBuffer = t.CreateIndexBuffer(indices, indexFormat32);

    const kPrimitiveTopology = 'triangle-strip';
    const pipeline32 = t.MakeRenderPipeline(kPrimitiveTopology, indexFormat32);
    const pipeline16 = t.MakeRenderPipeline(kPrimitiveTopology, indexFormat16);

    const colorAttachment = t.device.createTexture({
      format: kTextureFormat,
      size: { width: kWidth, height: kHeight, depthOrArrayLayers: 1 },
      usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
    });

    const result = t.device.createBuffer({
      size: byteLength,
      usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
    });

    const encoder = t.device.createCommandEncoder();
    const pass = encoder.beginRenderPass({
      colorAttachments: [
        {
          view: colorAttachment.createView(),
          clearValue: [0, 0, 0, 0],
          loadOp: 'clear',
          storeOp: 'store',
        },
      ],
    });

    if (t.params.setPipelineBeforeSetIndexBuffer) {
      pass.setPipeline(pipeline16);
    }
    pass.setIndexBuffer(indexBuffer, indexFormat32, indexOffset);
    pass.setPipeline(pipeline32); // Set the pipeline for 'indexFormat32' again.
    pass.drawIndexed(indexCount);
    pass.end();
    encoder.copyTextureToBuffer(
      { texture: colorAttachment },
      { buffer: result, bytesPerRow, rowsPerImage },
      [kWidth, kHeight]
    );
    t.device.queue.submit([encoder.finish()]);

    const expectedTextureValues = t.CreateExpectedUint8Array(expectedShape);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });

g.test('index_format,setIndexBuffer_before_setPipeline')
  .desc('Test that setting the index buffer before the pipeline works correctly.')
  .params(u => u.combine('setIndexBufferBeforeSetPipeline', [false, true]))
  .fn(t => {
    const indexOffset = 12;
    const indexCount = 7;
    const expectedShape = kBottomLeftTriangle;

    const indexFormat = 'uint32';

    const indices: number[] = [1, 2, 0, 0, 0, 0, 0, 1, 3, 0];
    const indexBuffer = t.CreateIndexBuffer(indices, indexFormat);

    const kPrimitiveTopology = 'triangle-strip';
    const pipeline = t.MakeRenderPipeline(kPrimitiveTopology, indexFormat);

    const colorAttachment = t.device.createTexture({
      format: kTextureFormat,
      size: { width: kWidth, height: kHeight, depthOrArrayLayers: 1 },
      usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
    });

    const result = t.device.createBuffer({
      size: byteLength,
      usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
    });

    const encoder = t.device.createCommandEncoder();
    const pass = encoder.beginRenderPass({
      colorAttachments: [
        {
          view: colorAttachment.createView(),
          clearValue: [0, 0, 0, 0],
          loadOp: 'clear',
          storeOp: 'store',
        },
      ],
    });

    if (t.params.setIndexBufferBeforeSetPipeline) {
      pass.setIndexBuffer(indexBuffer, indexFormat, indexOffset);
      pass.setPipeline(pipeline);
    } else {
      pass.setPipeline(pipeline);
      pass.setIndexBuffer(indexBuffer, indexFormat, indexOffset);
    }

    pass.drawIndexed(indexCount);
    pass.end();
    encoder.copyTextureToBuffer(
      { texture: colorAttachment },
      { buffer: result, bytesPerRow, rowsPerImage },
      [kWidth, kHeight]
    );
    t.device.queue.submit([encoder.finish()]);

    const expectedTextureValues = t.CreateExpectedUint8Array(expectedShape);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });

g.test('index_format,setIndexBuffer_different_formats')
  .desc(
    `
  Test that index buffers of multiple formats can be used with a pipeline that doesn't use strip
  primitive topology.
  `
  )
  .fn(t => {
    const indices: number[] = [1, 2, 0, 0, 0, 0, 0, 1, 3, 0];

    // Create a pipeline to be used by different index formats.
    const kPrimitiveTopology = 'triangle-list';
    const pipeline = t.MakeRenderPipeline(kPrimitiveTopology);

    const expectedTextureValues = t.CreateExpectedUint8Array(kBottomLeftTriangle);

    const colorAttachment = t.device.createTexture({
      format: kTextureFormat,
      size: { width: kWidth, height: kHeight, depthOrArrayLayers: 1 },
      usage: GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
    });

    const result = t.device.createBuffer({
      size: byteLength,
      usage: GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST,
    });

    let encoder = t.device.createCommandEncoder();
    {
      const indexFormat = 'uint32';
      const indexOffset = 12;
      const indexCount = 7;
      const indexBuffer = t.CreateIndexBuffer(indices, indexFormat);

      const pass = encoder.beginRenderPass({
        colorAttachments: [
          {
            view: colorAttachment.createView(),
            clearValue: [0, 0, 0, 0],
            loadOp: 'clear',
            storeOp: 'store',
          },
        ],
      });

      pass.setIndexBuffer(indexBuffer, indexFormat, indexOffset);
      pass.setPipeline(pipeline);
      pass.drawIndexed(indexCount);
      pass.end();
      encoder.copyTextureToBuffer(
        { texture: colorAttachment },
        { buffer: result, bytesPerRow, rowsPerImage },
        [kWidth, kHeight]
      );
    }
    t.device.queue.submit([encoder.finish()]);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);

    // Call setIndexBuffer with the pipeline and a different index format buffer.
    encoder = t.device.createCommandEncoder();
    {
      const indexFormat = 'uint16';
      const indexOffset = 6;
      const indexCount = 6;
      const indexBuffer = t.CreateIndexBuffer(indices, indexFormat);

      const pass = encoder.beginRenderPass({
        colorAttachments: [
          {
            view: colorAttachment.createView(),
            clearValue: [0, 0, 0, 0],
            loadOp: 'clear',
            storeOp: 'store',
          },
        ],
      });

      pass.setIndexBuffer(indexBuffer, indexFormat, indexOffset);
      pass.setPipeline(pipeline);
      pass.drawIndexed(indexCount);
      pass.end();
      encoder.copyTextureToBuffer(
        { texture: colorAttachment },
        { buffer: result, bytesPerRow, rowsPerImage },
        [kWidth, kHeight]
      );
    }
    t.device.queue.submit([encoder.finish()]);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });

g.test('primitive_restart')
  .desc(
    `
Test primitive restart with each primitive topology.

Primitive restart should be always active with strip primitive topologies
('line-strip' or 'triangle-strip') and never active for other topologies, where
the primitive restart value isn't special and should be treated as a regular index value.

The value -1 gets uploaded as 0xFFFF or 0xFFFF_FFFF according to the format.

The positions of these points are embedded in the shader above, and look like this:
  |   0  2|
  |       |
  -1  3  1|

Below are the indices lists used for each test, and the expected rendering result of each
(approximately, in the case of incorrect results). This shows the expected result (marked '->')
is different from what you would get if the topology were incorrect.

- primitiveTopology: triangle-list
  indices: [0, 1, 3, -1, 2, 1, 0, 0],
   -> triangle-list:              (0, 1, 3), (-1, 2, 1)
        |    #  #|
        |    ####|
        |   #####|
        | #######|
      triangle-list with restart: (0, 1, 3), (2, 1, 0)
      triangle-strip:             (0, 1, 3), (2, 1, 0), (1, 0, 0)
        |    ####|
        |    ####|
        |    ####|
        |    ####|
      triangle-strip w/o restart: (0, 1, 3), (1, 3, -1), (3, -1, 2), (-1, 2, 1), (2, 1, 0), (1, 0, 0)
        |    ####|
        |    ####|
        |   #####|
        | #######|

- primitiveTopology: triangle-strip
  indices: [3, 1, 0, -1, 2, 2, 1, 3],
   -> triangle-strip:             (3, 1, 0), (2, 2, 1), (2, 1, 3)
        |    #  #|
        |    ####|
        |    ####|
        |    ####|
      triangle-strip w/o restart: (3, 1, 0), (1, 0, -1), (0, -1, 2), (2, 2, 1), (2, 3, 1)
        |    ####|
        |   #####|
        |  ######|
        | #######|
      triangle-list:              (3, 1, 0), (-1, 2, 2)
      triangle-list with restart: (3, 1, 0), (2, 2, 1)
        |        |
        |    #   |
        |    ##  |
        |    ### |

- primitiveTopology: point, line-list, line-strip:
  indices: [0, 1, -1, 2, -1, 2, 3, 0],
   -> point-list:             (0), (1), (-1), (2), (3), (0)
        |    #  #|
        |        |
        |        |
        |#   #  #|
      point-list with restart (0), (1), (2), (3), (0)
        |    #  #|
        |        |
        |        |
        |    #  #|
   -> line-list:              (0, 1), (-1, 2), (3, 0)
        |    # ##|
        |    ##  |
        |  ### # |
        |##  #  #|
      line-list with restart: (0, 1), (2, 3)
        |    #  #|
        |     ## |
        |     ## |
        |    #  #|
   -> line-strip:             (0, 1), (2, 3), (3, 0)
        |    #  #|
        |    ### |
        |    ### |
        |    #  #|
      line-strip w/o restart: (0, 1), (1, -1), (-1, 2), (2, 3), (3, 3)
        |    # ##|
        |    ### |
        |  ## ## |
        |########|
`
  )
  .params(u =>
    u //
      .combine('indexFormat', ['uint16', 'uint32'] as const)
      .combineWithParams([
        {
          primitiveTopology: 'point-list',
          _indices: [0, 1, -1, 2, 3, 0],
          _expectedShape: [
            [0, 0, 0, 0, 1, 0, 0, 1],
            [0, 0, 0, 0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0, 0],
            [1, 0, 0, 0, 1, 0, 0, 1],
          ],
        },
        {
          primitiveTopology: 'line-list',
          _indices: [0, 1, -1, 2, 3, 0],
          _expectedShape: [
            [0, 0, 0, 0, 1, 0, 1, 1],
            [0, 0, 0, 0, 1, 1, 0, 0],
            [0, 0, 1, 1, 1, 0, 1, 0],
            [1, 1, 0, 0, 1, 0, 0, 1],
          ],
        },
        {
          primitiveTopology: 'line-strip',
          _indices: [0, 1, -1, 2, 3, 0],
          _expectedShape: [
            [0, 0, 0, 0, 1, 0, 0, 1],
            [0, 0, 0, 0, 1, 1, 1, 0],
            [0, 0, 0, 0, 1, 1, 1, 0],
            [0, 0, 0, 0, 1, 0, 0, 1],
          ],
        },
        {
          primitiveTopology: 'triangle-list',
          _indices: [0, 1, 3, -1, 2, 1, 0, 0],
          _expectedShape: [
            [0, 0, 0, 0, 0, 0, 0, 1],
            [0, 0, 0, 0, 1, 1, 1, 1],
            [0, 0, 0, 1, 1, 1, 1, 1],
            [0, 1, 1, 1, 1, 1, 1, 1],
          ],
        },
        {
          primitiveTopology: 'triangle-strip',
          _indices: [3, 1, 0, -1, 2, 2, 1, 3],
          _expectedShape: [
            [0, 0, 0, 0, 0, 0, 0, 1],
            [0, 0, 0, 0, 1, 0, 1, 1],
            [0, 0, 0, 0, 1, 1, 1, 1],
            [0, 0, 0, 0, 1, 1, 1, 1],
          ],
        },
      ] as const)
  )
  .fn(t => {
    const { indexFormat, primitiveTopology, _indices, _expectedShape } = t.params;

    const indexBuffer = t.CreateIndexBuffer(_indices, indexFormat);
    const result = t.run(indexBuffer, _indices.length, indexFormat, 0, primitiveTopology);

    const expectedTextureValues = t.CreateExpectedUint8Array(_expectedShape);
    t.expectGPUBufferValuesEqual(result, expectedTextureValues);
  });