Commit 50ade28c authored by Austin Eng's avatar Austin Eng Committed by Commit Bot

Fix leak of Dawn SharedImage WGPUTexture handles

This makes previously broken ref tests on Win crash the
GPU process instead, though the tests still render to the canvas
correctly when run.

This same crash already exists on Linux before this patch, but the
crash isn't reported by the harness.

This is likely a pre-existing issue in Chrome
where Dawn SharedImages don't work with the screenshots. In
general, canvas readback for WebGPU is currently unimplemented.

Bug: 976495, 1083478
Change-Id: I345151bd6ce38fc00e52c1efd12bddb8a425e283
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438893
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: default avatarCorentin Wallez <cwallez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813870}
parent 9e601fcc
......@@ -71,13 +71,6 @@ WGPUTexture ExternalVkImageDawnRepresentation::BeginAccess(
}
texture_ = dawn_native::vulkan::WrapVulkanImage(device_, &descriptor);
if (texture_) {
// Keep a reference to the texture so that it stays valid (its content
// might be destroyed).
dawn_procs_.textureReference(texture_);
}
return texture_;
}
......
......@@ -569,7 +569,7 @@ TEST_F(SharedImageBackingFactoryD3DTest, Dawn_SkiaGL) {
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(scoped_access);
wgpu::Texture texture = wgpu::Texture::Acquire(scoped_access->texture());
wgpu::Texture texture(scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
......@@ -686,8 +686,7 @@ TEST_F(SharedImageBackingFactoryD3DTest, GL_Dawn_Skia_UnclearTexture) {
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(dawn_scoped_access);
wgpu::Texture texture =
wgpu::Texture::Acquire(dawn_scoped_access->texture());
wgpu::Texture texture(dawn_scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
color_desc.resolveTarget = nullptr;
......@@ -771,8 +770,7 @@ TEST_F(SharedImageBackingFactoryD3DTest, UnclearDawn_SkiaFails) {
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(dawn_scoped_access);
wgpu::Texture texture =
wgpu::Texture::Acquire(dawn_scoped_access->texture());
wgpu::Texture texture(dawn_scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
color_desc.resolveTarget = nullptr;
......
......@@ -127,13 +127,6 @@ class SharedImageRepresentationDawnIOSurface
descriptor.plane = 0;
texture_ = dawn_native::metal::WrapIOSurface(device_, &descriptor);
if (texture_) {
// Keep a reference to the texture so that it stays valid (its content
// might be destroyed).
dawn_procs_.textureReference(texture_);
}
return texture_;
}
......
......@@ -416,7 +416,7 @@ TEST_F(SharedImageBackingFactoryIOSurfaceTest, Dawn_SkiaGL) {
WGPUTextureUsage_OutputAttachment,
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(scoped_access);
wgpu::Texture texture = wgpu::Texture::Acquire(scoped_access->texture());
wgpu::Texture texture(scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
......@@ -540,8 +540,7 @@ TEST_F(SharedImageBackingFactoryIOSurfaceTest, GL_Dawn_Skia_UnclearTexture) {
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(dawn_scoped_access);
wgpu::Texture texture =
wgpu::Texture::Acquire(dawn_scoped_access->texture());
wgpu::Texture texture(dawn_scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
color_desc.resolveTarget = nullptr;
......@@ -623,8 +622,7 @@ TEST_F(SharedImageBackingFactoryIOSurfaceTest, UnclearDawn_SkiaFails) {
SharedImageRepresentation::AllowUnclearedAccess::kYes);
ASSERT_TRUE(dawn_scoped_access);
wgpu::Texture texture =
wgpu::Texture::Acquire(dawn_scoped_access->texture());
wgpu::Texture texture(dawn_scoped_access->texture());
wgpu::RenderPassColorAttachmentDescriptor color_desc;
color_desc.attachment = texture.CreateView();
color_desc.resolveTarget = nullptr;
......
......@@ -364,6 +364,8 @@ class GPU_GLES2_EXPORT SharedImageRepresentationDawn
WGPUTexture texture);
~ScopedAccess();
// Get the unowned texture handle. The caller should take a reference
// if necessary by doing wgpu::Texture texture(access->texture());
WGPUTexture texture() const { return texture_; }
private:
......
......@@ -98,11 +98,7 @@ WGPUTexture SharedImageRepresentationDawnD3D::BeginAccess(
SHARED_IMAGE_USAGE_WEBGPU_SWAP_CHAIN_TEXTURE);
texture_ = dawn_native::d3d12::WrapSharedHandle(device_, &descriptor);
if (texture_) {
// Keep a reference to the texture so that it stays valid (its content
// might be destroyed).
dawn_procs_.textureReference(texture_);
} else {
if (!texture_) {
d3d_image_backing->EndAccessD3D12();
}
......
......@@ -82,11 +82,7 @@ WGPUTexture SharedImageRepresentationDawnOzone::BeginAccess(
descriptor.waitFDs = {};
texture_ = dawn_native::vulkan::WrapVulkanImage(device_, &descriptor);
if (texture_) {
// Keep a reference to the texture so that it stays valid (its content
// might be destroyed).
dawn_procs_->data.textureReference(texture_);
} else {
if (!texture_) {
close(fd);
}
......
......@@ -41,12 +41,12 @@ wpt_internal/webgpu/cts.html?q=webgpu:web-platform,copyImageBitmapToTexture:from
# These tests aren't working on CQ, unclear whether the test or harness (or Chrome) is broken.
# Mac: mostly works
# Linux: actual is white/blank
crbug.com/1083478 [ Linux ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_clear.html [ Failure ]
crbug.com/1083478 [ Linux ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_complex_bgra8unorm.html [ Failure ]
# Win: actual is black
crbug.com/1083478 [ Win ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_clear.html [ Failure ]
crbug.com/1083478 [ Win ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_complex_bgra8unorm.html [ Failure ]
# Linux: actual is white/blank - is actually crashing silently
crbug.com/1083478 [ Linux ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_clear.html [ Skip ]
crbug.com/1083478 [ Linux ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_complex_bgra8unorm.html [ Skip ]
# Win: takeScreenshot crashes
crbug.com/1083478 [ Win ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_clear.html [ Skip ]
crbug.com/1083478 [ Win ] wpt_internal/webgpu/webgpu/web-platform/reftests/canvas_complex_bgra8unorm.html [ Skip ]
#
# Platform-independent failures
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment