mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Clear OpenGL textures on first use if not initialized already
This prevents dirty textures to be used when memory is recycled while destroying/creating new textures. If a texture is being used for the first time and has not yet been initialized, it will be cleared to zeros. Bug: dawn:145 Change-Id: I1140ff0535241b247b855df2afefc01fbc003470 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8380 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Natasha Lee <natlee@microsoft.com>
This commit is contained in:
committed by
Commit Bot service account
parent
ce32a94b37
commit
4886403b61
@@ -403,8 +403,29 @@ TEST_P(TextureZeroInitTest, RenderingLoadingDepthStencil) {
|
||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), srcTexture, 0, 0, kSize, kSize, 0, 0);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
||||
ForceWorkarounds(D3D12Backend,
|
||||
{"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
ForceWorkarounds(VulkanBackend,
|
||||
{"nonzero_clear_resources_on_creation_for_testing"}));
|
||||
// This tests the color attachments clear to 0s
|
||||
TEST_P(TextureZeroInitTest, ColorAttachmentsClear) {
|
||||
dawn::TextureDescriptor descriptor = CreateTextureDescriptor(
|
||||
1, 1, dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc,
|
||||
kColorFormat);
|
||||
dawn::Texture texture = device.CreateTexture(&descriptor);
|
||||
utils::BasicRenderPass renderPass = utils::BasicRenderPass(kSize, kSize, texture, kColorFormat);
|
||||
renderPass.renderPassInfo.cColorAttachmentsInfoPtr[0]->loadOp = dawn::LoadOp::Load;
|
||||
|
||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
{
|
||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
pass.EndPass();
|
||||
}
|
||||
dawn::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
std::vector<RGBA8> expected(kSize * kSize, {0, 0, 0, 0});
|
||||
EXPECT_TEXTURE_RGBA8_EQ(expected.data(), renderPass.color, 0, 0, kSize, kSize, 0, 0);
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(
|
||||
TextureZeroInitTest,
|
||||
ForceWorkarounds(D3D12Backend, {"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
ForceWorkarounds(OpenGLBackend, {"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
ForceWorkarounds(VulkanBackend, {"nonzero_clear_resources_on_creation_for_testing"}));
|
||||
|
||||
Reference in New Issue
Block a user