Validate zero-attribute for VertexBufferNotUsed buffers
Add a validation to ensure zero-attribute for unused vertex buffer slots (stepMode = VertexBufferNotUsed). Fuzz tests found that non-zero-attribute with unused vertex buffer can cause an error in swiftshader. We may be able to think input data having non-zero-attribute with unused vertex buffe is malformed. Refusing such input data can avoid the error. Bug: chromium:1333293 Change-Id: Ib58d526bdaefa683e459b5c813e348b72e81e13e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/93560 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Takahiro <hogehoge@gachapin.jp> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
f0a97a0a23
commit
1f93b11939
|
@ -99,6 +99,11 @@ MaybeError ValidateVertexBufferLayout(
|
|||
DAWN_INVALID_IF(buffer->arrayStride % 4 != 0,
|
||||
"Vertex buffer arrayStride (%u) is not a multiple of 4.", buffer->arrayStride);
|
||||
|
||||
DAWN_INVALID_IF(
|
||||
buffer->stepMode == wgpu::VertexStepMode::VertexBufferNotUsed && buffer->attributeCount > 0,
|
||||
"attributeCount (%u) is not zero although vertex buffer stepMode is %s.",
|
||||
buffer->attributeCount, wgpu::VertexStepMode::VertexBufferNotUsed);
|
||||
|
||||
for (uint32_t i = 0; i < buffer->attributeCount; ++i) {
|
||||
DAWN_TRY_CONTEXT(ValidateVertexAttribute(device, &buffer->attributes[i], metadata,
|
||||
buffer->arrayStride, attributesSetMask),
|
||||
|
|
|
@ -427,3 +427,18 @@ TEST_F(VertexStateTest, BaseTypeMatchingForInexistentInput) {
|
|||
DoTest(wgpu::VertexFormat::Uint8x4);
|
||||
DoTest(wgpu::VertexFormat::Sint32x2);
|
||||
}
|
||||
|
||||
// Test that non-zero attributeCount with VertexBufferNotUsed stepMode is invalid
|
||||
TEST_F(VertexStateTest, UnusedBufferZeroAttribute) {
|
||||
// Non-zero attributeCount with non-VertexBufferNotUsed is valid
|
||||
utils::ComboVertexState state;
|
||||
state.vertexBufferCount = 1;
|
||||
state.cVertexBuffers[0].arrayStride = 0;
|
||||
state.cVertexBuffers[0].attributeCount = 1;
|
||||
state.cVertexBuffers[0].stepMode = wgpu::VertexStepMode::Vertex;
|
||||
CreatePipeline(true, state, kPlaceholderVertexShader);
|
||||
|
||||
// Non-zero attributeCount with VertexBufferNotUsed is invalid
|
||||
state.cVertexBuffers[0].stepMode = wgpu::VertexStepMode::VertexBufferNotUsed;
|
||||
CreatePipeline(false, state, kPlaceholderVertexShader);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue