Add depth/stencilReadOnly and validations in RenderBundleEncoderDescriptor

This change adds two arguments depthReadOnly and stencilReadOnly
into RenderBundleEncoderDescriptor in order to follow WebGPU spec.
It also adds one more validation rule: depthReadOnly must be equal
to stencilReadOnly if depthStencilFormat has both depth and stencil
aspects in RenderBundleEncoderDescriptor. We have already had a
similar validation rule in RenderPassDepthStencilAttachment in
RenderPassDescriptor.

Bug: dawn:485

Change-Id: I32c45b2bd90c7041aa881d8589720a9146d6ac7e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/66501
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Yunchao He <yunchao.he@intel.com>
This commit is contained in:
Yunchao He
2021-10-15 16:56:13 +00:00
committed by Dawn LUCI CQ
parent 17dd734e54
commit 79d2099125
3 changed files with 38 additions and 5 deletions

View File

@@ -626,6 +626,27 @@ TEST_F(RenderBundleValidationTest, DepthStencilFormatUndefined) {
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
}
// Test that depthReadOnly must be equal to stencilReadOnly if depth stencil format contain
// both depth and stencil formats.
TEST_F(RenderBundleValidationTest, DepthStencilReadOnly) {
for (wgpu::TextureFormat format :
{wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth32Float}) {
for (bool depthReadOnly : {true, false}) {
for (bool stencilReadOnly : {true, false}) {
utils::ComboRenderBundleEncoderDescriptor desc = {};
desc.depthStencilFormat = format;
desc.depthReadOnly = depthReadOnly;
desc.stencilReadOnly = stencilReadOnly;
if (format == wgpu::TextureFormat::Depth24PlusStencil8 &&
depthReadOnly != stencilReadOnly) {
ASSERT_DEVICE_ERROR(device.CreateRenderBundleEncoder(&desc));
} else {
device.CreateRenderBundleEncoder(&desc);
}
}
}
}
}
// Test that resource usages are validated inside render bundles.
TEST_F(RenderBundleValidationTest, UsageTracking) {
DummyRenderPass renderPass(device);