diff --git a/src/dawn/native/RenderPipeline.cpp b/src/dawn/native/RenderPipeline.cpp index 3c914e602a..1830b10ca8 100644 --- a/src/dawn/native/RenderPipeline.cpp +++ b/src/dawn/native/RenderPipeline.cpp @@ -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), diff --git a/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp b/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp index 422fa9fc41..32ed09e9ee 100644 --- a/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/VertexStateValidationTests.cpp @@ -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); +}