91 lines
No EOL
2.3 KiB
C++
91 lines
No EOL
2.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <wrl.h>
|
|
#include <d3d12.h>
|
|
#include <directx/d3dx12.h>
|
|
|
|
class Win32DxInterface;
|
|
namespace mt
|
|
{
|
|
class Window;
|
|
}
|
|
|
|
struct ID3D12CommandQueue;
|
|
struct ID3D12CommandAllocator;
|
|
struct ID3D12GraphicsCommandList;
|
|
struct IDXGISwapChain4;
|
|
struct ID3D12DescriptorHeap;
|
|
struct ID3D12Resource;
|
|
struct ID3D12Fence;
|
|
struct ID3D12RootSignature;
|
|
struct ID3D12PipelineState;
|
|
|
|
struct ID3D11Resource;
|
|
struct ID2D1Bitmap1;
|
|
struct D2D1_BITMAP_PROPERTIES1;
|
|
struct CD3DX12_CPU_DESCRIPTOR_HANDLE;
|
|
|
|
class Win32DxWindowInterface
|
|
{
|
|
public:
|
|
Win32DxWindowInterface(mt::Window* window, Win32DxInterface* dxInterface);
|
|
|
|
~Win32DxWindowInterface();
|
|
|
|
bool initialize();
|
|
|
|
void onRender();
|
|
|
|
private:
|
|
bool loadPipeline();
|
|
bool loadAssets();
|
|
|
|
void populateCommandList();
|
|
void waitForPreviousFrame();
|
|
void destroyWindow();
|
|
|
|
void renderD2d();
|
|
|
|
bool setupSwapChain();
|
|
void setupDescriptorHeaps();
|
|
|
|
void setupFrameResources();
|
|
void setupFrameResource(UINT idx, CD3DX12_CPU_DESCRIPTOR_HANDLE& descriptorHandle, const D2D1_BITMAP_PROPERTIES1& bitmapProps);
|
|
void setupFrameD2DResource(UINT idx, const D2D1_BITMAP_PROPERTIES1& bitmapProps);
|
|
|
|
void createSyncObjects();
|
|
|
|
static const UINT FrameCount = 2;
|
|
Win32DxInterface* mDxInterface{ nullptr };
|
|
bool mInitialized{ false };
|
|
bool mIsValid{ false };
|
|
|
|
mt::Window* mWindow{ nullptr };
|
|
CD3DX12_VIEWPORT mViewport;
|
|
CD3DX12_RECT mScissorRect;
|
|
|
|
Microsoft::WRL::ComPtr<ID3D12CommandAllocator> mCommandAllocator;
|
|
Microsoft::WRL::ComPtr<ID3D12GraphicsCommandList> mCommandList;
|
|
|
|
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];
|
|
Microsoft::WRL::ComPtr<ID3D11Resource> mWrappedBackBuffers[FrameCount];
|
|
Microsoft::WRL::ComPtr<ID2D1Bitmap1> mD2dRenderTargets[FrameCount];
|
|
|
|
Microsoft::WRL::ComPtr<ID3D12Fence> mFence;
|
|
uint64_t mFenceValue = 0;
|
|
uint64_t mFrameFenceValues[FrameCount] = {};
|
|
HANDLE mFenceEvent{};
|
|
|
|
uint64_t mFrameIndex{ 0 };
|
|
};
|
|
|
|
using XcbGlWindowInterfacePtr = std::unique_ptr<Win32DxWindowInterface>; |