mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-11 14:39:13 +00:00
RenderPassLoadOpTests.ClearsOnlyOnFirstUsePerRenderPass (#117)
Tests that an attachment is cleared only on the first subpass that uses it in a renderpass
This commit is contained in:
parent
afa45a9176
commit
b476abd915
@ -185,4 +185,50 @@ TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) {
|
|||||||
EXPECT_TEXTURE_RGBA8_EQ(expectBlue.data(), renderTarget, kRTSize / 2, 0, kRTSize / 2, kRTSize, 0);
|
EXPECT_TEXTURE_RGBA8_EQ(expectBlue.data(), renderTarget, kRTSize / 2, 0, kRTSize / 2, kRTSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that an attachment is cleared only on the first subpass that uses it in a renderpass
|
||||||
|
TEST_P(RenderPassLoadOpTests, ClearsOnlyOnFirstUsePerRenderPass) {
|
||||||
|
if (IsOpenGL()) {
|
||||||
|
// TODO(kainino@chromium.org): currently fails on OpenGL backend
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto renderpass = device.CreateRenderPassBuilder()
|
||||||
|
.SetAttachmentCount(1)
|
||||||
|
.SetSubpassCount(2)
|
||||||
|
.AttachmentSetFormat(0, nxt::TextureFormat::R8G8B8A8Unorm)
|
||||||
|
.AttachmentSetColorLoadOp(0, nxt::LoadOp::Clear)
|
||||||
|
.SubpassSetColorAttachment(0, 0, 0)
|
||||||
|
.SubpassSetColorAttachment(1, 0, 0)
|
||||||
|
.GetResult();
|
||||||
|
auto framebuffer = device.CreateFramebufferBuilder()
|
||||||
|
.SetRenderPass(renderpass)
|
||||||
|
.SetDimensions(kRTSize, kRTSize)
|
||||||
|
.SetAttachment(0, renderTargetView)
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
|
nxt::CommandBuffer commands;
|
||||||
|
auto builder = device.CreateCommandBufferBuilder()
|
||||||
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
|
.BeginRenderSubpass()
|
||||||
|
// Clear should occur implicitly
|
||||||
|
.Clone();
|
||||||
|
blueQuad.Draw(renderpass, &builder);
|
||||||
|
commands = builder
|
||||||
|
// Store should occur implicitly
|
||||||
|
.EndRenderSubpass()
|
||||||
|
.BeginRenderSubpass()
|
||||||
|
// Load (not clear!) should occur implicitly
|
||||||
|
// Store should occur implicitly
|
||||||
|
.EndRenderSubpass()
|
||||||
|
.EndRenderPass()
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
|
framebuffer.AttachmentSetClearColor(0, 0.0f, 1.0f, 0.0f, 1.0f); // green
|
||||||
|
queue.Submit(1, &commands);
|
||||||
|
// Left half should still be green from the first clear
|
||||||
|
EXPECT_TEXTURE_RGBA8_EQ(expectGreen.data(), renderTarget, 0, 0, kRTSize / 2, kRTSize, 0);
|
||||||
|
// Right half should be blue, not cleared by the second subpass
|
||||||
|
EXPECT_TEXTURE_RGBA8_EQ(expectBlue.data(), renderTarget, kRTSize / 2, 0, kRTSize / 2, kRTSize, 0);
|
||||||
|
}
|
||||||
|
|
||||||
NXT_INSTANTIATE_TEST(RenderPassLoadOpTests, D3D12Backend, MetalBackend, OpenGLBackend)
|
NXT_INSTANTIATE_TEST(RenderPassLoadOpTests, D3D12Backend, MetalBackend, OpenGLBackend)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user