webgpu: Move errorscopes to WGPU thread (#32304)

* Prepare errorscopes logic in wgpu_thread

* remove scope_id from ipc

* new GPUErrors per spec

* remove cotent timeline error_scope

* fixup poperrorscope types

* device_scope -> gpu_error and nice errors

* Handle errors detection more elegantly

* good expectations

* new expectations

* Make error_scope.errors Vec as per spec
This commit is contained in:
Samson 2024-05-22 18:47:35 +02:00 committed by GitHub
parent 9f32809671
commit 794110ebe5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 3401 additions and 725 deletions

View file

@ -7,7 +7,7 @@ use std::string::String;
use dom_struct::dom_struct;
use webgpu::wgc::resource;
use webgpu::{wgt, WebGPU, WebGPUOpResult, WebGPURequest, WebGPUTexture, WebGPUTextureView};
use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::{
@ -114,7 +114,7 @@ impl Drop for GPUTexture {
if let Err(e) = self
.channel
.0
.send((None, WebGPURequest::DropTexture(self.texture.0)))
.send(WebGPURequest::DropTexture(self.texture.0))
{
warn!(
"Failed to send WebGPURequest::DropTexture({:?}) ({})",
@ -143,8 +143,6 @@ impl GPUTextureMethods for GPUTexture {
/// <https://gpuweb.github.io/gpuweb/#dom-gputexture-createview>
fn CreateView(&self, descriptor: &GPUTextureViewDescriptor) -> DomRoot<GPUTextureView> {
let scope_id = self.device.use_current_scope();
let desc = if !matches!(descriptor.mipLevelCount, Some(0)) &&
!matches!(descriptor.arrayLayerCount, Some(0))
{
@ -165,12 +163,10 @@ impl GPUTextureMethods for GPUTexture {
},
})
} else {
self.device.handle_server_msg(
scope_id,
WebGPUOpResult::ValidationError(String::from(
self.device
.dispatch_error(webgpu::Error::Validation(String::from(
"arrayLayerCount and mipLevelCount cannot be 0",
)),
);
)));
None
};
@ -182,15 +178,12 @@ impl GPUTextureMethods for GPUTexture {
self.channel
.0
.send((
scope_id,
WebGPURequest::CreateTextureView {
texture_id: self.texture.0,
texture_view_id,
device_id: self.device.id().0,
descriptor: desc,
},
))
.send(WebGPURequest::CreateTextureView {
texture_id: self.texture.0,
texture_view_id,
device_id: self.device.id().0,
descriptor: desc,
})
.expect("Failed to create WebGPU texture view");
let texture_view = WebGPUTextureView(texture_view_id);
@ -209,13 +202,10 @@ impl GPUTextureMethods for GPUTexture {
if self.destroyed.get() {
return;
}
if let Err(e) = self.channel.0.send((
None,
WebGPURequest::DestroyTexture {
device_id: self.device.id().0,
texture_id: self.texture.0,
},
)) {
if let Err(e) = self.channel.0.send(WebGPURequest::DestroyTexture {
device_id: self.device.id().0,
texture_id: self.texture.0,
}) {
warn!(
"Failed to send WebGPURequest::DestroyTexture({:?}) ({})",
self.texture.0, e