From f082a507da2a09d579021f8b2f0930afdec74c24 Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Wed, 19 Aug 2020 16:44:26 +0530 Subject: Implement GPUPipelineBase for implicit pipeline layouts --- components/webgpu/lib.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'components/webgpu/lib.rs') diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs index 3c970a87760..a7169834586 100644 --- a/components/webgpu/lib.rs +++ b/components/webgpu/lib.rs @@ -36,7 +36,7 @@ use wgpu::{ BufferCopyView, ComputePass, RenderBundleDescriptor, RenderBundleEncoder, RenderPass, TextureCopyView, }, - device::HostMap, + device::{HostMap, ImplicitPipelineIds}, id, instance::RequestAdapterOptions, pipeline::{ComputePipelineDescriptor, RenderPipelineDescriptor}, @@ -141,6 +141,7 @@ pub enum WebGPURequest { device_id: id::DeviceId, compute_pipeline_id: id::ComputePipelineId, descriptor: ComputePipelineDescriptor<'static>, + implicit_ids: Option<(id::PipelineLayoutId, Vec)>, }, CreateContext(IpcSender), CreatePipelineLayout { @@ -152,6 +153,7 @@ pub enum WebGPURequest { device_id: id::DeviceId, render_pipeline_id: id::RenderPipelineId, descriptor: Option>, + implicit_ids: Option<(id::PipelineLayoutId, Vec)>, }, CreateSampler { device_id: id::DeviceId, @@ -611,13 +613,34 @@ impl<'a> WGPU<'a> { device_id, compute_pipeline_id, descriptor, + implicit_ids, } => { let global = &self.global; - let result = gfx_select!(compute_pipeline_id => - global.device_create_compute_pipeline(device_id, &descriptor, compute_pipeline_id, None)); + let bgls = implicit_ids + .as_ref() + .map_or(Vec::with_capacity(0), |(_, bgls)| bgls.clone()); + let implicit = + implicit_ids + .as_ref() + .map(|(layout, _)| ImplicitPipelineIds { + root_id: *layout, + group_ids: bgls.as_slice(), + }); + let result = gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline( + device_id, + &descriptor, + compute_pipeline_id, + implicit + )); if result.is_err() { let _ = gfx_select!(compute_pipeline_id => global.compute_pipeline_error(compute_pipeline_id)); + if let Some((layout, bgls)) = implicit_ids { + let _ = gfx_select!(layout => global.pipeline_layout_error(layout)); + bgls.iter().for_each(|&bgl| { + let _ = gfx_select!(bgl => global.bind_group_layout_error(bgl)); + }); + } } self.send_result(device_id, scope_id, result); }, @@ -648,14 +671,32 @@ impl<'a> WGPU<'a> { device_id, render_pipeline_id, descriptor, + implicit_ids, } => { let global = &self.global; + let bgls = implicit_ids + .as_ref() + .map_or(Vec::with_capacity(0), |(_, bgls)| bgls.clone()); + let implicit = + implicit_ids + .as_ref() + .map(|(layout, _)| ImplicitPipelineIds { + root_id: *layout, + group_ids: bgls.as_slice(), + }); if let Some(desc) = descriptor { let result = gfx_select!(render_pipeline_id => - global.device_create_render_pipeline(device_id, &desc, render_pipeline_id, None)); + global.device_create_render_pipeline(device_id, &desc, render_pipeline_id, implicit)); if result.is_err() { let _ = gfx_select!(render_pipeline_id => global.render_pipeline_error(render_pipeline_id)); + if let Some((layout, bgls)) = implicit_ids { + let _ = + gfx_select!(layout => global.pipeline_layout_error(layout)); + bgls.iter().for_each(|&bgl| { + let _ = gfx_select!(bgl => global.bind_group_layout_error(bgl)); + }); + } } self.send_result(device_id, scope_id, result); } else { -- cgit v1.2.3