Rename Error.h macros from NXT to DAWN

This commit is contained in:
Corentin Wallez 2018-07-18 11:45:17 +02:00 committed by Corentin Wallez
parent 226110f958
commit 33ca49614d
11 changed files with 152 additions and 152 deletions

View File

@ -24,7 +24,7 @@ namespace backend {
return {};
{% endfor %}
default:
NXT_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}");
DAWN_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}");
}
}
@ -35,7 +35,7 @@ namespace backend {
if ((value & static_cast<nxt::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
return {};
}
NXT_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}");
DAWN_RETURN_ERROR("Invalid value for {{as_cType(type.name)}}");
}
{% endfor %}

View File

@ -260,7 +260,7 @@
namespace nxt { namespace wire {
// Macro to simplify error handling, similar to NXT_TRY but for DeserializeResult.
// Macro to simplify error handling, similar to DAWN_TRY but for DeserializeResult.
#define DESERIALIZE_TRY(EXPR) \
{ \
DeserializeResult exprResult = EXPR; \

View File

@ -26,17 +26,17 @@ namespace backend {
MaybeError ValidateBindGroupLayoutDescriptor(
DeviceBase*,
const dawn::BindGroupLayoutDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
std::bitset<kMaxBindingsPerGroup> bindingsSet;
for (uint32_t i = 0; i < descriptor->numBindings; ++i) {
auto& binding = descriptor->bindings[i];
NXT_TRY_ASSERT(binding.binding <= kMaxBindingsPerGroup,
DAWN_TRY_ASSERT(binding.binding <= kMaxBindingsPerGroup,
"some binding index exceeds the maximum value");
NXT_TRY(ValidateShaderStageBit(binding.visibility));
NXT_TRY(ValidateBindingType(binding.type));
DAWN_TRY(ValidateShaderStageBit(binding.visibility));
DAWN_TRY(ValidateBindingType(binding.type));
NXT_TRY_ASSERT(!bindingsSet[i], "some binding index was specified more than once");
DAWN_TRY_ASSERT(!bindingsSet[i], "some binding index was specified more than once");
bindingsSet.set(binding.binding);
}
return {};

View File

@ -35,7 +35,7 @@ namespace backend {
MaybeError ValidateCopyLocationFitsInTexture(const TextureCopyLocation& location) {
const TextureBase* texture = location.texture.Get();
if (location.level >= texture->GetNumMipLevels()) {
NXT_RETURN_ERROR("Copy mip-level out of range");
DAWN_RETURN_ERROR("Copy mip-level out of range");
}
// All texture dimensions are in uint32_t so by doing checks in uint64_t we avoid
@ -45,13 +45,13 @@ namespace backend {
(static_cast<uint64_t>(texture->GetWidth()) >> level) ||
uint64_t(location.y) + uint64_t(location.height) >
(static_cast<uint64_t>(texture->GetHeight()) >> level)) {
NXT_RETURN_ERROR("Copy would touch outside of the texture");
DAWN_RETURN_ERROR("Copy would touch outside of the texture");
}
// TODO(cwallez@chromium.org): Check the depth bound differently for 2D arrays and 3D
// textures
if (location.z != 0 || location.depth != 1) {
NXT_RETURN_ERROR("No support for z != 0 and depth != 1 for now");
DAWN_RETURN_ERROR("No support for z != 0 and depth != 1 for now");
}
return {};
@ -65,7 +65,7 @@ namespace backend {
MaybeError ValidateCopySizeFitsInBuffer(const BufferCopyLocation& location,
uint32_t dataSize) {
if (!FitsInBuffer(location.buffer.Get(), location.offset, dataSize)) {
NXT_RETURN_ERROR("Copy would overflow the buffer");
DAWN_RETURN_ERROR("Copy would overflow the buffer");
}
return {};
@ -76,7 +76,7 @@ namespace backend {
uint32_t texelSize =
static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat()));
if (location.offset % texelSize != 0) {
NXT_RETURN_ERROR("Buffer offset must be a multiple of the texel size");
DAWN_RETURN_ERROR("Buffer offset must be a multiple of the texel size");
}
return {};
@ -98,12 +98,12 @@ namespace backend {
MaybeError ValidateRowPitch(const TextureCopyLocation& location, uint32_t rowPitch) {
if (rowPitch % kTextureRowPitchAlignment != 0) {
NXT_RETURN_ERROR("Row pitch must be a multiple of 256");
DAWN_RETURN_ERROR("Row pitch must be a multiple of 256");
}
uint32_t texelSize = TextureFormatPixelSize(location.texture.Get()->GetFormat());
if (rowPitch < location.width * texelSize) {
NXT_RETURN_ERROR("Row pitch must not be less than the number of bytes per row");
DAWN_RETURN_ERROR("Row pitch must not be less than the number of bytes per row");
}
return {};
@ -112,7 +112,7 @@ namespace backend {
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(buffer->GetAllowedUsage() & usage)) {
NXT_RETURN_ERROR("buffer doesn't have the required usage.");
DAWN_RETURN_ERROR("buffer doesn't have the required usage.");
}
return {};
@ -121,7 +121,7 @@ namespace backend {
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(texture->GetAllowedUsage() & usage)) {
NXT_RETURN_ERROR("texture doesn't have the required usage.");
DAWN_RETURN_ERROR("texture doesn't have the required usage.");
}
return {};
@ -168,7 +168,7 @@ namespace backend {
MaybeError ValidateUsages(PassType pass) const {
// Storage resources cannot be used twice in the same compute pass
if (pass == PassType::Compute && mStorageUsedMultipleTimes) {
NXT_RETURN_ERROR("Storage resource used multiple times in compute pass");
DAWN_RETURN_ERROR("Storage resource used multiple times in compute pass");
}
// Buffers can only be used as single-write or multiple read.
@ -177,14 +177,14 @@ namespace backend {
dawn::BufferUsageBit usage = it.second;
if (usage & ~buffer->GetAllowedUsage()) {
NXT_RETURN_ERROR("Buffer missing usage for the pass");
DAWN_RETURN_ERROR("Buffer missing usage for the pass");
}
bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
bool singleUse = dawn::HasZeroOrOneBits(usage);
if (!readOnly && !singleUse) {
NXT_RETURN_ERROR(
DAWN_RETURN_ERROR(
"Buffer used as writeable usage and another usage in pass");
}
}
@ -196,13 +196,13 @@ namespace backend {
dawn::TextureUsageBit usage = it.second;
if (usage & ~texture->GetAllowedUsage()) {
NXT_RETURN_ERROR("Texture missing usage for the pass");
DAWN_RETURN_ERROR("Texture missing usage for the pass");
}
// For textures the only read-only usage in a pass is Sampled, so checking the
// usage constraint simplifies to checking a single usage bit is set.
if (!dawn::HasZeroOrOneBits(it.second)) {
NXT_RETURN_ERROR("Texture used with more than one usage in pass");
DAWN_RETURN_ERROR("Texture used with more than one usage in pass");
}
}
@ -324,23 +324,23 @@ namespace backend {
switch (type) {
case Command::BeginComputePass: {
mIterator.NextCommand<BeginComputePassCmd>();
NXT_TRY(ValidateComputePass());
DAWN_TRY(ValidateComputePass());
} break;
case Command::BeginRenderPass: {
BeginRenderPassCmd* cmd = mIterator.NextCommand<BeginRenderPassCmd>();
NXT_TRY(ValidateRenderPass(cmd->info.Get()));
DAWN_TRY(ValidateRenderPass(cmd->info.Get()));
} break;
case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = mIterator.NextCommand<CopyBufferToBufferCmd>();
NXT_TRY(ValidateCopySizeFitsInBuffer(copy->source, copy->size));
NXT_TRY(ValidateCopySizeFitsInBuffer(copy->destination, copy->size));
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, copy->size));
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, copy->size));
NXT_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
dawn::BufferUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
dawn::BufferUsageBit::TransferDst));
} break;
@ -348,18 +348,18 @@ namespace backend {
CopyBufferToTextureCmd* copy = mIterator.NextCommand<CopyBufferToTextureCmd>();
uint32_t bufferCopySize = 0;
NXT_TRY(ValidateRowPitch(copy->destination, copy->rowPitch));
NXT_TRY(ComputeTextureCopyBufferSize(copy->destination, copy->rowPitch,
DAWN_TRY(ValidateRowPitch(copy->destination, copy->rowPitch));
DAWN_TRY(ComputeTextureCopyBufferSize(copy->destination, copy->rowPitch,
&bufferCopySize));
NXT_TRY(ValidateCopyLocationFitsInTexture(copy->destination));
NXT_TRY(ValidateCopySizeFitsInBuffer(copy->source, bufferCopySize));
NXT_TRY(
DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->destination));
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, bufferCopySize));
DAWN_TRY(
ValidateTexelBufferOffset(copy->destination.texture.Get(), copy->source));
NXT_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
dawn::BufferUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
dawn::TextureUsageBit::TransferDst));
} break;
@ -367,23 +367,23 @@ namespace backend {
CopyTextureToBufferCmd* copy = mIterator.NextCommand<CopyTextureToBufferCmd>();
uint32_t bufferCopySize = 0;
NXT_TRY(ValidateRowPitch(copy->source, copy->rowPitch));
NXT_TRY(ComputeTextureCopyBufferSize(copy->source, copy->rowPitch,
DAWN_TRY(ValidateRowPitch(copy->source, copy->rowPitch));
DAWN_TRY(ComputeTextureCopyBufferSize(copy->source, copy->rowPitch,
&bufferCopySize));
NXT_TRY(ValidateCopyLocationFitsInTexture(copy->source));
NXT_TRY(ValidateCopySizeFitsInBuffer(copy->destination, bufferCopySize));
NXT_TRY(
DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->source));
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, bufferCopySize));
DAWN_TRY(
ValidateTexelBufferOffset(copy->source.texture.Get(), copy->destination));
NXT_TRY(ValidateCanUseAs(copy->source.texture.Get(),
DAWN_TRY(ValidateCanUseAs(copy->source.texture.Get(),
dawn::TextureUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
dawn::BufferUsageBit::TransferDst));
} break;
default:
NXT_RETURN_ERROR("Command disallowed outside of a pass");
DAWN_RETURN_ERROR("Command disallowed outside of a pass");
}
}
@ -399,7 +399,7 @@ namespace backend {
case Command::EndComputePass: {
mIterator.NextCommand<EndComputePassCmd>();
NXT_TRY(usageTracker.ValidateUsages(PassType::Compute));
DAWN_TRY(usageTracker.ValidateUsages(PassType::Compute));
mPassResourceUsages.push_back(usageTracker.AcquireResourceUsage());
mState->EndPass();
@ -408,7 +408,7 @@ namespace backend {
case Command::Dispatch: {
mIterator.NextCommand<DispatchCmd>();
NXT_TRY(mState->ValidateCanDispatch());
DAWN_TRY(mState->ValidateCanDispatch());
} break;
case Command::SetComputePipeline: {
@ -424,7 +424,7 @@ namespace backend {
// recorded because it impacts the size of an allocation in the
// CommandAllocator.
if (cmd->stages & ~dawn::ShaderStageBit::Compute) {
NXT_RETURN_ERROR(
DAWN_RETURN_ERROR(
"SetPushConstants stage must be compute or 0 in compute passes");
}
} break;
@ -437,11 +437,11 @@ namespace backend {
} break;
default:
NXT_RETURN_ERROR("Command disallowed inside a compute pass");
DAWN_RETURN_ERROR("Command disallowed inside a compute pass");
}
}
NXT_RETURN_ERROR("Unfinished compute pass");
DAWN_RETURN_ERROR("Unfinished compute pass");
}
MaybeError CommandBufferBuilder::ValidateRenderPass(RenderPassDescriptorBase* renderPass) {
@ -464,7 +464,7 @@ namespace backend {
case Command::EndRenderPass: {
mIterator.NextCommand<EndRenderPassCmd>();
NXT_TRY(usageTracker.ValidateUsages(PassType::Render));
DAWN_TRY(usageTracker.ValidateUsages(PassType::Render));
mPassResourceUsages.push_back(usageTracker.AcquireResourceUsage());
mState->EndPass();
@ -473,12 +473,12 @@ namespace backend {
case Command::DrawArrays: {
mIterator.NextCommand<DrawArraysCmd>();
NXT_TRY(mState->ValidateCanDrawArrays());
DAWN_TRY(mState->ValidateCanDrawArrays());
} break;
case Command::DrawElements: {
mIterator.NextCommand<DrawElementsCmd>();
NXT_TRY(mState->ValidateCanDrawElements());
DAWN_TRY(mState->ValidateCanDrawElements());
} break;
case Command::SetRenderPipeline: {
@ -486,7 +486,7 @@ namespace backend {
RenderPipelineBase* pipeline = cmd->pipeline.Get();
if (!pipeline->IsCompatibleWith(renderPass)) {
NXT_RETURN_ERROR("Pipeline is incompatible with this render pass");
DAWN_RETURN_ERROR("Pipeline is incompatible with this render pass");
}
mState->SetRenderPipeline(pipeline);
@ -500,7 +500,7 @@ namespace backend {
// CommandAllocator.
if (cmd->stages &
~(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
NXT_RETURN_ERROR(
DAWN_RETURN_ERROR(
"SetPushConstants stage must be a subset of (vertex|fragment) in "
"render passes");
}
@ -529,7 +529,7 @@ namespace backend {
SetIndexBufferCmd* cmd = mIterator.NextCommand<SetIndexBufferCmd>();
usageTracker.BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsageBit::Index);
NXT_TRY(mState->SetIndexBuffer());
DAWN_TRY(mState->SetIndexBuffer());
} break;
case Command::SetVertexBuffers: {
@ -539,16 +539,16 @@ namespace backend {
for (uint32_t i = 0; i < cmd->count; ++i) {
usageTracker.BufferUsedAs(buffers[i].Get(), dawn::BufferUsageBit::Vertex);
NXT_TRY(mState->SetVertexBuffer(cmd->startSlot + i));
DAWN_TRY(mState->SetVertexBuffer(cmd->startSlot + i));
}
} break;
default:
NXT_RETURN_ERROR("Command disallowed inside a render pass");
DAWN_RETURN_ERROR("Command disallowed inside a render pass");
}
}
NXT_RETURN_ERROR("Unfinished render pass");
DAWN_RETURN_ERROR("Unfinished render pass");
}
// Implementation of the API's command recording methods

View File

@ -38,11 +38,11 @@ namespace backend {
}
if (!mAspects[VALIDATION_ASPECT_PIPELINE]) {
NXT_RETURN_ERROR("No active compute pipeline");
DAWN_RETURN_ERROR("No active compute pipeline");
}
// Compute the lazily computed mAspects
if (!RecomputeHaveAspectBindGroups()) {
NXT_RETURN_ERROR("Bind group state not valid");
DAWN_RETURN_ERROR("Bind group state not valid");
}
return {};
}
@ -69,7 +69,7 @@ namespace backend {
}
if (!mAspects[VALIDATION_ASPECT_INDEX_BUFFER]) {
NXT_RETURN_ERROR("Cannot DrawElements without index buffer set");
DAWN_RETURN_ERROR("Cannot DrawElements without index buffer set");
}
return RevalidateCanDraw();
}
@ -96,7 +96,7 @@ namespace backend {
MaybeError CommandBufferStateTracker::SetIndexBuffer() {
if (!HavePipeline()) {
NXT_RETURN_ERROR("Can't set the index buffer without a pipeline");
DAWN_RETURN_ERROR("Can't set the index buffer without a pipeline");
}
mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER);
@ -105,7 +105,7 @@ namespace backend {
MaybeError CommandBufferStateTracker::SetVertexBuffer(uint32_t index) {
if (!HavePipeline()) {
NXT_RETURN_ERROR("Can't set vertex buffers without a pipeline");
DAWN_RETURN_ERROR("Can't set vertex buffers without a pipeline");
}
mInputsSet.set(index);
@ -152,14 +152,14 @@ namespace backend {
MaybeError CommandBufferStateTracker::RevalidateCanDraw() {
if (!mAspects[VALIDATION_ASPECT_PIPELINE]) {
NXT_RETURN_ERROR("No active render pipeline");
DAWN_RETURN_ERROR("No active render pipeline");
}
// Compute the lazily computed mAspects
if (!RecomputeHaveAspectBindGroups()) {
NXT_RETURN_ERROR("Bind group state not valid");
DAWN_RETURN_ERROR("Bind group state not valid");
}
if (!RecomputeHaveAspectVertexBuffers()) {
NXT_RETURN_ERROR("Some vertex buffers are not set");
DAWN_RETURN_ERROR("Some vertex buffers are not set");
}
return {};
}

View File

@ -84,7 +84,7 @@ namespace backend {
}
BindGroupLayoutBase* backendObj;
NXT_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
mCaches->bindGroupLayouts.insert(backendObj);
return backendObj;
}
@ -194,28 +194,28 @@ namespace backend {
MaybeError DeviceBase::CreateBindGroupLayoutInternal(
BindGroupLayoutBase** result,
const dawn::BindGroupLayoutDescriptor* descriptor) {
NXT_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
return {};
}
MaybeError DeviceBase::CreatePipelineLayoutInternal(
PipelineLayoutBase** result,
const dawn::PipelineLayoutDescriptor* descriptor) {
NXT_TRY(ValidatePipelineLayoutDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor));
DAWN_TRY(ValidatePipelineLayoutDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor));
return {};
}
MaybeError DeviceBase::CreateQueueInternal(QueueBase** result) {
NXT_TRY_ASSIGN(*result, CreateQueueImpl());
DAWN_TRY_ASSIGN(*result, CreateQueueImpl());
return {};
}
MaybeError DeviceBase::CreateSamplerInternal(SamplerBase** result,
const dawn::SamplerDescriptor* descriptor) {
NXT_TRY(ValidateSamplerDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor));
DAWN_TRY(ValidateSamplerDescriptor(this, descriptor));
DAWN_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor));
return {};
}

View File

@ -35,29 +35,29 @@ namespace backend {
// return SomethingOfTypeT; // for ResultOrError<T>
//
// Returning an error is done via:
// NXT_RETURN_ERROR("My error message");
#define NXT_RETURN_ERROR(MESSAGE) return MakeError(MESSAGE, __FILE__, __func__, __LINE__)
#define NXT_TRY_ASSERT(EXPR, MESSAGE) \
// DAWN_RETURN_ERROR("My error message");
#define DAWN_RETURN_ERROR(MESSAGE) return MakeError(MESSAGE, __FILE__, __func__, __LINE__)
#define DAWN_TRY_ASSERT(EXPR, MESSAGE) \
{ \
if (!(EXPR)) { \
NXT_RETURN_ERROR(MESSAGE); \
DAWN_RETURN_ERROR(MESSAGE); \
} \
} \
for (;;) \
break
#define NXT_CONCAT1(x, y) x##y
#define NXT_CONCAT2(x, y) NXT_CONCAT1(x, y)
#define NXT_LOCAL_VAR NXT_CONCAT2(_localVar, __LINE__)
#define DAWN_CONCAT1(x, y) x##y
#define DAWN_CONCAT2(x, y) DAWN_CONCAT1(x, y)
#define DAWN_LOCAL_VAR DAWN_CONCAT2(_localVar, __LINE__)
// When Errors aren't handled explicitly, calls to functions returning errors should be
// wrapped in an NXT_TRY. It will return the error if any, otherwise keep executing
// wrapped in an DAWN_TRY. It will return the error if any, otherwise keep executing
// the current function.
#define NXT_TRY(EXPR) \
#define DAWN_TRY(EXPR) \
{ \
auto NXT_LOCAL_VAR = EXPR; \
if (NXT_UNLIKELY(NXT_LOCAL_VAR.IsError())) { \
ErrorData* error = NXT_LOCAL_VAR.AcquireError(); \
auto DAWN_LOCAL_VAR = EXPR; \
if (NXT_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
AppendBacktrace(error, __FILE__, __func__, __LINE__); \
return {error}; \
} \
@ -65,25 +65,25 @@ namespace backend {
for (;;) \
break
// NXT_TRY_ASSIGN is the same as NXT_TRY for ResultOrError and assigns the success value, if
// DAWN_TRY_ASSIGN is the same as DAWN_TRY for ResultOrError and assigns the success value, if
// any, to VAR.
#define NXT_TRY_ASSIGN(VAR, EXPR) \
#define DAWN_TRY_ASSIGN(VAR, EXPR) \
{ \
auto NXT_LOCAL_VAR = EXPR; \
if (NXT_UNLIKELY(NXT_LOCAL_VAR.IsError())) { \
ErrorData* error = NXT_LOCAL_VAR.AcquireError(); \
auto DAWN_LOCAL_VAR = EXPR; \
if (NXT_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
AppendBacktrace(error, __FILE__, __func__, __LINE__); \
return {error}; \
} \
VAR = NXT_LOCAL_VAR.AcquireSuccess(); \
VAR = DAWN_LOCAL_VAR.AcquireSuccess(); \
} \
for (;;) \
break
// Implementation detail of NXT_TRY and NXT_TRY_ASSIGN's adding to the Error's backtrace.
// Implementation detail of DAWN_TRY and DAWN_TRY_ASSIGN's adding to the Error's backtrace.
void AppendBacktrace(ErrorData* error, const char* file, const char* function, int line);
// Implementation detail of NXT_RETURN_ERROR
// Implementation detail of DAWN_RETURN_ERROR
ErrorData* MakeError(const char* message, const char* file, const char* function, int line);
} // namespace backend

View File

@ -22,11 +22,11 @@ namespace backend {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
const dawn::PipelineLayoutDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
NXT_TRY_ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups,
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
DAWN_TRY_ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups,
"too many bind group layouts");
for (uint32_t i = 0; i < descriptor->numBindGroupLayouts; ++i) {
NXT_TRY_ASSERT(descriptor->bindGroupLayouts[i].Get() != nullptr,
DAWN_TRY_ASSERT(descriptor->bindGroupLayouts[i].Get() != nullptr,
"bind group layouts may not be null");
}
return {};

View File

@ -36,7 +36,7 @@ namespace backend {
"invalid command buffer type");
for (uint32_t i = 0; i < numCommands; ++i) {
NXT_TRY(ValidateSubmitCommand(commands[i]));
DAWN_TRY(ValidateSubmitCommand(commands[i]));
}
return {};
}

View File

@ -20,13 +20,13 @@
namespace backend {
MaybeError ValidateSamplerDescriptor(DeviceBase*, const dawn::SamplerDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
NXT_TRY(ValidateFilterMode(descriptor->minFilter));
NXT_TRY(ValidateFilterMode(descriptor->magFilter));
NXT_TRY(ValidateFilterMode(descriptor->mipmapFilter));
NXT_TRY(ValidateAddressMode(descriptor->addressModeU));
NXT_TRY(ValidateAddressMode(descriptor->addressModeV));
NXT_TRY(ValidateAddressMode(descriptor->addressModeW));
DAWN_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
DAWN_TRY(ValidateFilterMode(descriptor->magFilter));
DAWN_TRY(ValidateFilterMode(descriptor->mipmapFilter));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeU));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeV));
DAWN_TRY(ValidateAddressMode(descriptor->addressModeW));
return {};
}

View File

@ -34,10 +34,10 @@ TEST(ErrorTests, Error_Success) {
ASSERT_TRUE(result.IsSuccess());
}
// Check returning an error MaybeError with NXT_RETURN_ERROR
// Check returning an error MaybeError with DAWN_RETURN_ERROR
TEST(ErrorTests, Error_Error) {
auto ReturnError = []() -> MaybeError {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
MaybeError result = ReturnError();
@ -59,10 +59,10 @@ TEST(ErrorTests, ResultOrError_Success) {
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
}
// Check returning an error ResultOrError with NXT_RETURN_ERROR
// Check returning an error ResultOrError with DAWN_RETURN_ERROR
TEST(ErrorTests, ResultOrError_Error) {
auto ReturnError = []() -> ResultOrError<int*> {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
ResultOrError<int*> result = ReturnError();
@ -73,17 +73,17 @@ TEST(ErrorTests, ResultOrError_Error) {
delete errorData;
}
// Check NXT_TRY handles successes correctly.
// Check DAWN_TRY handles successes correctly.
TEST(ErrorTests, TRY_Success) {
auto ReturnSuccess = []() -> MaybeError {
return {};
};
// We need to check that NXT_TRY doesn't return on successes
// We need to check that DAWN_TRY doesn't return on successes
bool tryReturned = true;
auto Try = [ReturnSuccess, &tryReturned]() -> MaybeError {
NXT_TRY(ReturnSuccess());
DAWN_TRY(ReturnSuccess());
tryReturned = false;
return {};
};
@ -93,15 +93,15 @@ TEST(ErrorTests, TRY_Success) {
ASSERT_FALSE(tryReturned);
}
// Check NXT_TRY handles errors correctly.
// Check DAWN_TRY handles errors correctly.
TEST(ErrorTests, TRY_Error) {
auto ReturnError = []() -> MaybeError {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto Try = [ReturnError]() -> MaybeError {
NXT_TRY(ReturnError());
// NXT_TRY should return before this point
DAWN_TRY(ReturnError());
// DAWN_TRY should return before this point
EXPECT_FALSE(true);
return {};
};
@ -114,19 +114,19 @@ TEST(ErrorTests, TRY_Error) {
delete errorData;
}
// Check NXT_TRY adds to the backtrace.
// Check DAWN_TRY adds to the backtrace.
TEST(ErrorTests, TRY_AddsToBacktrace) {
auto ReturnError = []() -> MaybeError {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto SingleTry = [ReturnError]() -> MaybeError {
NXT_TRY(ReturnError());
DAWN_TRY(ReturnError());
return {};
};
auto DoubleTry = [SingleTry]() -> MaybeError {
NXT_TRY(SingleTry());
DAWN_TRY(SingleTry());
return {};
};
@ -145,18 +145,18 @@ TEST(ErrorTests, TRY_AddsToBacktrace) {
delete doubleData;
}
// Check NXT_TRY_ASSIGN handles successes correctly.
// Check DAWN_TRY_ASSIGN handles successes correctly.
TEST(ErrorTests, TRY_RESULT_Success) {
auto ReturnSuccess = []() -> ResultOrError<int*> {
return &dummySuccess;
};
// We need to check that NXT_TRY doesn't return on successes
// We need to check that DAWN_TRY doesn't return on successes
bool tryReturned = true;
auto Try = [ReturnSuccess, &tryReturned]() -> ResultOrError<int*> {
int* result = nullptr;
NXT_TRY_ASSIGN(result, ReturnSuccess());
DAWN_TRY_ASSIGN(result, ReturnSuccess());
tryReturned = false;
EXPECT_EQ(result, &dummySuccess);
@ -169,18 +169,18 @@ TEST(ErrorTests, TRY_RESULT_Success) {
ASSERT_EQ(result.AcquireSuccess(), &dummySuccess);
}
// Check NXT_TRY_ASSIGN handles errors correctly.
// Check DAWN_TRY_ASSIGN handles errors correctly.
TEST(ErrorTests, TRY_RESULT_Error) {
auto ReturnError = []() -> ResultOrError<int*> {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto Try = [ReturnError]() -> ResultOrError<int*> {
int* result = nullptr;
NXT_TRY_ASSIGN(result, ReturnError());
DAWN_TRY_ASSIGN(result, ReturnError());
NXT_UNUSED(result);
// NXT_TRY should return before this point
// DAWN_TRY should return before this point
EXPECT_FALSE(true);
return &dummySuccess;
};
@ -193,19 +193,19 @@ TEST(ErrorTests, TRY_RESULT_Error) {
delete errorData;
}
// Check NXT_TRY_ASSIGN adds to the backtrace.
// Check DAWN_TRY_ASSIGN adds to the backtrace.
TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
auto ReturnError = []() -> ResultOrError<int*> {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto SingleTry = [ReturnError]() -> ResultOrError<int*> {
NXT_TRY(ReturnError());
DAWN_TRY(ReturnError());
return &dummySuccess;
};
auto DoubleTry = [SingleTry]() -> ResultOrError<int*> {
NXT_TRY(SingleTry());
DAWN_TRY(SingleTry());
return &dummySuccess;
};
@ -224,15 +224,15 @@ TEST(ErrorTests, TRY_RESULT_AddsToBacktrace) {
delete doubleData;
}
// Check a ResultOrError can be NXT_TRY_ASSIGNED in a function that returns an Error
// Check a ResultOrError can be DAWN_TRY_ASSIGNED in a function that returns an Error
TEST(ErrorTests, TRY_RESULT_ConversionToError) {
auto ReturnError = []() -> ResultOrError<int*> {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto Try = [ReturnError]() -> MaybeError {
int* result = nullptr;
NXT_TRY_ASSIGN(result, ReturnError());
DAWN_TRY_ASSIGN(result, ReturnError());
NXT_UNUSED(result);
return {};
@ -247,14 +247,14 @@ TEST(ErrorTests, TRY_RESULT_ConversionToError) {
}
// Check a MaybeError can be NXT_TRIED in a function that returns an ResultOrError
// Check NXT_TRY handles errors correctly.
// Check DAWN_TRY handles errors correctly.
TEST(ErrorTests, TRY_ConversionToErrorOrResult) {
auto ReturnError = []() -> MaybeError {
NXT_RETURN_ERROR(dummyErrorMessage);
DAWN_RETURN_ERROR(dummyErrorMessage);
};
auto Try = [ReturnError]() -> ResultOrError<int*>{
NXT_TRY(ReturnError());
DAWN_TRY(ReturnError());
return &dummySuccess;
};