Skip to content

Commit

Permalink
Expand error message if validating buffer binding
Browse files Browse the repository at this point in the history
This CLs expands error message when validating buffer binding with
maxUniformBufferBindingSize and maxStorageBufferBindingSize to indicate
when limits are hit that were not provided in the device requiredLimits.

Bug: 42240683
Change-Id: I176478750ea075f0b682074844ba3f67fb039bc6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/219675
Commit-Queue: Fr <[email protected]>
Reviewed-by: Brandon Jones <[email protected]>
  • Loading branch information
beaufortfrancois authored and Dawn LUCI CQ committed Dec 17, 2024
1 parent d09e3c7 commit 0c4e4be
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions src/dawn/native/BindGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "dawn/common/MatchVariant.h"
#include "dawn/common/Math.h"
#include "dawn/common/ityp_bitset.h"
#include "dawn/native/Adapter.h"
#include "dawn/native/BindGroupLayout.h"
#include "dawn/native/Buffer.h"
#include "dawn/native/ChainUtils.h"
Expand Down Expand Up @@ -84,18 +85,15 @@ MaybeError ValidateBufferBinding(const DeviceBase* device,
entry.offset, bufferSize, bindingSize, entry.buffer);

wgpu::BufferUsage requiredUsage;
uint64_t maxBindingSize;
uint64_t requiredBindingAlignment;
switch (layout.type) {
case wgpu::BufferBindingType::Uniform:
requiredUsage = wgpu::BufferUsage::Uniform;
maxBindingSize = device->GetLimits().v1.maxUniformBufferBindingSize;
requiredBindingAlignment = device->GetLimits().v1.minUniformBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Storage:
case wgpu::BufferBindingType::ReadOnlyStorage:
requiredUsage = wgpu::BufferUsage::Storage;
maxBindingSize = device->GetLimits().v1.maxStorageBufferBindingSize;
requiredBindingAlignment = device->GetLimits().v1.minStorageBufferOffsetAlignment;
DAWN_INVALID_IF(
bindingSize % 4 != 0,
Expand All @@ -104,7 +102,6 @@ MaybeError ValidateBufferBinding(const DeviceBase* device,
break;
case kInternalStorageBufferBinding:
requiredUsage = kInternalStorageBuffer;
maxBindingSize = device->GetLimits().v1.maxStorageBufferBindingSize;
requiredBindingAlignment = device->GetLimits().v1.minStorageBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::BindingNotUsed:
Expand All @@ -123,9 +120,32 @@ MaybeError ValidateBufferBinding(const DeviceBase* device,
"Binding size (%u) of %s is smaller than the minimum binding size (%u).",
bindingSize, entry.buffer, layout.minBindingSize);

DAWN_INVALID_IF(bindingSize > maxBindingSize,
"Binding size (%u) of %s is larger than the maximum binding size (%u).",
bindingSize, entry.buffer, maxBindingSize);
uint64_t maxUniformBufferBindingSize;
uint64_t maxStorageBufferBindingSize;
switch (layout.type) {
case wgpu::BufferBindingType::Uniform:
maxUniformBufferBindingSize = device->GetLimits().v1.maxUniformBufferBindingSize;
DAWN_INVALID_IF(bindingSize > maxUniformBufferBindingSize,
"Binding size (%u) of %s is larger than the maximum uniform buffer "
"binding size (%u).%s",
bindingSize, entry.buffer, maxUniformBufferBindingSize,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(),
maxUniformBufferBindingSize, bindingSize));
break;
case wgpu::BufferBindingType::Storage:
case wgpu::BufferBindingType::ReadOnlyStorage:
case kInternalStorageBufferBinding:
maxStorageBufferBindingSize = device->GetLimits().v1.maxStorageBufferBindingSize;
DAWN_INVALID_IF(bindingSize > maxStorageBufferBindingSize,
"Binding size (%u) of %s is larger than the maximum storage buffer "
"binding size (%u).%s",
bindingSize, entry.buffer, maxStorageBufferBindingSize,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(),
maxStorageBufferBindingSize, bindingSize));
break;
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}

return {};
}
Expand Down

0 comments on commit 0c4e4be

Please sign in to comment.