aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/gpurenderpipeline.rs
diff options
context:
space:
mode:
authorSamson <16504129+sagudev@users.noreply.github.com>2024-09-05 21:48:16 +0200
committerGitHub <noreply@github.com>2024-09-05 19:48:16 +0000
commitebed9218f2907767ba3c9dd9f27f30a6a6e9f225 (patch)
tree72e9817a359a1606415555514db9f1013aa5931f /components/script/dom/gpurenderpipeline.rs
parent312cf0df08e8a5044d286734bfdf3d6f0caff8dd (diff)
downloadservo-ebed9218f2907767ba3c9dd9f27f30a6a6e9f225.tar.gz
servo-ebed9218f2907767ba3c9dd9f27f30a6a6e9f225.zip
webgpu: Move actual Create* implementations from `GPUDevice` to Self (#33320)
* Move actual Create* implementations from `GPUDevice` to Self Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * move Create*Pipeline to Self::create Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * `parse_render_pipeline` outside`GPURenderPipeline::create` Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Diffstat (limited to 'components/script/dom/gpurenderpipeline.rs')
-rw-r--r--components/script/dom/gpurenderpipeline.rs32
1 files changed, 31 insertions, 1 deletions
diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs
index 9b4e64198ab..c0e9506835b 100644
--- a/components/script/dom/gpurenderpipeline.rs
+++ b/components/script/dom/gpurenderpipeline.rs
@@ -3,7 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use dom_struct::dom_struct;
-use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest};
+use ipc_channel::ipc::IpcSender;
+use webgpu::wgc::id::{BindGroupLayoutId, PipelineLayoutId};
+use webgpu::wgc::pipeline::RenderPipelineDescriptor;
+use webgpu::{WebGPU, WebGPUBindGroupLayout, WebGPURenderPipeline, WebGPURequest, WebGPUResponse};
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::WebGPUBinding::GPURenderPipelineMethods;
@@ -63,6 +66,33 @@ impl GPURenderPipeline {
pub fn id(&self) -> WebGPURenderPipeline {
self.render_pipeline
}
+
+ /// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createrenderpipeline>
+ pub fn create(
+ device: &GPUDevice,
+ implicit_ids: Option<(PipelineLayoutId, Vec<BindGroupLayoutId>)>,
+ descriptor: RenderPipelineDescriptor<'static>,
+ async_sender: Option<IpcSender<WebGPUResponse>>,
+ ) -> Fallible<WebGPURenderPipeline> {
+ let render_pipeline_id = device
+ .global()
+ .wgpu_id_hub()
+ .create_render_pipeline_id(device.id().0.backend());
+
+ device
+ .channel()
+ .0
+ .send(WebGPURequest::CreateRenderPipeline {
+ device_id: device.id().0,
+ render_pipeline_id,
+ descriptor,
+ implicit_ids,
+ async_sender,
+ })
+ .expect("Failed to create WebGPU render pipeline");
+
+ Ok(WebGPURenderPipeline(render_pipeline_id))
+ }
}
impl GPURenderPipelineMethods for GPURenderPipeline {