webgpu: destroy GPUTexture without erroring (#33534)

* destroy GPUTexture without erroring (errors can be safely ignored)

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Update expectations

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-09-25 11:36:09 +02:00 committed by GitHub
parent 43d92ecbcb
commit 6f797709cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 2134 deletions

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::cell::Cell;
use std::string::String;
use dom_struct::dom_struct;
@ -40,7 +39,6 @@ pub struct GPUTexture {
dimension: GPUTextureDimension,
format: GPUTextureFormat,
texture_usage: u32,
destroyed: Cell<bool>,
}
impl GPUTexture {
@ -69,7 +67,6 @@ impl GPUTexture {
dimension,
format,
texture_usage,
destroyed: Cell::new(false),
}
}
@ -107,9 +104,6 @@ impl GPUTexture {
impl Drop for GPUTexture {
fn drop(&mut self) {
if self.destroyed.get() {
return;
}
if let Err(e) = self
.channel
.0
@ -250,19 +244,16 @@ impl GPUTextureMethods for GPUTexture {
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy>
fn Destroy(&self) {
if self.destroyed.get() {
return;
}
if let Err(e) = self.channel.0.send(WebGPURequest::DestroyTexture {
device_id: self.device.id().0,
texture_id: self.texture.0,
}) {
if let Err(e) = self
.channel
.0
.send(WebGPURequest::DestroyTexture(self.texture.0))
{
warn!(
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
self.texture.0, e
);
};
self.destroyed.set(true);
}
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-width>

View file

@ -151,10 +151,7 @@ pub enum WebGPURequest {
},
DestroyBuffer(id::BufferId),
DestroyDevice(id::DeviceId),
DestroyTexture {
device_id: id::DeviceId,
texture_id: id::TextureId,
},
DestroyTexture(id::TextureId),
DestroySwapChain {
context_id: WebGPUContextId,
image_key: ImageKey,

View file

@ -567,13 +567,9 @@ impl WGPU {
} => {
self.destroy_swapchain(context_id, image_key);
},
WebGPURequest::DestroyTexture {
device_id,
texture_id,
} => {
WebGPURequest::DestroyTexture(texture_id) => {
let global = &self.global;
let result = global.texture_destroy(texture_id);
self.maybe_dispatch_wgpu_error(device_id, result.err());
let _ = global.texture_destroy(texture_id);
},
WebGPURequest::Exit(sender) => {
if let Err(e) = sender.send(()) {

File diff suppressed because it is too large Load diff