mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
dawn_native: Do debug marker validation at encoding time.
This also adds missing coverage for push/pop debug group in render bundles. The RenderBundleEncoder didn't validate itself on Finish, so add a regression test for that too. The overarching goal with this CL is to do validation at encoding time which will help produce SyncScopeResourceUsage in the frontend for dispatch() calls so that they can be reused by the backends. Bug: dawn:635 Change-Id: Ie5a2d987fda3854b3145ba4b7a34994ea605e820 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38842 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
c1d3a66bd2
commit
7ffaa219cb
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class DebugMarkerValidationTest : public ValidationTest {};
|
||||
@@ -70,6 +71,52 @@ TEST_F(DebugMarkerValidationTest, RenderUnbalancedPop) {
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Correct usage of debug markers should succeed in render bundle.
|
||||
TEST_F(DebugMarkerValidationTest, RenderBundleSuccess) {
|
||||
utils::ComboRenderBundleEncoderDescriptor desc;
|
||||
desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
|
||||
desc.colorFormatsCount = 1;
|
||||
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&desc);
|
||||
encoder.PushDebugGroup("Event Start");
|
||||
encoder.PushDebugGroup("Event Start");
|
||||
encoder.InsertDebugMarker("Marker");
|
||||
encoder.PopDebugGroup();
|
||||
encoder.PopDebugGroup();
|
||||
|
||||
encoder.Finish();
|
||||
}
|
||||
|
||||
// A PushDebugGroup call without a following PopDebugGroup produces an error in render bundle.
|
||||
TEST_F(DebugMarkerValidationTest, RenderBundleUnbalancedPush) {
|
||||
utils::ComboRenderBundleEncoderDescriptor desc;
|
||||
desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
|
||||
desc.colorFormatsCount = 1;
|
||||
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&desc);
|
||||
encoder.PushDebugGroup("Event Start");
|
||||
encoder.PushDebugGroup("Event Start");
|
||||
encoder.InsertDebugMarker("Marker");
|
||||
encoder.PopDebugGroup();
|
||||
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// A PopDebugGroup call without a preceding PushDebugGroup produces an error in render bundle.
|
||||
TEST_F(DebugMarkerValidationTest, RenderBundleUnbalancedPop) {
|
||||
utils::ComboRenderBundleEncoderDescriptor desc;
|
||||
desc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
|
||||
desc.colorFormatsCount = 1;
|
||||
|
||||
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&desc);
|
||||
encoder.PushDebugGroup("Event Start");
|
||||
encoder.InsertDebugMarker("Marker");
|
||||
encoder.PopDebugGroup();
|
||||
encoder.PopDebugGroup();
|
||||
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
}
|
||||
|
||||
// Correct usage of debug markers should succeed in compute pass.
|
||||
TEST_F(DebugMarkerValidationTest, ComputeSuccess) {
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
|
||||
@@ -141,6 +141,28 @@ TEST_F(RenderBundleValidationTest, Empty) {
|
||||
commandEncoder.Finish();
|
||||
}
|
||||
|
||||
// Test that an empty error bundle encoder produces an error bundle.
|
||||
// This is a regression test for error render bundle encoders containing no commands would
|
||||
// produce non-error render bundles.
|
||||
TEST_F(RenderBundleValidationTest, EmptyErrorEncoderProducesErrorBundle) {
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
utils::ComboRenderBundleEncoderDescriptor desc = {};
|
||||
// Having 0 attachments is invalid!
|
||||
desc.colorFormatsCount = 0;
|
||||
|
||||
wgpu::RenderBundleEncoder renderBundleEncoder;
|
||||
ASSERT_DEVICE_ERROR(renderBundleEncoder = device.CreateRenderBundleEncoder(&desc));
|
||||
wgpu::RenderBundle renderBundle;
|
||||
ASSERT_DEVICE_ERROR(renderBundle = renderBundleEncoder.Finish());
|
||||
|
||||
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
|
||||
wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPass);
|
||||
pass.ExecuteBundles(1, &renderBundle);
|
||||
pass.EndPass();
|
||||
ASSERT_DEVICE_ERROR(commandEncoder.Finish());
|
||||
}
|
||||
|
||||
// Test executing zero render bundles.
|
||||
TEST_F(RenderBundleValidationTest, ZeroBundles) {
|
||||
DummyRenderPass renderPass(device);
|
||||
|
||||
Reference in New Issue
Block a user