summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-13 02:34:18 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-13 02:34:18 +0000
commit321dfe299cd3b15bd0216113068f13dfa4b99cf0 (patch)
treefcbd6d410bdc1bb5b659471350dddf1e71e615ce /Graphics/GraphicsEngineD3D12
parentOptimized memory layout of ObjectBase<> (reduced size by 40 bytes on msvc x64) (diff)
downloadDiligentCore-321dfe299cd3b15bd0216113068f13dfa4b99cf0.tar.gz
DiligentCore-321dfe299cd3b15bd0216113068f13dfa4b99cf0.zip
Updated ALLOCATE macros to make it more convenient
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp9
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RootSignature.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp3
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp6
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp2
8 files changed, 12 insertions, 16 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
index ac065da6..1027fb82 100644
--- a/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/PipelineStateD3D12Impl.cpp
@@ -72,20 +72,17 @@ PipelineStateD3D12Impl :: PipelineStateD3D12Impl(IReferenceCounters* pRefCo
{
auto& ShaderResLayoutAllocator = GetRawAllocator();
- auto* pShaderResLayoutRawMem = ALLOCATE(ShaderResLayoutAllocator, "Raw memory for ShaderResourceLayoutD3D12", sizeof(ShaderResourceLayoutD3D12) * m_NumShaders * 2);
- m_pShaderResourceLayouts = reinterpret_cast<ShaderResourceLayoutD3D12*>(pShaderResLayoutRawMem);
+ m_pShaderResourceLayouts = ALLOCATE(ShaderResLayoutAllocator, "Raw memory for ShaderResourceLayoutD3D12", ShaderResourceLayoutD3D12, m_NumShaders * 2);
}
{
auto& ShaderResCacheAllocator = GetRawAllocator();
- auto* pShaderResCacheRawMem = ALLOCATE(ShaderResCacheAllocator, "Raw memory for ShaderResourceCacheD3D12", sizeof(ShaderResourceCacheD3D12) * m_NumShaders);
- m_pStaticResourceCaches = reinterpret_cast<ShaderResourceCacheD3D12*>(pShaderResCacheRawMem);
+ m_pStaticResourceCaches = ALLOCATE(ShaderResCacheAllocator, "Raw memory for ShaderResourceCacheD3D12", ShaderResourceCacheD3D12, m_NumShaders);
}
{
auto& ShaderVarMgrAllocator = GetRawAllocator();
- auto* pStaticVarsMgrRawMem = ALLOCATE(ShaderVarMgrAllocator, "Raw memory for ShaderVariableManagerD3D12", sizeof(ShaderVariableManagerD3D12) * m_NumShaders);
- m_pStaticVarManagers = reinterpret_cast<ShaderVariableManagerD3D12*>(pStaticVarsMgrRawMem);
+ m_pStaticVarManagers = ALLOCATE(ShaderVarMgrAllocator, "Raw memory for ShaderVariableManagerD3D12", ShaderVariableManagerD3D12, m_NumShaders);
}
#ifdef DEVELOPMENT
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 15e48743..a7d2f6c6 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -236,7 +236,7 @@ RenderDeviceD3D12Impl::PooledCommandContext RenderDeviceD3D12Impl::AllocateComma
}
auto& CmdCtxAllocator = GetRawAllocator();
- auto* pRawMem = ALLOCATE(CmdCtxAllocator, "CommandContext instance", sizeof(CommandContext));
+ auto* pRawMem = ALLOCATE(CmdCtxAllocator, "CommandContext instance", CommandContext, 1);
auto pCtx = new (pRawMem) CommandContext(m_CmdListManager);
pCtx->SetID(ID);
#ifdef DEVELOPMENT
diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
index 87139ef9..7f127ce7 100644
--- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
@@ -56,7 +56,7 @@ D3D12_DESCRIPTOR_RANGE* RootSignature::RootParamsManager::Extend(Uint32 NumExtra
VERIFY(NumExtraRootTables > 0 || NumExtraRootViews > 0 || NumExtraDescriptorRanges > 0, "At least one root table, root view or descriptor range must be added" );
auto MemorySize = GetRequiredMemorySize(NumExtraRootTables, NumExtraRootViews, NumExtraDescriptorRanges);
VERIFY_EXPR(MemorySize > 0);
- auto *pNewMemory = ALLOCATE(m_MemAllocator, "Memory buffer for root tables, root views & descriptor ranges", MemorySize);
+ auto* pNewMemory = ALLOCATE_RAW(m_MemAllocator, "Memory buffer for root tables, root views & descriptor ranges", MemorySize);
memset(pNewMemory, 0, MemorySize);
// Note: this order is more efficient than views->tables->ranges
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
index f4128b88..e331be89 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
@@ -40,7 +40,7 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters,
{
// Load shader resources
auto& Allocator = GetRawAllocator();
- auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", sizeof(ShaderResourcesD3D12));
+ auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", ShaderResourcesD3D12, 1);
auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc, ShaderCI.UseCombinedTextureSamplers ? ShaderCI.CombinedSamplerSuffix : nullptr);
m_pShaderResources.reset(pResources, STDDeleterRawMem<ShaderResourcesD3D12>(Allocator));
}
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
index 7d4c396f..4498a9eb 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceBindingD3D12Impl.cpp
@@ -43,8 +43,7 @@ ShaderResourceBindingD3D12Impl::ShaderResourceBindingD3D12Impl(IReferenceCounter
auto& ResCacheDataAllocator = pPSO->GetSRBMemoryAllocator().GetResourceCacheDataAllocator(0);
pPSO->GetRootSignature().InitResourceCache(pRenderDeviceD3D12Impl, m_ShaderResourceCache, ResCacheDataAllocator);
- auto *pVarMgrsRawMem = ALLOCATE(GetRawAllocator(), "Raw memory for ShaderVariableManagerD3D12", m_NumShaders * sizeof(ShaderVariableManagerD3D12));
- m_pShaderVarMgrs = reinterpret_cast<ShaderVariableManagerD3D12*>(pVarMgrsRawMem);
+ m_pShaderVarMgrs = ALLOCATE(GetRawAllocator(), "Raw memory for ShaderVariableManagerD3D12", ShaderVariableManagerD3D12, m_NumShaders);
for (Uint32 s = 0; s < m_NumShaders; ++s)
{
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
index 64f1ff06..56d21ec1 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp
@@ -61,9 +61,9 @@ namespace Diligent
VERIFY_EXPR(MemorySize == GetRequiredMemorySize(NumTables, TableSizes));
if(MemorySize > 0)
{
- m_pMemory = ALLOCATE( *m_pAllocator, "Memory for shader resource cache data", MemorySize);
- auto *pTables = reinterpret_cast<RootTable*>(m_pMemory);
- auto *pCurrResPtr = reinterpret_cast<Resource*>(pTables + m_NumTables);
+ m_pMemory = ALLOCATE_RAW( *m_pAllocator, "Memory for shader resource cache data", MemorySize);
+ auto* pTables = reinterpret_cast<RootTable*>(m_pMemory);
+ auto* pCurrResPtr = reinterpret_cast<Resource*>(pTables + m_NumTables);
for(Uint32 res=0; res < TotalResources; ++res)
new(pCurrResPtr + res) Resource();
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 393c1c3b..9b1a11f8 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -99,7 +99,7 @@ void ShaderResourceLayoutD3D12::AllocateMemory(IMemoryAllocator&
if(MemSize == 0)
return;
- auto* pRawMem = ALLOCATE(Allocator, "Raw memory buffer for shader resource layout resources", MemSize);
+ auto* pRawMem = ALLOCATE_RAW(Allocator, "Raw memory buffer for shader resource layout resources", MemSize);
m_ResourceBuffer = std::unique_ptr<void, STDDeleterRawMem<void> >(pRawMem, Allocator);
}
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp
index de8e9855..3a16e008 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderVariableD3D12.cpp
@@ -70,7 +70,7 @@ ShaderVariableManagerD3D12::ShaderVariableManagerD3D12(IObject&
if(m_NumVariables == 0)
return;
- auto* pRawMem = ALLOCATE(Allocator, "Raw memory buffer for shader variables", MemSize);
+ auto* pRawMem = ALLOCATE_RAW(Allocator, "Raw memory buffer for shader variables", MemSize);
m_pVariables = reinterpret_cast<ShaderVariableD3D12Impl*>(pRawMem);
Uint32 VarInd = 0;