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

Commit 00c648e

Browse files
committed
[msl-out] Add a get_ep_resources helper
1 parent 8f677dc commit 00c648e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/back/msl/mod.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,7 @@ impl Options {
329329
&self,
330330
ep: &crate::EntryPoint,
331331
) -> Result<ResolvedBinding, EntryPointError> {
332-
let slot = self
333-
.per_entry_point_map
334-
.as_ref()
335-
.and_then(|map| map.get(&ep.name))
336-
.and_then(|r| r.push_constant_buffer)
337-
.or_else(|| self.per_stage_map[ep.stage].push_constant_buffer);
332+
let slot = self.get_ep_resources(ep).push_constant_buffer;
338333
match slot {
339334
Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
340335
buffer: Some(slot),
@@ -356,12 +351,7 @@ impl Options {
356351
&self,
357352
ep: &crate::EntryPoint,
358353
) -> Result<ResolvedBinding, EntryPointError> {
359-
let slot = self
360-
.per_entry_point_map
361-
.as_ref()
362-
.and_then(|map| map.get(&ep.name))
363-
.and_then(|r| r.sizes_buffer)
364-
.or_else(|| self.per_stage_map[ep.stage].sizes_buffer);
354+
let slot = self.get_ep_resources(ep).sizes_buffer;
365355
match slot {
366356
Some(slot) => Ok(ResolvedBinding::Resource(BindTarget {
367357
buffer: Some(slot),
@@ -378,6 +368,13 @@ impl Options {
378368
None => Err(EntryPointError::MissingSizesBuffer),
379369
}
380370
}
371+
372+
fn get_ep_resources(&self, ep: &crate::EntryPoint) -> &PerStageResources {
373+
self.per_entry_point_map
374+
.as_ref()
375+
.and_then(|map| map.get(&ep.name))
376+
.unwrap_or_else(|| &self.per_stage_map[ep.stage])
377+
}
381378
}
382379

383380
impl ResolvedBinding {

0 commit comments

Comments
 (0)