Add missing WebGPU limits to Constants.h

This will help check that the Vulkan devices are enough for WebGPU in
a following CL.

In addition to additional limits this CL:

 - Change maxColorAttachments 4 -> 8 to match WebGPU
 - Renames kMinDynamicBufferOffsetAlignment to
   kMinUniformBufferOffsetAlignment.
 - Renames kMaxVertexBufferStride to kMaxVertexBufferArrayStride.
 - Changes validation of buffer offsets to use the separate uniform and
   storage limits (but no test is added because they are the same).
 - Adds validation and a test for kMaxStorageBufferBindingSize.
 - Augment the null::Device memory limit for that new test (it allocates
   a buffer of 512MB).
 - Fix the maxColorAttachment test to not use hardcoded values.

Bug: dawn:796
Change-Id: Ibe4219130a44355ae91c02aaa0a41cf5d9f9e234
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56081
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2021-06-29 08:12:00 +00:00
committed by Dawn LUCI CQ
parent 895bc934bb
commit 73b7cd624f
12 changed files with 133 additions and 94 deletions

View File

@@ -44,19 +44,23 @@ namespace dawn_native {
wgpu::BufferUsage requiredUsage;
uint64_t maxBindingSize;
uint64_t requiredBindingAlignment;
switch (bindingInfo.buffer.type) {
case wgpu::BufferBindingType::Uniform:
requiredUsage = wgpu::BufferUsage::Uniform;
maxBindingSize = kMaxUniformBufferBindingSize;
requiredBindingAlignment = kMinUniformBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Storage:
case wgpu::BufferBindingType::ReadOnlyStorage:
requiredUsage = wgpu::BufferUsage::Storage;
maxBindingSize = std::numeric_limits<uint64_t>::max();
maxBindingSize = kMaxStorageBufferBindingSize;
requiredBindingAlignment = kMinStorageBufferOffsetAlignment;
break;
case kInternalStorageBufferBinding:
requiredUsage = kInternalStorageBuffer;
maxBindingSize = std::numeric_limits<uint64_t>::max();
maxBindingSize = kMaxStorageBufferBindingSize;
requiredBindingAlignment = kMinStorageBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Undefined:
UNREACHABLE();
@@ -85,9 +89,9 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Buffer binding doesn't fit in the buffer");
}
if (!IsAligned(entry.offset, 256)) {
if (!IsAligned(entry.offset, requiredBindingAlignment)) {
return DAWN_VALIDATION_ERROR(
"Buffer offset for bind group needs to be 256-byte aligned");
"Buffer offset for bind group needs to satisfy the minimum alignment");
}
if (!(entry.buffer->GetUsage() & requiredUsage)) {

View File

@@ -123,7 +123,22 @@ namespace dawn_native {
ASSERT(bindingInfo.bindingType == BindingInfoType::Buffer);
ASSERT(bindingInfo.buffer.hasDynamicOffset);
if (dynamicOffsets[i] % kMinDynamicBufferOffsetAlignment != 0) {
uint64_t requiredAlignment;
switch (bindingInfo.buffer.type) {
case wgpu::BufferBindingType::Uniform:
requiredAlignment = kMinUniformBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Storage:
case wgpu::BufferBindingType::ReadOnlyStorage:
case kInternalStorageBufferBinding:
requiredAlignment = kMinStorageBufferOffsetAlignment;
requiredAlignment = kMinStorageBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Undefined:
UNREACHABLE();
}
if (!IsAligned(dynamicOffsets[i], requiredAlignment)) {
return DAWN_VALIDATION_ERROR("Dynamic Buffer Offset need to be aligned");
}

View File

@@ -39,16 +39,16 @@ namespace dawn_native {
}
// No underflow is possible because the max vertex format size is smaller than
// kMaxVertexBufferStride.
ASSERT(kMaxVertexBufferStride >= dawn::VertexFormatSize(attribute->format));
// kMaxVertexBufferArrayStride.
ASSERT(kMaxVertexBufferArrayStride >= dawn::VertexFormatSize(attribute->format));
if (attribute->offset >
kMaxVertexBufferStride - dawn::VertexFormatSize(attribute->format)) {
kMaxVertexBufferArrayStride - dawn::VertexFormatSize(attribute->format)) {
return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds");
}
// No overflow is possible because the offset is already validated to be less
// than kMaxVertexBufferStride.
ASSERT(attribute->offset < kMaxVertexBufferStride);
// than kMaxVertexBufferArrayStride.
ASSERT(attribute->offset < kMaxVertexBufferArrayStride);
if (vertexBufferStride > 0 &&
attribute->offset + dawn::VertexFormatSize(attribute->format) >
vertexBufferStride) {
@@ -73,7 +73,7 @@ namespace dawn_native {
const VertexBufferLayout* buffer,
std::bitset<kMaxVertexAttributes>* attributesSetMask) {
DAWN_TRY(ValidateInputStepMode(buffer->stepMode));
if (buffer->arrayStride > kMaxVertexBufferStride) {
if (buffer->arrayStride > kMaxVertexBufferArrayStride) {
return DAWN_VALIDATION_ERROR("Setting arrayStride out of bounds");
}

View File

@@ -160,7 +160,7 @@ namespace dawn_native { namespace null {
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
static constexpr uint64_t kMaxMemoryUsage = 256 * 1024 * 1024;
static constexpr uint64_t kMaxMemoryUsage = 512 * 1024 * 1024;
size_t mMemoryUsage = 0;
};