Use clear loadop to lazy clear depth stencil attachments

Bug: dawn:210, dawn:145
Change-Id: I1eb990266ccd7b51b4a336b0d4d37e0195c6fe69
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11020
Commit-Queue: Natasha Lee <natlee@microsoft.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Natasha Lee
2019-09-11 22:04:42 +00:00
committed by Commit Bot service account
parent fad96f6e59
commit 01600dfb3d
4 changed files with 71 additions and 39 deletions

View File

@@ -321,6 +321,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
renderPassDescriptor.cDepthStencilAttachmentInfo.clearStencil = 0;
renderPassDescriptor.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
@@ -328,8 +330,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepth) {
pass.Draw(6, 1, 0, 0);
pass.EndPass();
dawn::CommandBuffer commandBuffer = encoder.Finish();
// Expect 1 lazy clear for the depthStencilTexture
EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commandBuffer));
// Expect 0 lazy clears, depth stencil texture will clear using loadop
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer));
// Expect the texture to be red because depth test passed.
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
@@ -360,6 +362,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
renderPassDescriptor.cDepthStencilAttachmentInfo.clearDepth = 0.0f;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
renderPassDescriptor.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
@@ -367,8 +371,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingStencil) {
pass.Draw(6, 1, 0, 0);
pass.EndPass();
dawn::CommandBuffer commandBuffer = encoder.Finish();
// Expect 1 lazy clear for depthStencilTexture.
EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commandBuffer));
// Expect 0 lazy clears, depth stencil texture will clear using loadop
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer));
// Expect the texture to be red because stencil test passed.
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});
@@ -398,6 +402,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
depthStencilTexture.CreateView());
renderPassDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Load;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Load;
renderPassDescriptor.cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store;
renderPassDescriptor.cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store;
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
auto pass = encoder.BeginRenderPass(&renderPassDescriptor);
@@ -405,8 +411,8 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
pass.Draw(6, 1, 0, 0);
pass.EndPass();
dawn::CommandBuffer commandBuffer = encoder.Finish();
// Expect 1 lazy clear for depthStencilTexture.
EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commandBuffer));
// Expect 0 lazy clears, depth stencil texture will clear using loadop
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commandBuffer));
// Expect the texture to be red because both depth and stencil tests passed.
std::vector<RGBA8> expected(kSize * kSize, {255, 0, 0, 255});