Fix VVL error when creating a bind group from a destroyed texture
Fixed: dawn:1043 Change-Id: Ibc91361a984cd5d51d192d130206c20d620dff9a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60641 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
8e957160b1
commit
8ec325cfc6
|
@ -95,7 +95,17 @@ namespace dawn_native { namespace vulkan {
|
||||||
case BindingInfoType::Texture: {
|
case BindingInfoType::Texture: {
|
||||||
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
||||||
|
|
||||||
writeImageInfo[numWrites].imageView = view->GetHandle();
|
VkImageView handle = view->GetHandle();
|
||||||
|
if (handle == VK_NULL_HANDLE) {
|
||||||
|
// The Texture was destroyed before the TextureView was created.
|
||||||
|
// Skip this descriptor write since it would be
|
||||||
|
// a Vulkan Validation Layers error. This bind group won't be used as it
|
||||||
|
// is an error to submit a command buffer that references destroyed
|
||||||
|
// resources.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
writeImageInfo[numWrites].imageView = handle;
|
||||||
|
|
||||||
// The layout may be GENERAL here because of interactions between the Sampled
|
// The layout may be GENERAL here because of interactions between the Sampled
|
||||||
// and ReadOnlyStorage usages. See the logic in VulkanImageLayout.
|
// and ReadOnlyStorage usages. See the logic in VulkanImageLayout.
|
||||||
writeImageInfo[numWrites].imageLayout = VulkanImageLayout(
|
writeImageInfo[numWrites].imageLayout = VulkanImageLayout(
|
||||||
|
@ -108,7 +118,16 @@ namespace dawn_native { namespace vulkan {
|
||||||
case BindingInfoType::StorageTexture: {
|
case BindingInfoType::StorageTexture: {
|
||||||
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
||||||
|
|
||||||
writeImageInfo[numWrites].imageView = view->GetHandle();
|
VkImageView handle = view->GetHandle();
|
||||||
|
if (handle == VK_NULL_HANDLE) {
|
||||||
|
// The Texture was destroyed before the TextureView was created.
|
||||||
|
// Skip this descriptor write since it would be
|
||||||
|
// a Vulkan Validation Layers error. This bind group won't be used as it
|
||||||
|
// is an error to submit a command buffer that references destroyed
|
||||||
|
// resources.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
writeImageInfo[numWrites].imageView = handle;
|
||||||
writeImageInfo[numWrites].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
writeImageInfo[numWrites].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
|
|
||||||
write.pImageInfo = &writeImageInfo[numWrites];
|
write.pImageInfo = &writeImageInfo[numWrites];
|
||||||
|
|
|
@ -1291,11 +1291,22 @@ TEST_P(BindGroupTests, CreateWithDestroyedResource) {
|
||||||
textureDesc.size = {1, 1, 1};
|
textureDesc.size = {1, 1, 1};
|
||||||
textureDesc.format = wgpu::TextureFormat::BGRA8Unorm;
|
textureDesc.format = wgpu::TextureFormat::BGRA8Unorm;
|
||||||
|
|
||||||
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
// Create view, then destroy.
|
||||||
wgpu::TextureView textureView = texture.CreateView();
|
{
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||||
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||||
|
}
|
||||||
|
// Destroy, then create view.
|
||||||
|
{
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||||
|
texture.Destroy();
|
||||||
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
|
||||||
|
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test a storage texture.
|
// Test a storage texture.
|
||||||
|
@ -1313,11 +1324,22 @@ TEST_P(BindGroupTests, CreateWithDestroyedResource) {
|
||||||
textureDesc.size = {1, 1, 1};
|
textureDesc.size = {1, 1, 1};
|
||||||
textureDesc.format = wgpu::TextureFormat::R32Uint;
|
textureDesc.format = wgpu::TextureFormat::R32Uint;
|
||||||
|
|
||||||
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
// Create view, then destroy.
|
||||||
wgpu::TextureView textureView = texture.CreateView();
|
{
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||||
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
|
||||||
texture.Destroy();
|
texture.Destroy();
|
||||||
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||||
|
}
|
||||||
|
// Destroy, then create view.
|
||||||
|
{
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDesc);
|
||||||
|
texture.Destroy();
|
||||||
|
wgpu::TextureView textureView = texture.CreateView();
|
||||||
|
|
||||||
|
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, textureView}});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue