pub(super) fn record_layer_draw_commands(
        &mut self,
        frame: &mut Frame,
    ) -> Result<vk::CommandBuffer> {
        let command_buffer = self.begin_frame_commands(frame)?;
        unsafe {
            self.device.logical_device.cmd_bind_pipeline(
                command_buffer,
                vk::PipelineBindPoint::GRAPHICS,
                *self.pipeline2d.raw_pipeline(),
            );

            let descriptor_sets = [frame.descriptor.raw_descriptor_set()];
            self.device.logical_device.cmd_bind_descriptor_sets(
                command_buffer,
                vk::PipelineBindPoint::GRAPHICS,
                *self.pipeline2d.raw_pipeline_layout(),
                0,
                &descriptor_sets,
                &[],
            );

            let buffers = [frame.vertex_buffer.raw()];
            let offsets = [0];
            self.device.logical_device.cmd_bind_vertex_buffers(
                command_buffer,
                0,
                &buffers,
                &offsets,
            );

            let mut offset: u32 = 0;
            for layer in self.layer_stack.layers() {
                for batch in layer.batches() {
                    let consts = PushConsts {
                        projection: (*layer.projection()).into(),
                        texture_index: batch.texture_handle.texture_index(),
                    };
                    self.device.logical_device.cmd_push_constants(
                        command_buffer,
                        *self.pipeline2d.raw_pipeline_layout(),
                        vk::ShaderStageFlags::FRAGMENT
                            | vk::ShaderStageFlags::VERTEX,
                        0,
                        any_as_u8_slice(&consts),
                    );
                    self.device.logical_device.cmd_draw(
                        command_buffer,
                        batch.vertices.len() as u32, // vertex count
                        1,                           // instance count
                        offset,                      // first vertex
                        0,                           // first instance
                    );
                    offset += batch.vertices.len() as u32;
                }
            }
        }
        self.end_frame_commands(command_buffer)?;
        Ok(command_buffer)
    }
/// Record a command buffer for rendering each graphics layer in a single
/// pass.
Record a command buffer for rendering each graphics layer in a single
pass.
Record a command buffer for rendering each graphics layer in a single pass .
pub(super) fn record_layer_draw_commands(
        &mut self,
        frame: &mut Frame,
    ) -> Result<vk::CommandBuffer> {
        let command_buffer = self.begin_frame_commands(frame)?;
        unsafe {
            self.device.logical_device.cmd_bind_pipeline(
                command_buffer,
                vk::PipelineBindPoint::GRAPHICS,
                *self.pipeline2d.raw_pipeline(),
            );
            let descriptor_sets = [frame.descriptor.raw_descriptor_set()];
            self.device.logical_device.cmd_bind_descriptor_sets(
                command_buffer,
                vk::PipelineBindPoint::GRAPHICS,
                *self.pipeline2d.raw_pipeline_layout(),
                0,
                &descriptor_sets,
                &[],
            );
            let buffers = [frame.vertex_buffer.raw()];
            let offsets = [0];
            self.device.logical_device.cmd_bind_vertex_buffers(
                command_buffer,
                0,
                &buffers,
                &offsets,
            );
            let mut offset: u32 = 0;
            for layer in self.layer_stack.layers() {
                for batch in layer.batches() {
                    let consts = PushConsts {
                        projection: (*layer.projection()).into(),
                        texture_index: batch.texture_handle.texture_index(),
                    };
                    self.device.logical_device.cmd_push_constants(
                        command_buffer,
                        *self.pipeline2d.raw_pipeline_layout(),
                        vk::ShaderStageFlags::FRAGMENT
                            | vk::ShaderStageFlags::VERTEX,
                        0,
                        any_as_u8_slice(&consts),
                    );
                    self.device.logical_device.cmd_draw(
                        command_buffer,
                        batch.vertices.len() as u32, // vertex count
                        1,                           // instance count
                        offset,                      // first vertex
                        0,                           // first instance
                    );
                    offset += batch.vertices.len() as u32;
                }
            }
        }
        self.end_frame_commands(command_buffer)?;
        Ok(command_buffer)
    }
pub ( super ) fn record_layer_draw_commands ( & mut self , frame : & mut Frame , ) -> Result < vk :: CommandBuffer > { let command_buffer = self . begin_frame_commands ( frame ) ? ; unsafe { self . device . logical_device . cmd_bind_pipeline ( command_buffer , vk :: PipelineBindPoint :: GRAPHICS , * self . pipeline2d . raw_pipeline ( ) , ) ; let descriptor_sets = [ frame . descriptor . raw_descriptor_set ( ) ] ; self . device . logical_device . cmd_bind_descriptor_sets ( command_buffer , vk :: PipelineBindPoint :: GRAPHICS , * self . pipeline2d . raw_pipeline_layout ( ) , 0 , & descriptor_sets , & [ ] , ) ; let buffers = [ frame . vertex_buffer . raw ( ) ] ; let offsets = [ 0 ] ; self . device . logical_device . cmd_bind_vertex_buffers ( command_buffer , 0 , & buffers , & offsets , ) ; let mut offset : u32 = 0 ; for layer in self . layer_stack . layers ( ) { for batch in layer . batches ( ) { let consts = PushConsts { projection : ( * layer . projection ( ) ) . into ( ) , texture_index : batch . texture_handle . texture_index ( ) , } ; self . device . logical_device . cmd_push_constants ( command_buffer , * self . pipeline2d . raw_pipeline_layout ( ) , vk :: ShaderStageFlags :: FRAGMENT | vk :: ShaderStageFlags :: VERTEX , 0 , any_as_u8_slice ( & consts ) , ) ; self . device . logical_device . cmd_draw ( command_buffer , batch . vertices . len ( ) as u32 , // vertex count 1 , // instance count offset , // first vertex 0 , // first instance ) ; offset += batch . vertices . len ( ) as u32 ; } } } self . end_frame_commands ( command_buffer ) ? ; Ok ( command_buffer ) }
Record a command buffer for rendering each graphics layer in a single
pass.
Record a command buffer for rendering each graphics layer in a single pass .
&mut self
frame
&mut Frame