Commit b7d924a8 by Jamie Madill Committed by Commit Bot

Vulkan: Make free part of DescriptorPool.

This also fixes a missed VkResult error. In order to do this we also return an error from ProgramImpl::destroy. Bug: angleproject:2396 Change-Id: I649b19e64732785bb33eebadea7f361245137d0f Reviewed-on: https://chromium-review.googlesource.com/958406Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent e2995cce
......@@ -704,7 +704,8 @@ void Program::onDestroy(const Context *context)
mState.mAttachedGeometryShader = nullptr;
}
mProgram->destroy(context);
// TODO(jmadill): Handle error in the Context.
ANGLE_SWALLOW_ERR(mProgram->destroy(context));
ASSERT(!mState.mAttachedVertexShader && !mState.mAttachedFragmentShader &&
!mState.mAttachedComputeShader && !mState.mAttachedGeometryShader);
......
......@@ -35,7 +35,7 @@ class ProgramImpl : angle::NonCopyable
public:
ProgramImpl(const gl::ProgramState &state) : mState(state) {}
virtual ~ProgramImpl() {}
virtual void destroy(const gl::Context *context) {}
virtual gl::Error destroy(const gl::Context *context) { return gl::NoError(); }
virtual gl::LinkResult load(const gl::Context *context,
gl::InfoLog &infoLog,
......
......@@ -154,13 +154,13 @@ ProgramVk::~ProgramVk()
{
}
void ProgramVk::destroy(const gl::Context *contextImpl)
gl::Error ProgramVk::destroy(const gl::Context *contextImpl)
{
ContextVk *contextVk = vk::GetImpl(contextImpl);
reset(contextVk);
return reset(contextVk);
}
void ProgramVk::reset(ContextVk *contextVk)
vk::Error ProgramVk::reset(ContextVk *contextVk)
{
// TODO(jmadill): Handle re-linking a program that is in-use. http://anglebug.com/2397
......@@ -184,12 +184,14 @@ void ProgramVk::reset(ContextVk *contextVk)
if (!mDescriptorSets.empty())
{
vk::DescriptorPool *descriptorPool = contextVk->getDescriptorPool();
vkFreeDescriptorSets(device, descriptorPool->getHandle(),
static_cast<uint32_t>(mDescriptorSets.size()), mDescriptorSets.data());
ANGLE_TRY(descriptorPool->freeDescriptorSets(
device, static_cast<uint32_t>(mDescriptorSets.size()), mDescriptorSets.data()));
}
mDescriptorSets.clear();
mUsedDescriptorSetRange.invalidate();
mDirtyTextures = false;
return vk::NoError();
}
gl::LinkResult ProgramVk::load(const gl::Context *contextImpl,
......@@ -224,7 +226,7 @@ gl::LinkResult ProgramVk::link(const gl::Context *glContext,
GlslangWrapper *glslangWrapper = renderer->getGlslangWrapper();
VkDevice device = renderer->getDevice();
reset(contextVk);
ANGLE_TRY(reset(contextVk));
std::vector<uint32_t> vertexCode;
std::vector<uint32_t> fragmentCode;
......
......@@ -24,7 +24,7 @@ class ProgramVk : public ProgramImpl
public:
ProgramVk(const gl::ProgramState &state);
~ProgramVk() override;
void destroy(const gl::Context *context) override;
gl::Error destroy(const gl::Context *context) override;
gl::LinkResult load(const gl::Context *context,
gl::InfoLog &infoLog,
......@@ -120,7 +120,7 @@ class ProgramVk : public ProgramImpl
void invalidateTextures();
private:
void reset(ContextVk *contextVk);
vk::Error reset(ContextVk *contextVk);
vk::Error initDescriptorSets(ContextVk *contextVk);
gl::Error initDefaultUniformBlocks(const gl::Context *glContext);
vk::Error updateDefaultUniformsDescriptorSet(ContextVk *contextVk);
......
......@@ -1107,6 +1107,16 @@ Error DescriptorPool::allocateDescriptorSets(VkDevice device,
return NoError();
}
Error DescriptorPool::freeDescriptorSets(VkDevice device,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets)
{
ASSERT(valid());
ASSERT(descriptorSetCount > 0);
ANGLE_VK_TRY(vkFreeDescriptorSets(device, mHandle, descriptorSetCount, descriptorSets));
return NoError();
}
// Sampler implementation.
Sampler::Sampler()
{
......
......@@ -554,6 +554,9 @@ class DescriptorPool final : public WrappedObject<DescriptorPool, VkDescriptorPo
Error allocateDescriptorSets(VkDevice device,
const VkDescriptorSetAllocateInfo &allocInfo,
VkDescriptorSet *descriptorSetsOut);
Error freeDescriptorSets(VkDevice device,
uint32_t descriptorSetCount,
const VkDescriptorSet *descriptorSets);
};
class Sampler final : public WrappedObject<Sampler, VkSampler>
......
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