Dawn: Improve a couple error messages.

Bug: dawn:563
Change-Id: I49ad645d1b8a02efe029c391c3c70894de42cf9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/121542
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2023-02-27 15:10:21 +00:00 committed by Dawn LUCI CQ
parent 9efc12d4af
commit f615770780
3 changed files with 20 additions and 11 deletions

View File

@ -425,6 +425,7 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe
} }
if (aspects[VALIDATION_ASPECT_VERTEX_BUFFERS]) { if (aspects[VALIDATION_ASPECT_VERTEX_BUFFERS]) {
// Try to be helpful by finding one missing vertex buffer to surface in the error message.
const ityp::bitset<VertexBufferSlot, kMaxVertexBuffers> missingVertexBuffers = const ityp::bitset<VertexBufferSlot, kMaxVertexBuffers> missingVertexBuffers =
GetRenderPipeline()->GetVertexBufferSlotsUsed() & ~mVertexBufferSlotsUsed; GetRenderPipeline()->GetVertexBufferSlotsUsed() & ~mVertexBufferSlotsUsed;
ASSERT(missingVertexBuffers.any()); ASSERT(missingVertexBuffers.any());

View File

@ -157,9 +157,20 @@ MaybeError ValidateVertexState(DeviceBase* device,
// attribute number never exceed kMaxVertexAttributes. // attribute number never exceed kMaxVertexAttributes.
ASSERT(totalAttributesNum <= kMaxVertexAttributes); ASSERT(totalAttributesNum <= kMaxVertexAttributes);
// TODO(dawn:563): Specify which inputs were not used in error message. // Validate that attributes used by the VertexState are in the shader using bitmask operations
DAWN_INVALID_IF(!IsSubset(vertexMetadata.usedVertexInputs, attributesSetMask), // but try to be helpful by finding one missing attribute to surface in the error message
"Pipeline vertex stage uses vertex buffers not in the vertex state"); if (!IsSubset(vertexMetadata.usedVertexInputs, attributesSetMask)) {
const ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes> missingAttributes =
vertexMetadata.usedVertexInputs & ~attributesSetMask;
ASSERT(missingAttributes.any());
VertexAttributeLocation firstMissing = ityp::Sub(
GetHighestBitIndexPlusOne(missingAttributes), VertexAttributeLocation(uint8_t(1)));
return DAWN_VALIDATION_ERROR(
"Vertex attribute slot %u used in (%s, entryPoint: %s) is not present in the "
"VertexState.",
uint8_t(firstMissing), descriptor->module, descriptor->entryPoint);
}
return {}; return {};
} }

View File

@ -395,21 +395,18 @@ MaybeError ValidateCompatibilityOfSingleBindingWithLayout(const DeviceBase* devi
BindingIndex bindingIndex(bindingIt->second); BindingIndex bindingIndex(bindingIt->second);
const BindingInfo& layoutInfo = layout->GetBindingInfo(bindingIndex); const BindingInfo& layoutInfo = layout->GetBindingInfo(bindingIndex);
// TODO(dawn:563): Provide info about the binding types. DAWN_INVALID_IF(layoutInfo.bindingType != shaderInfo.bindingType,
DAWN_INVALID_IF( "Binding type in the shader (%s) doesn't match the type in the layout (%s).",
layoutInfo.bindingType != shaderInfo.bindingType, shaderInfo.bindingType, layoutInfo.bindingType);
"Binding type (buffer vs. texture vs. sampler vs. external) doesn't match the type "
"in the layout.");
ExternalTextureBindingExpansionMap expansions = layout->GetExternalTextureBindingExpansionMap(); ExternalTextureBindingExpansionMap expansions = layout->GetExternalTextureBindingExpansionMap();
DAWN_INVALID_IF(expansions.find(bindingNumber) != expansions.end(), DAWN_INVALID_IF(expansions.find(bindingNumber) != expansions.end(),
"Binding type (buffer vs. texture vs. sampler vs. external) doesn't " "Binding type (buffer vs. texture vs. sampler vs. external) doesn't "
"match the type in the layout."); "match the type in the layout.");
// TODO(dawn:563): Provide info about the visibility.
DAWN_INVALID_IF((layoutInfo.visibility & StageBit(entryPointStage)) == 0, DAWN_INVALID_IF((layoutInfo.visibility & StageBit(entryPointStage)) == 0,
"Entry point's stage is not in the binding visibility in the layout (%s)", "Entry point's stage (%s) is not in the binding visibility in the layout (%s).",
layoutInfo.visibility); StageBit(entryPointStage), layoutInfo.visibility);
switch (layoutInfo.bindingType) { switch (layoutInfo.bindingType) {
case BindingInfoType::Texture: { case BindingInfoType::Texture: {