Small refactor, now that we are bindless we only need a pool for samplers
This commit is contained in:
@@ -388,7 +388,7 @@ namespace Juliet::D3D12
|
||||
|
||||
viewHeap = commandList->Driver->BindlessDescriptorHeap;
|
||||
|
||||
samplerHeap = AcquireDescriptorHeapFromPool(commandList->Driver, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||
samplerHeap = AcquireSamplerHeapFromPool(commandList->Driver);
|
||||
|
||||
commandList->CRB_SRV_UAV_Heap = viewHeap;
|
||||
commandList->RTV_Heap = samplerHeap;
|
||||
@@ -437,7 +437,7 @@ namespace Juliet::D3D12
|
||||
|
||||
// Return heap descriptor to pool
|
||||
// CRB_SRV_UAV_Heap is global bindless, do not return it.
|
||||
ReturnDescriptorHeapToPool(driver, commandList->RTV_Heap);
|
||||
ReturnSamplerHeapToPool(driver, commandList->RTV_Heap);
|
||||
commandList->CRB_SRV_UAV_Heap = nullptr;
|
||||
commandList->RTV_Heap = nullptr;
|
||||
|
||||
|
||||
@@ -105,21 +105,10 @@ namespace Juliet::D3D12::Internal
|
||||
heap->FreeIndicesCount++;
|
||||
}
|
||||
|
||||
D3D12DescriptorHeap* AcquireDescriptorHeapFromPool(NonNullPtr<D3D12Driver> d3d12Driver, D3D12_DESCRIPTOR_HEAP_TYPE type)
|
||||
D3D12DescriptorHeap* AcquireSamplerHeapFromPool(NonNullPtr<D3D12Driver> d3d12Driver)
|
||||
{
|
||||
D3D12DescriptorHeapPool* pool = nullptr;
|
||||
uint32 count = 0;
|
||||
if (type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
|
||||
{
|
||||
pool = &d3d12Driver->CRB_SRV_UAV_HeapPool;
|
||||
count = GPUDriver::kCBV_SRV_UAV_HeapDescriptorCount;
|
||||
}
|
||||
else if (type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
|
||||
{
|
||||
pool = &d3d12Driver->RTV_HeapPool;
|
||||
count = GPUDriver::kSampler_HeapDescriptorCount;
|
||||
}
|
||||
Assert(pool != nullptr);
|
||||
D3D12DescriptorHeapPool* pool = &d3d12Driver->SamplerHeapPool;
|
||||
uint32 count = GPUDriver::kSampler_HeapDescriptorCount;
|
||||
|
||||
D3D12DescriptorHeap* result = nullptr;
|
||||
if (pool->Count > 0)
|
||||
@@ -129,34 +118,27 @@ namespace Juliet::D3D12::Internal
|
||||
}
|
||||
else
|
||||
{
|
||||
result = CreateDescriptorHeap(d3d12Driver, type, count, false);
|
||||
result = CreateDescriptorHeap(d3d12Driver, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, count, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ReturnDescriptorHeapToPool(NonNullPtr<D3D12Driver> d3d12Driver, D3D12DescriptorHeap* heap)
|
||||
void ReturnSamplerHeapToPool(NonNullPtr<D3D12Driver> d3d12Driver, D3D12DescriptorHeap* heap)
|
||||
{
|
||||
if (heap == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
D3D12DescriptorHeapPool* pool = nullptr;
|
||||
if (heap->HeapType == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV)
|
||||
{
|
||||
pool = &d3d12Driver->CRB_SRV_UAV_HeapPool;
|
||||
}
|
||||
else if (heap->HeapType == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER)
|
||||
{
|
||||
pool = &d3d12Driver->RTV_HeapPool;
|
||||
}
|
||||
Assert(pool != nullptr);
|
||||
Assert(heap->HeapType == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
|
||||
D3D12DescriptorHeapPool* pool = &d3d12Driver->SamplerHeapPool;
|
||||
|
||||
heap->CurrentDescriptorIndex = 0;
|
||||
|
||||
if (pool->Count >= pool->Capacity)
|
||||
{
|
||||
pool->Capacity *= 2;
|
||||
pool->Capacity = pool->Capacity == 0 ? 1 : pool->Capacity * 2;
|
||||
pool->Heaps =
|
||||
static_cast<D3D12DescriptorHeap**>(Realloc(pool->Heaps, pool->Capacity * sizeof(D3D12DescriptorHeap*)));
|
||||
}
|
||||
|
||||
@@ -48,9 +48,8 @@ namespace Juliet::D3D12::Internal
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE type, uint32 count, bool isStaging);
|
||||
extern void DestroyDescriptorHeap(NonNullPtr<D3D12DescriptorHeap> heap);
|
||||
|
||||
extern D3D12DescriptorHeap* AcquireDescriptorHeapFromPool(NonNullPtr<D3D12Driver> commandList,
|
||||
D3D12_DESCRIPTOR_HEAP_TYPE type);
|
||||
extern void ReturnDescriptorHeapToPool(NonNullPtr<D3D12Driver> d3d12Driver, D3D12DescriptorHeap* heap);
|
||||
extern D3D12DescriptorHeap* AcquireSamplerHeapFromPool(NonNullPtr<D3D12Driver> d3d12Driver);
|
||||
extern void ReturnSamplerHeapToPool(NonNullPtr<D3D12Driver> d3d12Driver, D3D12DescriptorHeap* heap);
|
||||
|
||||
extern bool AssignDescriptor(D3D12DescriptorHeap* heap, D3D12Descriptor& outDescriptor);
|
||||
extern void ReleaseDescriptor(const D3D12Descriptor& descriptor);
|
||||
|
||||
@@ -496,8 +496,7 @@ namespace Juliet::D3D12
|
||||
SafeFree(heapPool.Heaps);
|
||||
}
|
||||
};
|
||||
DestroyDescriptorHeapPool(driver->CRB_SRV_UAV_HeapPool);
|
||||
DestroyDescriptorHeapPool(driver->RTV_HeapPool);
|
||||
DestroyDescriptorHeapPool(driver->SamplerHeapPool);
|
||||
|
||||
// Release command buffers
|
||||
for (uint32 i = 0; i < driver->AvailableCommandListCount; i += 1)
|
||||
@@ -950,14 +949,7 @@ namespace Juliet::D3D12
|
||||
return true;
|
||||
};
|
||||
|
||||
if (!CreateDescriptorPool(driver->CRB_SRV_UAV_HeapPool, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||
GPUDriver::kCBV_SRV_UAV_HeapDescriptorCount))
|
||||
{
|
||||
DestroyDriver_Internal(driver);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!CreateDescriptorPool(driver->RTV_HeapPool, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, GPUDriver::kSampler_HeapDescriptorCount))
|
||||
if (!CreateDescriptorPool(driver->SamplerHeapPool, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, GPUDriver::kSampler_HeapDescriptorCount))
|
||||
{
|
||||
DestroyDriver_Internal(driver);
|
||||
return nullptr;
|
||||
@@ -1029,7 +1021,7 @@ namespace Juliet::D3D12
|
||||
driver->GraphicsDevice = device;
|
||||
|
||||
// Create Global Bindless Heap that stays alive for the driver whole lifetime
|
||||
driver->BindlessDescriptorHeap = Internal::AcquireDescriptorHeapFromPool(driver, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
|
||||
driver->BindlessDescriptorHeap = Internal::CreateDescriptorHeap(driver, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, GPUDriver::kCBV_SRV_UAV_HeapDescriptorCount, false);
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,7 @@ namespace Juliet::D3D12
|
||||
|
||||
D3D12StagingDescriptorPool* StagingDescriptorPools[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES];
|
||||
Internal::D3D12DescriptorHeap* BindlessDescriptorHeap;
|
||||
Internal::D3D12DescriptorHeapPool CRB_SRV_UAV_HeapPool;
|
||||
Internal::D3D12DescriptorHeapPool RTV_HeapPool;
|
||||
Internal::D3D12DescriptorHeapPool SamplerHeapPool;
|
||||
|
||||
String Semantic;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user