mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
- Intel on Linux used the footnote in the standard saying a descriptor pool can become fragmented (thanks guys!)
This commit is contained in:
parent
ce73fe5b16
commit
7c3e99a6f1
4 changed files with 42 additions and 18 deletions
|
@ -271,17 +271,25 @@ void VkPostprocess::UpdateShadowMap()
|
|||
}
|
||||
}
|
||||
|
||||
void VkPostprocess::BeginFrame()
|
||||
std::unique_ptr<VulkanDescriptorSet> VkPostprocess::AllocateDescriptorSet(VulkanDescriptorSetLayout *layout)
|
||||
{
|
||||
if (!mDescriptorPool)
|
||||
if (mDescriptorPool)
|
||||
{
|
||||
auto descriptors = mDescriptorPool->tryAllocate(layout);
|
||||
if (descriptors)
|
||||
return descriptors;
|
||||
|
||||
GetVulkanFrameBuffer()->FrameDeleteList.DescriptorPools.push_back(std::move(mDescriptorPool));
|
||||
}
|
||||
|
||||
DescriptorPoolBuilder builder;
|
||||
builder.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 200);
|
||||
builder.addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 4);
|
||||
builder.setMaxSets(100);
|
||||
mDescriptorPool = builder.create(GetVulkanFrameBuffer()->device);
|
||||
mDescriptorPool->SetDebugName("VkPostprocess.mDescriptorPool");
|
||||
}
|
||||
|
||||
return mDescriptorPool->allocate(layout);
|
||||
}
|
||||
|
||||
void VkPostprocess::RenderBuffersReset()
|
||||
|
@ -522,7 +530,7 @@ VulkanDescriptorSet *VkPPRenderState::GetInput(VkPPRenderPassSetup *passSetup, c
|
|||
{
|
||||
auto fb = GetVulkanFrameBuffer();
|
||||
auto pp = fb->GetPostprocess();
|
||||
auto descriptors = pp->mDescriptorPool->allocate(passSetup->DescriptorLayout.get());
|
||||
auto descriptors = pp->AllocateDescriptorSet(passSetup->DescriptorLayout.get());
|
||||
descriptors->SetDebugName("VkPostprocess.descriptors");
|
||||
|
||||
WriteDescriptors write;
|
||||
|
|
|
@ -52,7 +52,6 @@ public:
|
|||
VkPostprocess();
|
||||
~VkPostprocess();
|
||||
|
||||
void BeginFrame();
|
||||
void RenderBuffersReset();
|
||||
|
||||
void SetActiveRenderTarget();
|
||||
|
@ -73,6 +72,7 @@ public:
|
|||
private:
|
||||
void NextEye(int eyeCount);
|
||||
|
||||
std::unique_ptr<VulkanDescriptorSet> AllocateDescriptorSet(VulkanDescriptorSetLayout *layout);
|
||||
VulkanSampler *GetSampler(PPFilterMode filter, PPWrapMode wrap);
|
||||
|
||||
std::array<std::unique_ptr<VulkanSampler>, 4> mSamplers;
|
||||
|
|
|
@ -796,18 +796,17 @@ TArray<uint8_t> VulkanFrameBuffer::GetScreenshotBuffer(int &pitch, ESSType &colo
|
|||
|
||||
void VulkanFrameBuffer::BeginFrame()
|
||||
{
|
||||
SetViewportRects(nullptr);
|
||||
mScreenBuffers->BeginFrame(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||
mSaveBuffers->BeginFrame(SAVEPICWIDTH, SAVEPICHEIGHT, SAVEPICWIDTH, SAVEPICHEIGHT);
|
||||
mRenderState->BeginFrame();
|
||||
mRenderPassManager->UpdateDynamicSet();
|
||||
|
||||
if (mNextTimestampQuery > 0)
|
||||
{
|
||||
GetDrawCommands()->resetQueryPool(mTimestampQueryPool.get(), 0, mNextTimestampQuery);
|
||||
mNextTimestampQuery = 0;
|
||||
}
|
||||
|
||||
SetViewportRects(nullptr);
|
||||
mScreenBuffers->BeginFrame(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||
mSaveBuffers->BeginFrame(SAVEPICWIDTH, SAVEPICHEIGHT, SAVEPICWIDTH, SAVEPICHEIGHT);
|
||||
mPostprocess->BeginFrame();
|
||||
mRenderState->BeginFrame();
|
||||
mRenderPassManager->UpdateDynamicSet();
|
||||
}
|
||||
|
||||
void VulkanFrameBuffer::PushGroup(const FString &name)
|
||||
|
|
|
@ -192,6 +192,7 @@ public:
|
|||
|
||||
void SetDebugName(const char *name) { device->SetDebugObjectName(name, (uint64_t)pool, VK_OBJECT_TYPE_DESCRIPTOR_POOL); }
|
||||
|
||||
std::unique_ptr<VulkanDescriptorSet> tryAllocate(VulkanDescriptorSetLayout *layout);
|
||||
std::unique_ptr<VulkanDescriptorSet> allocate(VulkanDescriptorSetLayout *layout);
|
||||
|
||||
VulkanDevice *device;
|
||||
|
@ -932,6 +933,22 @@ inline VulkanDescriptorPool::~VulkanDescriptorPool()
|
|||
vkDestroyDescriptorPool(device->device, pool, nullptr);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::tryAllocate(VulkanDescriptorSetLayout *layout)
|
||||
{
|
||||
VkDescriptorSetAllocateInfo allocInfo = {};
|
||||
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
||||
allocInfo.descriptorPool = pool;
|
||||
allocInfo.descriptorSetCount = 1;
|
||||
allocInfo.pSetLayouts = &layout->layout;
|
||||
|
||||
VkDescriptorSet descriptorSet;
|
||||
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet);
|
||||
if (result != VK_SUCCESS)
|
||||
return nullptr;
|
||||
|
||||
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(VulkanDescriptorSetLayout *layout)
|
||||
{
|
||||
VkDescriptorSetAllocateInfo allocInfo = {};
|
||||
|
@ -943,7 +960,7 @@ inline std::unique_ptr<VulkanDescriptorSet> VulkanDescriptorPool::allocate(Vulka
|
|||
VkDescriptorSet descriptorSet;
|
||||
VkResult result = vkAllocateDescriptorSets(device->device, &allocInfo, &descriptorSet);
|
||||
if (result != VK_SUCCESS)
|
||||
I_Error("Could not allocate descriptor sets");
|
||||
I_FatalError("Could not allocate descriptor sets");
|
||||
|
||||
return std::make_unique<VulkanDescriptorSet>(device, this, descriptorSet);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue