@@ -111,7 +111,7 @@ use crate::{
111111 hub:: Hub ,
112112 id,
113113 init_tracker:: { BufferInitTrackerAction , MemoryInitKind , TextureInitTrackerAction } ,
114- pipeline:: { PipelineFlags , RenderPipeline , VertexStep } ,
114+ pipeline:: { PipelineFlags , RenderPipeline } ,
115115 resource:: {
116116 Buffer , DestroyedResourceError , Fallible , InvalidResourceError , Labeled , ParentDevice ,
117117 RawResourceAccess , TrackingData ,
@@ -662,13 +662,11 @@ fn set_pipeline(
662662 return Err ( RenderCommandError :: IncompatibleStencilAccess ( pipeline. error_ident ( ) ) . into ( ) ) ;
663663 }
664664
665- let pipeline_state = PipelineState :: new ( & pipeline) ;
666-
667665 state
668666 . commands
669667 . push ( ArcRenderCommand :: SetPipeline ( pipeline. clone ( ) ) ) ;
670668
671- state. pipeline = Some ( pipeline_state ) ;
669+ state. pipeline = Some ( pipeline . clone ( ) ) ;
672670
673671 state
674672 . binder
@@ -791,10 +789,9 @@ fn set_immediates(
791789 size_bytes : u32 ,
792790 values_offset : Option < u32 > ,
793791) -> Result < ( ) , RenderBundleErrorInner > {
794- let pipeline_state = state. pipeline ( ) ?;
792+ let pipeline = state. pipeline ( ) ?;
795793
796- pipeline_state
797- . pipeline
794+ pipeline
798795 . layout
799796 . validate_immediates_ranges ( offset, size_bytes) ?;
800797
@@ -817,7 +814,8 @@ fn draw(
817814 state. is_ready ( DrawCommandFamily :: Draw ) ?;
818815 let pipeline = state. pipeline ( ) ?;
819816
820- let vertex_limits = super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. steps ) ;
817+ let vertex_limits =
818+ super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. vertex_steps ) ;
821819 vertex_limits. validate_vertex_limit ( first_vertex, vertex_count) ?;
822820 vertex_limits. validate_instance_limit ( first_instance, instance_count) ?;
823821
@@ -847,7 +845,8 @@ fn draw_indexed(
847845
848846 let index = state. index . as_ref ( ) . unwrap ( ) ;
849847
850- let vertex_limits = super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. steps ) ;
848+ let vertex_limits =
849+ super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. vertex_steps ) ;
851850
852851 let last_index = first_index as u64 + index_count as u64 ;
853852 let index_limit = index. limit ( ) ;
@@ -884,18 +883,17 @@ fn draw_mesh_tasks(
884883 state. is_ready ( DrawCommandFamily :: DrawMeshTasks ) ?;
885884
886885 let limits = & state. device . limits ;
887- let ( groups_size_limit, max_groups) =
888- if state. pipeline . as_ref ( ) . unwrap ( ) . pipeline . has_task_shader {
889- (
890- limits. max_task_workgroups_per_dimension ,
891- limits. max_task_workgroup_total_count ,
892- )
893- } else {
894- (
895- limits. max_mesh_workgroups_per_dimension ,
896- limits. max_mesh_workgroup_total_count ,
897- )
898- } ;
886+ let ( groups_size_limit, max_groups) = if state. pipeline . as_ref ( ) . unwrap ( ) . has_task_shader {
887+ (
888+ limits. max_task_workgroups_per_dimension ,
889+ limits. max_task_workgroup_total_count ,
890+ )
891+ } else {
892+ (
893+ limits. max_mesh_workgroups_per_dimension ,
894+ limits. max_mesh_workgroup_total_count ,
895+ )
896+ } ;
899897
900898 let total_count = check_workgroup_sizes (
901899 & [ group_count_x, group_count_y, group_count_z] ,
@@ -936,7 +934,8 @@ fn multi_draw_indirect(
936934 buffer. same_device ( & state. device ) ?;
937935 buffer. check_usage ( wgt:: BufferUsages :: INDIRECT ) ?;
938936
939- let vertex_limits = super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. steps ) ;
937+ let vertex_limits =
938+ super :: VertexLimits :: new ( state. vertex_buffer_sizes ( ) , & pipeline. vertex_steps ) ;
940939
941940 let stride = super :: get_src_stride_of_indirect_args ( family) ;
942941 // TODO(https://github.com/gfx-rs/wgpu/issues/8051): It would be better to report this
@@ -1391,25 +1390,6 @@ impl VertexState {
13911390 }
13921391}
13931392
1394- /// The bundle's current pipeline, and some cached information needed for validation.
1395- struct PipelineState {
1396- /// The pipeline
1397- pipeline : Arc < RenderPipeline > ,
1398-
1399- /// How this pipeline's vertex shader traverses each vertex buffer, indexed
1400- /// by vertex buffer slot number. `None` signifies unused vertex buffer slots.
1401- steps : Vec < Option < VertexStep > > ,
1402- }
1403-
1404- impl PipelineState {
1405- fn new ( pipeline : & Arc < RenderPipeline > ) -> Self {
1406- Self {
1407- pipeline : pipeline. clone ( ) ,
1408- steps : pipeline. vertex_steps . to_vec ( ) ,
1409- }
1410- }
1411- }
1412-
14131393/// State for analyzing and cleaning up bundle command streams.
14141394///
14151395/// To minimize state updates, [`RenderBundleEncoder::finish`]
@@ -1425,7 +1405,7 @@ struct State {
14251405 trackers : RenderBundleScope ,
14261406
14271407 /// The currently set pipeline, if any.
1428- pipeline : Option < PipelineState > ,
1408+ pipeline : Option < Arc < RenderPipeline > > ,
14291409
14301410 /// The state of each vertex buffer slot.
14311411 vertex : [ Option < VertexState > ; hal:: MAX_VERTEX_BUFFERS ] ,
@@ -1455,9 +1435,9 @@ struct State {
14551435
14561436impl State {
14571437 /// Return the current pipeline state. Return an error if none is set.
1458- fn pipeline ( & self ) -> Result < & PipelineState , RenderBundleErrorInner > {
1438+ fn pipeline ( & self ) -> Result < & RenderPipeline , RenderBundleErrorInner > {
14591439 self . pipeline
1460- . as_ref ( )
1440+ . as_deref ( )
14611441 . ok_or ( DrawError :: MissingPipeline ( pass:: MissingPipeline ) . into ( ) )
14621442 }
14631443
@@ -1508,20 +1488,19 @@ impl State {
15081488 /// This should be further deduplicated with similar validation on render/compute passes.
15091489 fn is_ready ( & mut self , family : DrawCommandFamily ) -> Result < ( ) , DrawError > {
15101490 if let Some ( pipeline) = self . pipeline . as_ref ( ) {
1511- self . binder
1512- . check_compatibility ( pipeline. pipeline . as_ref ( ) ) ?;
1491+ self . binder . check_compatibility ( pipeline. as_ref ( ) ) ?;
15131492 self . binder . check_late_buffer_bindings ( ) ?;
15141493
15151494 // Check all needed vertex buffers have been bound
15161495 for index in pipeline
1517- . steps
1496+ . vertex_steps
15181497 . iter ( )
15191498 . enumerate ( )
15201499 . filter_map ( |( index, step) | step. map ( |_| index) )
15211500 {
15221501 if self . vertex . get ( index) . is_none ( ) {
15231502 return Err ( DrawError :: MissingVertexBuffer {
1524- pipeline : pipeline. pipeline . error_ident ( ) ,
1503+ pipeline : pipeline. error_ident ( ) ,
15251504 index,
15261505 } ) ;
15271506 }
@@ -1548,7 +1527,6 @@ impl State {
15481527 }
15491528
15501529 if family == DrawCommandFamily :: DrawIndexed {
1551- let pipeline = & pipeline. pipeline ;
15521530 let index_format = match & self . index {
15531531 Some ( index) => index. format ,
15541532 None => return Err ( DrawError :: MissingIndexBuffer ) ,
@@ -1566,11 +1544,10 @@ impl State {
15661544
15671545 if !self
15681546 . immediate_slots_set
1569- . contains ( pipeline. pipeline . immediate_slots_required )
1547+ . contains ( pipeline. immediate_slots_required )
15701548 {
15711549 return Err ( DrawError :: MissingImmediateData {
15721550 missing : pipeline
1573- . pipeline
15741551 . immediate_slots_required
15751552 . difference ( self . immediate_slots_set ) ,
15761553 } ) ;
0 commit comments