@@ -35,7 +35,6 @@ bool D3D12::ResetState(const bool acDestroyContext)
35
35
m_pd3d12Device.Reset ();
36
36
m_pd3dRtvDescHeap.Reset ();
37
37
m_pd3dSrvDescHeap.Reset ();
38
- m_pd3dCommandList.Reset ();
39
38
40
39
m_pCommandQueue.Reset ();
41
40
m_pdxgiSwapChain.Reset ();
@@ -113,17 +112,19 @@ bool D3D12::Initialize()
113
112
}
114
113
115
114
for (auto & context : m_frameContexts)
115
+ {
116
116
if (FAILED (m_pd3d12Device->CreateCommandAllocator (D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS (&context.CommandAllocator ))))
117
117
{
118
118
Log::Error (" D3D12::Initialize() - failed to create command allocator!" );
119
119
return ResetState ();
120
120
}
121
121
122
- if (FAILED (m_pd3d12Device->CreateCommandList (0 , D3D12_COMMAND_LIST_TYPE_DIRECT, m_frameContexts[0 ].CommandAllocator .Get (), nullptr , IID_PPV_ARGS (&m_pd3dCommandList))) ||
123
- FAILED (m_pd3dCommandList->Close ()))
124
- {
125
- Log::Error (" D3D12::Initialize() - failed to create command list!" );
126
- return ResetState ();
122
+ if (FAILED (m_pd3d12Device->CreateCommandList (0 , D3D12_COMMAND_LIST_TYPE_DIRECT, context.CommandAllocator .Get (), nullptr , IID_PPV_ARGS (&context.CommandList ))) ||
123
+ FAILED (context.CommandList ->Close ()))
124
+ {
125
+ Log::Error (" D3D12::Initialize() - failed to create command list!" );
126
+ return ResetState ();
127
+ }
127
128
}
128
129
129
130
if (!InitializeImGui (buffersCounts))
@@ -404,18 +405,18 @@ void D3D12::Update()
404
405
405
406
ID3D12DescriptorHeap* heaps[] = {m_pd3dSrvDescHeap.Get ()};
406
407
407
- m_pd3dCommandList ->Reset (frameContext.CommandAllocator .Get (), nullptr );
408
- m_pd3dCommandList ->ResourceBarrier (1 , &barrier);
409
- m_pd3dCommandList ->SetDescriptorHeaps (1 , heaps);
410
- m_pd3dCommandList ->OMSetRenderTargets (1 , &frameContext.MainRenderTargetDescriptor , FALSE , nullptr );
408
+ frameContext. CommandList ->Reset (frameContext.CommandAllocator .Get (), nullptr );
409
+ frameContext. CommandList ->ResourceBarrier (1 , &barrier);
410
+ frameContext. CommandList ->SetDescriptorHeaps (1 , heaps);
411
+ frameContext. CommandList ->OMSetRenderTargets (1 , &frameContext.MainRenderTargetDescriptor , FALSE , nullptr );
411
412
412
- ImGui_ImplDX12_RenderDrawData (&m_imguiDrawDataBuffers[0 ], m_pd3dCommandList .Get ());
413
+ ImGui_ImplDX12_RenderDrawData (&m_imguiDrawDataBuffers[0 ], frameContext. CommandList .Get ());
413
414
414
415
barrier.Transition .StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET;
415
416
barrier.Transition .StateAfter = D3D12_RESOURCE_STATE_PRESENT;
416
- m_pd3dCommandList ->ResourceBarrier (1 , &barrier);
417
- m_pd3dCommandList ->Close ();
417
+ frameContext. CommandList ->ResourceBarrier (1 , &barrier);
418
+ frameContext. CommandList ->Close ();
418
419
419
- ID3D12CommandList* commandLists[] = {m_pd3dCommandList .Get ()};
420
+ ID3D12CommandList* commandLists[] = {frameContext. CommandList .Get ()};
420
421
m_pCommandQueue->ExecuteCommandLists (1 , commandLists);
421
422
}
0 commit comments