Clarify stride validation errors It was pointed out that these messages, validating that a vertex attribute offset/size fits within the buffer stride, were confusing and easy to misunderstand. Updating in hopes of making the intent clearer for the reader. Bug: 361461530 Change-Id: Ibf8f7e7f2004ffad3a5a6636876cdce079d1489f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/203614 Reviewed-by: Gregg Tavares <gman@chromium.org> Auto-Submit: Brandon Jones <bajones@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/RenderPipeline.cpp b/src/dawn/native/RenderPipeline.cpp index e93a627..64d8f41 100644 --- a/src/dawn/native/RenderPipeline.cpp +++ b/src/dawn/native/RenderPipeline.cpp
@@ -116,20 +116,23 @@ // No underflow is possible because the max vertex format size is smaller than // kMaxVertexBufferArrayStride. DAWN_ASSERT(kMaxVertexBufferArrayStride >= formatInfo.byteSize); - DAWN_INVALID_IF( - attribute->offset > kMaxVertexBufferArrayStride - formatInfo.byteSize, - "Attribute offset (%u) with format %s (size: %u) doesn't fit in the maximum vertex " - "buffer stride (%u).", - attribute->offset, attribute->format, formatInfo.byteSize, kMaxVertexBufferArrayStride); + DAWN_INVALID_IF(attribute->offset > kMaxVertexBufferArrayStride - formatInfo.byteSize, + "Attribute offset (%u) + format size (%u for %s) must be <= the maximum vertex " + "buffer stride (%u). Offsets larger than the maximum vertex buffer stride are " + "accomodated by setting buffer offsets when calling setVertexBuffer, which the " + "attribute offset is added to.", + attribute->offset, formatInfo.byteSize, attribute->format, + kMaxVertexBufferArrayStride); // No overflow is possible because the offset is already validated to be less // than kMaxVertexBufferArrayStride. DAWN_ASSERT(attribute->offset < kMaxVertexBufferArrayStride); DAWN_INVALID_IF( vertexBufferStride > 0 && attribute->offset + formatInfo.byteSize > vertexBufferStride, - "Attribute offset (%u) with format %s (size: %u) doesn't fit in the vertex buffer " - "stride (%u).", - attribute->offset, attribute->format, formatInfo.byteSize, vertexBufferStride); + "Attribute offset (%u) + format size (%u for %s) must be <= the vertex buffer stride (%u). " + "Offsets larger than the vertex buffer stride are accomodated by setting buffer offsets " + "when calling setVertexBuffer, which the attribute offset is added to.", + attribute->offset, formatInfo.byteSize, attribute->format, vertexBufferStride); DAWN_INVALID_IF(attribute->offset % std::min(4u, formatInfo.byteSize) != 0, "Attribute offset (%u) in not a multiple of %u.", attribute->offset,