mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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:
parent
43d92ecbcb
commit
6f797709cf
4 changed files with 8 additions and 2134 deletions
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::Cell;
|
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
|
@ -40,7 +39,6 @@ pub struct GPUTexture {
|
||||||
dimension: GPUTextureDimension,
|
dimension: GPUTextureDimension,
|
||||||
format: GPUTextureFormat,
|
format: GPUTextureFormat,
|
||||||
texture_usage: u32,
|
texture_usage: u32,
|
||||||
destroyed: Cell<bool>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUTexture {
|
impl GPUTexture {
|
||||||
|
@ -69,7 +67,6 @@ impl GPUTexture {
|
||||||
dimension,
|
dimension,
|
||||||
format,
|
format,
|
||||||
texture_usage,
|
texture_usage,
|
||||||
destroyed: Cell::new(false),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +104,6 @@ impl GPUTexture {
|
||||||
|
|
||||||
impl Drop for GPUTexture {
|
impl Drop for GPUTexture {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if self.destroyed.get() {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if let Err(e) = self
|
if let Err(e) = self
|
||||||
.channel
|
.channel
|
||||||
.0
|
.0
|
||||||
|
@ -250,19 +244,16 @@ impl GPUTextureMethods for GPUTexture {
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-destroy>
|
||||||
fn Destroy(&self) {
|
fn Destroy(&self) {
|
||||||
if self.destroyed.get() {
|
if let Err(e) = self
|
||||||
return;
|
.channel
|
||||||
}
|
.0
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::DestroyTexture {
|
.send(WebGPURequest::DestroyTexture(self.texture.0))
|
||||||
device_id: self.device.id().0,
|
{
|
||||||
texture_id: self.texture.0,
|
|
||||||
}) {
|
|
||||||
warn!(
|
warn!(
|
||||||
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
|
||||||
self.texture.0, e
|
self.texture.0, e
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
self.destroyed.set(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-width>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-width>
|
||||||
|
|
|
@ -151,10 +151,7 @@ pub enum WebGPURequest {
|
||||||
},
|
},
|
||||||
DestroyBuffer(id::BufferId),
|
DestroyBuffer(id::BufferId),
|
||||||
DestroyDevice(id::DeviceId),
|
DestroyDevice(id::DeviceId),
|
||||||
DestroyTexture {
|
DestroyTexture(id::TextureId),
|
||||||
device_id: id::DeviceId,
|
|
||||||
texture_id: id::TextureId,
|
|
||||||
},
|
|
||||||
DestroySwapChain {
|
DestroySwapChain {
|
||||||
context_id: WebGPUContextId,
|
context_id: WebGPUContextId,
|
||||||
image_key: ImageKey,
|
image_key: ImageKey,
|
||||||
|
|
|
@ -567,13 +567,9 @@ impl WGPU {
|
||||||
} => {
|
} => {
|
||||||
self.destroy_swapchain(context_id, image_key);
|
self.destroy_swapchain(context_id, image_key);
|
||||||
},
|
},
|
||||||
WebGPURequest::DestroyTexture {
|
WebGPURequest::DestroyTexture(texture_id) => {
|
||||||
device_id,
|
|
||||||
texture_id,
|
|
||||||
} => {
|
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let result = global.texture_destroy(texture_id);
|
let _ = global.texture_destroy(texture_id);
|
||||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
|
||||||
},
|
},
|
||||||
WebGPURequest::Exit(sender) => {
|
WebGPURequest::Exit(sender) => {
|
||||||
if let Err(e) = sender.send(()) {
|
if let Err(e) = sender.send(()) {
|
||||||
|
|
2110
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
2110
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue