using Ghost.Graphics.Data;
namespace Ghost.Graphics.RHI;
///
/// D3D12-style command buffer interface for recording rendering commands
///
public interface ICommandBuffer : IDisposable
{
///
/// Begins recording commands into this command buffer
///
void Begin();
///
/// Ends recording commands and prepares for submission
///
void End();
///
/// Begins a render pass with the specified render target
///
/// Render target to render into
/// Color to clear the render target with
void BeginRenderPass(IRenderTarget renderTarget, Color128 clearColor);
///
/// Ends the current render pass
///
void EndRenderPass();
///
/// Sets the viewport for rendering
///
/// Viewport to set
void SetViewport(ViewportDesc viewport);
///
/// Sets the scissor rectangle
///
/// Scissor rectangle to set
void SetScissorRect(RectDesc rect);
///
/// Inserts a resource barrier for state transitions
///
/// Resource to transition
/// Current resource state
/// Target resource state
void ResourceBarrier(IResource resource, ResourceState before, ResourceState after);
///
/// Sets the graphics root signature
///
/// Root signature to set
void SetGraphicsRootSignature(IRootSignature rootSignature);
///
/// Sets the pipeline state object
///
/// Pipeline state to set
void SetPipelineState(IPipelineState pipelineState);
///
/// Sets descriptor heaps for bindless rendering
///
/// Descriptor heaps to set
void SetDescriptorHeaps(IDescriptorHeap[] heaps);
///
/// Draws indexed geometry
///
/// Number of indices to draw
/// Number of instances to draw
/// Starting index location
/// Base vertex location
/// Starting instance location
void DrawIndexedInstanced(uint indexCount, uint instanceCount = 1, uint startIndex = 0, int baseVertex = 0, uint startInstance = 0);
///
/// Dispatches compute threads
///
/// Thread groups in X dimension
/// Thread groups in Y dimension
/// Thread groups in Z dimension
void Dispatch(uint threadGroupCountX, uint threadGroupCountY = 1, uint threadGroupCountZ = 1);
}
///
/// Viewport description
///
public struct ViewportDesc
{
public float X;
public float Y;
public float Width;
public float Height;
public float MinDepth;
public float MaxDepth;
public ViewportDesc(float width, float height)
{
X = 0;
Y = 0;
Width = width;
Height = height;
MinDepth = 0.0f;
MaxDepth = 1.0f;
}
}
///
/// Rectangle description
///
public struct RectDesc
{
public int Left;
public int Top;
public int Right;
public int Bottom;
public RectDesc(int left, int top, int right, int bottom)
{
Left = left;
Top = top;
Right = right;
Bottom = bottom;
}
}
///
/// D3D12-style resource states
///
public enum ResourceState
{
Common = 0,
VertexAndConstantBuffer = 0x1,
IndexBuffer = 0x2,
RenderTarget = 0x4,
UnorderedAccess = 0x8,
DepthWrite = 0x10,
DepthRead = 0x20,
PixelShaderResource = 0x80,
CopyDest = 0x400,
CopySource = 0x800,
Present = 0
}