12#include "render/Renderer.h"
13#include "misc/Error.h"
14#include "render/directx/resource/DirectXResource.h"
17#include "directx/d3dx12.h"
24 using namespace Microsoft::WRL;
27 class DirectXResourceManager;
29 class CameraProperties;
31 struct QueuedForExecutionComputeShaders;
32 class ComputeShaderInterface;
33 struct DirectXFrameResource;
55 static std::variant<std::unique_ptr<Renderer>, std::pair<Error, std::string>>
113 virtual std::variant<std::set<std::pair<unsigned int, unsigned int>>,
Error>
124 virtual std::variant<std::set<std::pair<unsigned int, unsigned int>>,
Error>
144 virtual RendererType
getType()
const override;
232 size_t iCurrentFrameResourceIndex,
244 size_t iCurrentFrameResourceIndex,
245 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vOpaquePipelines)
override;
258 size_t iCurrentFrameResourceIndex,
259 ComputeExecutionStage stage)
override;
271 size_t iCurrentFrameResourceIndex,
272 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vOpaquePipelines,
273 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& vTransparentPipelines)
298 size_t iCurrentFrameResourceIndex,
299 const std::vector<Renderer::MeshesInFrustum::PipelineInFrustumInfo>& pipelinesOfSpecificType,
300 D3D12_GPU_DESCRIPTOR_HANDLE directionalShadowMapsHandle,
301 D3D12_GPU_DESCRIPTOR_HANDLE spotShadowMapsHandle,
302 D3D12_GPU_DESCRIPTOR_HANDLE pointShadowMapsGpuHandle,
303 const bool bIsDrawingTransparentMeshes);
332 virtual std::variant<std::optional<AntialiasingQuality>,
Error>
358 [[nodiscard]] std::optional<Error>
initialize(
const std::vector<std::string>& vBlacklistedGpuNames);
370 [[nodiscard]] std::optional<Error> enableDebugLayer();
393 [[nodiscard]] std::optional<Error>
443 [[nodiscard]] std::optional<Error>
495 ID3D12CommandAllocator* pCommandAllocator,
496 std::unordered_map<
Pipeline*, std::unordered_set<ComputeShaderInterface*>>&
497 computePipelinesToSubmit);
543 ComPtr<ID3D12InfoQueue1> pInfoQueue;
546 ComPtr<ID3D12Debug> pDebugController;
633 static constexpr DXGI_MODE_SCALING
usedScaling = DXGI_MODE_SCALING_UNSPECIFIED;
640 D3D_FEATURE_LEVEL::D3D_FEATURE_LEVEL_12_1;
Definition: CameraProperties.h:22
Definition: DirectXRenderer.h:36
ComPtr< ID3D12CommandQueue > pCommandQueue
Definition: DirectXRenderer.h:530
virtual RendererType getType() const override
Definition: DirectXRenderer.cpp:2359
virtual std::variant< std::optional< AntialiasingQuality >, Error > getMaxSupportedAntialiasingQuality() const override
Definition: DirectXRenderer.cpp:2275
virtual std::pair< unsigned int, unsigned int > getRenderTargetSize() const override
Definition: DirectXRenderer.cpp:2101
virtual std::vector< std::string > getSupportedGpuNames() const override
Definition: DirectXRenderer.cpp:481
ComPtr< ID3D12Device > pDevice
Definition: DirectXRenderer.h:518
std::pair< std::recursive_mutex, UINT64 > mtxCurrentFenceValue
Definition: DirectXRenderer.h:550
std::optional< Error > updateMsaaQualityLevelCount()
Definition: DirectXRenderer.cpp:1566
static constexpr D3D_FEATURE_LEVEL rendererD3dFeatureLevel
Definition: DirectXRenderer.h:639
ComPtr< ID3D12Fence > pFence
Definition: DirectXRenderer.h:539
static constexpr DXGI_FORMAT getBackBufferFormat()
Definition: DirectXRenderer.h:63
static constexpr DXGI_FORMAT shadowMappingPointLightColorTargetFormat
Definition: DirectXRenderer.h:619
static constexpr DXGI_FORMAT backBufferFormat
Definition: DirectXRenderer.h:608
void drawMeshesMainPassSpecificPipelines(DirectXFrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &pipelinesOfSpecificType, D3D12_GPU_DESCRIPTOR_HANDLE directionalShadowMapsHandle, D3D12_GPU_DESCRIPTOR_HANDLE spotShadowMapsHandle, D3D12_GPU_DESCRIPTOR_HANDLE pointShadowMapsGpuHandle, const bool bIsDrawingTransparentMeshes)
Definition: DirectXRenderer.cpp:1353
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > getSupportedRenderResolutions() const override
Definition: DirectXRenderer.cpp:484
ID3D12Device * getD3dDevice() const
Definition: DirectXRenderer.cpp:2368
ID3D12CommandQueue * getD3dCommandQueue()
Definition: DirectXRenderer.cpp:2372
std::optional< Error > pickVideoAdapter(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: DirectXRenderer.cpp:291
UINT iMsaaQualityLevelsCount
Definition: DirectXRenderer.h:581
DirectXResource * getCurrentBackBufferResource()
Definition: DirectXRenderer.cpp:2412
static std::variant< std::unique_ptr< Renderer >, std::pair< Error, std::string > > create(GameManager *pGameManager, const std::vector< std::string > &vBlacklistedGpuNames)
Definition: DirectXRenderer.cpp:162
static constexpr DXGI_FORMAT getShadowMapFormat()
Definition: DirectXRenderer.h:86
static constexpr DXGI_FORMAT shadowMapFormat
Definition: DirectXRenderer.h:614
std::optional< Error > createCommandList()
Definition: DirectXRenderer.cpp:1754
ComPtr< IDXGIFactory4 > pFactory
Definition: DirectXRenderer.h:515
virtual void drawShadowMappingPass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, GraphicsPipelineRegistry *pGraphicsPipelines) override
Definition: DirectXRenderer.cpp:777
static constexpr DXGI_FORMAT getShadowMappingPointLightColorTargetFormat()
Definition: DirectXRenderer.h:94
virtual void waitForGpuToFinishUsingFrameResource(FrameResource *pFrameResource) override
Definition: DirectXRenderer.cpp:2266
virtual GpuResource * getDepthTextureNoMultisampling() override
Definition: DirectXRenderer.cpp:2088
static constexpr DXGI_MODE_SCANLINE_ORDER usedScanlineOrdering
Definition: DirectXRenderer.h:636
static constexpr DXGI_MODE_SCALING usedScaling
Definition: DirectXRenderer.h:633
std::optional< Error > initializeDirectX(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: DirectXRenderer.cpp:1867
virtual std::variant< std::set< std::pair< unsigned int, unsigned int > >, Error > getSupportedRefreshRates() const override
Definition: DirectXRenderer.cpp:503
void resetCommandListForGraphics(DirectXFrameResource *pCurrentFrameResource)
Definition: DirectXRenderer.cpp:545
std::variant< std::vector< DXGI_MODE_DESC >, Error > getSupportedDisplayModes() const
Definition: DirectXRenderer.cpp:2374
virtual std::string getCurrentlyUsedGpuName() const override
Definition: DirectXRenderer.cpp:522
virtual void present(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex) override
Definition: DirectXRenderer.cpp:1529
void dispatchComputeShadersOnGraphicsQueue(ID3D12CommandAllocator *pCommandAllocator, std::unordered_map< Pipeline *, std::unordered_set< ComputeShaderInterface * > > &computePipelinesToSubmit)
Definition: DirectXRenderer.cpp:1647
static constexpr DXGI_FORMAT depthStencilBufferFormat
Definition: DirectXRenderer.h:611
std::optional< Error > setOutputAdapter()
Definition: DirectXRenderer.cpp:1716
std::string sUsedVideoAdapter
Definition: DirectXRenderer.h:590
ComPtr< ID3D12GraphicsCommandList > pCommandList
Definition: DirectXRenderer.h:533
static constexpr DXGI_FORMAT getDepthBufferFormatNoMultisampling()
Definition: DirectXRenderer.h:77
D3D12_VIEWPORT screenViewport
Definition: DirectXRenderer.h:584
std::optional< Error > createCommandQueue()
Definition: DirectXRenderer.cpp:1736
virtual std::optional< Error > onRenderSettingsChangedDerived() override
Definition: DirectXRenderer.cpp:2105
bool bIsDirectXInitialized
Definition: DirectXRenderer.h:605
static size_t rateGpuSuitability(DXGI_ADAPTER_DESC1 adapterDesc)
Definition: DirectXRenderer.cpp:1697
static constexpr DXGI_FORMAT depthBufferNoMultisamplingFormat
Definition: DirectXRenderer.h:630
virtual void waitForGpuToFinishWorkUpToThisPoint() override
Definition: DirectXRenderer.cpp:2325
std::vector< std::string > vSupportedGpuNames
Definition: DirectXRenderer.h:575
std::optional< Error > createSwapChain()
Definition: DirectXRenderer.cpp:1807
ComPtr< ID3D12GraphicsCommandList > pComputeCommandList
Definition: DirectXRenderer.h:536
IDXGIAdapter3 * getVideoAdapter() const
Definition: DirectXRenderer.cpp:2084
virtual void drawMeshesDepthPrepass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines) override
Definition: DirectXRenderer.cpp:574
void executeGraphicsCommandList(ID3D12GraphicsCommandList *pCommandListToExecute)
Definition: DirectXRenderer.cpp:2309
virtual bool isInitialized() const override
Definition: DirectXRenderer.cpp:2307
std::unique_ptr< DirectXResource > pMsaaRenderBuffer
Definition: DirectXRenderer.h:572
std::optional< Error > initialize(const std::vector< std::string > &vBlacklistedGpuNames)
Definition: DirectXRenderer.cpp:121
UINT iPresentFlags
Definition: DirectXRenderer.h:596
virtual void prepareForDrawingNextFrame(CameraProperties *pCameraProperties, FrameResource *pCurrentFrameResource) override
Definition: DirectXRenderer.cpp:524
std::unique_ptr< DirectXResource > pDepthStencilBuffer
Definition: DirectXRenderer.h:556
virtual void executeComputeShadersOnGraphicsQueue(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, ComputeExecutionStage stage) override
Definition: DirectXRenderer.cpp:1192
static constexpr DXGI_FORMAT getDepthStencilBufferFormat()
Definition: DirectXRenderer.h:70
ComPtr< IDXGISwapChain3 > pSwapChain
Definition: DirectXRenderer.h:527
virtual std::string getUsedApiVersion() const override
Definition: DirectXRenderer.cpp:2361
void waitForFenceValue(UINT64 iFenceToWaitFor)
Definition: DirectXRenderer.cpp:1625
ComPtr< IDXGIOutput > pOutputAdapter
Definition: DirectXRenderer.h:524
float backBufferFillColor[4]
Definition: DirectXRenderer.h:569
std::pair< unsigned int, unsigned int > renderTargetSize
Definition: DirectXRenderer.h:578
ComPtr< IDXGIAdapter3 > pVideoAdapter
Definition: DirectXRenderer.h:521
bool bIsUsingMsaaRenderTarget
Definition: DirectXRenderer.h:602
UINT getMsaaQualityLevel() const
Definition: DirectXRenderer.cpp:2086
std::vector< std::unique_ptr< DirectXResource > > vSwapChainBuffers
Definition: DirectXRenderer.h:553
virtual void drawMeshesMainPass(FrameResource *pCurrentFrameResource, size_t iCurrentFrameResourceIndex, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vOpaquePipelines, const std::vector< Renderer::MeshesInFrustum::PipelineInFrustumInfo > &vTransparentPipelines) override
Definition: DirectXRenderer.cpp:1212
std::unique_ptr< DirectXResource > pDepthBufferNoMultisampling
Definition: DirectXRenderer.h:566
UINT iPresentSyncInterval
Definition: DirectXRenderer.h:593
std::optional< Error > createDepthStencilBuffer()
Definition: DirectXRenderer.cpp:202
ID3D12GraphicsCommandList * getD3dCommandList()
Definition: DirectXRenderer.cpp:2370
D3D12_RECT scissorRect
Definition: DirectXRenderer.h:587
Definition: DirectXResource.h:32
Definition: GameManager.h:34
Definition: GpuResource.h:16
Definition: Pipeline.h:20
Definition: Renderer.h:43
GameManager * pGameManager
Definition: Renderer.h:870
Definition: DirectXFrameResource.h:30
Definition: FrameResource.h:15
Definition: PipelineRegistry.hpp:31