Skip to content

Commit 46db841

Browse files
USD Viewer: added option to disable render state cache. Enable async shaders when cache is disabled
1 parent 6251227 commit 46db841

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Samples/USDViewer/src/USDViewer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ SampleBase::CommandLineStatus USDViewer::ProcessCommandLine(int argc, const char
132132
ArgsParser.Parse("vertex_pool", m_UseVertexPool);
133133
ArgsParser.Parse("index_pool", m_UseIndexPool);
134134
ArgsParser.Parse("atlas_dim", m_TextureAtlasDim);
135+
ArgsParser.Parse("shader_cache", m_EnableShaderCache);
135136
LOG_INFO_MESSAGE("USD Viewer Arguments:",
136137
"\n USD Path: ", m_UsdFileName,
137138
"\n Use vertex pool: ", m_UseVertexPool ? "Yes" : "No",
@@ -154,8 +155,9 @@ void USDViewer::Initialize(const SampleInitInfo& InitInfo)
154155
{
155156
SampleBase::Initialize(InitInfo);
156157

157-
// Create render state cache
158+
if (m_EnableShaderCache)
158159
{
160+
// Create render state cache
159161
RenderStateCacheCreateInfo StateCacheCI;
160162
StateCacheCI.LogLevel = RENDER_STATE_CACHE_LOG_LEVEL_NORMAL;
161163

@@ -189,6 +191,10 @@ void USDViewer::Initialize(const SampleInitInfo& InitInfo)
189191
const bool SaveOnExit = true;
190192
m_DeviceWithCache.LoadCacheFromFile(CachePath.c_str(), SaveOnExit);
191193
}
194+
else
195+
{
196+
m_DeviceWithCache = RenderDeviceWithCache<false>{m_pDevice};
197+
}
192198

193199
ImGuizmo::SetGizmoSizeClipSpace(0.15f);
194200

@@ -298,7 +304,8 @@ void USDViewer::LoadStage()
298304
DelegateCI.UseIndexPool = m_UseIndexPool;
299305
DelegateCI.EnableShadows = true;
300306

301-
DelegateCI.AllowHotShaderReload = m_EnableHotShaderReload;
307+
DelegateCI.AllowHotShaderReload = m_EnableHotShaderReload;
308+
DelegateCI.AsyncShaderCompilation = !m_EnableShaderCache;
302309

303310
if (m_DeviceWithCache.GetDeviceInfo().Features.BindlessResources)
304311
{

Samples/USDViewer/src/USDViewer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class USDViewer final : public SampleBase
8484
private:
8585
RenderDeviceWithCache_N m_DeviceWithCache;
8686

87+
bool m_EnableShaderCache = false;
8788
bool m_EnableHotShaderReload = false;
8889

8990
struct StageInfo

0 commit comments

Comments
 (0)