D3D12: Add test for the crash issue about T2T copy with Depth32Float
Currently on D3D12 backend a device lost will occur when we do a T2T copy under the following situations: 1. with Depth32Float 2. only copy one row 3. bufferCopyOffset == 256 This is because in current implementation it is possible for us to do a copy with D3D12_SUBRESOURCE_FOOTPRINT.Depth > 1, which is not allowed with DXGI_FORMAT_D32_FLOAT because this format is not supported to be used as 3D textures. This patch adds a regression test for this bug and we will fix it later. BUG=dawn:693 TEST=dawn_end2end_tests Change-Id: Ib6fe70988b5b217d5f14d3f32999b3841e5d23b9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42600 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Brandon Jones <brandon1.jones@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
4165c1cd9c
commit
7564ae1def
|
@ -1582,6 +1582,55 @@ TEST_P(CopyTests_T2T, MultipleMipSrcSingleMipDst) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A regression test for a bug on D3D12 backend that causes crash when doing texture-to-texture
|
||||||
|
// copy one row with the texture format Depth32Float.
|
||||||
|
TEST_P(CopyTests_T2B, CopyOneRowWithDepth32Float) {
|
||||||
|
// TODO(jiawei.shao@intel.com): enable this test when the bug on D3D12 is fixed. See dawn:693
|
||||||
|
// for more details.
|
||||||
|
DAWN_SKIP_TEST_IF(IsD3D12());
|
||||||
|
|
||||||
|
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::Depth32Float;
|
||||||
|
constexpr uint32_t kPixelsPerRow = 4u;
|
||||||
|
|
||||||
|
wgpu::TextureDescriptor textureDescriptor;
|
||||||
|
textureDescriptor.format = kFormat;
|
||||||
|
textureDescriptor.size = {kPixelsPerRow, 1, 1};
|
||||||
|
textureDescriptor.usage = wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::OutputAttachment;
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
|
||||||
|
|
||||||
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
|
// Initialize the depth texture with 0.5f.
|
||||||
|
constexpr float kClearDepthValue = 0.5f;
|
||||||
|
utils::ComboRenderPassDescriptor renderPass({}, texture.CreateView());
|
||||||
|
renderPass.cDepthStencilAttachmentInfo.clearDepth = kClearDepthValue;
|
||||||
|
renderPass.cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Clear;
|
||||||
|
renderPass.cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Store;
|
||||||
|
wgpu::RenderPassEncoder renderPassEncoder = encoder.BeginRenderPass(&renderPass);
|
||||||
|
renderPassEncoder.EndPass();
|
||||||
|
|
||||||
|
constexpr uint32_t kBufferCopyOffset = kTextureBytesPerRowAlignment;
|
||||||
|
const uint32_t kBufferSize =
|
||||||
|
kBufferCopyOffset + utils::GetTexelBlockSizeInBytes(kFormat) * kPixelsPerRow;
|
||||||
|
wgpu::BufferDescriptor bufferDescriptor;
|
||||||
|
bufferDescriptor.size = kBufferSize;
|
||||||
|
bufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||||
|
wgpu::Buffer buffer = device.CreateBuffer(&bufferDescriptor);
|
||||||
|
|
||||||
|
wgpu::BufferCopyView bufferCopyView =
|
||||||
|
utils::CreateBufferCopyView(buffer, kBufferCopyOffset, kTextureBytesPerRowAlignment);
|
||||||
|
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
|
||||||
|
|
||||||
|
wgpu::Extent3D copySize = textureDescriptor.size;
|
||||||
|
encoder.CopyTextureToBuffer(&textureCopyView, &bufferCopyView, ©Size);
|
||||||
|
wgpu::CommandBuffer commandBuffer = encoder.Finish();
|
||||||
|
queue.Submit(1, &commandBuffer);
|
||||||
|
|
||||||
|
std::array<float, kPixelsPerRow> expectedValues;
|
||||||
|
std::fill(expectedValues.begin(), expectedValues.end(), kClearDepthValue);
|
||||||
|
EXPECT_BUFFER_FLOAT_RANGE_EQ(expectedValues.data(), buffer, kBufferCopyOffset, kPixelsPerRow);
|
||||||
|
}
|
||||||
|
|
||||||
DAWN_INSTANTIATE_TEST(CopyTests_T2T,
|
DAWN_INSTANTIATE_TEST(CopyTests_T2T,
|
||||||
D3D12Backend(),
|
D3D12Backend(),
|
||||||
MetalBackend(),
|
MetalBackend(),
|
||||||
|
|
Loading…
Reference in New Issue