Skip to content
Permalink
Browse files

- Intel on Linux used the footnote in the standard saying a descripto…

…r pool can become fragmented (thanks guys!)
  • Loading branch information...
dpjudas authored and madame-rachelle committed May 10, 2019
1 parent d972229 commit d00ff65a42a9a96aefd4f405a7329d93770cf6c5
@@ -271,17 +271,25 @@ void VkPostprocess::UpdateShadowMap()
}
}

void VkPostprocess::BeginFrame()
std::unique_ptr<VulkanDescriptorSet> VkPostprocess::AllocateDescriptorSet(VulkanDescriptorSetLayout *layout)
{
if (!mDescriptorPool)
if (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");
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 @@ class VkPostprocess
VkPostprocess();
~VkPostprocess();

void BeginFrame();
void RenderBuffersReset();

void SetActiveRenderTarget();
@@ -73,6 +72,7 @@ class VkPostprocess
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()
{
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();

if (mNextTimestampQuery > 0)
{
GetDrawCommands()->resetQueryPool(mTimestampQueryPool.get(), 0, mNextTimestampQuery);
mNextTimestampQuery = 0;
}
}

void VulkanFrameBuffer::PushGroup(const FString &name)
@@ -192,6 +192,7 @@ class VulkanDescriptorPool

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);
}

0 comments on commit d00ff65

Please sign in to comment.
You can’t perform that action at this time.