mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
Add validation rule for depth/stencil between bundle and pass
If we use render bundle, the compability validation between
writeDepth/Stencil in DepthStencilState in render pipeline and
depth/stencilReadOnly in DepthStencilAttachment in render pass
will become two steps:
1. validation between render pipeline and render bundle during
RenderBundleEncoder's SetPipeline().
2. validation between render bundle and render pass during
RenderPassEncoder's ExecuteBundles().
So, render bundle is like a bridge for this compability validation
between pipeline and pass.
The first step has been done in previous patch. The patch does
the second step.
Bug: dawn:485
Change-Id: I1226494e901c07bdb9f565bce7b9073d420f2fe2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/66842
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
constexpr static uint32_t kSize = 4;
|
||||
// Note that format Depth24PlusStencil8 has both depth and stencil aspects, so parameters
|
||||
// depthReadOnly and stencilReadOnly should be the same in render pass and render bundle.
|
||||
wgpu::TextureFormat kFormat = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -76,13 +79,9 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
// Test depthWrite/stencilWrite in DepthStencilState in pipeline vs
|
||||
// depthReadOnly/stencilReadOnly in DepthStencilAttachment in pass
|
||||
// Test depthWrite/stencilWrite in DepthStencilState in render pipeline vs
|
||||
// depthReadOnly/stencilReadOnly in DepthStencilAttachment in render pass.
|
||||
TEST_F(RenderPipelineAndPassCompatibilityTests, WriteAndReadOnlyConflictForDepthStencil) {
|
||||
wgpu::TextureFormat kFormat = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
// If the format has both depth and stencil aspects, depthReadOnly and stencilReadOnly
|
||||
// should be the same. So it is not necessary to set two separate booleans like
|
||||
// depthReadOnlyInPass and stencilReadOnlyInPass.
|
||||
for (bool depthStencilReadOnlyInPass : {true, false}) {
|
||||
for (bool depthWriteInPipeline : {true, false}) {
|
||||
for (bool stencilWriteInPipeline : {true, false}) {
|
||||
@@ -106,14 +105,10 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Test depthWrite/stencilWrite in DepthStencilState in pipeline vs
|
||||
// depthReadOnly/stencilReadOnly in RenderBundleEncoderDescriptor in RenderBundle
|
||||
// Test depthWrite/stencilWrite in DepthStencilState in render pipeline vs
|
||||
// depthReadOnly/stencilReadOnly in RenderBundleEncoderDescriptor in render bundle.
|
||||
TEST_F(RenderPipelineAndPassCompatibilityTests,
|
||||
WriteAndReadOnlyConflictForDepthStencilWithRenderBundle) {
|
||||
wgpu::TextureFormat kFormat = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||
// If the format has both depth and stencil aspects, depthReadOnly and stencilReadOnly
|
||||
// should be the same. So it is not necessary to set two separate booleans like
|
||||
// depthReadOnlyInBundle and stencilReadOnlyInBundle.
|
||||
WriteAndReadOnlyConflictForDepthStencilBetweenPipelineAndBundle) {
|
||||
for (bool depthStencilReadOnlyInBundle : {true, false}) {
|
||||
utils::ComboRenderBundleEncoderDescriptor desc = {};
|
||||
desc.depthStencilFormat = kFormat;
|
||||
@@ -139,6 +134,45 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
// Test depthReadOnly/stencilReadOnly in RenderBundleEncoderDescriptor in render bundle vs
|
||||
// depthReadOnly/stencilReadOnly in DepthStencilAttachment in render pass.
|
||||
TEST_F(RenderPipelineAndPassCompatibilityTests,
|
||||
WriteAndReadOnlyConflictForDepthStencilBetweenBundleAndPass) {
|
||||
for (bool depthStencilReadOnlyInPass : {true, false}) {
|
||||
for (bool depthStencilReadOnlyInBundle : {true, false}) {
|
||||
for (bool emptyBundle : {true, false}) {
|
||||
// Create render bundle, with or without a pipeline
|
||||
utils::ComboRenderBundleEncoderDescriptor desc = {};
|
||||
desc.depthStencilFormat = kFormat;
|
||||
desc.depthReadOnly = depthStencilReadOnlyInBundle;
|
||||
desc.stencilReadOnly = depthStencilReadOnlyInBundle;
|
||||
wgpu::RenderBundleEncoder renderBundleEncoder =
|
||||
device.CreateRenderBundleEncoder(&desc);
|
||||
if (!emptyBundle) {
|
||||
wgpu::RenderPipeline pipeline = CreatePipeline(
|
||||
kFormat, !depthStencilReadOnlyInBundle, !depthStencilReadOnlyInBundle);
|
||||
renderBundleEncoder.SetPipeline(pipeline);
|
||||
renderBundleEncoder.Draw(3);
|
||||
}
|
||||
wgpu::RenderBundle bundle = renderBundleEncoder.Finish();
|
||||
|
||||
// Create render pass and call ExecuteBundles()
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
utils::ComboRenderPassDescriptor passDescriptor = CreateRenderPassDescriptor(
|
||||
kFormat, depthStencilReadOnlyInPass, depthStencilReadOnlyInPass);
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&passDescriptor);
|
||||
pass.ExecuteBundles(1, &bundle);
|
||||
pass.EndPass();
|
||||
if (depthStencilReadOnlyInPass != depthStencilReadOnlyInBundle) {
|
||||
ASSERT_DEVICE_ERROR(encoder.Finish());
|
||||
} else {
|
||||
encoder.Finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(dawn:485): add more tests. For example:
|
||||
// - depth/stencil attachment should be designated if depth/stencil test is enabled.
|
||||
// - pipeline and pass compatibility tests for color attachment(s).
|
||||
|
||||
Reference in New Issue
Block a user