Use whole size of buffer if binding buffer size is UINT64_MAX

Following WebGPU spec change at https://github.com/gpuweb/gpuweb/issues/331,
bind groups in Dawn now use the whole size of the buffer if binding buffer
size is UINT64_MAX.

Bug: dawn:22
Change-Id: If28d905e634432755dad5c67c69eadedcee53dfe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8863
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
This commit is contained in:
François Beaufort
2019-07-17 08:54:19 +00:00
committed by Commit Bot service account
parent 56a21a6151
commit 0326b8012b
4 changed files with 13 additions and 4 deletions

View File

@@ -38,13 +38,14 @@ namespace dawn_native {
DAWN_TRY(device->ValidateObject(binding.buffer));
uint64_t bufferSize = binding.buffer->GetSize();
if (binding.size > bufferSize) {
uint64_t bindingSize = (binding.size == dawn::kWholeSize) ? bufferSize : binding.size;
if (bindingSize > bufferSize) {
return DAWN_VALIDATION_ERROR("Buffer binding size larger than the buffer");
}
// Note that no overflow can happen because we already checked that
// bufferSize >= binding.size
if (binding.offset > bufferSize - binding.size) {
// bufferSize >= bindingSize
if (binding.offset > bufferSize - bindingSize) {
return DAWN_VALIDATION_ERROR("Buffer binding doesn't fit in the buffer");
}
@@ -172,7 +173,9 @@ namespace dawn_native {
ASSERT(mBindings[bindingIndex].Get() == nullptr);
mBindings[bindingIndex] = binding.buffer;
mOffsets[bindingIndex] = binding.offset;
mSizes[bindingIndex] = binding.size;
uint64_t bufferSize =
(binding.size == dawn::kWholeSize) ? binding.buffer->GetSize() : binding.size;
mSizes[bindingIndex] = bufferSize;
continue;
}