Commit 67ae6c58 by Jamie Madill Committed by Commit Bot

Vulkan: Use free descriptor set bits in pool.

This forces us to free descriptor sets when we're done with them, but saves us from needing to track when a descriptor set pool is no longer in use. We may need to revisit this in the future if we want to support pool allocation for performance. Bug: angleproject:2396 Change-Id: I3f3184f3dd9e4c2911e1aade4dcb95962a26c3a7 Reviewed-on: https://chromium-review.googlesource.com/956574Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 1505c750
...@@ -107,7 +107,7 @@ gl::Error ContextVk::initialize() ...@@ -107,7 +107,7 @@ gl::Error ContextVk::initialize()
VkDescriptorPoolCreateInfo descriptorPoolInfo; VkDescriptorPoolCreateInfo descriptorPoolInfo;
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
descriptorPoolInfo.pNext = nullptr; descriptorPoolInfo.pNext = nullptr;
descriptorPoolInfo.flags = 0; descriptorPoolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
// TODO(jmadill): Pick non-arbitrary max. // TODO(jmadill): Pick non-arbitrary max.
descriptorPoolInfo.maxSets = 2048; descriptorPoolInfo.maxSets = 2048;
......
...@@ -156,12 +156,16 @@ ProgramVk::~ProgramVk() ...@@ -156,12 +156,16 @@ ProgramVk::~ProgramVk()
void ProgramVk::destroy(const gl::Context *contextImpl) void ProgramVk::destroy(const gl::Context *contextImpl)
{ {
VkDevice device = vk::GetImpl(contextImpl)->getDevice(); ContextVk *contextVk = vk::GetImpl(contextImpl);
reset(device); reset(contextVk);
} }
void ProgramVk::reset(VkDevice device) void ProgramVk::reset(ContextVk *contextVk)
{ {
// TODO(jmadill): Handle re-linking a program that is in-use. http://anglebug.com/2397
VkDevice device = contextVk->getDevice();
for (auto &uniformBlock : mDefaultUniformBlocks) for (auto &uniformBlock : mDefaultUniformBlocks)
{ {
uniformBlock.storage.memory.destroy(device); uniformBlock.storage.memory.destroy(device);
...@@ -176,7 +180,13 @@ void ProgramVk::reset(VkDevice device) ...@@ -176,7 +180,13 @@ void ProgramVk::reset(VkDevice device)
mVertexModuleSerial = Serial(); mVertexModuleSerial = Serial();
mFragmentModuleSerial = Serial(); mFragmentModuleSerial = Serial();
// Descriptor Sets are pool allocated, so do not need to be explicitly freed. // Free our descriptor set handles.
if (!mDescriptorSets.empty())
{
vk::DescriptorPool *descriptorPool = contextVk->getDescriptorPool();
vkFreeDescriptorSets(device, descriptorPool->getHandle(),
static_cast<uint32_t>(mDescriptorSets.size()), mDescriptorSets.data());
}
mDescriptorSets.clear(); mDescriptorSets.clear();
mUsedDescriptorSetRange.invalidate(); mUsedDescriptorSetRange.invalidate();
mDirtyTextures = false; mDirtyTextures = false;
...@@ -214,7 +224,7 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext, ...@@ -214,7 +224,7 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext,
GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper(); GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper();
VkDevice device = renderer->getDevice(); VkDevice device = renderer->getDevice();
reset(device); reset(contextVk);
std::vector<uint32_t> vertexCode; std::vector<uint32_t> vertexCode;
std::vector<uint32_t> fragmentCode; std::vector<uint32_t> fragmentCode;
......
...@@ -120,7 +120,7 @@ class ProgramVk : public ProgramImpl ...@@ -120,7 +120,7 @@ class ProgramVk : public ProgramImpl
void invalidateTextures(); void invalidateTextures();
private: private:
void reset(VkDevice device); void reset(ContextVk *contextVk);
vk::Error initDescriptorSets(ContextVk *contextVk); vk::Error initDescriptorSets(ContextVk *contextVk);
gl::Error initDefaultUniformBlocks(const gl::Context *glContext); gl::Error initDefaultUniformBlocks(const gl::Context *glContext);
vk::Error updateDefaultUniformsDescriptorSet(ContextVk *contextVk); vk::Error updateDefaultUniformsDescriptorSet(ContextVk *contextVk);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment