// Copyright (C) 2021 Jérôme "Lynix" Leclercq (lynix680@gmail.com) // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_GRAPHICS_HPP #define NAZARA_GRAPHICS_HPP #include #include #include #include #include #include #include #include #include namespace Nz { class AbstractBuffer; class NAZARA_GRAPHICS_API Graphics : public ModuleBase { friend ModuleBase; public: using Dependencies = TypeList; struct Config; struct DefaultTextures; Graphics(Config config); ~Graphics(); inline const std::shared_ptr& GetBlitPipeline() const; inline const std::shared_ptr& GetBlitPipelineLayout() const; inline const DefaultTextures& GetDefaultTextures() const; inline const std::shared_ptr& GetFullscreenVertexBuffer() const; inline const std::shared_ptr& GetFullscreenVertexDeclaration() const; inline MaterialPassRegistry& GetMaterialPassRegistry(); inline const MaterialPassRegistry& GetMaterialPassRegistry() const; inline PixelFormat GetPreferredDepthStencilFormat() const; inline const std::shared_ptr& GetReferencePipelineLayout() const; inline const std::shared_ptr& GetRenderDevice() const; inline const RenderPassCache& GetRenderPassCache() const; inline TextureSamplerCache& GetSamplerCache(); struct Config { RenderDeviceFeatures forceDisableFeatures; bool useDedicatedRenderDevice = true; }; struct DefaultTextures { std::shared_ptr whiteTexture2d; }; static constexpr UInt32 DrawDataBindingSet = 2; static constexpr UInt32 MaterialBindingSet = 3; static constexpr UInt32 ViewerBindingSet = 0; static constexpr UInt32 WorldBindingSet = 1; static void FillDrawDataPipelineLayout(RenderPipelineLayoutInfo& layoutInfo, UInt32 set = DrawDataBindingSet); static void FillViewerPipelineLayout(RenderPipelineLayoutInfo& layoutInfo, UInt32 set = ViewerBindingSet); static void FillWorldPipelineLayout(RenderPipelineLayoutInfo& layoutInfo, UInt32 set = WorldBindingSet); private: void BuildBlitPipeline(); void BuildDefaultTextures(); void BuildFullscreenVertexBuffer(); void RegisterMaterialPasses(); void SelectDepthStencilFormats(); std::optional m_renderPassCache; std::optional m_samplerCache; std::shared_ptr m_fullscreenVertexBuffer; std::shared_ptr m_renderDevice; std::shared_ptr m_blitPipeline; std::shared_ptr m_blitPipelineLayout; std::shared_ptr m_referencePipelineLayout; std::shared_ptr m_fullscreenVertexDeclaration; DefaultTextures m_defaultTextures; MaterialPassRegistry m_materialPassRegistry; PixelFormat m_preferredDepthStencilFormat; static Graphics* s_instance; }; } #include #endif // NAZARA_GRAPHICS_HPP