Skip to content

Commit

Permalink
Expand error message if validating maxColorAttachments with higher limit
Browse files Browse the repository at this point in the history
This CLs expands error message when validating render pass descriptor,
fragment state, render bundle descriptor to indicate when limits are hit
that were not provided in the device requiredLimits.

Bug: 42240683
Change-Id: Ie1596c2561e00875e86fd94f203248c7b048f4e8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/217575
Reviewed-by: Kai Ninomiya <[email protected]>
Commit-Queue: Kai Ninomiya <[email protected]>
Reviewed-by: Brandon Jones <[email protected]>
  • Loading branch information
beaufortfrancois authored and Dawn LUCI CQ committed Dec 12, 2024
1 parent e58f176 commit 1eff04c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
11 changes: 5 additions & 6 deletions src/dawn/native/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,11 @@ ResultOrError<UnpackedPtr<BufferDescriptor>> ValidateBufferDescriptor(
descriptor->size);

uint64_t maxBufferSize = device->GetLimits().v1.maxBufferSize;
if (DAWN_UNLIKELY(descriptor->size > maxBufferSize)) {
return DAWN_VALIDATION_ERROR(
"Buffer size (%u) exceeds the max buffer size limit (%u).%s", descriptor->size,
maxBufferSize,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxBufferSize, descriptor->size));
}
DAWN_INVALID_IF(
descriptor->size > maxBufferSize,
"Buffer size (%u) exceeds the max buffer size limit (%u).%s", descriptor->size,
maxBufferSize,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxBufferSize, descriptor->size));

return unpacked;
}
Expand Down
7 changes: 5 additions & 2 deletions src/dawn/native/CommandEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "dawn/common/Enumerator.h"
#include "dawn/common/Math.h"
#include "dawn/common/NonMovable.h"
#include "dawn/native/Adapter.h"
#include "dawn/native/ApplyClearColorValueWithDrawHelper.h"
#include "dawn/native/BindGroup.h"
#include "dawn/native/BlitBufferToDepthStencil.h"
Expand Down Expand Up @@ -754,8 +755,10 @@ ResultOrError<UnpackedPtr<RenderPassDescriptor>> ValidateRenderPassDescriptor(
uint32_t maxColorAttachments = device->GetLimits().v1.maxColorAttachments;
DAWN_INVALID_IF(
descriptor->colorAttachmentCount > maxColorAttachments,
"Color attachment count (%u) exceeds the maximum number of color attachments (%u).",
descriptor->colorAttachmentCount, maxColorAttachments);
"Color attachment count (%u) exceeds the maximum number of color attachments (%u).%s",
descriptor->colorAttachmentCount, maxColorAttachments,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxColorAttachments,
descriptor->colorAttachmentCount));

auto colorAttachments = ityp::SpanFromUntyped<ColorAttachmentIndex>(
descriptor->colorAttachments, descriptor->colorAttachmentCount);
Expand Down
15 changes: 7 additions & 8 deletions src/dawn/native/CommandValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,13 @@ MaybeError ValidateColorAttachmentBytesPerSample(DeviceBase* device,
}
uint32_t maxColorAttachmentBytesPerSample =
device->GetLimits().v1.maxColorAttachmentBytesPerSample;
if (DAWN_UNLIKELY(totalByteSize > maxColorAttachmentBytesPerSample)) {
return DAWN_VALIDATION_ERROR(
"Total color attachment bytes per sample (%u) exceeds maximum (%u) with formats "
"(%s).%s",
totalByteSize, maxColorAttachmentBytesPerSample, TextureFormatsToString(formats),
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxColorAttachmentBytesPerSample,
totalByteSize));
}
DAWN_INVALID_IF(
totalByteSize > maxColorAttachmentBytesPerSample,
"Total color attachment bytes per sample (%u) exceeds maximum (%u) with formats "
"(%s).%s",
totalByteSize, maxColorAttachmentBytesPerSample, TextureFormatsToString(formats),
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxColorAttachmentBytesPerSample,
totalByteSize));

return {};
}
Expand Down
8 changes: 6 additions & 2 deletions src/dawn/native/RenderBundleEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

#include "dawn/native/RenderBundleEncoder.h"

#include <string>
#include <utility>

#include "dawn/native/Adapter.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Commands.h"
#include "dawn/native/Device.h"
Expand Down Expand Up @@ -70,8 +72,10 @@ MaybeError ValidateRenderBundleEncoderDescriptor(DeviceBase* device,

uint32_t maxColorAttachments = device->GetLimits().v1.maxColorAttachments;
DAWN_INVALID_IF(descriptor->colorFormatCount > maxColorAttachments,
"Color formats count (%u) exceeds maximum number of color attachements (%u).",
descriptor->colorFormatCount, maxColorAttachments);
"Color formats count (%u) exceeds maximum number of color attachments (%u).%s",
descriptor->colorFormatCount, maxColorAttachments,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxColorAttachments,
descriptor->colorFormatCount));

bool allColorFormatsUndefined = true;
ColorAttachmentFormats colorAttachmentFormats;
Expand Down
20 changes: 11 additions & 9 deletions src/dawn/native/RenderPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "dawn/common/Enumerator.h"
#include "dawn/common/ityp_array.h"
#include "dawn/common/ityp_span.h"
#include "dawn/native/Adapter.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/CommandValidation.h"
#include "dawn/native/Commands.h"
Expand Down Expand Up @@ -202,13 +203,11 @@ ResultOrError<ShaderModuleEntryPoint> ValidateVertexState(
const CombinedLimits& limits = device->GetLimits();

const uint32_t maxVertexBuffers = limits.v1.maxVertexBuffers;
if (DAWN_UNLIKELY(descriptor->bufferCount > maxVertexBuffers)) {
return DAWN_VALIDATION_ERROR(
"Vertex buffer count (%u) exceeds the maximum number of vertex buffers (%u).%s",
descriptor->bufferCount, maxVertexBuffers,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxVertexBuffers,
descriptor->bufferCount));
}
DAWN_INVALID_IF(descriptor->bufferCount > maxVertexBuffers,
"Vertex buffer count (%u) exceeds the maximum number of vertex buffers (%u).%s",
descriptor->bufferCount, maxVertexBuffers,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxVertexBuffers,
descriptor->bufferCount));

ShaderModuleEntryPoint entryPoint;
DAWN_TRY_ASSIGN_CONTEXT(
Expand Down Expand Up @@ -676,8 +675,11 @@ ResultOrError<ShaderModuleEntryPoint> ValidateFragmentState(DeviceBase* device,

uint32_t maxColorAttachments = device->GetLimits().v1.maxColorAttachments;
DAWN_INVALID_IF(descriptor->targetCount > maxColorAttachments,
"Number of targets (%u) exceeds the maximum (%u).", descriptor->targetCount,
maxColorAttachments);
"Number of targets (%u) exceeds the maximum (%u).%s", descriptor->targetCount,
maxColorAttachments,
DAWN_INCREASE_LIMIT_MESSAGE(device->GetAdapter(), maxColorAttachments,
descriptor->targetCount));

auto targets =
ityp::SpanFromUntyped<ColorAttachmentIndex>(descriptor->targets, descriptor->targetCount);

Expand Down

0 comments on commit 1eff04c

Please sign in to comment.