类名: CommandQueue
GPU会不断的执行命令队列中的指令,根据d3dx12.h能够看到一个GPU维护多种类型的命令队列ui
类名:CommandAllocatorPool
记录命令列表插入的GPU指令this
类名:CommandListManager
插入GPU指令到命令分配器中3d
能够理解为特殊的GPU指令,GPU执行到围栏指令时,会更新围栏的值,用于判断GPU执行到了哪一步code
命令分配器池子。用于管理生成并复用命令分配器。队列
命令队列。根据类型维护一个命令分配器池子、独立赋值的围栏string
维护命令队列。it
直接生成了3个命令队列。命令队列内部有本身的分配器池子、围栏。
这个会在程序启动时初始化。io
CommandContext& CommandContext::Begin( const std::wstring ID ) { CommandContext* NewContext = g_ContextManager.AllocateContext(D3D12_COMMAND_LIST_TYPE_DIRECT); NewContext->SetID(ID); if (ID.length() > 0) EngineProfiling::BeginBlock(ID, NewContext); return *NewContext; }
AllocateContext中初始化或重置一个命令列表 CommandListManager::CreateNewCommandListclass
uint64_t CommandContext::Finish( bool WaitForCompletion ) { ... CommandQueue& Queue = g_CommandManager.GetQueue(m_Type); // 返回本次命令队列的围栏值 uint64_t FenceValue = Queue.ExecuteCommandList(m_CommandList); // 这里面会把命令分配器与围栏值关联起来,存到等待队列中 // 等下次再想分配一个命令分配器时,会根据已经执行完的围栏值,来判断等待队列中的分配器是否能够复用 Queue.DiscardAllocator(FenceValue, m_CurrentAllocator); m_CurrentAllocator = nullptr; ... if (WaitForCompletion) g_CommandManager.WaitForFence(FenceValue); g_ContextManager.FreeContext(this); return FenceValue; }