summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-12-08 04:15:17 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-12-08 04:15:17 +0000
commitddb47f872d7084c76986227cc8d578a4a5102952 (patch)
tree78aef303be602a89ba3aa8e0ceb2f28605c8b754 /Graphics/GraphicsTools
parentFixed issue with the last reference to TextureAtlasSuballocation and BufferSu... (diff)
downloadDiligentCore-ddb47f872d7084c76986227cc8d578a4a5102952.tar.gz
DiligentCore-ddb47f872d7084c76986227cc8d578a4a5102952.zip
Moved pDevice parameter from BufferSuballocatorCreateInfo and DynamicTextureAtlasCreateInfo structs to corresponding create functions
Diffstat (limited to 'Graphics/GraphicsTools')
-rw-r--r--Graphics/GraphicsTools/interface/BufferSuballocator.h16
-rw-r--r--Graphics/GraphicsTools/interface/DynamicTextureAtlas.h16
-rw-r--r--Graphics/GraphicsTools/src/BufferSuballocator.cpp9
-rw-r--r--Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp11
4 files changed, 31 insertions, 21 deletions
diff --git a/Graphics/GraphicsTools/interface/BufferSuballocator.h b/Graphics/GraphicsTools/interface/BufferSuballocator.h
index 90afa58f..7ec6b2db 100644
--- a/Graphics/GraphicsTools/interface/BufferSuballocator.h
+++ b/Graphics/GraphicsTools/interface/BufferSuballocator.h
@@ -108,12 +108,6 @@ struct IBufferSuballocator : public IObject
/// Buffer suballocator create information.
struct BufferSuballocatorCreateInfo
{
- /// Pointer to the render device.
- /// May be null, in which case internal buffer initialization will
- /// be postponed until GetBuffer() is called.
- IRenderDevice* pDevice = nullptr;
-
-
/// Buffer description
BufferDesc Desc;
@@ -131,6 +125,14 @@ struct BufferSuballocatorCreateInfo
};
/// Creates a new buffer suballocator.
-void CreateBufferSuballocator(BufferSuballocatorCreateInfo& CreateInfo, IBufferSuballocator** ppBufferSuballocator);
+
+/// \param[in] pDevice - Pointer to the render device that will be used to initialize
+/// internal buffer object. If this parameter is null, the
+/// buffer will be created when GetBuffer() is called.
+/// \param[in] CreateInfo - Suballocator create info, see Diligent::BufferSuballocatorCreateInfo.
+/// \param[in] ppBufferSuballocator - Memory location where pointer to the buffer suballocator will be stored.
+void CreateBufferSuballocator(IRenderDevice* pDevice,
+ BufferSuballocatorCreateInfo& CreateInfo,
+ IBufferSuballocator** ppBufferSuballocator);
} // namespace Diligent
diff --git a/Graphics/GraphicsTools/interface/DynamicTextureAtlas.h b/Graphics/GraphicsTools/interface/DynamicTextureAtlas.h
index ad32f379..31c4b2a5 100644
--- a/Graphics/GraphicsTools/interface/DynamicTextureAtlas.h
+++ b/Graphics/GraphicsTools/interface/DynamicTextureAtlas.h
@@ -117,12 +117,6 @@ struct IDynamicTextureAtlas : public IObject
/// Dynamic texture atlas create information.
struct DynamicTextureAtlasCreateInfo
{
- /// Pointer to the render device.
- /// May be null, in which case internal texture initialization will
- /// be postponed until GetTexture() is called.
- IRenderDevice* pDevice = nullptr;
-
-
/// Texture description
/// Texture type must be 2D or 2D array. When the type is
@@ -154,6 +148,14 @@ struct DynamicTextureAtlasCreateInfo
};
/// Creates a new dynamic texture atlas.
-void CreateDynamicTextureAtlas(DynamicTextureAtlasCreateInfo& CreateInfo, IDynamicTextureAtlas** ppAtlas);
+
+/// \param[in] pDevice - Pointer to the render device that will be used to create internal
+/// texture array. If this parameter is null, the texture will be created
+/// when GetTexture() is called.
+/// \param[in] CreateInfo - Atlas create info, see Diligent::DynamicTextureAtlasCreateInfo.
+/// \param[in] ppAtlas - Memory location where pointer to the texture atlas object will be written.
+void CreateDynamicTextureAtlas(IRenderDevice* pDevice,
+ DynamicTextureAtlasCreateInfo& CreateInfo,
+ IDynamicTextureAtlas** ppAtlas);
} // namespace Diligent
diff --git a/Graphics/GraphicsTools/src/BufferSuballocator.cpp b/Graphics/GraphicsTools/src/BufferSuballocator.cpp
index 7f59edcd..4a5c212c 100644
--- a/Graphics/GraphicsTools/src/BufferSuballocator.cpp
+++ b/Graphics/GraphicsTools/src/BufferSuballocator.cpp
@@ -109,11 +109,12 @@ public:
IMPLEMENT_QUERY_INTERFACE_IN_PLACE(IID_BufferSuballocator, TBase)
BufferSuballocatorImpl(IReferenceCounters* pRefCounters,
+ IRenderDevice* pDevice,
BufferSuballocatorCreateInfo& CreateInfo) :
// clang-format off
TBase {pRefCounters},
m_Mgr {CreateInfo.Desc.uiSizeInBytes, DefaultRawMemoryAllocator::GetAllocator()},
- m_Buffer {CreateInfo.pDevice, CreateInfo.Desc},
+ m_Buffer {pDevice, CreateInfo.Desc},
m_ExpansionSize {CreateInfo.ExpansionSize},
m_SuballocationsAllocator
{
@@ -226,11 +227,13 @@ IBufferSuballocator* BufferSuballocationImpl::GetAllocator()
}
-void CreateBufferSuballocator(BufferSuballocatorCreateInfo& CreateInfo, IBufferSuballocator** ppBufferSuballocator)
+void CreateBufferSuballocator(IRenderDevice* pDevice,
+ BufferSuballocatorCreateInfo& CreateInfo,
+ IBufferSuballocator** ppBufferSuballocator)
{
try
{
- auto* pAllocator = MakeNewRCObj<BufferSuballocatorImpl>()(CreateInfo);
+ auto* pAllocator = MakeNewRCObj<BufferSuballocatorImpl>()(pDevice, CreateInfo);
pAllocator->QueryInterface(IID_BufferSuballocator, reinterpret_cast<IObject**>(ppBufferSuballocator));
}
catch (...)
diff --git a/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp b/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp
index 6881decf..f8128b5d 100644
--- a/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp
+++ b/Graphics/GraphicsTools/src/DynamicTextureAtlas.cpp
@@ -113,6 +113,7 @@ public:
using TBase = ObjectBase<IDynamicTextureAtlas>;
DynamicTextureAtlasImpl(IReferenceCounters* pRefCounters,
+ IRenderDevice* pDevice,
DynamicTextureAtlasCreateInfo& CreateInfo) :
// clang-format off
TBase {pRefCounters},
@@ -160,11 +161,11 @@ public:
m_Slices.emplace_back(new SliceManager{m_Desc.Width / m_Granularity, m_Desc.Height / m_Granularity});
}
- if (CreateInfo.pDevice == nullptr)
+ if (pDevice == nullptr)
m_Desc.ArraySize = 0;
if (m_Desc.ArraySize > 0)
{
- CreateInfo.pDevice->CreateTexture(m_Desc, nullptr, &m_pTexture);
+ pDevice->CreateTexture(m_Desc, nullptr, &m_pTexture);
if (!m_pTexture)
LOG_ERROR_AND_THROW("Failed to create texture atlas texture");
}
@@ -394,11 +395,13 @@ float4 TextureAtlasSuballocationImpl::GetUVScaleBias() const
}
-void CreateDynamicTextureAtlas(DynamicTextureAtlasCreateInfo& CreateInfo, IDynamicTextureAtlas** ppAtlas)
+void CreateDynamicTextureAtlas(IRenderDevice* pDevice,
+ DynamicTextureAtlasCreateInfo& CreateInfo,
+ IDynamicTextureAtlas** ppAtlas)
{
try
{
- auto* pAllocator = MakeNewRCObj<DynamicTextureAtlasImpl>()(CreateInfo);
+ auto* pAllocator = MakeNewRCObj<DynamicTextureAtlasImpl>()(pDevice, CreateInfo);
pAllocator->QueryInterface(IID_DynamicTextureAtlas, reinterpret_cast<IObject**>(ppAtlas));
}
catch (...)