Luna::RHI::ICommandBuffer
Used to allocate memory for commands, record commands, submitting commands to GPU and tracks the state of the submitted commands.
interface Luna::RHI::ICommandBuffer : public virtual IDeviceChild, public virtual IWaitable
Command buffer is not thread safe. If the user need to record commands simultaneously, she should create multiple command buffers, one per thread.
All synchroizations for command buffers are performed explicitly, for instance:1. Use ICommandBuffer::wait to wait for one command buffer from host side,
-
Use fence objects to wait for one command buffer from another command buffer.
-
Only call ICommandBuffer::reset after the command buffer is not submitted, or is finished by GPU.
Base types
Member functions
-
virtual u32 get_command_queue_index()=0
Gets the command queue index of the command queue attached to this buffer.
-
Resets the command buffer. This call clears all commands in the command buffer, resets the state tracking infrastructure and reopens the command buffer for recording new commands.
-
virtual void attach_device_object(IDeviceChild *obj)=0
Attaches one graphic device object to this command buffer. The command buffer keeps a strong reference to the object until the next
reset
is called. -
virtual void begin_event(const c8 *event_name)=0
Begins a new event. This is for use in diagnostic tools like RenderDoc, PIX, XCode, etc to group commands into hierarchical sections.
-
Ends the latest event opened by begin_event that has not been ended.
-
virtual void begin_render_pass(const RenderPassDesc &desc)=0
Starts a new render pass. The previous render pass should be closed before beginning another one.
-
virtual void set_graphics_pipeline_layout(IPipelineLayout *pipeline_layout)=0
Sets the graphic pipeline layout.
-
virtual void set_graphics_pipeline_state(IPipelineState *pso)=0
Sets the pipeline state for graphics pipeline.
-
virtual void set_vertex_buffers(u32 start_slot, Span< const VertexBufferView > views)=0
Sets vertex buffers.
-
virtual void set_index_buffer(const IndexBufferView &view)=0
Sets the index buffer.
-
virtual void set_graphics_descriptor_set(u32 index, IDescriptorSet *descriptor_set)=0
Sets the descriptor set to be used by the graphic pipeline.
-
Sets descriptor sets to be used by the graphic pipeline.
-
virtual void set_viewport(const Viewport &viewport)=0
Bind one viewport to the rasterizer stage of the pipeline.
-
virtual void set_viewports(Span< const Viewport > viewports)=0
Bind an array of viewports to the rasterizer stage of the pipeline.
-
virtual void set_scissor_rect(const RectI &rect)=0
Binds one scissor rectangle to the rasterizer stage. The scissor rectangle points are relative to the top-left corner of the render target, with x-axis points to right and y-axis points to down.
-
virtual void set_scissor_rects(Span< const RectI > rects)=0
Binds an array of scissor rectangles to the rasterizer stage. The scissor rectangle points are relative to the top-left corner of the render target, with x-axis points to right and y-axis points to down.
-
virtual void set_blend_factor(const Float4U &blend_factor)=0
Sets the blend factor of the graphics pipeline.
-
virtual void set_stencil_ref(u32 stencil_ref)=0
Sets the reference value for stencil testing.
-
virtual void draw(u32 vertex_count, u32 start_vertex_location)=0
Draw primitives.
-
virtual void draw_indexed(u32 index_count, u32 start_index_location, i32 base_vertex_location)=0
Draw indexed primitives.
-
Draws non-indexed, instanced primitives.
-
Draws indexed, instanced primitives.
-
virtual void begin_occlusion_query(OcclusionQueryMode mode, u32 index)=0
Starts one occlusion query.
-
virtual void end_occlusion_query(u32 index)=0
Ends one existing occlusion query.
-
virtual void end_render_pass()=0
Finishes the current render pass.
-
virtual void begin_compute_pass(const ComputePassDesc &desc=ComputePassDesc())=0
Begins a compute pass.
-
virtual void set_compute_pipeline_layout(IPipelineLayout *pipeline_layout)=0
Sets the compute pipeline layout.
-
virtual void set_compute_pipeline_state(IPipelineState *pso)=0
Sets the pipeline state for compute pipeline.
-
virtual void set_compute_descriptor_set(u32 index, IDescriptorSet *descriptor_set)=0
Sets the descriptor set to be used by the compute pipeline.
-
Sets descriptor sets to be used by the compute pipeline.
-
Dispatches one compute task.
-
virtual void end_compute_pass()=0
Ends a compute pass.
-
virtual void begin_copy_pass(const CopyPassDesc &desc=CopyPassDesc())=0
Begins a copy pass.
-
virtual void copy_resource(IResource dst, IResource src)=0
Copies the entire contents of the source resource to the destination resource.
-
virtual void copy_buffer(IBuffer dst, u64 dst_offset, IBuffer src, u64 src_offset, u64 copy_bytes)=0
Copies buffer data region from one buffer to another.
-
Copies texture data region from one texture to another.
-
Copies texture data region from one buffer to one texture. Texture data in the buffer is interpreted in row-major arrangement.
-
Copies texture data region from one texture to one buffer. Texture data is written to the buffer in row-major arrangement.
-
virtual void end_copy_pass()=0
Ends a copy pass.
-
Issues one resource barrier that synchronizes GPU pipeline access to multiple resources.
-
Submits the recorded commands in this command buffer to the attached command queue.