Lower the maxVertexBuffer limit to 8.

This is to match the upstream WebGPU specification.

Also remove maxVertexAttributeEnd in favor maxVertexBufferStride.

Bug:dawn:678
Change-Id: Ia498ff522ba257d40e9ddd6e145a0ba77f6753ca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41182
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2021-02-10 19:47:13 +00:00 committed by Commit Bot service account
parent 725e03b0c9
commit fb3991e7d2
3 changed files with 8 additions and 15 deletions

View File

@ -19,14 +19,7 @@
static constexpr uint32_t kMaxBindGroups = 4u; static constexpr uint32_t kMaxBindGroups = 4u;
static constexpr uint8_t kMaxVertexAttributes = 16u; static constexpr uint8_t kMaxVertexAttributes = 16u;
// Vulkan has a standalone limit named maxVertexInputAttributeOffset (2047u at least) for vertex static constexpr uint8_t kMaxVertexBuffers = 8u;
// attribute offset. The limit might be meaningless because Vulkan has another limit named
// maxVertexInputBindingStride (2048u at least). We use maxVertexAttributeEnd (2048u) here to
// verify vertex attribute offset, which equals to maxOffset + smallest size of vertex format
// (char). We may use maxVertexInputBindingStride (maxVertexBufferStride below) instead to replace
// maxVertexAttributeEnd in future.
static constexpr uint32_t kMaxVertexAttributeEnd = 2048u;
static constexpr uint8_t kMaxVertexBuffers = 16u;
static constexpr uint32_t kMaxVertexBufferStride = 2048u; static constexpr uint32_t kMaxVertexBufferStride = 2048u;
static constexpr uint32_t kNumStages = 3; static constexpr uint32_t kNumStages = 3;
static constexpr uint8_t kMaxColorAttachments = 4u; static constexpr uint8_t kMaxColorAttachments = 4u;

View File

@ -37,15 +37,15 @@ namespace dawn_native {
} }
// No underflow is possible because the max vertex format size is smaller than // No underflow is possible because the max vertex format size is smaller than
// kMaxVertexAttributeEnd. // kMaxVertexBufferStride.
ASSERT(kMaxVertexAttributeEnd >= VertexFormatSize(attribute->format)); ASSERT(kMaxVertexBufferStride >= VertexFormatSize(attribute->format));
if (attribute->offset > kMaxVertexAttributeEnd - VertexFormatSize(attribute->format)) { if (attribute->offset > kMaxVertexBufferStride - VertexFormatSize(attribute->format)) {
return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds"); return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds");
} }
// No overflow is possible because the offset is already validated to be less // No overflow is possible because the offset is already validated to be less
// than kMaxVertexAttributeEnd. // than kMaxVertexBufferStride.
ASSERT(attribute->offset < kMaxVertexAttributeEnd); ASSERT(attribute->offset < kMaxVertexBufferStride);
if (vertexBufferStride > 0 && if (vertexBufferStride > 0 &&
attribute->offset + VertexFormatSize(attribute->format) > vertexBufferStride) { attribute->offset + VertexFormatSize(attribute->format) > vertexBufferStride) {
return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds"); return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds");

View File

@ -284,11 +284,11 @@ TEST_F(VertexStateTest, SetAttributeOffsetOutOfBounds) {
utils::ComboVertexStateDescriptor state; utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1; state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1; state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = kMaxVertexAttributeEnd - sizeof(wgpu::VertexFormat::Float); state.cAttributes[0].offset = kMaxVertexBufferStride - sizeof(wgpu::VertexFormat::Float);
CreatePipeline(true, state, kDummyVertexShader); CreatePipeline(true, state, kDummyVertexShader);
// Test attribute offset out of bounds // Test attribute offset out of bounds
state.cAttributes[0].offset = kMaxVertexAttributeEnd - 1; state.cAttributes[0].offset = kMaxVertexBufferStride - 1;
CreatePipeline(false, state, kDummyVertexShader); CreatePipeline(false, state, kDummyVertexShader);
} }