From 293ea7746d7f5bbb8eade19100df0269003dc79c Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 26 Jun 2019 20:28:13 +0000 Subject: [PATCH] Make RenderPipeline::ValidateCompatibleWith produce an error message Previously it would only return a boolean which made it difficult to know why the validation is failing. BUG=dawn:128 Change-Id: Id129a84f7777ba2efc5f12292aeccb83c076b9af Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8362 Commit-Queue: Kai Ninomiya Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya --- src/dawn_native/CommandEncoder.cpp | 6 +----- src/dawn_native/RenderPipeline.cpp | 19 ++++++++++++------- src/dawn_native/RenderPipeline.h | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index b20dbc4064..300e832256 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -1199,11 +1199,7 @@ namespace dawn_native { SetRenderPipelineCmd* cmd = mIterator.NextCommand(); RenderPipelineBase* pipeline = cmd->pipeline.Get(); - if (!pipeline->IsCompatibleWith(renderPass)) { - return DAWN_VALIDATION_ERROR( - "Pipeline is incompatible with this render pass"); - } - + DAWN_TRY(pipeline->ValidateCompatibleWith(renderPass)); persistentState.SetRenderPipeline(pipeline); } break; diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp index 7e85287c1e..cd82a83bbc 100644 --- a/src/dawn_native/RenderPipeline.cpp +++ b/src/dawn_native/RenderPipeline.cpp @@ -492,38 +492,43 @@ namespace dawn_native { return mSampleCount; } - bool RenderPipelineBase::IsCompatibleWith(const BeginRenderPassCmd* renderPass) const { + MaybeError RenderPipelineBase::ValidateCompatibleWith( + const BeginRenderPassCmd* renderPass) const { ASSERT(!IsError()); // TODO(cwallez@chromium.org): This is called on every SetPipeline command. Optimize it for // example by caching some "attachment compatibility" object that would make the // compatibility check a single pointer comparison. if (renderPass->colorAttachmentsSet != mColorAttachmentsSet) { - return false; + return DAWN_VALIDATION_ERROR( + "Pipeline doesn't have same color attachments set as renderPass"); } for (uint32_t i : IterateBitSet(mColorAttachmentsSet)) { if (renderPass->colorAttachments[i].view->GetFormat().format != mColorStates[i].format) { - return false; + return DAWN_VALIDATION_ERROR( + "Pipeline color attachment format doesn't match renderPass"); } } if (renderPass->hasDepthStencilAttachment != mHasDepthStencilAttachment) { - return false; + return DAWN_VALIDATION_ERROR( + "Pipeline depth stencil attachment doesn't match renderPass"); } if (mHasDepthStencilAttachment && (renderPass->depthStencilAttachment.view->GetFormat().format != mDepthStencilState.format)) { - return false; + return DAWN_VALIDATION_ERROR( + "Pipeline depth stencil attachment format doesn't match renderPass"); } if (renderPass->sampleCount != mSampleCount) { - return false; + return DAWN_VALIDATION_ERROR("Pipeline sample count doesn't match renderPass"); } - return true; + return {}; } std::bitset RenderPipelineBase::GetAttributesUsingInput( diff --git a/src/dawn_native/RenderPipeline.h b/src/dawn_native/RenderPipeline.h index 0f33fa6718..fd951e49c9 100644 --- a/src/dawn_native/RenderPipeline.h +++ b/src/dawn_native/RenderPipeline.h @@ -79,7 +79,7 @@ namespace dawn_native { // A pipeline can be used in a render pass if its attachment info matches the actual // attachments in the render pass. This returns whether it is the case. - bool IsCompatibleWith(const BeginRenderPassCmd* renderPassCmd) const; + MaybeError ValidateCompatibleWith(const BeginRenderPassCmd* renderPassCmd) const; std::bitset GetAttributesUsingInput(uint32_t slot) const; std::array, kMaxVertexBuffers> attributesUsingInput;