mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
webgpu: Implement proper async pipeline creation and GPUPipelineError (#32636)
* Add GPUPipelineError Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Proper GetBindGroupLayout Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Proper Create*PipelineAsync Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fixups Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * more good 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
08eb4faf4d
commit
b8cf0cf9af
11 changed files with 465 additions and 790 deletions
|
@ -2,14 +2,12 @@
|
|||
* 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::string::String;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest};
|
||||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::USVString;
|
||||
|
@ -26,8 +24,6 @@ pub struct GPURenderPipeline {
|
|||
label: DomRefCell<USVString>,
|
||||
#[no_trace]
|
||||
render_pipeline: WebGPURenderPipeline,
|
||||
#[no_trace]
|
||||
bind_group_layouts: Vec<WebGPUBindGroupLayout>,
|
||||
device: Dom<GPUDevice>,
|
||||
}
|
||||
|
||||
|
@ -35,7 +31,6 @@ impl GPURenderPipeline {
|
|||
fn new_inherited(
|
||||
render_pipeline: WebGPURenderPipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
device: &GPUDevice,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -43,7 +38,6 @@ impl GPURenderPipeline {
|
|||
channel: device.channel(),
|
||||
label: DomRefCell::new(label),
|
||||
render_pipeline,
|
||||
bind_group_layouts: bgls,
|
||||
device: Dom::from_ref(device),
|
||||
}
|
||||
}
|
||||
|
@ -52,14 +46,12 @@ impl GPURenderPipeline {
|
|||
global: &GlobalScope,
|
||||
render_pipeline: WebGPURenderPipeline,
|
||||
label: USVString,
|
||||
bgls: Vec<WebGPUBindGroupLayout>,
|
||||
device: &GPUDevice,
|
||||
) -> DomRoot<Self> {
|
||||
reflect_dom_object(
|
||||
Box::new(GPURenderPipeline::new_inherited(
|
||||
render_pipeline,
|
||||
label,
|
||||
bgls,
|
||||
device,
|
||||
)),
|
||||
global,
|
||||
|
@ -86,13 +78,28 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
|
|||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
|
||||
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||
if index > self.bind_group_layouts.len() as u32 {
|
||||
return Err(Error::Range(String::from("Index out of bounds")));
|
||||
let id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.create_bind_group_layout_id(self.render_pipeline.0.backend());
|
||||
|
||||
if let Err(e) = self
|
||||
.channel
|
||||
.0
|
||||
.send(WebGPURequest::RenderGetBindGroupLayout {
|
||||
device_id: self.device.id().0,
|
||||
pipeline_id: self.render_pipeline.0,
|
||||
index,
|
||||
id,
|
||||
})
|
||||
{
|
||||
warn!("Failed to send WebGPURequest::RenderGetBindGroupLayout {e:?}");
|
||||
}
|
||||
|
||||
Ok(GPUBindGroupLayout::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
self.bind_group_layouts[index as usize],
|
||||
WebGPUBindGroupLayout(id),
|
||||
USVString::default(),
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue