mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
D3D12: Properly compute rowsPerImage for lazy texture clear
This code was incorrectly passing 0 and dividing by zero for non-renderable, unaligned-size textures. Bug: dawn:451 Change-Id: Ic79183a7ccee712b9a9ee002056f090c8e9fae15 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22665 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
a2fe305797
commit
ee0516e398
@@ -1034,6 +1034,42 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) {
|
||||
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(sampleTexture.Get(), 0, 1, 0, 2));
|
||||
}
|
||||
|
||||
// This is a regression test for crbug.com/dawn/451 where the lazy texture
|
||||
// init path on D3D12 had a divide-by-zero exception in the copy split logic.
|
||||
TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) {
|
||||
wgpu::TextureDescriptor descriptor;
|
||||
descriptor.size.width = kUnalignedSize;
|
||||
descriptor.size.height = kUnalignedSize;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.format = wgpu::TextureFormat::R8Snorm;
|
||||
descriptor.usage = wgpu::TextureUsage::CopySrc;
|
||||
wgpu::Texture texture = device.CreateTexture(&descriptor);
|
||||
|
||||
{
|
||||
uint32_t bytesPerRow = Align(kUnalignedSize, kTextureBytesPerRowAlignment);
|
||||
|
||||
wgpu::BufferDescriptor bufferDesc;
|
||||
bufferDesc.size = kUnalignedSize * bytesPerRow;
|
||||
bufferDesc.usage = wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||
|
||||
wgpu::TextureCopyView textureCopyView =
|
||||
utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||
wgpu::BufferCopyView bufferCopyView =
|
||||
utils::CreateBufferCopyView(buffer, 0, bytesPerRow, 0);
|
||||
wgpu::Extent3D copySize = {kUnalignedSize, kUnalignedSize, 1};
|
||||
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
|
||||
|
||||
wgpu::CommandBuffer commands = encoder.Finish();
|
||||
EXPECT_LAZY_CLEAR(1u, queue.Submit(1, &commands));
|
||||
}
|
||||
|
||||
// Expect texture subresource initialized to be true
|
||||
EXPECT_EQ(true, dawn_native::IsTextureSubresourceInitialized(texture.Get(), 0, 1, 0, 1));
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(
|
||||
TextureZeroInitTest,
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
|
||||
Reference in New Issue
Block a user