Skip to content

Commit

Permalink
RenderDeviceBase: use ObjectsRegistry for the sampler cache; removed …
Browse files Browse the repository at this point in the history
…StateObjectsRegistry
  • Loading branch information
TheMostDiligent committed Sep 1, 2023
1 parent 4ede319 commit dd31824
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 237 deletions.
1 change: 0 additions & 1 deletion Graphics/GraphicsEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ set(INCLUDE
include/ShaderResourceCacheCommon.hpp
include/ShaderResourceVariableBase.hpp
include/ShaderBindingTableBase.hpp
include/StateObjectsRegistry.hpp
include/SwapChainBase.hpp
include/TextureBase.hpp
include/TextureViewBase.hpp
Expand Down
21 changes: 9 additions & 12 deletions Graphics/GraphicsEngine/include/RenderDeviceBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "DeviceObjectBase.hpp"
#include "Defines.h"
#include "ResourceMappingImpl.hpp"
#include "StateObjectsRegistry.hpp"
#include "ObjectsRegistry.hpp"
#include "HashUtils.hpp"
#include "ObjectBase.hpp"
#include "DeviceContext.h"
Expand Down Expand Up @@ -127,7 +127,6 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
m_pEngineFactory {pEngineFactory},
m_ValidationFlags {EngineCI.ValidationFlags},
m_AdapterInfo {AdapterInfo},
m_SamplersRegistry {RawMemAllocator, "sampler"},
m_TextureFormatsInfo (TEX_FORMAT_NUM_FORMATS, TextureFormatInfoExt(), STD_ALLOCATOR_RAW_MEM(TextureFormatInfoExt, RawMemAllocator, "Allocator for vector<TextureFormatInfoExt>")),
m_TexFmtInfoInitFlags (TEX_FORMAT_NUM_FORMATS, false, STD_ALLOCATOR_RAW_MEM(bool, RawMemAllocator, "Allocator for vector<bool>")),
m_wpImmediateContexts (std::max(1u, EngineCI.NumImmediateContexts), RefCntWeakPtr<DeviceContextImplType>(), STD_ALLOCATOR_RAW_MEM(RefCntWeakPtr<DeviceContextImplType>, RawMemAllocator, "Allocator for vector<RefCntWeakPtr<DeviceContextImplType>>")),
Expand Down Expand Up @@ -289,8 +288,6 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
UNSUPPORTED("Tile pipeline is not supported by this device. Please check DeviceFeatures.TileShaders feature.");
}

StateObjectsRegistry<SamplerDesc>& GetSamplerRegistry() { return m_SamplersRegistry; }

/// Set weak reference to the immediate context
void SetImmediateContext(size_t Ctx, DeviceContextImplType* pImmediateContext)
{
Expand Down Expand Up @@ -442,13 +439,13 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
CreateDeviceObject("Sampler", SamplerDesc, ppSampler,
[&]() //
{
m_SamplersRegistry.Find(SamplerDesc, reinterpret_cast<IDeviceObject**>(ppSampler));
if (*ppSampler == nullptr)
{
auto* pSamplerImpl = NEW_RC_OBJ(m_SamplerObjAllocator, "Sampler instance", SamplerImplType)(static_cast<RenderDeviceImplType*>(this), SamplerDesc, ExtraArgs...);
pSamplerImpl->QueryInterface(IID_Sampler, reinterpret_cast<IObject**>(ppSampler));
m_SamplersRegistry.Add(SamplerDesc, *ppSampler);
}
auto pSampler = m_SamplersRegistry.Get(
SamplerDesc,
[&]() {
return RefCntAutoPtr<ISampler>{NEW_RC_OBJ(m_SamplerObjAllocator, "Sampler instance", SamplerImplType)(static_cast<RenderDeviceImplType*>(this), SamplerDesc, ExtraArgs...)};
});

*ppSampler = pSampler.Detach();
});
}

Expand Down Expand Up @@ -569,7 +566,7 @@ class RenderDeviceBase : public ObjectBase<typename EngineImplTraits::RenderDevi
// All state object registries hold raw pointers.
// This is safe because every object unregisters itself
// when it is deleted.
StateObjectsRegistry<SamplerDesc> m_SamplersRegistry; ///< Sampler state registry
ObjectsRegistry<SamplerDesc, RefCntAutoPtr<ISampler>> m_SamplersRegistry; ///< Sampler state registry
std::vector<TextureFormatInfoExt, STDAllocatorRawMem<TextureFormatInfoExt>> m_TextureFormatsInfo;
std::vector<bool, STDAllocatorRawMem<bool>> m_TexFmtInfoInitFlags;

Expand Down
7 changes: 0 additions & 7 deletions Graphics/GraphicsEngine/include/SamplerBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ class SamplerBase : public DeviceObjectBase<typename EngineImplTraits::SamplerIn

~SamplerBase()
{
/// \note Destructor cannot directly remove the object from the registry as this may cause a
/// deadlock.
if (this->HasDevice())
{
auto& SamplerRegistry = this->GetDevice()->GetSamplerRegistry();
SamplerRegistry.ReportDeletedObject();
}
}

IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_Sampler, TDeviceObjectBase)
Expand Down
217 changes: 0 additions & 217 deletions Graphics/GraphicsEngine/include/StateObjectsRegistry.hpp

This file was deleted.

0 comments on commit dd31824

Please sign in to comment.