Validate stripIndexFormat at draw time.
Updates validation logic to match the recent changes in
https://github.com/gpuweb/gpuweb/pull/2385 that allows stripIndexFormat
to be undefined at pipeline creation time, even for strip topologies.
Non indexed draw calls are valid with such pipelines. Indexed draw calls
fail validation at draw time.
Bug: dawn:1224
Change-Id: I28ff78eac726d46f99a099ffb2338b5da81a4a88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/72000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
diff --git a/src/tests/unittests/validation/IndexBufferValidationTests.cpp b/src/tests/unittests/validation/IndexBufferValidationTests.cpp
index d1d62b3..7c05e961 100644
--- a/src/tests/unittests/validation/IndexBufferValidationTests.cpp
+++ b/src/tests/unittests/validation/IndexBufferValidationTests.cpp
@@ -155,6 +155,8 @@
wgpu::PrimitiveTopology::TriangleStrip);
wgpu::RenderPipeline pipeline16 = MakeTestPipeline(wgpu::IndexFormat::Uint16,
wgpu::PrimitiveTopology::LineStrip);
+ wgpu::RenderPipeline pipelineUndef =
+ MakeTestPipeline(wgpu::IndexFormat::Undefined, wgpu::PrimitiveTopology::LineStrip);
wgpu::Buffer indexBuffer =
utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Index, {0, 1, 2});
@@ -196,6 +198,31 @@
encoder.DrawIndexed(3);
encoder.Finish();
}
+
+ // Expected to fail because pipeline doesn't specify an index format.
+ {
+ wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
+ encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint16);
+ encoder.SetPipeline(pipelineUndef);
+ encoder.DrawIndexed(3);
+ ASSERT_DEVICE_ERROR(encoder.Finish());
+ }
+
+ {
+ wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
+ encoder.SetIndexBuffer(indexBuffer, wgpu::IndexFormat::Uint32);
+ encoder.SetPipeline(pipelineUndef);
+ encoder.DrawIndexed(3);
+ ASSERT_DEVICE_ERROR(encoder.Finish());
+ }
+
+ // Expected to succeed because non-indexed draw calls don't require a pipeline index format.
+ {
+ wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&renderBundleDesc);
+ encoder.SetPipeline(pipelineUndef);
+ encoder.Draw(3);
+ encoder.Finish();
+ }
}
// Check that the index buffer must have the Index usage.