mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 07:36:15 +00:00
Add validation for some null arguments and dangling render passes
And add tests for both
This commit is contained in:
committed by
Corentin Wallez
parent
2b055c38fd
commit
613eee30c3
@@ -186,6 +186,15 @@ namespace backend {
|
||||
BeginRenderPassCmd* cmd = iterator.NextCommand<BeginRenderPassCmd>();
|
||||
auto* renderPass = cmd->renderPass.Get();
|
||||
auto* framebuffer = cmd->framebuffer.Get();
|
||||
// TODO(kainino@chromium.org): null checks should not be necessary
|
||||
if (renderPass == nullptr) {
|
||||
HandleError("Render pass is invalid");
|
||||
return false;
|
||||
}
|
||||
if (framebuffer == nullptr) {
|
||||
HandleError("Framebuffer is invalid");
|
||||
return false;
|
||||
}
|
||||
if (!state->BeginRenderPass(renderPass, framebuffer)) {
|
||||
return false;
|
||||
}
|
||||
@@ -353,6 +362,10 @@ namespace backend {
|
||||
}
|
||||
}
|
||||
|
||||
if (!state->ValidateEndCommandBuffer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,14 @@ namespace backend {
|
||||
return RevalidateCanDraw();
|
||||
}
|
||||
|
||||
bool CommandBufferStateTracker::ValidateEndCommandBuffer() const {
|
||||
if (currentRenderPass != nullptr) {
|
||||
builder->HandleError("Can't end command buffer with an active render pass");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CommandBufferStateTracker::BeginSubpass() {
|
||||
if (currentRenderPass == nullptr) {
|
||||
builder->HandleError("Can't begin a subpass without an active render pass");
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace backend {
|
||||
bool ValidateCanDispatch();
|
||||
bool ValidateCanDrawArrays();
|
||||
bool ValidateCanDrawElements();
|
||||
bool ValidateEndCommandBuffer() const;
|
||||
|
||||
// State-modifying methods
|
||||
bool BeginSubpass();
|
||||
|
||||
@@ -85,6 +85,11 @@ namespace backend {
|
||||
HandleError("Framebuffer render pass property set multiple times");
|
||||
return;
|
||||
}
|
||||
// TODO(kainino@chromium.org): null checks should not be necessary
|
||||
if (renderPass == nullptr) {
|
||||
HandleError("Render pass invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
this->renderPass = renderPass;
|
||||
this->textureViews.resize(renderPass->GetAttachmentCount());
|
||||
|
||||
Reference in New Issue
Block a user