From 145643a542e9905008566278ed05a6f723747a2a Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Thu, 1 Dec 2022 12:23:07 +0000 Subject: [PATCH] Improve the error message of missing vertex buffers It now shows at least one vertex buffer that wasn't set, which helped debug another issue. Bug: dawn:563 Change-Id: Ifd40611bc10b049780cb1239aeee3186a26bc0c9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112020 Reviewed-by: Brandon Jones Kokoro: Kokoro Commit-Queue: Corentin Wallez --- src/dawn/native/CommandBufferStateTracker.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp index ebf00ad65c..6677398ef2 100644 --- a/src/dawn/native/CommandBufferStateTracker.cpp +++ b/src/dawn/native/CommandBufferStateTracker.cpp @@ -300,9 +300,16 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe return DAWN_VALIDATION_ERROR("Index buffer is invalid."); } - // TODO(dawn:563): Indicate which slots were not set. - DAWN_INVALID_IF(aspects[VALIDATION_ASPECT_VERTEX_BUFFERS], - "Vertex buffer slots required by %s were not set.", GetRenderPipeline()); + if (aspects[VALIDATION_ASPECT_VERTEX_BUFFERS]) { + const ityp::bitset missingVertexBuffers = + GetRenderPipeline()->GetVertexBufferSlotsUsed() & ~mVertexBufferSlotsUsed; + ASSERT(missingVertexBuffers.any()); + + VertexBufferSlot firstMissing = ityp::Sub(GetHighestBitIndexPlusOne(missingVertexBuffers), + VertexBufferSlot(uint8_t(1))); + return DAWN_VALIDATION_ERROR("Vertex buffer slot %u required by %s was not set.", + uint8_t(firstMissing), GetRenderPipeline()); + } if (DAWN_UNLIKELY(aspects[VALIDATION_ASPECT_BIND_GROUPS])) { for (BindGroupIndex i : IterateBitSet(mLastPipelineLayout->GetBindGroupLayoutsMask())) {