Fixes to Vulkan backend
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "GPUTimerQueryVulkan.h"
|
||||
#endif
|
||||
#include "DescriptorSetVulkan.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
|
||||
void CmdBufferVulkan::AddWaitSemaphore(VkPipelineStageFlags waitFlags, SemaphoreVulkan* waitSemaphore)
|
||||
@@ -32,7 +33,7 @@ void CmdBufferVulkan::Begin()
|
||||
// Acquire a descriptor pool set on
|
||||
if (_descriptorPoolSetContainer == nullptr)
|
||||
{
|
||||
_descriptorPoolSetContainer = &_device->DescriptorPoolsManager->AcquirePoolSetContainer();
|
||||
_descriptorPoolSetContainer = _device->DescriptorPoolsManager->AcquirePoolSetContainer();
|
||||
}
|
||||
|
||||
_state = State::IsInsideBegin;
|
||||
@@ -138,7 +139,7 @@ void CmdBufferVulkan::RefreshFenceStatus()
|
||||
|
||||
if (_descriptorPoolSetContainer)
|
||||
{
|
||||
_device->DescriptorPoolsManager->ReleasePoolSet(*_descriptorPoolSetContainer);
|
||||
_descriptorPoolSetContainer->LastFrameUsed = Engine::FrameCount;
|
||||
_descriptorPoolSetContainer = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -279,6 +280,7 @@ void CmdBufferManagerVulkan::WaitForCmdBuffer(CmdBufferVulkan* cmdBuffer, float
|
||||
void CmdBufferManagerVulkan::PrepareForNewActiveCommandBuffer()
|
||||
{
|
||||
PROFILE_CPU();
|
||||
ASSERT_LOW_LAYER(_activeCmdBuffer == nullptr)
|
||||
for (int32 i = 0; i < _pool._cmdBuffers.Count(); i++)
|
||||
{
|
||||
auto cmdBuffer = _pool._cmdBuffers.Get()[i];
|
||||
@@ -286,8 +288,7 @@ void CmdBufferManagerVulkan::PrepareForNewActiveCommandBuffer()
|
||||
if (cmdBuffer->GetState() == CmdBufferVulkan::State::ReadyForBegin)
|
||||
{
|
||||
_activeCmdBuffer = cmdBuffer;
|
||||
_activeCmdBuffer->Begin();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -295,8 +296,12 @@ void CmdBufferManagerVulkan::PrepareForNewActiveCommandBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
// Always begin fresh command buffer for rendering
|
||||
_activeCmdBuffer = _pool.Create();
|
||||
if (_activeCmdBuffer == nullptr)
|
||||
{
|
||||
// Always begin fresh command buffer for rendering
|
||||
_activeCmdBuffer = _pool.Create();
|
||||
}
|
||||
|
||||
_activeCmdBuffer->Begin();
|
||||
|
||||
#if VULKAN_USE_QUERIES
|
||||
|
||||
@@ -287,7 +287,7 @@ DescriptorPoolsManagerVulkan::~DescriptorPoolsManagerVulkan()
|
||||
_poolSets.ClearDelete();
|
||||
}
|
||||
|
||||
DescriptorPoolSetContainerVulkan& DescriptorPoolsManagerVulkan::AcquirePoolSetContainer()
|
||||
DescriptorPoolSetContainerVulkan* DescriptorPoolsManagerVulkan::AcquirePoolSetContainer()
|
||||
{
|
||||
ScopeLock lock(_locker);
|
||||
for (auto* poolSet : _poolSets)
|
||||
@@ -296,17 +296,12 @@ DescriptorPoolSetContainerVulkan& DescriptorPoolsManagerVulkan::AcquirePoolSetCo
|
||||
{
|
||||
poolSet->LastFrameUsed = Engine::FrameCount;
|
||||
poolSet->Reset();
|
||||
return *poolSet;
|
||||
return poolSet;
|
||||
}
|
||||
}
|
||||
const auto poolSet = New<DescriptorPoolSetContainerVulkan>(_device);
|
||||
_poolSets.Add(poolSet);
|
||||
return *poolSet;
|
||||
}
|
||||
|
||||
void DescriptorPoolsManagerVulkan::ReleasePoolSet(DescriptorPoolSetContainerVulkan& poolSet)
|
||||
{
|
||||
poolSet.LastFrameUsed = Engine::FrameCount;
|
||||
return poolSet;
|
||||
}
|
||||
|
||||
void DescriptorPoolsManagerVulkan::GC()
|
||||
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
void Reset();
|
||||
|
||||
mutable uint64 Refs = 0;
|
||||
mutable uint32 LastFrameUsed;
|
||||
mutable uint64 LastFrameUsed;
|
||||
};
|
||||
|
||||
class DescriptorPoolsManagerVulkan
|
||||
@@ -236,8 +236,7 @@ public:
|
||||
DescriptorPoolsManagerVulkan(GPUDeviceVulkan* device);
|
||||
~DescriptorPoolsManagerVulkan();
|
||||
|
||||
DescriptorPoolSetContainerVulkan& AcquirePoolSetContainer();
|
||||
void ReleasePoolSet(DescriptorPoolSetContainerVulkan& poolSet);
|
||||
DescriptorPoolSetContainerVulkan* AcquirePoolSetContainer();
|
||||
void GC();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user