mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
d3d12/vulkan: Skip descriptor update/creation if resource is destroyed
Validation of resource destroy state does not happen on bind group creation. It happens on queue submit. This means the Vulkan and D3D12 backends need to gracefully handle BindGroup creation with destroyed resources by skipping the descriptor creation if the resource has been destroyed. Bug: dawn:319 Change-Id: I270afba86d1a961e1e4c39f2419d8c34ff889e46 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38440 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
72cd1a5e89
commit
db1572102b
@@ -1320,6 +1320,63 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
||||
EXPECT_BUFFER_U32_EQ(1, result, 0);
|
||||
}
|
||||
|
||||
// This is a regression test for crbug.com/dawn/319 where creating a bind group with a
|
||||
// destroyed resource would crash the backend.
|
||||
TEST_P(BindGroupTests, CreateWithDestroyedResource) {
|
||||
auto doBufferTest = [&](wgpu::BufferBindingType bindingType, wgpu::BufferUsage usage) {
|
||||
wgpu::BindGroupLayout bgl =
|
||||
utils::MakeBindGroupLayout(device, {{0, wgpu::ShaderStage::Fragment, bindingType}});
|
||||
|
||||
wgpu::BufferDescriptor bufferDesc;
|
||||
bufferDesc.size = sizeof(float);
|
||||
bufferDesc.usage = usage;
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||
buffer.Destroy();
|
||||
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}});
|
||||
};
|
||||
|
||||
// Test various usages and binding types since they take different backend code paths.
|
||||
doBufferTest(wgpu::BufferBindingType::Uniform, wgpu::BufferUsage::Uniform);
|
||||
doBufferTest(wgpu::BufferBindingType::Storage, wgpu::BufferUsage::Storage);
|
||||
doBufferTest(wgpu::BufferBindingType::ReadOnlyStorage, wgpu::BufferUsage::Storage);
|
||||
|
||||
// Test a sampled texture.
|
||||
{
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
|
||||
|
||||
wgpu::TextureDescriptor textureDesc;
|
||||
textureDesc.usage = wgpu::TextureUsage::Sampled;
|
||||
textureDesc.size = {1, 1, 1};
|
||||
textureDesc.format = wgpu::TextureFormat::BGRA8Unorm;
|
||||
|
||||
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||
wgpu::TextureView textureView = texture.CreateView();
|
||||
|
||||
texture.Destroy();
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||
}
|
||||
|
||||
// Test a storage texture.
|
||||
{
|
||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
|
||||
wgpu::TextureFormat::R32Uint}});
|
||||
|
||||
wgpu::TextureDescriptor textureDesc;
|
||||
textureDesc.usage = wgpu::TextureUsage::Storage;
|
||||
textureDesc.size = {1, 1, 1};
|
||||
textureDesc.format = wgpu::TextureFormat::R32Uint;
|
||||
|
||||
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||
wgpu::TextureView textureView = texture.CreateView();
|
||||
|
||||
texture.Destroy();
|
||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||
}
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(BindGroupTests,
|
||||
D3D12Backend(),
|
||||
MetalBackend(),
|
||||
|
||||
Reference in New Issue
Block a user