// Copyright (C) 2022 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 #include #include #include namespace Nz { class RenderBuffer; class NAZARA_GRAPHICS_API Graphics : public ModuleBase { friend ModuleBase; public: using Dependencies = TypeList; struct Config; struct DefaultMaterials; struct DefaultTextures; Graphics(Config config); ~Graphics(); inline const std::shared_ptr& GetBlitPipeline(bool transparent) const; inline const std::shared_ptr& GetBlitPipelineLayout() const; inline const DefaultMaterials& GetDefaultMaterials() const; inline const DefaultTextures& GetDefaultTextures() const; inline MaterialPassRegistry& GetMaterialPassRegistry(); inline const MaterialPassRegistry& GetMaterialPassRegistry() const; inline MaterialInstanceLoader& GetMaterialInstanceLoader(); inline const MaterialInstanceLoader& GetMaterialInstanceLoader() const; inline MaterialLoader& GetMaterialLoader(); inline const MaterialLoader& GetMaterialLoader() const; inline PixelFormat GetPreferredDepthFormat() const; inline PixelFormat GetPreferredDepthStencilFormat() const; inline const std::shared_ptr& GetRenderDevice() const; inline const RenderPassCache& GetRenderPassCache() const; inline TextureSamplerCache& GetSamplerCache(); inline const std::shared_ptr& GetShaderModuleResolver() const; struct Config { RenderDeviceFeatures forceDisableFeatures; bool useDedicatedRenderDevice = true; }; struct DefaultMaterials { std::shared_ptr basicMaterial; std::shared_ptr phongMaterial; std::shared_ptr pbrMaterial; std::shared_ptr basicDefault; std::shared_ptr basicNoDepth; std::shared_ptr basicTransparent; }; struct DefaultTextures { std::array, ImageTypeCount> depthTextures; std::array, ImageTypeCount> whiteTextures; }; private: void BuildBlitPipeline(); void BuildDefaultMaterials(); void BuildDefaultTextures(); void RegisterMaterialPasses(); void RegisterShaderModules(); template void RegisterEmbedShaderModule(const UInt8(&content)[N]); void SelectDepthStencilFormats(); std::optional m_renderPassCache; std::optional m_samplerCache; std::shared_ptr m_shaderModuleResolver; std::shared_ptr m_renderDevice; std::shared_ptr m_blitPipeline; std::shared_ptr m_blitPipelineTransparent; std::shared_ptr m_blitPipelineLayout; DefaultMaterials m_defaultMaterials; DefaultTextures m_defaultTextures; MaterialInstanceLoader m_materialInstanceLoader; MaterialLoader m_materialLoader; MaterialPassRegistry m_materialPassRegistry; PixelFormat m_preferredDepthFormat; PixelFormat m_preferredDepthStencilFormat; static Graphics* s_instance; }; } #include #endif // NAZARA_GRAPHICS_HPP