Improve various error messages

Improves various error messages that have received feeback indicating
that they were too confusing or poorly worded.

Bug: dawn:1152
Bug: dawn:1157
Change-Id: If740300f31278ab04d4493887c03918a09cf0f86
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68100
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2021-11-02 15:39:49 +00:00 committed by Dawn LUCI CQ
parent e5b6bbc433
commit d4b9cda056
2 changed files with 38 additions and 8 deletions

View File

@ -110,15 +110,17 @@ namespace dawn_native {
wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
DAWN_INVALID_IF(
usage & wgpu::BufferUsage::MapWrite && !IsSubset(usage, kMapWriteAllowedUsages),
"Buffer usages (%s) contains %s but is not a subset of %s.", usage,
wgpu::BufferUsage::MapWrite, kMapWriteAllowedUsages);
"Buffer usages (%s) is invalid. If a buffer usage contains %s the only other allowed "
"usage is %s.",
usage, wgpu::BufferUsage::MapWrite, wgpu::BufferUsage::CopySrc);
const wgpu::BufferUsage kMapReadAllowedUsages =
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst;
DAWN_INVALID_IF(
usage & wgpu::BufferUsage::MapRead && !IsSubset(usage, kMapReadAllowedUsages),
"Buffer usages (%s) contains %s but is not a subset of %s.", usage,
wgpu::BufferUsage::MapRead, kMapReadAllowedUsages);
"Buffer usages (%s) is invalid. If a buffer usage contains %s the only other allowed "
"usage is %s.",
usage, wgpu::BufferUsage::MapRead, wgpu::BufferUsage::CopyDst);
DAWN_INVALID_IF(descriptor->mappedAtCreation && descriptor->size % 4 != 0,
"Buffer is mapped at creation but its size (%u) is not a multiple of 4.",

View File

@ -238,6 +238,8 @@ namespace dawn_native {
return {};
}
DAWN_INVALID_IF(aspects[VALIDATION_ASPECT_PIPELINE], "No pipeline set.");
if (DAWN_UNLIKELY(aspects[VALIDATION_ASPECT_INDEX_BUFFER])) {
DAWN_INVALID_IF(!mIndexBufferSet, "Index buffer was not set.");
@ -263,15 +265,43 @@ namespace dawn_native {
if (DAWN_UNLIKELY(aspects[VALIDATION_ASPECT_BIND_GROUPS])) {
for (BindGroupIndex i : IterateBitSet(mLastPipelineLayout->GetBindGroupLayoutsMask())) {
ASSERT(HasPipeline());
DAWN_INVALID_IF(mBindgroups[i] == nullptr, "No bind group set at index %u.",
static_cast<uint32_t>(i));
BindGroupLayoutBase* requiredBGL = mLastPipelineLayout->GetBindGroupLayout(i);
BindGroupLayoutBase* currentBGL = mBindgroups[i]->GetLayout();
DAWN_INVALID_IF(
requiredBGL->GetPipelineCompatibilityToken() != PipelineCompatibilityToken(0) &&
currentBGL->GetPipelineCompatibilityToken() !=
requiredBGL->GetPipelineCompatibilityToken(),
"The current pipeline (%s) was created with a default layout, and is not "
"compatible with the %s at index %u which uses a %s that was not created by "
"the pipeline. Either use the bind group layout returned by calling "
"getBindGroupLayout(%u) on the pipeline when creating the bind group, or "
"provide an explicit pipeline layout when creating the pipeline.",
mLastPipeline, mBindgroups[i], static_cast<uint32_t>(i), currentBGL,
static_cast<uint32_t>(i));
DAWN_INVALID_IF(
requiredBGL->GetPipelineCompatibilityToken() == PipelineCompatibilityToken(0) &&
currentBGL->GetPipelineCompatibilityToken() !=
PipelineCompatibilityToken(0),
"%s at index %u uses a %s which was created as part of the default layout for "
"a different pipeline than the current one (%s), and as a result is not "
"compatible. Use an explicit bind group layout when creating bind groups and "
"an explicit pipeline layout when creating pipelines to share bind groups "
"between pipelines.",
mBindgroups[i], static_cast<uint32_t>(i), currentBGL, mLastPipeline);
DAWN_INVALID_IF(
mLastPipelineLayout->GetBindGroupLayout(i) != mBindgroups[i]->GetLayout(),
"Bind group layout %s of pipeline layout %s does not match layout %s of bind "
"group %s at index %u.",
mLastPipelineLayout->GetBindGroupLayout(i), mLastPipelineLayout,
mBindgroups[i]->GetLayout(), mBindgroups[i], static_cast<uint32_t>(i));
requiredBGL, mLastPipelineLayout, currentBGL, mBindgroups[i],
static_cast<uint32_t>(i));
// TODO(dawn:563): Report the binding sizes and which ones are failing.
DAWN_INVALID_IF(!BufferSizesAtLeastAsBig(mBindgroups[i]->GetUnverifiedBufferSizes(),
@ -288,8 +318,6 @@ namespace dawn_native {
return DAWN_FORMAT_VALIDATION_ERROR("Bind groups are invalid.");
}
DAWN_INVALID_IF(aspects[VALIDATION_ASPECT_PIPELINE], "No pipeline set.");
UNREACHABLE();
}