diff --git a/src/dawn/native/Buffer.cpp b/src/dawn/native/Buffer.cpp index 4781e17f6e..c38e2a788e 100644 --- a/src/dawn/native/Buffer.cpp +++ b/src/dawn/native/Buffer.cpp @@ -462,12 +462,11 @@ ResultOrError> 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; } diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp index b30f98b7f4..0bda7a6eae 100644 --- a/src/dawn/native/CommandEncoder.cpp +++ b/src/dawn/native/CommandEncoder.cpp @@ -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" @@ -754,8 +755,10 @@ ResultOrError> 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( descriptor->colorAttachments, descriptor->colorAttachmentCount); diff --git a/src/dawn/native/CommandValidation.cpp b/src/dawn/native/CommandValidation.cpp index 0843946b88..6cee3bf0de 100644 --- a/src/dawn/native/CommandValidation.cpp +++ b/src/dawn/native/CommandValidation.cpp @@ -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 {}; } diff --git a/src/dawn/native/RenderBundleEncoder.cpp b/src/dawn/native/RenderBundleEncoder.cpp index 439db803e4..710866459b 100644 --- a/src/dawn/native/RenderBundleEncoder.cpp +++ b/src/dawn/native/RenderBundleEncoder.cpp @@ -27,8 +27,10 @@ #include "dawn/native/RenderBundleEncoder.h" +#include #include +#include "dawn/native/Adapter.h" #include "dawn/native/CommandValidation.h" #include "dawn/native/Commands.h" #include "dawn/native/Device.h" @@ -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; diff --git a/src/dawn/native/RenderPipeline.cpp b/src/dawn/native/RenderPipeline.cpp index 850afcc23b..7febe0e491 100644 --- a/src/dawn/native/RenderPipeline.cpp +++ b/src/dawn/native/RenderPipeline.cpp @@ -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" @@ -202,13 +203,11 @@ ResultOrError 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( @@ -676,8 +675,11 @@ ResultOrError 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(descriptor->targets, descriptor->targetCount);