Start aligning Dx and OpenGl approaches.

This commit is contained in:
jmsgrogan 2023-01-05 08:46:01 +00:00
parent d1ec8b4f68
commit d99a36f24f
22 changed files with 899 additions and 366 deletions

View file

@ -4,7 +4,6 @@
#include <wrl.h>
#include <d3d12.h>
#include <directxmath.h>
#include <directx/d3dx12.h>
class Win32DxInterface;
@ -25,27 +24,23 @@ struct ID3D12PipelineState;
struct ID3D11Resource;
struct ID2D1Bitmap1;
struct ID2D1SolidColorBrush;
struct IDWriteTextFormat;
struct D2D1_BITMAP_PROPERTIES1;
struct CD3DX12_CPU_DESCRIPTOR_HANDLE;
class Win32DxWindowInterface
{
public:
Win32DxWindowInterface(Win32DxInterface* dxInterface);
Win32DxWindowInterface(mt::Window* window, Win32DxInterface* dxInterface);
~Win32DxWindowInterface();
bool initialize(mt::Window* window);
bool initialize();
void onRender();
//void afterPaint();
//void resizeViewPort(unsigned width, unsigned height);
private:
void loadPipeline(mt::Window* window);
void loadAssets();
bool loadPipeline();
bool loadAssets();
void populateCommandList();
void waitForPreviousFrame();
@ -53,16 +48,21 @@ private:
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 };
struct Vertex
{
DirectX::XMFLOAT3 position;
DirectX::XMFLOAT4 color;
};
mt::Window* mWindow{ nullptr };
CD3DX12_VIEWPORT mViewport;
CD3DX12_RECT mScissorRect;
@ -71,9 +71,6 @@ private:
Microsoft::WRL::ComPtr<IDXGISwapChain4> mSwapChain;
Microsoft::WRL::ComPtr<ID3D12RootSignature> mRootSignature;
Microsoft::WRL::ComPtr<ID3D12PipelineState> mPipelineState;
Microsoft::WRL::ComPtr<ID3D12DescriptorHeap> mRtvHeap;
UINT mRtvDescriptorSize{ 0 };
@ -81,12 +78,6 @@ private:
Microsoft::WRL::ComPtr<ID3D11Resource> mWrappedBackBuffers[FrameCount];
Microsoft::WRL::ComPtr<ID2D1Bitmap1> mD2dRenderTargets[FrameCount];
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> mTextBrush;
Microsoft::WRL::ComPtr<IDWriteTextFormat> mTextFormat;
Microsoft::WRL::ComPtr<ID3D12Resource> mVertexBuffer;
D3D12_VERTEX_BUFFER_VIEW mVertexBufferView{};
Microsoft::WRL::ComPtr<ID3D12Fence> mFence;
uint64_t mFenceValue = 0;
uint64_t mFrameFenceValues[FrameCount] = {};