From 34f8ffd511c795d50bce6d5980d3971ef206b61f Mon Sep 17 00:00:00 2001 From: Tristam MacDonald Date: Sat, 29 Sep 2018 22:32:17 -0700 Subject: [PATCH] implement missing draw_indexed_indirect call (#1056) --- vulkano/src/command_buffer/auto.rs | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/vulkano/src/command_buffer/auto.rs b/vulkano/src/command_buffer/auto.rs index 6e2cfb80..47b206a4 100644 --- a/vulkano/src/command_buffer/auto.rs +++ b/vulkano/src/command_buffer/auto.rs @@ -22,6 +22,7 @@ use buffer::TypedBufferAccess; use command_buffer::CommandBuffer; use command_buffer::CommandBufferExecError; use command_buffer::DrawIndirectCommand; +use command_buffer::DrawIndexedIndirectCommand; use command_buffer::DynamicState; use command_buffer::StateCacher; use command_buffer::StateCacherOutcome; @@ -1134,6 +1135,67 @@ impl

AutoCommandBufferBuilder

{ } } + #[inline] + pub fn draw_indexed_indirect(mut self, pipeline: Gp, dynamic: &DynamicState, + vertices: V, index_buffer: Ib, indirect_buffer: Inb, sets: S, constants: Pc) + -> Result + where Gp: GraphicsPipelineAbstract + VertexSource + Send + Sync + 'static + Clone, // TODO: meh for Clone + S: DescriptorSetsCollection, + Ib: BufferAccess + TypedBufferAccess + Send + Sync + 'static, + Inb: BufferAccess + + TypedBufferAccess + + Send + + Sync + + 'static, + I: Index + 'static + { + unsafe { + // TODO: must check that pipeline is compatible with render pass + + self.ensure_inside_render_pass_inline(&pipeline)?; + let ib_infos = check_index_buffer(self.device(), &index_buffer)?; + check_dynamic_state_validity(&pipeline, dynamic)?; + check_push_constants_validity(&pipeline, &constants)?; + check_descriptor_sets_validity(&pipeline, &sets)?; + let vb_infos = check_vertex_buffers(&pipeline, vertices)?; + + let draw_count = indirect_buffer.len() as u32; + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_graphics_pipeline(&pipeline) + { + self.inner.bind_pipeline_graphics(pipeline.clone()); + } + + if let StateCacherOutcome::NeedChange = + self.state_cacher.bind_index_buffer(&index_buffer, I::ty()) + { + self.inner.bind_index_buffer(index_buffer, I::ty())?; + } + + let dynamic = self.state_cacher.dynamic_state(dynamic); + + push_constants(&mut self.inner, pipeline.clone(), constants); + set_state(&mut self.inner, &dynamic); + descriptor_sets(&mut self.inner, + &mut self.state_cacher, + true, + pipeline.clone(), + sets)?; + vertex_buffers(&mut self.inner, + &mut self.state_cacher, + vb_infos.vertex_buffers)?; + + debug_assert!(self.graphics_allowed); + + self.inner + .draw_indexed_indirect(indirect_buffer, + draw_count, + mem::size_of::() as u32)?; + Ok(self) + } + } + /// Adds a command that ends the current render pass. /// /// This must be called after you went through all the subpasses and before you can build @@ -1627,6 +1689,16 @@ err_gen!(DrawIndirectError { SyncCommandBufferBuilderError, }); +err_gen!(DrawIndexedIndirectError { + AutoCommandBufferBuilderContextError, + CheckDynamicStateValidityError, + CheckPushConstantsValidityError, + CheckDescriptorSetsValidityError, + CheckVertexBufferError, + CheckIndexBufferError, + SyncCommandBufferBuilderError, + }); + err_gen!(ExecuteCommandsError { AutoCommandBufferBuilderContextError, SyncCommandBufferBuilderError,