Add setIndexBufferWithFormat method

First step of a multi-part change to bring the setIndexBuffer
method up-to-date with the current WebGPU spec. This change
preserves the previous setIndexBuffer semantics for backwards
compatibility until developers have been notified and given
a grace period to transition to the new signature.

BUG=dawn:502
Change-Id: Ia8c665639494d244f52296ceadaedb320fa6c985
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/27182
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Brandon Jones
2020-08-27 01:13:35 +00:00
committed by Commit Bot service account
parent 320c6c87b2
commit 8575cb3ec7
27 changed files with 492 additions and 106 deletions

View File

@@ -526,3 +526,60 @@ TEST_F(RenderPipelineValidationTest, MultisampledTexture) {
})");
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
// Tests that strip primitive topologies require an index format
TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
constexpr uint32_t kNumStripType = 2u;
constexpr uint32_t kNumListType = 3u;
constexpr uint32_t kNumIndexFormat = 3u;
std::array<wgpu::PrimitiveTopology, kNumStripType> kStripTopologyTypes = {{
wgpu::PrimitiveTopology::LineStrip,
wgpu::PrimitiveTopology::TriangleStrip
}};
std::array<wgpu::PrimitiveTopology, kNumListType> kListTopologyTypes = {{
wgpu::PrimitiveTopology::PointList,
wgpu::PrimitiveTopology::LineList,
wgpu::PrimitiveTopology::TriangleList
}};
std::array<wgpu::IndexFormat, kNumIndexFormat> kIndexFormatTypes = {{
wgpu::IndexFormat::Undefined,
wgpu::IndexFormat::Uint16,
wgpu::IndexFormat::Uint32
}};
for (wgpu::PrimitiveTopology primitiveTopology : kStripTopologyTypes) {
for (wgpu::IndexFormat indexFormat : kIndexFormatTypes) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexState.indexFormat = indexFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Fail because the index format is undefined and the primitive
// topology is a strip type.
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
} else {
// Succeeds because the index format is given.
device.CreateRenderPipeline(&descriptor);
}
}
}
for (wgpu::PrimitiveTopology primitiveTopology : kListTopologyTypes) {
for (wgpu::IndexFormat indexFormat : kIndexFormatTypes) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexState.indexFormat = indexFormat;
// Succeeds even when the index format is undefined because the
// primitive topology isn't a strip type.
device.CreateRenderPipeline(&descriptor);
}
}
}