| 597 | } |
| 598 | |
| 599 | void PTRenderer::initCommandList() |
| 600 | { |
| 601 | // Create a command queue. |
| 602 | D3D12_COMMAND_QUEUE_DESC queueDesc = {}; |
| 603 | queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; |
| 604 | queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; |
| 605 | checkHR(_pDXDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&_pCommandQueue))); |
| 606 | |
| 607 | // Create a command allocator for each active task, as a command allocator is needed for each |
| 608 | // possible command list that is queued at once. |
| 609 | _commandAllocators.resize(_taskCount); |
| 610 | for (uint32_t i = 0; i < _taskCount; i++) |
| 611 | { |
| 612 | checkHR(_pDXDevice->CreateCommandAllocator( |
| 613 | D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&(_commandAllocators[i])))); |
| 614 | } |
| 615 | |
| 616 | // Create a command list. Only a single command list is required for each thread, just one here. |
| 617 | // NOTE: It is initialized with the first command allocator but will be reset with the command |
| 618 | // allocator for the current active task index. |
| 619 | checkHR(_pDXDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, |
| 620 | _commandAllocators[0].Get(), nullptr, IID_PPV_ARGS(&_pCommandList))); |
| 621 | _pCommandList->Close(); |
| 622 | |
| 623 | // Create a fence and event for detecting when a command list is complete. |
| 624 | checkHR(_pDXDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&_pTaskFence))); |
| 625 | _hTaskEvent = ::CreateEvent(nullptr, FALSE, FALSE, nullptr); |
| 626 | } |
| 627 | |
| 628 | void PTRenderer::initFrameData() |
| 629 | { |