From c2dc1a86ed2f5e160749fe9f99b70db6c3e4d7a6 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:25:48 +0100 Subject: Refactor shader cache (#2558) * Fix a bug in Path::find * Fix code formatting * Fix LockFile and add LockFileGuard * Add PersistentCache and unit test * Replace file path dependency list with source file dependency list * Add note on ordering in Module/FileDependencyList * Remove old shader cache code * Refactor shader cache implementation * Temporarily skip unit tests reading/writing files * Fix warning * Reenable lock file test * Rename shader cache tests and disable crashing test * Testing * Stop using Path::getCanonical * Fix persistent cache lock and test * Fix threading issues * Move adding file dependency hashes to getEntryPointHash() * Fix handling of #include files * Allow specifying additional search paths for gfx testing device * Work on shader cache tests * Update project files * Revive shader cache graphics tests * Split graphics pipeline test * Fix compilation --- tools/gfx/renderer-shared.h | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'tools/gfx/renderer-shared.h') diff --git a/tools/gfx/renderer-shared.h b/tools/gfx/renderer-shared.h index 01111e292..c7137f0fa 100644 --- a/tools/gfx/renderer-shared.h +++ b/tools/gfx/renderer-shared.h @@ -4,8 +4,7 @@ #include "slang-context.h" #include "core/slang-basic.h" #include "core/slang-com-object.h" - -#include "persistent-shader-cache.h" +#include "core/slang-persistent-cache.h" #include "resource-desc-utils.h" @@ -28,7 +27,7 @@ struct GfxGUID static const Slang::Guid IID_ITextureResource; static const Slang::Guid IID_IInputLayout; static const Slang::Guid IID_IDevice; - static const Slang::Guid IID_IShaderCacheStatistics; + static const Slang::Guid IID_IShaderCache; static const Slang::Guid IID_IShaderObjectLayout; static const Slang::Guid IID_IShaderObject; static const Slang::Guid IID_IRenderPassLayout; @@ -1214,7 +1213,7 @@ public: // Renderer implementation shared by all platforms. // Responsible for shader compilation, specialization and caching. -class RendererBase : public IDevice, public IShaderCacheStatistics, public Slang::ComObject +class RendererBase : public IDevice, public IShaderCache, public Slang::ComObject { friend class ShaderObjectBase; public: @@ -1354,27 +1353,21 @@ public: ShaderObjectLayoutBase* layout, IShaderObject** outObject) = 0; + public: + // IShaderCache interface + virtual SLANG_NO_THROW Result SLANG_MCALL clearShaderCache() SLANG_OVERRIDE; + virtual SLANG_NO_THROW Result SLANG_MCALL getShaderCacheStats(ShaderCacheStats* outStats) SLANG_OVERRIDE; + virtual SLANG_NO_THROW Result SLANG_MCALL resetShaderCacheStats() SLANG_OVERRIDE; + protected: virtual SLANG_NO_THROW SlangResult SLANG_MCALL initialize(const Desc& desc); protected: Slang::List m_features; - -public: - virtual SLANG_NO_THROW GfxCount SLANG_MCALL getCacheMissCount() override; - virtual SLANG_NO_THROW GfxCount SLANG_MCALL getCacheHitCount() override; - virtual SLANG_NO_THROW GfxCount SLANG_MCALL getCacheEntryDirtyCount() override; - virtual SLANG_NO_THROW Result SLANG_MCALL resetCacheStatistics() override; - -protected: - GfxCount shaderCacheMissCount = 0; - GfxCount shaderCacheHitCount = 0; - GfxCount shaderCacheEntryDirtyCount = 0; - public: SlangContext slangContext; ShaderCache shaderCache; - RefPtr persistentShaderCache = nullptr; + Slang::RefPtr persistentShaderCache; Slang::Dictionary> m_shaderObjectLayoutCache; Slang::ComPtr m_pipelineCreationAPIDispatcher; -- cgit v1.2.3