From ce74d8256ee75d53a03ec3f287e5f6149559c67f Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 25 Nov 2020 09:16:14 +0000 Subject: [PATCH] Improve the dynamic binding OOB error message when binding.size is defaulted. A common error when using dynamic offset bindings is to forget to set the size of the binding, which causes all offsets != 0 to produce an error. Make the error more explicit when that happens to guide developers. Bug: dawn:583 Change-Id: I38a5dfaf3f6756765c7e50cd470ac205b567d00c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33784 Commit-Queue: Corentin Wallez Reviewed-by: Stephen White --- src/dawn_native/ProgrammablePassEncoder.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dawn_native/ProgrammablePassEncoder.cpp b/src/dawn_native/ProgrammablePassEncoder.cpp index 9150ac9aa9..7ef2d1c540 100644 --- a/src/dawn_native/ProgrammablePassEncoder.cpp +++ b/src/dawn_native/ProgrammablePassEncoder.cpp @@ -180,7 +180,15 @@ namespace dawn_native { if ((dynamicOffsets[i] > bufferBinding.buffer->GetSize() - bufferBinding.offset - bufferBinding.size)) { - return DAWN_VALIDATION_ERROR("dynamic offset out of bounds"); + if ((bufferBinding.buffer->GetSize() - bufferBinding.offset) == + bufferBinding.size) { + return DAWN_VALIDATION_ERROR( + "Dynamic offset out of bounds. The binding goes to the end of the " + "buffer even with a dynamic offset of 0. Did you forget to specify " + "the binding's size?"); + } else { + return DAWN_VALIDATION_ERROR("Dynamic offset out of bounds"); + } } } }