Commit d838178d by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Rename vk::Shared* to vk::RefCounted*

To be specific regarding what being "shared" entails. Also, avoids confusion w.r.t to an upcoming vk::Shared class. Bug: angleproject:2464 Change-Id: Ib9c112bbb822ae30dab39c75a8cde25dd79b2258 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1499693Reviewed-by: 's avatarJamie Madill <jmadill@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 0e1ce2e5
...@@ -344,7 +344,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff ...@@ -344,7 +344,7 @@ class ContextVk : public ContextImpl, public vk::Context, public vk::CommandBuff
vk::DynamicBuffer mDriverUniformsBuffer; vk::DynamicBuffer mDriverUniformsBuffer;
VkDescriptorSet mDriverUniformsDescriptorSet; VkDescriptorSet mDriverUniformsDescriptorSet;
vk::BindingPointer<vk::DescriptorSetLayout> mDriverUniformsSetLayout; vk::BindingPointer<vk::DescriptorSetLayout> mDriverUniformsSetLayout;
vk::SharedDescriptorPoolBinding mDriverUniformsDescriptorPoolBinding; vk::RefCountedDescriptorPoolBinding mDriverUniformsDescriptorPoolBinding;
// This cache should also probably include the texture index (shader location) and array // This cache should also probably include the texture index (shader location) and array
// index (also in the shader). This info is used in the descriptor update step. // index (also in the shader). This info is used in the descriptor update step.
......
...@@ -215,7 +215,7 @@ void ProgramVk::reset(RendererVk *renderer) ...@@ -215,7 +215,7 @@ void ProgramVk::reset(RendererVk *renderer)
mDescriptorSets.clear(); mDescriptorSets.clear();
mUsedDescriptorSetRange.invalidate(); mUsedDescriptorSetRange.invalidate();
for (vk::SharedDescriptorPoolBinding &binding : mDescriptorPoolBindings) for (vk::RefCountedDescriptorPoolBinding &binding : mDescriptorPoolBindings)
{ {
binding.reset(); binding.reset();
} }
......
...@@ -224,7 +224,7 @@ class ProgramVk : public ProgramImpl ...@@ -224,7 +224,7 @@ class ProgramVk : public ProgramImpl
// Keep bindings to the descriptor pools. This ensures the pools stay valid while the Program // Keep bindings to the descriptor pools. This ensures the pools stay valid while the Program
// is in use. // is in use.
vk::DescriptorSetLayoutArray<vk::SharedDescriptorPoolBinding> mDescriptorPoolBindings; vk::DescriptorSetLayoutArray<vk::RefCountedDescriptorPoolBinding> mDescriptorPoolBindings;
class ShaderInfo final : angle::NonCopyable class ShaderInfo final : angle::NonCopyable
{ {
......
...@@ -389,7 +389,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context, ...@@ -389,7 +389,7 @@ angle::Result UtilsVk::clearBuffer(vk::Context *context,
shaderParams.clearValue = params.clearValue; shaderParams.clearValue = params.clearValue;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::SharedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::BufferClear].allocateSets( ANGLE_TRY(mDescriptorPools[Function::BufferClear].allocateSets(
context, mDescriptorSetLayouts[Function::BufferClear][kSetIndex].get().ptr(), 1, context, mDescriptorSetLayouts[Function::BufferClear][kSetIndex].get().ptr(), 1,
&descriptorPoolBinding, &descriptorSet)); &descriptorPoolBinding, &descriptorSet));
...@@ -451,7 +451,7 @@ angle::Result UtilsVk::copyBuffer(vk::Context *context, ...@@ -451,7 +451,7 @@ angle::Result UtilsVk::copyBuffer(vk::Context *context,
shaderParams.srcOffset = params.srcOffset; shaderParams.srcOffset = params.srcOffset;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::SharedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::BufferCopy].allocateSets( ANGLE_TRY(mDescriptorPools[Function::BufferCopy].allocateSets(
context, mDescriptorSetLayouts[Function::BufferCopy][kSetIndex].get().ptr(), 1, context, mDescriptorSetLayouts[Function::BufferCopy][kSetIndex].get().ptr(), 1,
&descriptorPoolBinding, &descriptorSet)); &descriptorPoolBinding, &descriptorSet));
...@@ -534,7 +534,7 @@ angle::Result UtilsVk::convertVertexBuffer(vk::Context *context, ...@@ -534,7 +534,7 @@ angle::Result UtilsVk::convertVertexBuffer(vk::Context *context,
flags |= isAligned ? ConvertVertex_comp::kIsAligned : 0; flags |= isAligned ? ConvertVertex_comp::kIsAligned : 0;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::SharedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::ConvertVertexBuffer].allocateSets( ANGLE_TRY(mDescriptorPools[Function::ConvertVertexBuffer].allocateSets(
context, mDescriptorSetLayouts[Function::ConvertVertexBuffer][kSetIndex].get().ptr(), 1, context, mDescriptorSetLayouts[Function::ConvertVertexBuffer][kSetIndex].get().ptr(), 1,
&descriptorPoolBinding, &descriptorSet)); &descriptorPoolBinding, &descriptorSet));
...@@ -710,7 +710,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk, ...@@ -710,7 +710,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
flags |= src->getLayerCount() > 1 ? ImageCopy_frag::kSrcIsArray : 0; flags |= src->getLayerCount() > 1 ? ImageCopy_frag::kSrcIsArray : 0;
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
vk::SharedDescriptorPoolBinding descriptorPoolBinding; vk::RefCountedDescriptorPoolBinding descriptorPoolBinding;
ANGLE_TRY(mDescriptorPools[Function::ImageCopy].allocateSets( ANGLE_TRY(mDescriptorPools[Function::ImageCopy].allocateSets(
contextVk, mDescriptorSetLayouts[Function::ImageCopy][kSetIndex].get().ptr(), 1, contextVk, mDescriptorSetLayouts[Function::ImageCopy][kSetIndex].get().ptr(), 1,
&descriptorPoolBinding, &descriptorSet)); &descriptorPoolBinding, &descriptorSet));
......
...@@ -1391,7 +1391,7 @@ void DescriptorSetLayoutCache::destroy(VkDevice device) ...@@ -1391,7 +1391,7 @@ void DescriptorSetLayoutCache::destroy(VkDevice device)
{ {
for (auto &item : mPayload) for (auto &item : mPayload)
{ {
vk::SharedDescriptorSetLayout &layout = item.second; vk::RefCountedDescriptorSetLayout &layout = item.second;
ASSERT(!layout.isReferenced()); ASSERT(!layout.isReferenced());
layout.get().destroy(device); layout.get().destroy(device);
} }
...@@ -1407,7 +1407,7 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout( ...@@ -1407,7 +1407,7 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout(
auto iter = mPayload.find(desc); auto iter = mPayload.find(desc);
if (iter != mPayload.end()) if (iter != mPayload.end())
{ {
vk::SharedDescriptorSetLayout &layout = iter->second; vk::RefCountedDescriptorSetLayout &layout = iter->second;
descriptorSetLayoutOut->set(&layout); descriptorSetLayoutOut->set(&layout);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -1425,8 +1425,9 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout( ...@@ -1425,8 +1425,9 @@ angle::Result DescriptorSetLayoutCache::getDescriptorSetLayout(
vk::DescriptorSetLayout newLayout; vk::DescriptorSetLayout newLayout;
ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo)); ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo));
auto insertedItem = mPayload.emplace(desc, vk::SharedDescriptorSetLayout(std::move(newLayout))); auto insertedItem =
vk::SharedDescriptorSetLayout &insertedLayout = insertedItem.first->second; mPayload.emplace(desc, vk::RefCountedDescriptorSetLayout(std::move(newLayout)));
vk::RefCountedDescriptorSetLayout &insertedLayout = insertedItem.first->second;
descriptorSetLayoutOut->set(&insertedLayout); descriptorSetLayoutOut->set(&insertedLayout);
return angle::Result::Continue; return angle::Result::Continue;
...@@ -1444,7 +1445,7 @@ void PipelineLayoutCache::destroy(VkDevice device) ...@@ -1444,7 +1445,7 @@ void PipelineLayoutCache::destroy(VkDevice device)
{ {
for (auto &item : mPayload) for (auto &item : mPayload)
{ {
vk::SharedPipelineLayout &layout = item.second; vk::RefCountedPipelineLayout &layout = item.second;
layout.get().destroy(device); layout.get().destroy(device);
} }
...@@ -1460,7 +1461,7 @@ angle::Result PipelineLayoutCache::getPipelineLayout( ...@@ -1460,7 +1461,7 @@ angle::Result PipelineLayoutCache::getPipelineLayout(
auto iter = mPayload.find(desc); auto iter = mPayload.find(desc);
if (iter != mPayload.end()) if (iter != mPayload.end())
{ {
vk::SharedPipelineLayout &layout = iter->second; vk::RefCountedPipelineLayout &layout = iter->second;
pipelineLayoutOut->set(&layout); pipelineLayoutOut->set(&layout);
return angle::Result::Continue; return angle::Result::Continue;
} }
...@@ -1518,8 +1519,8 @@ angle::Result PipelineLayoutCache::getPipelineLayout( ...@@ -1518,8 +1519,8 @@ angle::Result PipelineLayoutCache::getPipelineLayout(
vk::PipelineLayout newLayout; vk::PipelineLayout newLayout;
ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo)); ANGLE_VK_TRY(context, newLayout.init(context->getDevice(), createInfo));
auto insertedItem = mPayload.emplace(desc, vk::SharedPipelineLayout(std::move(newLayout))); auto insertedItem = mPayload.emplace(desc, vk::RefCountedPipelineLayout(std::move(newLayout)));
vk::SharedPipelineLayout &insertedLayout = insertedItem.first->second; vk::RefCountedPipelineLayout &insertedLayout = insertedItem.first->second;
pipelineLayoutOut->set(&insertedLayout); pipelineLayoutOut->set(&insertedLayout);
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -25,8 +25,8 @@ class ImageHelper; ...@@ -25,8 +25,8 @@ class ImageHelper;
using RenderPassAndSerial = ObjectAndSerial<RenderPass>; using RenderPassAndSerial = ObjectAndSerial<RenderPass>;
using PipelineAndSerial = ObjectAndSerial<Pipeline>; using PipelineAndSerial = ObjectAndSerial<Pipeline>;
using SharedDescriptorSetLayout = RefCounted<DescriptorSetLayout>; using RefCountedDescriptorSetLayout = RefCounted<DescriptorSetLayout>;
using SharedPipelineLayout = RefCounted<PipelineLayout>; using RefCountedPipelineLayout = RefCounted<PipelineLayout>;
// Packed Vk resource descriptions. // Packed Vk resource descriptions.
// Most Vk types use many more bits than required to represent the underlying data. // Most Vk types use many more bits than required to represent the underlying data.
...@@ -772,7 +772,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable ...@@ -772,7 +772,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable
vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut); vk::BindingPointer<vk::DescriptorSetLayout> *descriptorSetLayoutOut);
private: private:
std::unordered_map<vk::DescriptorSetLayoutDesc, vk::SharedDescriptorSetLayout> mPayload; std::unordered_map<vk::DescriptorSetLayoutDesc, vk::RefCountedDescriptorSetLayout> mPayload;
}; };
class PipelineLayoutCache final : angle::NonCopyable class PipelineLayoutCache final : angle::NonCopyable
...@@ -789,7 +789,7 @@ class PipelineLayoutCache final : angle::NonCopyable ...@@ -789,7 +789,7 @@ class PipelineLayoutCache final : angle::NonCopyable
vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut); vk::BindingPointer<vk::PipelineLayout> *pipelineLayoutOut);
private: private:
std::unordered_map<vk::PipelineLayoutDesc, vk::SharedPipelineLayout> mPayload; std::unordered_map<vk::PipelineLayoutDesc, vk::RefCountedPipelineLayout> mPayload;
}; };
// Some descriptor set and pipeline layout constants. // Some descriptor set and pipeline layout constants.
......
...@@ -516,13 +516,13 @@ angle::Result DynamicDescriptorPool::init(Context *context, ...@@ -516,13 +516,13 @@ angle::Result DynamicDescriptorPool::init(Context *context,
mPoolSizes[i].descriptorCount *= mMaxSetsPerPool; mPoolSizes[i].descriptorCount *= mMaxSetsPerPool;
} }
mDescriptorPools.push_back(new SharedDescriptorPoolHelper()); mDescriptorPools.push_back(new RefCountedDescriptorPoolHelper());
return mDescriptorPools[0]->get().init(context, mPoolSizes, mMaxSetsPerPool); return mDescriptorPools[0]->get().init(context, mPoolSizes, mMaxSetsPerPool);
} }
void DynamicDescriptorPool::destroy(VkDevice device) void DynamicDescriptorPool::destroy(VkDevice device)
{ {
for (SharedDescriptorPoolHelper *pool : mDescriptorPools) for (RefCountedDescriptorPoolHelper *pool : mDescriptorPools)
{ {
ASSERT(!pool->isReferenced()); ASSERT(!pool->isReferenced());
pool->get().destroy(device); pool->get().destroy(device);
...@@ -535,7 +535,7 @@ void DynamicDescriptorPool::destroy(VkDevice device) ...@@ -535,7 +535,7 @@ void DynamicDescriptorPool::destroy(VkDevice device)
angle::Result DynamicDescriptorPool::allocateSets(Context *context, angle::Result DynamicDescriptorPool::allocateSets(Context *context,
const VkDescriptorSetLayout *descriptorSetLayout, const VkDescriptorSetLayout *descriptorSetLayout,
uint32_t descriptorSetCount, uint32_t descriptorSetCount,
SharedDescriptorPoolBinding *bindingOut, RefCountedDescriptorPoolBinding *bindingOut,
VkDescriptorSet *descriptorSetsOut) VkDescriptorSet *descriptorSetsOut)
{ {
if (!bindingOut->valid() || !bindingOut->get().hasCapacity(descriptorSetCount)) if (!bindingOut->valid() || !bindingOut->get().hasCapacity(descriptorSetCount))
...@@ -580,7 +580,7 @@ angle::Result DynamicDescriptorPool::allocateNewPool(Context *context) ...@@ -580,7 +580,7 @@ angle::Result DynamicDescriptorPool::allocateNewPool(Context *context)
if (!found) if (!found)
{ {
mDescriptorPools.push_back(new SharedDescriptorPoolHelper()); mDescriptorPools.push_back(new RefCountedDescriptorPoolHelper());
mCurrentPoolIndex = mDescriptorPools.size() - 1; mCurrentPoolIndex = mDescriptorPools.size() - 1;
static constexpr size_t kMaxPools = 99999; static constexpr size_t kMaxPools = 99999;
......
...@@ -126,8 +126,8 @@ class DescriptorPoolHelper ...@@ -126,8 +126,8 @@ class DescriptorPoolHelper
Serial mMostRecentSerial; Serial mMostRecentSerial;
}; };
using SharedDescriptorPoolHelper = RefCounted<DescriptorPoolHelper>; using RefCountedDescriptorPoolHelper = RefCounted<DescriptorPoolHelper>;
using SharedDescriptorPoolBinding = BindingPointer<DescriptorPoolHelper>; using RefCountedDescriptorPoolBinding = BindingPointer<DescriptorPoolHelper>;
class DynamicDescriptorPool final : angle::NonCopyable class DynamicDescriptorPool final : angle::NonCopyable
{ {
...@@ -148,7 +148,7 @@ class DynamicDescriptorPool final : angle::NonCopyable ...@@ -148,7 +148,7 @@ class DynamicDescriptorPool final : angle::NonCopyable
angle::Result allocateSets(Context *context, angle::Result allocateSets(Context *context,
const VkDescriptorSetLayout *descriptorSetLayout, const VkDescriptorSetLayout *descriptorSetLayout,
uint32_t descriptorSetCount, uint32_t descriptorSetCount,
SharedDescriptorPoolBinding *bindingOut, RefCountedDescriptorPoolBinding *bindingOut,
VkDescriptorSet *descriptorSetsOut); VkDescriptorSet *descriptorSetsOut);
// For testing only! // For testing only!
...@@ -159,7 +159,7 @@ class DynamicDescriptorPool final : angle::NonCopyable ...@@ -159,7 +159,7 @@ class DynamicDescriptorPool final : angle::NonCopyable
uint32_t mMaxSetsPerPool; uint32_t mMaxSetsPerPool;
size_t mCurrentPoolIndex; size_t mCurrentPoolIndex;
std::vector<SharedDescriptorPoolHelper *> mDescriptorPools; std::vector<RefCountedDescriptorPoolHelper *> mDescriptorPools;
std::vector<VkDescriptorPoolSize> mPoolSizes; std::vector<VkDescriptorPoolSize> mPoolSizes;
}; };
......
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