Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
Public Member Functions | Private Attributes | List of all members
blowbox::CommandManager Class Reference

#include <command_manager.h>

Public Member Functions

 CommandManager ()
 
 ~CommandManager ()
 
void Startup ()
 
void CreateCommandList (D3D12_COMMAND_LIST_TYPE type, ID3D12GraphicsCommandList **out_list, ID3D12CommandAllocator **out_allocator)
 
CommandQueueGetQueue (D3D12_COMMAND_LIST_TYPE type=D3D12_COMMAND_LIST_TYPE_DIRECT)
 
CommandQueueGetCommandQueue ()
 
CommandQueueGetGraphicsQueue ()
 
CommandQueueGetComputeQueue ()
 
CommandQueueGetCopyQueue ()
 
bool IsFenceComplete (uint64_t fence_value)
 
void WaitForIdleGPU ()
 
void WaitForFence (uint64_t fence_value)
 

Private Attributes

CommandQueuegraphics_queue_
 
CommandQueuecompute_queue_
 
CommandQueuecopy_queue_
 

Detailed Description

Manages all the CommandQueues in the application.

The CommandManager manages all the different CommandQueues in the engine. At any time, there are three different queues: a graphics queue, a compute queue and a copy queue. A big convenience that the CommandManager offers is the CPU/GPU synchronization features. Fence values are constructed in a unique way. The first (highest order) 8 bits are reserved for data that specifies the type of command queue the fence value is for. So by calling CommandManager::WaitForFence() and passing in a Blowbox generated fence value, it will automatically figure out which command queue needs to be waited on. This way, CPU/GPU synchronization becomes tentalizingly easy. That is the main purpose of the CommandManager.

Constructor & Destructor Documentation

blowbox::CommandManager::CommandManager ( )

Constructs the CommandManager.

blowbox::CommandManager::~CommandManager ( )

Destructs the CommandManager.

Member Function Documentation

void blowbox::CommandManager::CreateCommandList ( D3D12_COMMAND_LIST_TYPE  type,
ID3D12GraphicsCommandList **  out_list,
ID3D12CommandAllocator **  out_allocator 
)

Creates a ID3D12GraphicsCommandList with an ID3D12CommandAllocator that is ready for use.

Parameters
[in]typeThe type of ID3D12GraphicsCommandList that should be created.
[out]out_listThe generated ID3D12GraphicsCommandList will be output here.
[out]out_allocatorThe generated ID3D12CommandAllocator willl be output here.
CommandQueue * blowbox::CommandManager::GetCommandQueue ( )
Returns
Returns the main CommandQueue.
CommandQueue * blowbox::CommandManager::GetComputeQueue ( )
Returns
Returns the compute CommandQueue.
CommandQueue * blowbox::CommandManager::GetCopyQueue ( )
Returns
Returns the copy CommandQueue.
CommandQueue * blowbox::CommandManager::GetGraphicsQueue ( )
Returns
Returns the graphics CommandQueue.
CommandQueue * blowbox::CommandManager::GetQueue ( D3D12_COMMAND_LIST_TYPE  type = D3D12_COMMAND_LIST_TYPE_DIRECT)
Returns
The CommandQueue of a given type.
Parameters
[in]typeThe type of CommandQueue you want.
bool blowbox::CommandManager::IsFenceComplete ( uint64_t  fence_value)

Checks if a given fence value (point in time) has been passed by the corresponding command queue.

Parameters
[in]fence_valueThe fence value that you want to check whether it has been passed.
Remarks
Remember, a fence_value is in fact two values. The first (highest-order) 8 bits represent the type of CommandQueue that generated the fence value. The remaining 56 bits are the actual value of the fence point. A fence point is essentially a point in time. After a command list is submitted, a fence point is generated for the correct command queue. That means that after every command list submission, a new point in time is "generated".
void blowbox::CommandManager::Startup ( )

Starts up the CommandManager.

void blowbox::CommandManager::WaitForFence ( uint64_t  fence_value)

This function is blocking until a given fence point is hit by the corresponding CommandQueue.

Parameters
[in]fence_valueThe fence value that has to be waited for.
Remarks
Remember, a fence_value is in fact two values. The first (highest-order) 8 bits represent the type of CommandQueue that generated the fence value. The remaining 56 bits are the actual value of the fence point. A fence point is essentially a point in time. After a command list is submitted, a fence point is generated for the correct command queue. That means that after every command list submission, a new point in time is "generated".
void blowbox::CommandManager::WaitForIdleGPU ( )

This function is blocking until all pending work in the CommandQueues is done executing.

Member Data Documentation

CommandQueue* blowbox::CommandManager::compute_queue_
private

The compute CommandQueue.

CommandQueue* blowbox::CommandManager::copy_queue_
private

The copy CommandQueue.

CommandQueue* blowbox::CommandManager::graphics_queue_
private

The graphics CommandQueue.


The documentation for this class was generated from the following files: