New get_bind_group_layout functions

This commit is contained in:
Dzmitry Malyshau committed 2020-08-09 18:33:47 -04:00
1 parent d8efe3b6fe
commit 55064ace4c
3 files changed
+54

No files matched your search

+8
View File
@@ -523,3 +523,11 @@ impl<B: hal::Backend> Borrow<()> for BindGroup<B> {
&DUMMY_SELECTOR
}
}
#[derive(Clone, Debug, Error)]
pub enum GetBindGroupLayoutError {
#[error("pipeline is invalid")]
InvalidPipeline,
#[error("invalid group index {0}")]
InvalidGroupIndex(u32),
}
+44
View File
@@ -2957,6 +2957,28 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Ok((id.0, derived_bind_group_count))
}
pub fn render_pipeline_get_bind_group_layout<B: GfxBackend>(
&self,
pipeline_id: id::RenderPipelineId,
index: u32,
) -> Result<id::BindGroupLayoutId, binding_model::GetBindGroupLayoutError> {
let hub = B::hub(self);
let mut token = Token::root();
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
let (pipeline_guard, _) = hub.render_pipelines.read(&mut token);
let pipeline = pipeline_guard
.get(pipeline_id)
.map_err(|_| binding_model::GetBindGroupLayoutError::InvalidPipeline)?;
pipeline_layout_guard[pipeline.layout_id.value]
.bind_group_layout_ids
.get(index as usize)
.map(|valid| valid.0)
.ok_or(binding_model::GetBindGroupLayoutError::InvalidGroupIndex(
index,
))
}
pub fn render_pipeline_error<B: GfxBackend>(
&self,
id_in: Input<G, id::RenderPipelineId>,
@@ -3149,6 +3171,28 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
Ok((id.0, derived_bind_group_count))
}
pub fn compute_pipeline_get_bind_group_layout<B: GfxBackend>(
&self,
pipeline_id: id::ComputePipelineId,
index: u32,
) -> Result<id::BindGroupLayoutId, binding_model::GetBindGroupLayoutError> {
let hub = B::hub(self);
let mut token = Token::root();
let (pipeline_layout_guard, mut token) = hub.pipeline_layouts.read(&mut token);
let (pipeline_guard, _) = hub.compute_pipelines.read(&mut token);
let pipeline = pipeline_guard
.get(pipeline_id)
.map_err(|_| binding_model::GetBindGroupLayoutError::InvalidPipeline)?;
pipeline_layout_guard[pipeline.layout_id.value]
.bind_group_layout_ids
.get(index as usize)
.map(|valid| valid.0)
.ok_or(binding_model::GetBindGroupLayoutError::InvalidGroupIndex(
index,
))
}
pub fn compute_pipeline_error<B: GfxBackend>(
&self,
id_in: Input<G, id::ComputePipelineId>,
+2
View File
@@ -239,8 +239,10 @@ impl<B: hal::Backend> Access<CommandBuffer<B>> for SwapChain<B> {}
impl<B: hal::Backend> Access<RenderBundle> for Device<B> {}
impl<B: hal::Backend> Access<RenderBundle> for CommandBuffer<B> {}
impl<B: hal::Backend> Access<ComputePipeline<B>> for Device<B> {}
impl<B: hal::Backend> Access<ComputePipeline<B>> for PipelineLayout<B> {}
impl<B: hal::Backend> Access<ComputePipeline<B>> for BindGroup<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for Device<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for PipelineLayout<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for BindGroup<B> {}
impl<B: hal::Backend> Access<RenderPipeline<B>> for ComputePipeline<B> {}
impl<B: hal::Backend> Access<ShaderModule<B>> for Device<B> {}