Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
|
#include <graphics_context.h>
Public Member Functions | |
void | ClearUAV (GpuBuffer &target) |
void | ClearUAV (ColorBuffer &target) |
void | ClearColor (ColorBuffer &target) |
void | ClearDepth (DepthBuffer &target) |
void | ClearStencil (DepthBuffer &target) |
void | ClearDepthAndStencil (DepthBuffer &target) |
void | BeginQuery (ID3D12QueryHeap *query_heap, D3D12_QUERY_TYPE type, UINT heap_index) |
void | EndQuery (ID3D12QueryHeap *query_heap, D3D12_QUERY_TYPE type, UINT heap_index) |
void | ResolveQueryData (ID3D12QueryHeap *query_heap, D3D12_QUERY_TYPE type, UINT start_index, UINT num_queries, ID3D12Resource *dest_buffer, UINT64 dest_buffer_offset) |
void | SetRootSignature (const RootSignature &root_signature) |
void | SetRenderTargets (UINT num_rtvs, const UINT rtvs[]) |
void | SetRenderTargets (UINT num_rtvs, const UINT rtvs[], UINT dsv) |
void | SetRenderTarget (UINT rtv) |
void | SetRenderTarget (UINT rtv, UINT dsv) |
void | SetDepthStencilTarget (UINT dsv) |
void | SetViewport (const D3D12_VIEWPORT &vp) |
void | SetViewport (FLOAT x, FLOAT y, FLOAT w, FLOAT h, FLOAT min_depth=0.0f, FLOAT max_depth=1.0f) |
void | SetScissor (const D3D12_RECT &rect) |
void | SetScissor (UINT left, UINT top, UINT right, UINT bottom) |
void | SetViewportAndScissor (const D3D12_VIEWPORT &vp, const D3D12_RECT &rect) |
void | SetViewportAndScissor (UINT x, UINT y, UINT w, UINT h) |
void | SetStencilRef (UINT stencil_ref) |
void | SetBlendFactor (float colorRGBA[]) |
void | SetPrimitiveTopology (D3D12_PRIMITIVE_TOPOLOGY topology) |
void | SetPipelineState (const GraphicsPSO &pso) |
void | SetConstants (UINT root_index, UINT num_constants, const void *constants) |
void | SetConstants (UINT root_index, Param32Bit x) |
void | SetConstants (UINT root_index, Param32Bit x, Param32Bit y) |
void | SetConstants (UINT root_index, Param32Bit x, Param32Bit y, Param32Bit z) |
void | SetConstants (UINT root_index, Param32Bit x, Param32Bit y, Param32Bit z, Param32Bit w) |
void | SetConstantBuffer (UINT root_index, D3D12_GPU_VIRTUAL_ADDRESS cbv) |
void | SetBufferSRV (UINT root_index, GpuBuffer &srv, UINT offset=0) |
void | SetBufferUAV (UINT root_index, GpuBuffer &uav, UINT offset=0) |
void | SetDescriptorTable (UINT root_index, D3D12_GPU_DESCRIPTOR_HANDLE first_handle) |
void | SetIndexBuffer (const D3D12_INDEX_BUFFER_VIEW &ibv) |
void | SetVertexBuffer (UINT slot, const D3D12_VERTEX_BUFFER_VIEW &vbv) |
void | SetVertexBuffers (UINT start_slot, UINT count, const D3D12_VERTEX_BUFFER_VIEW vbvs[]) |
void | Draw (UINT vertex_count, UINT vertex_start_offset=0) |
void | DrawIndexed (UINT index_count, UINT start_index_location=0, INT base_vertex_location=0) |
void | DrawInstanced (UINT vertex_count_per_instance, UINT instance_count, UINT start_vertex_location=0, UINT start_instance_location=0) |
void | DrawIndexedInstanced (UINT index_count_per_instance, UINT instance_count, UINT start_index_location, INT start_vertex_location, UINT start_instance_location) |
void | DrawIndirect (GpuBuffer &argument_buffer, UINT argument_buffer_offset=0) |
Public Member Functions inherited from blowbox::CommandContext | |
~CommandContext () | |
GraphicsContext & | GetGraphicsContext () |
ComputeContext & | GetComputeContext () |
void | Initialize () |
void | CopyBuffer (GpuResource &dest_resource, UploadBuffer &source_resource) |
void | CopyBuffer (GpuResource &dest_resource, GpuResource &source_resource) |
void | CopyBufferRegion (GpuResource &dest_resource, UINT dest_offset, GpuResource &source_resource, UINT source_offset, UINT num_bytes) |
void | CopySubresource (GpuResource &dest_resource, UINT dest_subresource_index, GpuResource &source_resource, UINT source_subresource_index) |
void | CopyCounter (GpuResource &dest_resource, UINT dest_offset, StructuredBuffer &source_resource) |
uint64_t | Flush (bool wait_for_completion=false) |
uint64_t | Finish (bool wait_for_completion=false) |
void | TransitionResource (GpuResource &resource, const D3D12_RESOURCE_STATES &new_state, bool flush_immediate=false) |
void | BeginResourceTransition (GpuResource &resource, const D3D12_RESOURCE_STATES &new_state, bool flush_immediate=false) |
void | InsertUAVBarrier (GpuResource &resource, bool flush_immediate=false) |
void | InsertAliasBuffer (GpuResource &before, GpuResource &after, bool flush_immediate=false) |
void | FlushResourceBarriers () |
void | InsertTimeStamp (ID3D12QueryHeap *query_heap, UINT query_idx) |
void | ResolveTimeStamps (ID3D12Resource *read_back_heap, ID3D12QueryHeap *query_heap, UINT num_queries) |
void | SetDescriptorHeap (D3D12_DESCRIPTOR_HEAP_TYPE type, ID3D12DescriptorHeap *heap) |
void | SetDescriptorHeaps (UINT heap_count, D3D12_DESCRIPTOR_HEAP_TYPE heap_types[], ID3D12DescriptorHeap *heaps[]) |
void | SetPredication (ID3D12Resource *buffer, UINT64 buffer_offset, D3D12_PREDICATION_OP op) |
ID3D12GraphicsCommandList * | Get () |
Static Public Member Functions | |
static GraphicsContext & | Begin (const eastl::wstring &name=L"") |
Static Public Member Functions inherited from blowbox::CommandContext | |
static CommandContext & | Begin (const WString &name=L"") |
static void | InitializeTexture (GpuResource &dest_resource, UINT num_subresources, D3D12_SUBRESOURCE_DATA subresource_data[]) |
static void | InitializeBuffer (GpuResource &dest_resource, const void *data, UINT num_bytes, bool use_offset=false, UINT offset=0) |
Additional Inherited Members | |
Protected Member Functions inherited from blowbox::CommandContext | |
void | BindDescriptorHeaps () |
void | SetName (const WString &name) |
Protected Attributes inherited from blowbox::CommandContext | |
WString | name_ |
D3D12_COMMAND_LIST_TYPE | type_ |
ID3D12GraphicsCommandList * | list_ |
ID3D12CommandAllocator * | allocator_ |
UINT | num_flushable_barriers_ |
D3D12_RESOURCE_BARRIER | resource_barrier_buffer_ [COMMAND_CONTEXT_BARRIER_BUFFER_SIZE] |
ID3D12DescriptorHeap * | descriptor_heaps_ [4] |
ID3D12RootSignature * | graphics_root_signature_ |
ID3D12PipelineState * | graphics_pipeline_state_ |
ID3D12RootSignature * | compute_root_signature_ |
ID3D12PipelineState * | compute_pipeline_state_ |
Wraps functionality for submitting graphics related command lists.
Inherting from the CommandContext, this GraphicsContext allows you to create, record and submit graphics command lists to the GPU. Use GraphicsContext::Begin() to start a new context and submit it by either calling GraphicsContext::Finish() or GraphicsContext::Flush() on it.
|
static |
Begins a new GraphicsContext.
[in] | name | The name of the newly created GraphicsContext. |
void blowbox::GraphicsContext::BeginQuery | ( | ID3D12QueryHeap * | query_heap, |
D3D12_QUERY_TYPE | type, | ||
UINT | heap_index | ||
) |
Begins a query.
[in] | query_heap | The query heap. |
[in] | type | The query type. |
[in] | heap_index | The heap index. |
void blowbox::GraphicsContext::ClearColor | ( | ColorBuffer & | target | ) |
Clears a RTV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::ClearDepth | ( | DepthBuffer & | target | ) |
Clears a DSV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::ClearDepthAndStencil | ( | DepthBuffer & | target | ) |
Clears a DSV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::ClearStencil | ( | DepthBuffer & | target | ) |
Clears a DSV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::ClearUAV | ( | GpuBuffer & | target | ) |
Clears a UAV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::ClearUAV | ( | ColorBuffer & | target | ) |
Clears a UAV resource.
[in] | target | The resource that should be cleared. |
void blowbox::GraphicsContext::Draw | ( | UINT | vertex_count, |
UINT | vertex_start_offset = 0 |
||
) |
Issues a non-instanced non-indexed draw call.
[in] | vertex_count | Number of vertices that should be drawn. |
[in] | vertex_start_offset | The offset into the vertex buffer from which the vertices should start counting, usually 0. |
void blowbox::GraphicsContext::DrawIndexed | ( | UINT | index_count, |
UINT | start_index_location = 0 , |
||
INT | base_vertex_location = 0 |
||
) |
Issues an non-instanced indexed draw call.
[in] | index_count | Number of indices that should be drawn. |
[in] | start_index_location | The offset into the index buffer from which the indices should start counting, usually 0. |
[in] | base_vertex_location | The offset into the vertex buffer from which the vertices should start counting, usually 0. |
void blowbox::GraphicsContext::DrawIndexedInstanced | ( | UINT | index_count_per_instance, |
UINT | instance_count, | ||
UINT | start_index_location, | ||
INT | start_vertex_location, | ||
UINT | start_instance_location | ||
) |
Issues an instanced indexed draw call.
[in] | index_count_per_instance | Number of vertices per instance. |
[in] | instance_count | Number of instances that should be drawn. |
[in] | start_index_location | The offset into the index buffer from which the indices should start counting, usually 0. |
[in] | start_vertex_location | The offset into the vertex buffer from which the vertices should start counting, usually 0. |
[in] | start_instance_location | The offset into the vertex buffer from which the per instance vertex buffer should start counting, usually 0. |
void blowbox::GraphicsContext::DrawIndirect | ( | GpuBuffer & | argument_buffer, |
UINT | argument_buffer_offset = 0 |
||
) |
Issues an indirect draw buffer.
[in] | argument_buffer | Argument buffer. |
[in] | argument_buffer_offset | Argument buffer offset. |
void blowbox::GraphicsContext::DrawInstanced | ( | UINT | vertex_count_per_instance, |
UINT | instance_count, | ||
UINT | start_vertex_location = 0 , |
||
UINT | start_instance_location = 0 |
||
) |
Issues an instanced non-indexed draw call.
[in] | vertex_count_per_instance | Number of vertices per instance. |
[in] | instance_count | Number of instances that should be drawn. |
[in] | start_vertex_location | The offset into the vertex buffer from which the vertices should start counting, usually 0. |
[in] | start_instance_location | The offset into the vertex buffer from which the per instance vertex buffer should start counting, usually 0. |
void blowbox::GraphicsContext::EndQuery | ( | ID3D12QueryHeap * | query_heap, |
D3D12_QUERY_TYPE | type, | ||
UINT | heap_index | ||
) |
Ends a query.
[in] | query_heap | The query heap. |
[in] | type | The query type. |
[in] | heap_index | The heap index. |
void blowbox::GraphicsContext::ResolveQueryData | ( | ID3D12QueryHeap * | query_heap, |
D3D12_QUERY_TYPE | type, | ||
UINT | start_index, | ||
UINT | num_queries, | ||
ID3D12Resource * | dest_buffer, | ||
UINT64 | dest_buffer_offset | ||
) |
Resolves a query.
[in] | query_heap | The query heap. |
[in] | type | The query type. |
[in] | start_index | The start heap index. |
[in] | num_queries | The number of queries. |
[in] | dest_buffer | The destination buffer. |
[in] | dest_buffer_offset | The offset into the destination buffer. |
void blowbox::GraphicsContext::SetBlendFactor | ( | float | colorRGBA[] | ) |
Sets the blend factor.
[in] | colorRGBA | The blend factor. |
void blowbox::GraphicsContext::SetBufferSRV | ( | UINT | root_index, |
GpuBuffer & | srv, | ||
UINT | offset = 0 |
||
) |
Binds a root SRV buffer to the pipeline.
[in] | root_index | The index in the root signature that the buffer should be put at. |
[in] | srv | The descriptor ID of the SRV that should be bound to the pipeline. |
[in] | offset | If an offset into the SRV buffer should be used, this is the place to do it. |
void blowbox::GraphicsContext::SetBufferUAV | ( | UINT | root_index, |
GpuBuffer & | uav, | ||
UINT | offset = 0 |
||
) |
Binds a root UAV buffer to the pipeline.
[in] | root_index | The index in the root signature that the buffer should be put at. |
[in] | uav | The descriptor ID of the UAV that should be bound to the pipeline. |
[in] | offset | If an offset into the UAV buffer should be used, this is the place to do it. |
void blowbox::GraphicsContext::SetConstantBuffer | ( | UINT | root_index, |
D3D12_GPU_VIRTUAL_ADDRESS | cbv | ||
) |
Sets a root constant buffer.
[in] | root_index | The index in the root signature that the buffer should be put at. |
[in] | cbv | The GPU address where the buffer exists. |
void blowbox::GraphicsContext::SetConstants | ( | UINT | root_index, |
UINT | num_constants, | ||
const void * | constants | ||
) |
Sets a number of root constants.
[in] | root_index | The index in the root signature that the constants should be put at. |
[in] | num_constants | The number of constants to be set. |
[in] | constants | The constants that should be set. |
void blowbox::GraphicsContext::SetConstants | ( | UINT | root_index, |
Param32Bit | x | ||
) |
Sets a root constant.
[in] | root_index | The index in the root signature that the constants should be put at. |
[in] | x | The first constant data. |
void blowbox::GraphicsContext::SetConstants | ( | UINT | root_index, |
Param32Bit | x, | ||
Param32Bit | y | ||
) |
Sets a root constant.
[in] | root_index | The index in the root signature that the constants should be put at. |
[in] | x | The first constant data. |
[in] | y | The second constant data. |
void blowbox::GraphicsContext::SetConstants | ( | UINT | root_index, |
Param32Bit | x, | ||
Param32Bit | y, | ||
Param32Bit | z | ||
) |
Sets a root constant.
[in] | root_index | The index in the root signature that the constants should be put at. |
[in] | x | The first constant data. |
[in] | y | The second constant data. |
[in] | z | The third constant data. |
void blowbox::GraphicsContext::SetConstants | ( | UINT | root_index, |
Param32Bit | x, | ||
Param32Bit | y, | ||
Param32Bit | z, | ||
Param32Bit | w | ||
) |
Sets a root constant.
[in] | root_index | The index in the root signature that the constants should be put at. |
[in] | x | The first constant data. |
[in] | y | The second constant data. |
[in] | z | The third constant data. |
[in] | w | The fourth constant data. |
|
inline |
Sets a depth stencil.
[in] | dsv | The descriptor id of the DSV that should be bound. |
void blowbox::GraphicsContext::SetDescriptorTable | ( | UINT | root_index, |
D3D12_GPU_DESCRIPTOR_HANDLE | first_handle | ||
) |
Bind a descriptortable to the pipeline.
[in] | root_index | The index in the root signature that the buffer should be put at. |
[in] | first_handle | The first handle to a descriptor in a descriptor heap from where the descriptor table should start. |
void blowbox::GraphicsContext::SetIndexBuffer | ( | const D3D12_INDEX_BUFFER_VIEW & | ibv | ) |
Binds an index buffer to the pipeline.
[in] | ibv | The index buffer view that should be bound. |
void blowbox::GraphicsContext::SetPipelineState | ( | const GraphicsPSO & | pso | ) |
Sets the pipeline state.
[in] | pso | The PSO that should be bound to the pipeline. |
void blowbox::GraphicsContext::SetPrimitiveTopology | ( | D3D12_PRIMITIVE_TOPOLOGY | topology | ) |
Sets the primitive topology.
[in] | topology | The primitive topology. |
|
inline |
Sets a render target.
[in] | rtv | The descriptor id of the RTV that should be bound. |
|
inline |
Sets a render target and depth stencil.
[in] | rtv | The descriptor id of the RTV that should be bound. |
[in] | dsv | The descriptor id of the DSV that should be bound. |
void blowbox::GraphicsContext::SetRenderTargets | ( | UINT | num_rtvs, |
const UINT | rtvs[] | ||
) |
Sets a number of render targets.
[in] | num_rtvs | The number of render targets that you want to set. |
[in] | rtvs | The descriptor ids of the render targets that should be bound to the pipeline. |
void blowbox::GraphicsContext::SetRenderTargets | ( | UINT | num_rtvs, |
const UINT | rtvs[], | ||
UINT | dsv | ||
) |
Sets a number of render targets, and a depth stencil.
[in] | num_rtvs | The number of render targets that you want to set. |
[in] | rtvs | The descriptor ids of the render targets that should be bound to the pipeline. |
[in] | dsv | The descriptor id of the depth stencil buffer you want to bind. |
void blowbox::GraphicsContext::SetRootSignature | ( | const RootSignature & | root_signature | ) |
Sets the pipeline's root signature.
[in] | root_signature | The root signature that you want to set. |
void blowbox::GraphicsContext::SetScissor | ( | const D3D12_RECT & | rect | ) |
Sets the current scissor rect.
[in] | rect | The scissor rect you want to set. |
void blowbox::GraphicsContext::SetScissor | ( | UINT | left, |
UINT | top, | ||
UINT | right, | ||
UINT | bottom | ||
) |
Sets the current scissor rect.
[in] | left | The left most coordinate of the rect. |
[in] | top | The top most coordinate of the rect. |
[in] | right | The right most coordinate of the rect. |
[in] | bottom | The bottom most coordinate of the rect. |
void blowbox::GraphicsContext::SetStencilRef | ( | UINT | stencil_ref | ) |
Sets the stencil reference value.
[in] | stencil_ref | The stencil reference value. |
void blowbox::GraphicsContext::SetVertexBuffer | ( | UINT | slot, |
const D3D12_VERTEX_BUFFER_VIEW & | vbv | ||
) |
Binds a vertex buffer to the pipeline.
[in] | slot | The slot at which the buffer should be bound, usually 0. |
[in] | vbv | The vertex buffer view that should be bound. |
void blowbox::GraphicsContext::SetVertexBuffers | ( | UINT | start_slot, |
UINT | count, | ||
const D3D12_VERTEX_BUFFER_VIEW | vbvs[] | ||
) |
Binds a number of vertex buffers to the pipeline.
[in] | start_slot | The slot at which the buffers should be bound, usually 0. |
[in] | count | The number of vertex buffers to bind. |
[in] | vbvs | The vertex buffer views that should be bound. |
void blowbox::GraphicsContext::SetViewport | ( | const D3D12_VIEWPORT & | vp | ) |
Sets the current viewport.
[in] | vp | The viewport that should be set. |
void blowbox::GraphicsContext::SetViewport | ( | FLOAT | x, |
FLOAT | y, | ||
FLOAT | w, | ||
FLOAT | h, | ||
FLOAT | min_depth = 0.0f , |
||
FLOAT | max_depth = 1.0f |
||
) |
Sets the current viewport.
[in] | x | The top left X coordinate. |
[in] | y | The top left Y coordinate. |
[in] | w | The width of the viewport. |
[in] | h | The height of the viewport. |
[in] | min_depth | The minimum depth value (closest). |
[in] | max_depth | The maximum depth value (furthest). |
void blowbox::GraphicsContext::SetViewportAndScissor | ( | const D3D12_VIEWPORT & | vp, |
const D3D12_RECT & | rect | ||
) |
Sets the current viewport and scissor rect.
[in] | vp | The viewport to be set. |
[in] | rect | The scissor rect to be set. |
void blowbox::GraphicsContext::SetViewportAndScissor | ( | UINT | x, |
UINT | y, | ||
UINT | w, | ||
UINT | h | ||
) |
Sets the current viewport and scissor rect - identically. (!)
[in] | x | The top left X coordinate. |
[in] | y | The top left Y coordinate. |
[in] | w | The width of the rect to be set. |
[in] | h | The height of the rect to be set. |