Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
[msl-out] Add a get_ep_resources helper
Browse files Browse the repository at this point in the history
  • Loading branch information
armansito committed Feb 20, 2023
1 parent 8f677dc commit 00c648e
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/back/msl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,7 @@ impl Options {
&self,
ep: &crate::EntryPoint,
) -> Result<ResolvedBinding, EntryPointError> {
let slot = self
.per_entry_point_map
.as_ref()
.and_then(|map| map.get(&ep.name))
.and_then(|r| r.push_constant_buffer)
.or_else(|| self.per_stage_map[ep.stage].push_constant_buffer);
let slot = self.get_ep_resources(ep).push_constant_buffer;
match slot {
Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
buffer: Some(slot),
Expand All @@ -356,12 +351,7 @@ impl Options {
&self,
ep: &crate::EntryPoint,
) -> Result<ResolvedBinding, EntryPointError> {
let slot = self
.per_entry_point_map
.as_ref()
.and_then(|map| map.get(&ep.name))
.and_then(|r| r.sizes_buffer)
.or_else(|| self.per_stage_map[ep.stage].sizes_buffer);
let slot = self.get_ep_resources(ep).sizes_buffer;
match slot {
Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
buffer: Some(slot),
Expand All @@ -378,6 +368,13 @@ impl Options {
None => Err(EntryPointError::MissingSizesBuffer),
}
}

fn get_ep_resources(&self, ep: &crate::EntryPoint) -> &PerStageResources {
self.per_entry_point_map
.as_ref()
.and_then(|map| map.get(&ep.name))
.unwrap_or_else(|| &self.per_stage_map[ep.stage])
}
}

impl ResolvedBinding {
Expand Down

0 comments on commit 00c648e

Please sign in to comment.