Skip to content

Commit

Permalink
IRenderStateCache: added GetReloadVersion method
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Jan 9, 2025
1 parent 54d524a commit 9014dee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Diligent Graphics LLC
* Copyright 2024-2025 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -105,6 +105,11 @@ class RenderStateCacheImpl final : public ObjectBase<IRenderStateCache>
return m_pDearchiver ? m_pDearchiver->GetContentVersion() : ~0u;
}

virtual Uint32 DILIGENT_CALL_TYPE GetReloadVersion() const override final
{
return m_ReloadVersion;
}

bool CreateShaderInternal(const ShaderCreateInfo& ShaderCI,
IShader** ppShader);

Expand Down Expand Up @@ -150,6 +155,8 @@ class RenderStateCacheImpl final : public ObjectBase<IRenderStateCache>

std::mutex m_ReloadablePipelinesMtx;
std::unordered_map<UniqueIdentifier, RefCntWeakPtr<IPipelineState>> m_ReloadablePipelines;

Uint32 m_ReloadVersion = 0;
};

} // namespace Diligent
8 changes: 7 additions & 1 deletion Graphics/GraphicsTools/interface/RenderStateCache.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2019-2025 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -250,6 +250,11 @@ DILIGENT_BEGIN_INTERFACE(IRenderStateCache, IObject)
/// Returns the content version of the cache data.
/// If no data has been loaded, returns ~0u (aka 0xFFFFFFFF).
VIRTUAL Uint32 METHOD(GetContentVersion)(THIS) CONST PURE;


/// Returns the reload version of the cache data.
/// The reload version is incremented every time the cache is reloaded.
VIRTUAL Uint32 METHOD(GetReloadVersion)(THIS) CONST PURE;
};
DILIGENT_END_INTERFACE

Expand All @@ -269,6 +274,7 @@ DILIGENT_END_INTERFACE
# define IRenderStateCache_Reset(This) CALL_IFACE_METHOD(RenderStateCache, Reset, This)
# define IRenderStateCache_Reload(This, ...) CALL_IFACE_METHOD(RenderStateCache, Reload, This, __VA_ARGS__)
# define IRenderStateCache_GetContentVersion(This) CALL_IFACE_METHOD(RenderStateCache, GetContentVersion, This)
# define IRenderStateCache_GetReloadVersion(This) CALL_IFACE_METHOD(RenderStateCache, GetReloadVersion, This)
// clang-format on

#endif
Expand Down
4 changes: 3 additions & 1 deletion Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2019-2025 Diligent Graphics LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -941,6 +941,8 @@ Uint32 RenderStateCacheImpl::Reload(ReloadGraphicsPipelineCallbackType ReloadGra
}
}

++m_ReloadVersion;

return NumStatesReloaded;
}

Expand Down

0 comments on commit 9014dee

Please sign in to comment.