Merge DAWN_FORMAT_VALIDATION_ERROR in DAWN_VALIDATION_ERROR.

Done with changes to Error.h and the following command:
git grep -l DAWN_FORMAT_VALIDATION_ERROR | xargs sed -i "" "s/DAWN_FORMAT_VALIDATION_ERROR/DAWN_VALIDATION_ERROR/"
then fixing compilation errors in ErrorTests.cpp, Pipeline.cpp and
CommandEncoder.cpp.

Bug: dawn:563
Change-Id: I081a514d662e81f4842b6d7fadfcea67c12720d6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100468
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2022-08-30 13:39:47 +00:00 committed by Dawn LUCI CQ
parent 1eb6d2dd02
commit 1105ec78fe
31 changed files with 73 additions and 82 deletions

View File

@ -29,7 +29,7 @@ namespace {{native_namespace}} {
return {}; return {};
{% endfor %} {% endfor %}
default: default:
return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value)); return DAWN_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value));
} }
} }
@ -40,7 +40,7 @@ namespace {{native_namespace}} {
if ((value & static_cast<{{namespace}}::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) { if ((value & static_cast<{{namespace}}::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
return {}; return {};
} }
return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value)); return DAWN_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value));
} }
{% endfor %} {% endfor %}

View File

@ -29,7 +29,7 @@ InstanceBase* BackendConnection::GetInstance() const {
ResultOrError<std::vector<Ref<AdapterBase>>> BackendConnection::DiscoverAdapters( ResultOrError<std::vector<Ref<AdapterBase>>> BackendConnection::DiscoverAdapters(
const AdapterDiscoveryOptionsBase* options) { const AdapterDiscoveryOptionsBase* options) {
return DAWN_FORMAT_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend."); return DAWN_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend.");
} }
} // namespace dawn::native } // namespace dawn::native

View File

@ -48,8 +48,8 @@ MaybeError ValidateStorageTextureViewDimension(wgpu::TextureViewDimension dimens
switch (dimension) { switch (dimension) {
case wgpu::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case wgpu::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR("%s texture views cannot be used as storage textures.",
"%s texture views cannot be used as storage textures.", dimension); dimension);
case wgpu::TextureViewDimension::e1D: case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:

View File

@ -292,10 +292,10 @@ MaybeError BufferBase::ValidateCanUseOnQueueNow() const {
switch (mState) { switch (mState) {
case BufferState::Destroyed: case BufferState::Destroyed:
return DAWN_FORMAT_VALIDATION_ERROR("%s used in submit while destroyed.", this); return DAWN_VALIDATION_ERROR("%s used in submit while destroyed.", this);
case BufferState::Mapped: case BufferState::Mapped:
case BufferState::MappedAtCreation: case BufferState::MappedAtCreation:
return DAWN_FORMAT_VALIDATION_ERROR("%s used in submit while mapped.", this); return DAWN_VALIDATION_ERROR("%s used in submit while mapped.", this);
case BufferState::Unmapped: case BufferState::Unmapped:
return {}; return {};
} }
@ -463,9 +463,9 @@ MaybeError BufferBase::ValidateMapAsync(wgpu::MapMode mode,
switch (mState) { switch (mState) {
case BufferState::Mapped: case BufferState::Mapped:
case BufferState::MappedAtCreation: case BufferState::MappedAtCreation:
return DAWN_FORMAT_VALIDATION_ERROR("%s is already mapped.", this); return DAWN_VALIDATION_ERROR("%s is already mapped.", this);
case BufferState::Destroyed: case BufferState::Destroyed:
return DAWN_FORMAT_VALIDATION_ERROR("%s is destroyed.", this); return DAWN_VALIDATION_ERROR("%s is destroyed.", this);
case BufferState::Unmapped: case BufferState::Unmapped:
break; break;
} }
@ -540,9 +540,9 @@ MaybeError BufferBase::ValidateUnmap() const {
// even if it did not have a mappable usage. // even if it did not have a mappable usage.
return {}; return {};
case BufferState::Unmapped: case BufferState::Unmapped:
return DAWN_FORMAT_VALIDATION_ERROR("%s is unmapped.", this); return DAWN_VALIDATION_ERROR("%s is unmapped.", this);
case BufferState::Destroyed: case BufferState::Destroyed:
return DAWN_FORMAT_VALIDATION_ERROR("%s is destroyed.", this); return DAWN_VALIDATION_ERROR("%s is destroyed.", this);
} }
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -297,7 +297,7 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe
// because to have invalid aspects one of the above conditions must have failed earlier. // because to have invalid aspects one of the above conditions must have failed earlier.
// If this is reached, make sure lazy aspects and the error checks above are consistent. // If this is reached, make sure lazy aspects and the error checks above are consistent.
UNREACHABLE(); UNREACHABLE();
return DAWN_FORMAT_VALIDATION_ERROR("Index buffer is invalid."); return DAWN_VALIDATION_ERROR("Index buffer is invalid.");
} }
// TODO(dawn:563): Indicate which slots were not set. // TODO(dawn:563): Indicate which slots were not set.
@ -355,7 +355,7 @@ MaybeError CommandBufferStateTracker::CheckMissingAspects(ValidationAspects aspe
// because to have invalid aspects one of the above conditions must have failed earlier. // because to have invalid aspects one of the above conditions must have failed earlier.
// If this is reached, make sure lazy aspects and the error checks above are consistent. // If this is reached, make sure lazy aspects and the error checks above are consistent.
UNREACHABLE(); UNREACHABLE();
return DAWN_FORMAT_VALIDATION_ERROR("Bind groups are invalid."); return DAWN_VALIDATION_ERROR("Bind groups are invalid.");
} }
UNREACHABLE(); UNREACHABLE();

View File

@ -88,7 +88,7 @@ MaybeError ValidateTextureDepthStencilToBufferCopyRestrictions(const ImageCopyTe
switch (src.texture->GetFormat().format) { switch (src.texture->GetFormat().format) {
case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The depth aspect of %s format %s cannot be selected in a texture to " "The depth aspect of %s format %s cannot be selected in a texture to "
"buffer copy.", "buffer copy.",
src.texture, src.texture->GetFormat().format); src.texture, src.texture->GetFormat().format);
@ -734,7 +734,7 @@ CommandEncoder::CommandEncoder(DeviceBase* device, ObjectBase::ErrorTag tag)
: ApiObjectBase(device, tag), : ApiObjectBase(device, tag),
mEncodingContext(device, this), mEncodingContext(device, this),
mUsageValidationMode(UsageValidationMode::Default) { mUsageValidationMode(UsageValidationMode::Default) {
mEncodingContext.HandleError(DAWN_FORMAT_VALIDATION_ERROR("%s is invalid.", this)); mEncodingContext.HandleError(DAWN_VALIDATION_ERROR("%s is invalid.", this));
} }
ObjectType CommandEncoder::GetType() const { ObjectType CommandEncoder::GetType() const {
@ -1300,7 +1300,7 @@ void CommandEncoder::APIClearBuffer(BufferBase* buffer, uint64_t offset, uint64_
void CommandEncoder::APIInjectValidationError(const char* message) { void CommandEncoder::APIInjectValidationError(const char* message) {
if (mEncodingContext.CheckCurrentEncoder(this)) { if (mEncodingContext.CheckCurrentEncoder(this)) {
mEncodingContext.HandleError(DAWN_VALIDATION_ERROR(message)); mEncodingContext.HandleError(DAWN_MAKE_ERROR(InternalErrorType::Validation, message));
} }
} }

View File

@ -55,7 +55,7 @@ MaybeError ValidateSyncScopeResourceUsage(const SyncScopeResourceUsage& scope) {
bool readOnly = IsSubset(usage, kReadOnlyTextureUsages); bool readOnly = IsSubset(usage, kReadOnlyTextureUsages);
bool singleUse = wgpu::HasZeroOrOneBits(usage); bool singleUse = wgpu::HasZeroOrOneBits(usage);
if (!readOnly && !singleUse && !error.IsError()) { if (!readOnly && !singleUse && !error.IsError()) {
error = DAWN_FORMAT_VALIDATION_ERROR( error = DAWN_VALIDATION_ERROR(
"%s usage (%s) includes writable usage and another usage in the same " "%s usage (%s) includes writable usage and another usage in the same "
"synchronization scope.", "synchronization scope.",
scope.textures[i], usage); scope.textures[i], usage);
@ -420,7 +420,7 @@ MaybeError ValidateTextureToTextureCopyCommonRestrictions(const ImageCopyTexture
switch (src.texture->GetDimension()) { switch (src.texture->GetDimension()) {
case wgpu::TextureDimension::e1D: case wgpu::TextureDimension::e1D:
ASSERT(src.mipLevel == 0 && src.origin.z == 0 && dst.origin.z == 0); ASSERT(src.mipLevel == 0 && src.origin.z == 0 && dst.origin.z == 0);
return DAWN_FORMAT_VALIDATION_ERROR("Copy is from %s to itself.", src.texture); return DAWN_VALIDATION_ERROR("Copy is from %s to itself.", src.texture);
case wgpu::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
DAWN_INVALID_IF( DAWN_INVALID_IF(

View File

@ -23,7 +23,7 @@ namespace dawn::native {
MaybeError ValidateComputePipelineDescriptor(DeviceBase* device, MaybeError ValidateComputePipelineDescriptor(DeviceBase* device,
const ComputePipelineDescriptor* descriptor) { const ComputePipelineDescriptor* descriptor) {
if (descriptor->nextInChain != nullptr) { if (descriptor->nextInChain != nullptr) {
return DAWN_FORMAT_VALIDATION_ERROR("nextInChain must be nullptr."); return DAWN_VALIDATION_ERROR("nextInChain must be nullptr.");
} }
if (descriptor->layout != nullptr) { if (descriptor->layout != nullptr) {

View File

@ -242,8 +242,7 @@ MaybeError ValidateCopyTextureFormatConversion(const wgpu::TextureFormat srcForm
case wgpu::TextureFormat::RGBA16Float: case wgpu::TextureFormat::RGBA16Float:
break; break;
default: default:
return DAWN_FORMAT_VALIDATION_ERROR("Source texture format (%s) is not supported.", return DAWN_VALIDATION_ERROR("Source texture format (%s) is not supported.", srcFormat);
srcFormat);
} }
switch (dstFormat) { switch (dstFormat) {
@ -262,8 +261,8 @@ MaybeError ValidateCopyTextureFormatConversion(const wgpu::TextureFormat srcForm
case wgpu::TextureFormat::RGBA32Float: case wgpu::TextureFormat::RGBA32Float:
break; break;
default: default:
return DAWN_FORMAT_VALIDATION_ERROR("Destination texture format (%s) is not supported.", return DAWN_VALIDATION_ERROR("Destination texture format (%s) is not supported.",
dstFormat); dstFormat);
} }
return {}; return {};

View File

@ -44,7 +44,7 @@ void EncodingContext::Destroy() {
// If we weren't already finished, then we want to handle an error here so that any calls // If we weren't already finished, then we want to handle an error here so that any calls
// to Finish after Destroy will return a meaningful error. // to Finish after Destroy will return a meaningful error.
if (!IsFinished()) { if (!IsFinished()) {
HandleError(DAWN_FORMAT_VALIDATION_ERROR("Destroyed encoder cannot be finished.")); HandleError(DAWN_VALIDATION_ERROR("Destroyed encoder cannot be finished."));
} }
mDestroyed = true; mDestroyed = true;
mCurrentEncoder = nullptr; mCurrentEncoder = nullptr;
@ -151,8 +151,8 @@ void EncodingContext::EnsurePassExited(const ApiObjectBase* passEncoder) {
if (mCurrentEncoder != mTopLevelEncoder && mCurrentEncoder == passEncoder) { if (mCurrentEncoder != mTopLevelEncoder && mCurrentEncoder == passEncoder) {
// The current pass encoder is being deleted. Implicitly end the pass with an error. // The current pass encoder is being deleted. Implicitly end the pass with an error.
mCurrentEncoder = mTopLevelEncoder; mCurrentEncoder = mTopLevelEncoder;
HandleError(DAWN_FORMAT_VALIDATION_ERROR( HandleError(DAWN_VALIDATION_ERROR("Command buffer recording ended before %s was ended.",
"Command buffer recording ended before %s was ended.", passEncoder)); passEncoder));
} }
} }

View File

@ -80,18 +80,17 @@ class EncodingContext {
inline bool CheckCurrentEncoder(const ApiObjectBase* encoder) { inline bool CheckCurrentEncoder(const ApiObjectBase* encoder) {
if (mDestroyed) { if (mDestroyed) {
HandleError( HandleError(DAWN_VALIDATION_ERROR("Recording in a destroyed %s.", mCurrentEncoder));
DAWN_FORMAT_VALIDATION_ERROR("Recording in a destroyed %s.", mCurrentEncoder));
return false; return false;
} }
if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) { if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) {
if (mCurrentEncoder != mTopLevelEncoder) { if (mCurrentEncoder != mTopLevelEncoder) {
// The top level encoder was used when a pass encoder was current. // The top level encoder was used when a pass encoder was current.
HandleError(DAWN_FORMAT_VALIDATION_ERROR( HandleError(DAWN_VALIDATION_ERROR("Command cannot be recorded while %s is active.",
"Command cannot be recorded while %s is active.", mCurrentEncoder)); mCurrentEncoder));
} else { } else {
HandleError(DAWN_FORMAT_VALIDATION_ERROR( HandleError(
"Recording in an error or already ended %s.", encoder)); DAWN_VALIDATION_ERROR("Recording in an error or already ended %s.", encoder));
} }
return false; return false;
} }

View File

@ -43,7 +43,7 @@ using ResultOrError = Result<T, ErrorData>;
// return DAWN_MAKE_ERROR(errorType, "My error message"); // return DAWN_MAKE_ERROR(errorType, "My error message");
// //
// but shorthand version for specific error types are preferred: // but shorthand version for specific error types are preferred:
// return DAWN_VALIDATION_ERROR("My error message"); // return DAWN_VALIDATION_ERROR("My error message with details %s", details);
// //
// There are different types of errors that should be used for different purpose: // There are different types of errors that should be used for different purpose:
// //
@ -71,11 +71,7 @@ using ResultOrError = Result<T, ErrorData>;
#define DAWN_MAKE_ERROR(TYPE, MESSAGE) \ #define DAWN_MAKE_ERROR(TYPE, MESSAGE) \
::dawn::native::ErrorData::Create(TYPE, MESSAGE, __FILE__, __func__, __LINE__) ::dawn::native::ErrorData::Create(TYPE, MESSAGE, __FILE__, __func__, __LINE__)
#define DAWN_VALIDATION_ERROR(MESSAGE) DAWN_MAKE_ERROR(InternalErrorType::Validation, MESSAGE) #define DAWN_VALIDATION_ERROR(...) \
// TODO(dawn:563): Rename to DAWN_VALIDATION_ERROR once all message format strings have been
// converted to constexpr.
#define DAWN_FORMAT_VALIDATION_ERROR(...) \
DAWN_MAKE_ERROR(InternalErrorType::Validation, absl::StrFormat(__VA_ARGS__)) DAWN_MAKE_ERROR(InternalErrorType::Validation, absl::StrFormat(__VA_ARGS__))
#define DAWN_INVALID_IF(EXPR, ...) \ #define DAWN_INVALID_IF(EXPR, ...) \

View File

@ -91,7 +91,7 @@ MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
DAWN_TRY(ValidateExternalTexturePlane(descriptor->plane0)); DAWN_TRY(ValidateExternalTexturePlane(descriptor->plane0));
break; break;
default: default:
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The external texture plane (%s) format (%s) is not a supported format " "The external texture plane (%s) format (%s) is not a supported format "
"(%s, %s, %s).", "(%s, %s, %s).",
descriptor->plane0, plane0Format, wgpu::TextureFormat::RGBA8Unorm, descriptor->plane0, plane0Format, wgpu::TextureFormat::RGBA8Unorm,

View File

@ -385,7 +385,7 @@ MaybeError InstanceBase::DiscoverAdaptersInternal(const AdapterDiscoveryOptionsB
DAWN_TRY(ValidateBackendType(backendType)); DAWN_TRY(ValidateBackendType(backendType));
if (!GetEnabledBackends()[backendType]) { if (!GetEnabledBackends()[backendType]) {
return DAWN_FORMAT_VALIDATION_ERROR("%s not supported.", backendType); return DAWN_VALIDATION_ERROR("%s not supported.", backendType);
} }
EnsureBackendConnection(backendType); EnsureBackendConnection(backendType);

View File

@ -42,12 +42,12 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
const EntryPointMetadata& metadata = module->GetEntryPoint(entryPoint); const EntryPointMetadata& metadata = module->GetEntryPoint(entryPoint);
if (!metadata.infringedLimitErrors.empty()) { if (!metadata.infringedLimitErrors.empty()) {
std::ostringstream out; std::ostringstream limitList;
out << "Entry point \"" << entryPoint << "\" infringes limits:\n";
for (const std::string& limit : metadata.infringedLimitErrors) { for (const std::string& limit : metadata.infringedLimitErrors) {
out << " - " << limit << "\n"; limitList << " - " << limit << "\n";
} }
return DAWN_VALIDATION_ERROR(out.str()); return DAWN_VALIDATION_ERROR("Entry point \"%s\" infringes limits:\n%s", entryPoint,
limitList.str());
} }
DAWN_INVALID_IF(metadata.stage != stage, DAWN_INVALID_IF(metadata.stage != stage,
@ -81,7 +81,7 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
stageInitializedConstantIdentifiers.insert(constants[i].key); stageInitializedConstantIdentifiers.insert(constants[i].key);
} else { } else {
// There are duplicate initializations // There are duplicate initializations
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"Pipeline overridable constants \"%s\" is set more than once in %s", "Pipeline overridable constants \"%s\" is set more than once in %s",
constants[i].key, module); constants[i].key, module);
} }
@ -104,7 +104,7 @@ MaybeError ValidateProgrammableStage(DeviceBase* device,
uninitializedConstantsArray.append(identifier); uninitializedConstantsArray.append(identifier);
} }
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"There are uninitialized pipeline overridable constants in shader module %s, their " "There are uninitialized pipeline overridable constants in shader module %s, their "
"identifiers:[%s]", "identifiers:[%s]",
module, uninitializedConstantsArray); module, uninitializedConstantsArray);

View File

@ -170,7 +170,7 @@ MaybeError ProgrammableEncoder::ValidateSetBindGroup(BindGroupIndex index,
static_cast<uint32_t>(i), dynamicOffsets[i], bufferBinding.buffer, static_cast<uint32_t>(i), dynamicOffsets[i], bufferBinding.buffer,
bufferBinding.buffer->GetSize(), bufferBinding.offset, bufferBinding.size); bufferBinding.buffer->GetSize(), bufferBinding.offset, bufferBinding.size);
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"Dynamic Offset[%u] (%u) is out of bounds of " "Dynamic Offset[%u] (%u) is out of bounds of "
"%s with a size of %u and a bound range of (offset: %u, size: %u).", "%s with a size of %u and a bound range of (offset: %u, size: %u).",
static_cast<uint32_t>(i), dynamicOffsets[i], bufferBinding.buffer, static_cast<uint32_t>(i), dynamicOffsets[i], bufferBinding.buffer,

View File

@ -46,8 +46,8 @@ MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descr
descriptor->magFilter, descriptor->minFilter, descriptor->mipmapFilter, descriptor->magFilter, descriptor->minFilter, descriptor->mipmapFilter,
wgpu::FilterMode::Linear, descriptor->maxAnisotropy); wgpu::FilterMode::Linear, descriptor->maxAnisotropy);
} else if (descriptor->maxAnisotropy == 0u) { } else if (descriptor->maxAnisotropy == 0u) {
return DAWN_FORMAT_VALIDATION_ERROR("Max anisotropy (%f) is less than 1.", return DAWN_VALIDATION_ERROR("Max anisotropy (%f) is less than 1.",
descriptor->maxAnisotropy); descriptor->maxAnisotropy);
} }
DAWN_TRY(ValidateFilterMode(descriptor->minFilter)); DAWN_TRY(ValidateFilterMode(descriptor->minFilter));

View File

@ -299,13 +299,12 @@ ResultOrError<tint::Program> ParseWGSL(const tint::Source::File* file,
outMessages->AddMessages(program.Diagnostics()); outMessages->AddMessages(program.Diagnostics());
} }
if (!program.IsValid()) { if (!program.IsValid()) {
return DAWN_FORMAT_VALIDATION_ERROR("Tint WGSL reader failure: %s\n", return DAWN_VALIDATION_ERROR("Tint WGSL reader failure: %s\n", program.Diagnostics().str());
program.Diagnostics().str());
} }
return std::move(program); return std::move(program);
#else #else
return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_WGSL_READER is not defined."); return DAWN_VALIDATION_ERROR("TINT_BUILD_WGSL_READER is not defined.");
#endif #endif
} }
@ -317,13 +316,13 @@ ResultOrError<tint::Program> ParseSPIRV(const std::vector<uint32_t>& spirv,
outMessages->AddMessages(program.Diagnostics()); outMessages->AddMessages(program.Diagnostics());
} }
if (!program.IsValid()) { if (!program.IsValid()) {
return DAWN_FORMAT_VALIDATION_ERROR("Tint SPIR-V reader failure:\nParser: %s\n", return DAWN_VALIDATION_ERROR("Tint SPIR-V reader failure:\nParser: %s\n",
program.Diagnostics().str()); program.Diagnostics().str());
} }
return std::move(program); return std::move(program);
#else #else
return DAWN_FORMAT_VALIDATION_ERROR("TINT_BUILD_SPV_READER is not defined."); return DAWN_VALIDATION_ERROR("TINT_BUILD_SPV_READER is not defined.");
#endif #endif
} }

View File

@ -162,7 +162,7 @@ MaybeError ValidateSurfaceDescriptor(const InstanceBase* instance,
} }
#endif // defined(DAWN_USE_X11) #endif // defined(DAWN_USE_X11)
return DAWN_FORMAT_VALIDATION_ERROR("Unsupported sType (%s)", descriptor->nextInChain->sType); return DAWN_VALIDATION_ERROR("Unsupported sType (%s)", descriptor->nextInChain->sType);
} }
// static // static

View File

@ -35,16 +35,16 @@ class ErrorSwapChain final : public SwapChainBase {
wgpu::TextureUsage allowedUsage, wgpu::TextureUsage allowedUsage,
uint32_t width, uint32_t width,
uint32_t height) override { uint32_t height) override {
GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
} }
TextureViewBase* APIGetCurrentTextureView() override { TextureViewBase* APIGetCurrentTextureView() override {
GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
return TextureViewBase::MakeError(GetDevice()); return TextureViewBase::MakeError(GetDevice());
} }
void APIPresent() override { void APIPresent() override {
GetDevice()->ConsumedError(DAWN_FORMAT_VALIDATION_ERROR("%s is an error swapchain.", this)); GetDevice()->ConsumedError(DAWN_VALIDATION_ERROR("%s is an error swapchain.", this));
} }
}; };
@ -301,7 +301,7 @@ void NewSwapChainBase::APIConfigure(wgpu::TextureFormat format,
uint32_t width, uint32_t width,
uint32_t height) { uint32_t height) {
GetDevice()->ConsumedError( GetDevice()->ConsumedError(
DAWN_FORMAT_VALIDATION_ERROR("Configure is invalid for surface-based swapchains.")); DAWN_VALIDATION_ERROR("Configure is invalid for surface-based swapchains."));
} }
TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() { TextureViewBase* NewSwapChainBase::APIGetCurrentTextureView() {

View File

@ -54,7 +54,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device,
if (viewFormat.format == aspectFormat) { if (viewFormat.format == aspectFormat) {
return {}; return {};
} else { } else {
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The view format (%s) is not compatible with %s of %s (%s).", viewFormat.format, "The view format (%s) is not compatible with %s of %s (%s).", viewFormat.format,
aspect, format.format, aspectFormat); aspect, format.format, aspectFormat);
} }
@ -78,7 +78,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device,
// The view format isn't compatible with the format at all. Return an error // The view format isn't compatible with the format at all. Return an error
// that indicates this, in addition to reporting that it's missing from the // that indicates this, in addition to reporting that it's missing from the
// list. // list.
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The texture view format (%s) is not compatible with the " "The texture view format (%s) is not compatible with the "
"texture format (%s)." "texture format (%s)."
"The formats must be compatible, and the view format " "The formats must be compatible, and the view format "
@ -86,7 +86,7 @@ MaybeError ValidateCanViewTextureAs(const DeviceBase* device,
viewFormat.format, format.format); viewFormat.format, format.format);
} else { } else {
// The view format is compatible, but not in the list. // The view format is compatible, but not in the list.
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"%s was not created with the texture view format (%s) " "%s was not created with the texture view format (%s) "
"in the list of compatible view formats.", "in the list of compatible view formats.",
texture, viewFormat.format); texture, viewFormat.format);

View File

@ -282,8 +282,8 @@ ResultOrError<ComPtr<IDxcBlob>> CompileShaderDXC(const D3DBytecodeCompilationReq
ComPtr<IDxcBlobEncoding> errors; ComPtr<IDxcBlobEncoding> errors;
DAWN_TRY(CheckHRESULT(result->GetErrorBuffer(&errors), "DXC get error buffer")); DAWN_TRY(CheckHRESULT(result->GetErrorBuffer(&errors), "DXC get error buffer"));
return DAWN_FORMAT_VALIDATION_ERROR("DXC compile failed with: %s", return DAWN_VALIDATION_ERROR("DXC compile failed with: %s",
static_cast<char*>(errors->GetBufferPointer())); static_cast<char*>(errors->GetBufferPointer()));
} }
ComPtr<IDxcBlob> compiledShader; ComPtr<IDxcBlob> compiledShader;
@ -447,15 +447,14 @@ ResultOrError<std::string> TranslateToHLSL(
*remappedEntryPointName = r.entryPointName; *remappedEntryPointName = r.entryPointName;
} }
} else { } else {
return DAWN_FORMAT_VALIDATION_ERROR("Transform output missing renamer data."); return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
} }
if (r.stage == SingleShaderStage::Vertex) { if (r.stage == SingleShaderStage::Vertex) {
if (auto* data = transformOutputs.Get<tint::transform::FirstIndexOffset::Data>()) { if (auto* data = transformOutputs.Get<tint::transform::FirstIndexOffset::Data>()) {
*usesVertexOrInstanceIndex = data->has_vertex_or_instance_index; *usesVertexOrInstanceIndex = data->has_vertex_or_instance_index;
} else { } else {
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR("Transform output missing first index offset data.");
"Transform output missing first index offset data.");
} }
} }

View File

@ -490,7 +490,7 @@ MaybeError ValidateD3D12VideoTextureCanBeShared(Device* device, DXGI_FORMAT text
break; break;
} }
return DAWN_FORMAT_VALIDATION_ERROR("DXGI format does not support cross-API sharing."); return DAWN_VALIDATION_ERROR("DXGI format does not support cross-API sharing.");
} }
// static // static

View File

@ -227,7 +227,7 @@ ResultOrError<CacheResult<MslCompilation>> TranslateToMSL(DeviceBase* device,
remappedEntryPointName = r.entryPointName; remappedEntryPointName = r.entryPointName;
} }
} else { } else {
return DAWN_FORMAT_VALIDATION_ERROR("Transform output missing renamer data."); return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
} }
tint::writer::msl::Options options; tint::writer::msl::Options options;
@ -335,8 +335,8 @@ MaybeError ShaderModule::CreateFunction(const char* entryPointName,
error:&error]); error:&error]);
if (error != nullptr) { if (error != nullptr) {
if (error.code != MTLLibraryErrorCompileWarning) { if (error.code != MTLLibraryErrorCompileWarning) {
return DAWN_FORMAT_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR("Function compile error: %s",
"Function compile error: %s", [error.localizedDescription UTF8String]); [error.localizedDescription UTF8String]);
} }
} }
ASSERT(out->function != nil); ASSERT(out->function != nil);

View File

@ -197,7 +197,7 @@ ResultOrError<wgpu::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
return wgpu::TextureFormat::R8BG8Biplanar420Unorm; return wgpu::TextureFormat::R8BG8Biplanar420Unorm;
default: default:
return DAWN_FORMAT_VALIDATION_ERROR("Unsupported IOSurface format (%x).", format); return DAWN_VALIDATION_ERROR("Unsupported IOSurface format (%x).", format);
} }
} }

View File

@ -299,7 +299,7 @@ ResultOrError<Ref<NewSwapChainBase>> Device::CreateSwapChainImpl(
Surface* surface, Surface* surface,
NewSwapChainBase* previousSwapChain, NewSwapChainBase* previousSwapChain,
const SwapChainDescriptor* descriptor) { const SwapChainDescriptor* descriptor) {
return DAWN_FORMAT_VALIDATION_ERROR("New swapchains not implemented."); return DAWN_VALIDATION_ERROR("New swapchains not implemented.");
} }
ResultOrError<Ref<TextureBase>> Device::CreateTextureImpl(const TextureDescriptor* descriptor) { ResultOrError<Ref<TextureBase>> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
return AcquireRef(new Texture(this, descriptor)); return AcquireRef(new Texture(this, descriptor));
@ -364,7 +364,7 @@ TextureBase* Device::CreateTextureWrappingEGLImage(const ExternalImageDescriptor
if (textureDescriptor->size.width != static_cast<uint32_t>(width) || if (textureDescriptor->size.width != static_cast<uint32_t>(width) ||
textureDescriptor->size.height != static_cast<uint32_t>(height) || textureDescriptor->size.height != static_cast<uint32_t>(height) ||
textureDescriptor->size.depthOrArrayLayers != 1) { textureDescriptor->size.depthOrArrayLayers != 1) {
ConsumedError(DAWN_FORMAT_VALIDATION_ERROR( ConsumedError(DAWN_VALIDATION_ERROR(
"EGLImage size (width: %u, height: %u, depth: 1) doesn't match descriptor size %s.", "EGLImage size (width: %u, height: %u, depth: 1) doesn't match descriptor size %s.",
width, height, &textureDescriptor->size)); width, height, &textureDescriptor->size));
gl.DeleteTextures(1, &tex); gl.DeleteTextures(1, &tex);

View File

@ -82,7 +82,7 @@ MaybeError PipelineGL::InitializeBase(const OpenGLFunctions& gl,
if (infoLogLength > 1) { if (infoLogLength > 1) {
std::vector<char> buffer(infoLogLength); std::vector<char> buffer(infoLogLength);
gl.GetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]); gl.GetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]);
return DAWN_FORMAT_VALIDATION_ERROR("Program link failed:\n%s", buffer.data()); return DAWN_VALIDATION_ERROR("Program link failed:\n%s", buffer.data());
} }
} }

View File

@ -264,8 +264,8 @@ ResultOrError<GLuint> ShaderModule::CompileShader(const OpenGLFunctions& gl,
std::vector<char> buffer(infoLogLength); std::vector<char> buffer(infoLogLength);
gl.GetShaderInfoLog(shader, infoLogLength, nullptr, &buffer[0]); gl.GetShaderInfoLog(shader, infoLogLength, nullptr, &buffer[0]);
gl.DeleteShader(shader); gl.DeleteShader(shader);
return DAWN_FORMAT_VALIDATION_ERROR("%s\nProgram compilation failed:\n%s", source, return DAWN_VALIDATION_ERROR("%s\nProgram compilation failed:\n%s", source,
buffer.data()); buffer.data());
} }
} }

View File

@ -225,8 +225,7 @@ ResultOrError<VkSurfaceKHR> CreateVulkanSurface(Adapter* adapter, Surface* surfa
break; break;
} }
return DAWN_FORMAT_VALIDATION_ERROR("Unsupported surface type (%s) for Vulkan.", return DAWN_VALIDATION_ERROR("Unsupported surface type (%s) for Vulkan.", surface->GetType());
surface->GetType());
} }
VkPresentModeKHR ToVulkanPresentMode(wgpu::PresentMode mode) { VkPresentModeKHR ToVulkanPresentMode(wgpu::PresentMode mode) {

View File

@ -69,7 +69,7 @@ ResultOrError<uint32_t> GetModifierPlaneCount(const VulkanFunctions& fn,
if (GetFormatModifierProps(fn, physicalDevice, format, modifier, &props)) { if (GetFormatModifierProps(fn, physicalDevice, format, modifier, &props)) {
return static_cast<uint32_t>(props.drmFormatModifierPlaneCount); return static_cast<uint32_t>(props.drmFormatModifierPlaneCount);
} }
return DAWN_FORMAT_VALIDATION_ERROR("DRM format modifier not supported."); return DAWN_VALIDATION_ERROR("DRM format modifier not supported.");
} }
bool IsMultiPlanarVkFormat(VkFormat format) { bool IsMultiPlanarVkFormat(VkFormat format) {

View File

@ -22,7 +22,7 @@ namespace dawn::native {
namespace { namespace {
int placeholderSuccess = 0xbeef; int placeholderSuccess = 0xbeef;
const char* placeholderErrorMessage = "I am an error message :3"; constexpr const char* placeholderErrorMessage = "I am an error message :3";
// Check returning a success MaybeError with {}; // Check returning a success MaybeError with {};
TEST(ErrorTests, Error_Success) { TEST(ErrorTests, Error_Success) {