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 <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
Corentin Wallez 2020-11-25 09:16:14 +00:00 committed by Commit Bot service account
parent 441f10a4db
commit ce74d8256e

View File

@ -180,7 +180,15 @@ namespace dawn_native {
if ((dynamicOffsets[i] > bufferBinding.buffer->GetSize() - if ((dynamicOffsets[i] > bufferBinding.buffer->GetSize() -
bufferBinding.offset - bufferBinding.size)) { 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");
}
} }
} }
} }