mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
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:
committed by
Commit Bot service account
parent
320c6c87b2
commit
8575cb3ec7
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user