Further directx cleaning.
This commit is contained in:
parent
d99a36f24f
commit
7fcc8e43ae
23 changed files with 401 additions and 304 deletions
|
@ -92,7 +92,8 @@ void Win32DxWindowInterface::populateCommandList()
|
|||
CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(mRtvHeap->GetCPUDescriptorHandleForHeapStart(), static_cast<INT>(mFrameIndex), mRtvDescriptorSize);
|
||||
mCommandList->OMSetRenderTargets(1, &rtvHandle, FALSE, nullptr);
|
||||
|
||||
painter->getMeshPainter()->updateCommandList(rtvHandle, mCommandList.Get());
|
||||
painter->paintBackground(rtvHandle, mCommandList.Get());
|
||||
painter->paintMesh(mCommandList.Get());
|
||||
|
||||
// Indicate that the back buffer will now be used to present.
|
||||
//barrier = CD3DX12_RESOURCE_BARRIER::Transition(mRenderTargets[mFrameIndex].Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT);
|
||||
|
@ -110,8 +111,7 @@ void Win32DxWindowInterface::renderD2d()
|
|||
mDxInterface->getD2dContext()->SetTarget(mD2dRenderTargets[mFrameIndex].Get());
|
||||
|
||||
auto painter = dynamic_cast<DirectXPainter*>(mWindow->getDrawingContent()->getPainter());
|
||||
D2D1_SIZE_F rtSize = mD2dRenderTargets[mFrameIndex]->GetSize();
|
||||
painter->getTextPainter()->paint(mDxInterface->getD2dContext(), rtSize.width, rtSize.height);
|
||||
painter->paintText(mDxInterface->getD2dContext(), mDxInterface->getDirectWriteFactory());
|
||||
|
||||
// Release our wrapped render target resource. Releasing
|
||||
// transitions the back buffer resource to the state specified
|
||||
|
@ -205,6 +205,19 @@ void Win32DxWindowInterface::setupDescriptorHeaps()
|
|||
rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV;
|
||||
rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
|
||||
mDxInterface->getDevice()->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&mRtvHeap));
|
||||
|
||||
D3D12_DESCRIPTOR_HEAP_DESC srvHeapDesc = {};
|
||||
srvHeapDesc.NumDescriptors = 1;
|
||||
srvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
||||
srvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||
mDxInterface->getDevice()->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(&mSrvHeap));
|
||||
|
||||
D3D12_DESCRIPTOR_HEAP_DESC cbvHeapDesc = {};
|
||||
cbvHeapDesc.NumDescriptors = 1;
|
||||
cbvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV;
|
||||
cbvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE;
|
||||
mDxInterface->getDevice()->CreateDescriptorHeap(&cbvHeapDesc, IID_PPV_ARGS(&mCbvHeap));
|
||||
|
||||
mRtvDescriptorSize = mDxInterface->getDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||
}
|
||||
|
||||
|
@ -253,25 +266,22 @@ bool Win32DxWindowInterface::loadAssets()
|
|||
{
|
||||
auto painter = dynamic_cast<DirectXPainter*>(mWindow->getDrawingContent()->getPainter());
|
||||
|
||||
painter->getMeshPainter()->createRootSignature(mDxInterface->getDevice());
|
||||
painter->getMeshPainter()->createPipelineStateObject(mDxInterface->getDevice());
|
||||
painter->initializeMesh(mDxInterface->getDevice());
|
||||
|
||||
// Create the command list.
|
||||
mDxInterface->getDevice()->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, mCommandAllocator.Get(),
|
||||
painter->getMeshPainter()->getPipelineState(), IID_PPV_ARGS(&mCommandList));
|
||||
|
||||
// Create D2D/DWrite objects for rendering text.
|
||||
painter->getTextPainter()->initializeBrush(mDxInterface->getD2dContext());
|
||||
painter->getTextPainter()->initializeTextFormat(mDxInterface->getDirectWriteFactory());
|
||||
painter->initializeText(mDxInterface->getD2dContext(), mDxInterface->getDirectWriteFactory());
|
||||
|
||||
// Command lists are created in the recording state, but there is nothing
|
||||
// to record yet. The main loop expects it to be closed, so close it now.
|
||||
mCommandList->Close();
|
||||
|
||||
painter->getMeshPainter()->createVertexBuffer(mDxInterface->getDevice());
|
||||
painter->updateMesh(mDxInterface->getDevice());
|
||||
|
||||
createSyncObjects();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -306,6 +316,5 @@ void Win32DxWindowInterface::waitForPreviousFrame()
|
|||
mFence->SetEventOnCompletion(fence, mFenceEvent);
|
||||
::WaitForSingleObject(mFenceEvent, INFINITE);
|
||||
}
|
||||
|
||||
mFrameIndex = mSwapChain->GetCurrentBackBufferIndex();
|
||||
}
|
|
@ -72,6 +72,8 @@ private:
|
|||
Microsoft::WRL::ComPtr<IDXGISwapChain4> mSwapChain;
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mRtvHeap;
|
||||
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mSrvHeap;
|
||||
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mCbvHeap;
|
||||
UINT mRtvDescriptorSize{ 0 };
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> mRenderTargets[FrameCount];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue