@@ -12,10 +12,10 @@ use super::{
12
12
WrappedZeroValue ,
13
13
} ,
14
14
storage:: StoreValue ,
15
- BackendResult , Error , FragmentEntryPoint , Options , ShaderModel ,
15
+ BackendResult , Error , FragmentEntryPoint , Options , PipelineOptions , ShaderModel ,
16
16
} ;
17
17
use crate :: {
18
- back:: { self , Baked } ,
18
+ back:: { self , get_entry_points , Baked } ,
19
19
common,
20
20
proc:: { self , index, NameKey } ,
21
21
valid, Handle , Module , RayQueryFunction , Scalar , ScalarKind , ShaderStage , TypeInner ,
@@ -123,13 +123,14 @@ struct BindingArraySamplerInfo {
123
123
}
124
124
125
125
impl < ' a , W : fmt:: Write > super :: Writer < ' a , W > {
126
- pub fn new ( out : W , options : & ' a Options ) -> Self {
126
+ pub fn new ( out : W , options : & ' a Options , pipeline_options : & ' a PipelineOptions ) -> Self {
127
127
Self {
128
128
out,
129
129
names : crate :: FastHashMap :: default ( ) ,
130
130
namer : proc:: Namer :: default ( ) ,
131
131
options,
132
- entry_point_io : Vec :: new ( ) ,
132
+ pipeline_options,
133
+ entry_point_io : crate :: FastHashMap :: default ( ) ,
133
134
named_expressions : crate :: NamedExpressions :: default ( ) ,
134
135
wrapped : super :: Wrapped :: default ( ) ,
135
136
written_committed_intersection : false ,
@@ -387,8 +388,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
387
388
writeln ! ( self . out) ?;
388
389
}
389
390
391
+ let ep_range = get_entry_points ( module, self . pipeline_options . entry_point . as_ref ( ) )
392
+ . map_err ( |( stage, name) | Error :: EntryPointNotFound ( stage, name) ) ?;
393
+
390
394
// Write all entry points wrapped structs
391
- for ( index, ep) in module. entry_points . iter ( ) . enumerate ( ) {
395
+ for index in ep_range. clone ( ) {
396
+ let ep = & module. entry_points [ index] ;
392
397
let ep_name = self . names [ & NameKey :: EntryPoint ( index as u16 ) ] . clone ( ) ;
393
398
let ep_io = self . write_ep_interface (
394
399
module,
@@ -397,7 +402,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
397
402
& ep_name,
398
403
fragment_entry_point,
399
404
) ?;
400
- self . entry_point_io . push ( ep_io) ;
405
+ self . entry_point_io . insert ( index , ep_io) ;
401
406
}
402
407
403
408
// Write all regular functions
@@ -442,10 +447,11 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
442
447
writeln ! ( self . out) ?;
443
448
}
444
449
445
- let mut entry_point_names = Vec :: with_capacity ( module . entry_points . len ( ) ) ;
450
+ let mut translated_ep_names = Vec :: with_capacity ( ep_range . len ( ) ) ;
446
451
447
452
// Write all entry points
448
- for ( index, ep) in module. entry_points . iter ( ) . enumerate ( ) {
453
+ for index in ep_range {
454
+ let ep = & module. entry_points [ index] ;
449
455
let info = module_info. get_entry_point ( index) ;
450
456
451
457
if !self . options . fake_missing_bindings {
@@ -462,7 +468,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
462
468
}
463
469
}
464
470
if let Some ( err) = ep_error {
465
- entry_point_names . push ( Err ( err) ) ;
471
+ translated_ep_names . push ( Err ( err) ) ;
466
472
continue ;
467
473
}
468
474
}
@@ -493,10 +499,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
493
499
writeln ! ( self . out) ?;
494
500
}
495
501
496
- entry_point_names . push ( Ok ( name) ) ;
502
+ translated_ep_names . push ( Ok ( name) ) ;
497
503
}
498
504
499
- Ok ( super :: ReflectionInfo { entry_point_names } )
505
+ Ok ( super :: ReflectionInfo {
506
+ entry_point_names : translated_ep_names,
507
+ } )
500
508
}
501
509
502
510
fn write_modifier ( & mut self , binding : & crate :: Binding ) -> BackendResult {
@@ -816,7 +824,13 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
816
824
ep_index : u16 ,
817
825
) -> BackendResult {
818
826
let ep = & module. entry_points [ ep_index as usize ] ;
819
- let ep_input = match self . entry_point_io [ ep_index as usize ] . input . take ( ) {
827
+ let ep_input = match self
828
+ . entry_point_io
829
+ . get_mut ( & ( ep_index as usize ) )
830
+ . unwrap ( )
831
+ . input
832
+ . take ( )
833
+ {
820
834
Some ( ep_input) => ep_input,
821
835
None => return Ok ( ( ) ) ,
822
836
} ;
@@ -1432,7 +1446,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
1432
1446
}
1433
1447
}
1434
1448
back:: FunctionType :: EntryPoint ( index) => {
1435
- if let Some ( ref ep_output) = self . entry_point_io [ index as usize ] . output {
1449
+ if let Some ( ref ep_output) =
1450
+ self . entry_point_io . get ( & ( index as usize ) ) . unwrap ( ) . output
1451
+ {
1436
1452
write ! ( self . out, "{}" , ep_output. ty_name) ?;
1437
1453
} else {
1438
1454
self . write_type ( module, result. ty ) ?;
@@ -1479,7 +1495,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
1479
1495
}
1480
1496
}
1481
1497
back:: FunctionType :: EntryPoint ( ep_index) => {
1482
- if let Some ( ref ep_input) = self . entry_point_io [ ep_index as usize ] . input {
1498
+ if let Some ( ref ep_input) =
1499
+ self . entry_point_io . get ( & ( ep_index as usize ) ) . unwrap ( ) . input
1500
+ {
1483
1501
write ! ( self . out, "{} {}" , ep_input. ty_name, ep_input. arg_name) ?;
1484
1502
} else {
1485
1503
let stage = module. entry_points [ ep_index as usize ] . stage ;
@@ -1501,7 +1519,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
1501
1519
}
1502
1520
}
1503
1521
if need_workgroup_variables_initialization {
1504
- if self . entry_point_io [ ep_index as usize ] . input . is_some ( )
1522
+ if self
1523
+ . entry_point_io
1524
+ . get ( & ( ep_index as usize ) )
1525
+ . unwrap ( )
1526
+ . input
1527
+ . is_some ( )
1505
1528
|| !func. arguments . is_empty ( )
1506
1529
{
1507
1530
write ! ( self . out, ", " ) ?;
@@ -1870,9 +1893,12 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
1870
1893
// for entry point returns, we may need to reshuffle the outputs into a different struct
1871
1894
let ep_output = match func_ctx. ty {
1872
1895
back:: FunctionType :: Function ( _) => None ,
1873
- back:: FunctionType :: EntryPoint ( index) => {
1874
- self . entry_point_io [ index as usize ] . output . as_ref ( )
1875
- }
1896
+ back:: FunctionType :: EntryPoint ( index) => self
1897
+ . entry_point_io
1898
+ . get ( & ( index as usize ) )
1899
+ . unwrap ( )
1900
+ . output
1901
+ . as_ref ( ) ,
1876
1902
} ;
1877
1903
let final_name = match ep_output {
1878
1904
Some ( ep_output) => {
0 commit comments