#ifndef Renderer_h__ #define Renderer_h__ #include #include #include #include #include #include #include "FatalError.h" #include #include "d3d11_types.h" #include #include #include "D3d12DescriptorHeapAllocator.h" #include using namespace Microsoft::WRL; #define HR_ASSERT_MSG(__hr_expression, __message)\ while(true){\ HRESULT hr_ = (__hr_expression);\ if (FAILED(hr_)) {\ std::wstringstream ss; \ ss << L"Application fail with HRESULT:" << hr_ << " in file " << TEXT(__FILE__) << " at line " << __LINE__ << L" with message: " << __message; \ FatalError(ss.str().c_str()); \ }\ break;\ } #define HR_ASSERT(__hr_expression) HR_ASSERT_MSG(__hr_expression, "") class Renderer { public: bool Init(); ID3D12DevicePtr GetDevice(); ComPtr GetAdapter() { return dxgiAdapter; } ComPtr GetFactory() { return dxgiFactory; } ComPtr BeginCommandList(); void EndCommandList(); std::vector EnumOutputs(); IDXGISwapChain1Ptr CreateSwapChain(HWND window, bool windowed, uint32_t width, uint32_t height, uint32_t buffers_count, bool stereo); std::vector GetDisplayModes(DXGI_FORMAT format, IDXGIOutput1Ptr output); std::vector GetStereoModes(std::vector& modes); void WaitCommandsQueue(); std::shared_ptr getSrvDescriptorsAllocator(); void reportLiveObjects() const; private: ComPtr dxgiInfoQueue; ID3D12DevicePtr device; IDXGIAdapter1Ptr dxgiAdapter; IDXGIFactory4Ptr dxgiFactory; ComPtr _directCommandQueue; ComPtr _directCommandList; ComPtr _directCommandAllocator; ComPtr _srvDescriptorsHeap; std::shared_ptr _srvDescriptorAllocator; }; typedef std::shared_ptr RendererPtr; #endif // Renderer_h__