Commit 98b56e60 by Mohan Maiya Committed by Commit Bot

Vulkan: Accumulate internal cache stats in renderer

The CacheStats of all internal caches are accumulated by the renderer. In order to see the hit ratios of all caches, the following GN args must be enabled: is_debug = true angle_enable_perf_counter_output = true Bug: angleproject:5447 Test: Manual verification with angle_end2end_tests Change-Id: Iaca3249192e9e4e130d8291b7759c459d79b06ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2588430 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 5cf7472d
...@@ -363,6 +363,7 @@ void ContextVk::DriverUniformsDescriptorSet::destroy(RendererVk *renderer) ...@@ -363,6 +363,7 @@ void ContextVk::DriverUniformsDescriptorSet::destroy(RendererVk *renderer)
descriptorPoolBinding.reset(); descriptorPoolBinding.reset();
dynamicBuffer.destroy(renderer); dynamicBuffer.destroy(renderer);
descriptorSetCache.clear(); descriptorSetCache.clear();
descriptorSetCache.destroy(renderer);
} }
// ContextVk implementation. // ContextVk implementation.
...@@ -541,7 +542,7 @@ void ContextVk::onDestroy(const gl::Context *context) ...@@ -541,7 +542,7 @@ void ContextVk::onDestroy(const gl::Context *context)
mUtils.destroy(mRenderer); mUtils.destroy(mRenderer);
mRenderPassCache.destroy(device); mRenderPassCache.destroy(mRenderer);
mShaderLibrary.destroy(device); mShaderLibrary.destroy(device);
mGpuEventQueryPool.destroy(device); mGpuEventQueryPool.destroy(device);
mCommandPool.destroy(device); mCommandPool.destroy(device);
......
...@@ -288,7 +288,7 @@ void ShareGroupVk::onDestroy(const egl::Display *display) ...@@ -288,7 +288,7 @@ void ShareGroupVk::onDestroy(const egl::Display *display)
{ {
DisplayVk *displayVk = vk::GetImpl(display); DisplayVk *displayVk = vk::GetImpl(display);
mPipelineLayoutCache.destroy(displayVk->getDevice()); mPipelineLayoutCache.destroy(displayVk->getRenderer());
mDescriptorSetLayoutCache.destroy(displayVk->getDevice()); mDescriptorSetLayoutCache.destroy(displayVk->getRenderer());
} }
} // namespace rx } // namespace rx
...@@ -349,10 +349,12 @@ FramebufferVk::~FramebufferVk() = default; ...@@ -349,10 +349,12 @@ FramebufferVk::~FramebufferVk() = default;
void FramebufferVk::destroy(const gl::Context *context) void FramebufferVk::destroy(const gl::Context *context)
{ {
ContextVk *contextVk = vk::GetImpl(context); ContextVk *contextVk = vk::GetImpl(context);
RendererVk *rendererVk = contextVk->getRenderer();
mReadPixelBuffer.release(contextVk->getRenderer()); mReadPixelBuffer.release(rendererVk);
mFramebufferCache.clear(contextVk); mFramebufferCache.clear(contextVk);
mFramebufferCache.destroy(rendererVk);
} }
angle::Result FramebufferVk::discard(const gl::Context *context, angle::Result FramebufferVk::discard(const gl::Context *context,
......
...@@ -190,11 +190,12 @@ void ProgramExecutableVk::reset(ContextVk *contextVk) ...@@ -190,11 +190,12 @@ void ProgramExecutableVk::reset(ContextVk *contextVk)
descriptorPool.release(contextVk); descriptorPool.release(contextVk);
} }
mTextureDescriptorsCache.clear(); RendererVk *rendererVk = contextVk->getRenderer();
mUniformsAndXfbDescriptorSetCache.clear(); mTextureDescriptorsCache.destroy(rendererVk);
mUniformsAndXfbDescriptorSetCache.destroy(rendererVk);
// Initialize with a unique BufferSerial // Initialize with a unique BufferSerial
vk::ResourceSerialFactory &factory = contextVk->getRenderer()->getResourceSerialFactory(); vk::ResourceSerialFactory &factory = rendererVk->getResourceSerialFactory();
mCurrentDefaultUniformBufferSerial = factory.generateBufferSerial(); mCurrentDefaultUniformBufferSerial = factory.generateBufferSerial();
for (ProgramInfo &programInfo : mGraphicsProgramInfos) for (ProgramInfo &programInfo : mGraphicsProgramInfos)
...@@ -376,7 +377,7 @@ angle::Result ProgramExecutableVk::allocUniformAndXfbDescriptorSet( ...@@ -376,7 +377,7 @@ angle::Result ProgramExecutableVk::allocUniformAndXfbDescriptorSet(
// Clear descriptor set cache. It may no longer be valid. // Clear descriptor set cache. It may no longer be valid.
if (newPoolAllocated) if (newPoolAllocated)
{ {
mUniformsAndXfbDescriptorSetCache.clear(); mUniformsAndXfbDescriptorSetCache.destroy(contextVk->getRenderer());
} }
// Add the descriptor set into cache // Add the descriptor set into cache
...@@ -1475,7 +1476,7 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(ContextVk *contex ...@@ -1475,7 +1476,7 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet(ContextVk *contex
// Clear descriptor set cache. It may no longer be valid. // Clear descriptor set cache. It may no longer be valid.
if (newPoolAllocated) if (newPoolAllocated)
{ {
mTextureDescriptorsCache.clear(); mTextureDescriptorsCache.destroy(contextVk->getRenderer());
} }
descriptorSet = mDescriptorSets[ToUnderlying(DescriptorSetIndex::Texture)]; descriptorSet = mDescriptorSets[ToUnderlying(DescriptorSetIndex::Texture)];
......
...@@ -245,8 +245,10 @@ class ProgramExecutableVk ...@@ -245,8 +245,10 @@ class ProgramExecutableVk
size_t mNumDefaultUniformDescriptors; size_t mNumDefaultUniformDescriptors;
vk::BufferSerial mCurrentDefaultUniformBufferSerial; vk::BufferSerial mCurrentDefaultUniformBufferSerial;
DescriptorSetCache<vk::UniformsAndXfbDesc> mUniformsAndXfbDescriptorSetCache; DescriptorSetCache<vk::UniformsAndXfbDesc, VulkanCacheType::UniformsAndXfbDescriptorSet>
DescriptorSetCache<vk::TextureDescriptorDesc> mTextureDescriptorsCache; mUniformsAndXfbDescriptorSetCache;
DescriptorSetCache<vk::TextureDescriptorDesc, VulkanCacheType::TextureDescriptors>
mTextureDescriptorsCache;
// We keep a reference to the pipeline and descriptor set layouts. This ensures they don't get // We keep a reference to the pipeline and descriptor set layouts. This ensures they don't get
// deleted while this program is in use. // deleted while this program is in use.
......
...@@ -576,6 +576,8 @@ void RendererVk::onDestroy(vk::Context *context) ...@@ -576,6 +576,8 @@ void RendererVk::onDestroy(vk::Context *context)
vkDestroyDebugReportCallbackEXT(mInstance, mDebugReportCallback, nullptr); vkDestroyDebugReportCallbackEXT(mInstance, mDebugReportCallback, nullptr);
} }
logCacheStats();
if (mInstance) if (mInstance)
{ {
vkDestroyInstance(mInstance, nullptr); vkDestroyInstance(mInstance, nullptr);
...@@ -2711,6 +2713,21 @@ void RendererVk::recycleCommandBufferHelper(vk::CommandBufferHelper *commandBuff ...@@ -2711,6 +2713,21 @@ void RendererVk::recycleCommandBufferHelper(vk::CommandBufferHelper *commandBuff
mCommandBufferHelperFreeList.push_back(commandBuffer); mCommandBufferHelperFreeList.push_back(commandBuffer);
} }
void RendererVk::logCacheStats() const
{
if (!vk::kOutputCumulativePerfCounters)
{
return;
}
int cacheType = 0;
INFO() << "Vulkan object cache hit ratios: ";
for (const CacheStats &stats : mVulkanCacheStats)
{
INFO() << " CacheType " << cacheType++ << ": " << stats.getHitRatio();
}
}
vk::MemoryReport::MemoryReport() vk::MemoryReport::MemoryReport()
: mCurrentTotalAllocatedMemory(0), : mCurrentTotalAllocatedMemory(0),
mMaxTotalAllocatedMemory(0), mMaxTotalAllocatedMemory(0),
......
...@@ -365,6 +365,14 @@ class RendererVk : angle::NonCopyable ...@@ -365,6 +365,14 @@ class RendererVk : angle::NonCopyable
mMemoryReport.processCallback(callbackData, logCallback); mMemoryReport.processCallback(callbackData, logCallback);
} }
// Accumulate cache stats for a specific cache
void accumulateCacheStats(VulkanCacheType cache, const CacheStats &stats)
{
mVulkanCacheStats[cache].accumulate(stats);
}
// Log cache stats for all caches
void logCacheStats() const;
private: private:
angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex); angle::Result initializeDevice(DisplayVk *displayVk, uint32_t queueFamilyIndex);
void ensureCapsInitialized() const; void ensureCapsInitialized() const;
...@@ -491,6 +499,10 @@ class RendererVk : angle::NonCopyable ...@@ -491,6 +499,10 @@ class RendererVk : angle::NonCopyable
// Process GPU memory reports // Process GPU memory reports
vk::MemoryReport mMemoryReport; vk::MemoryReport mMemoryReport;
// Stats about all Vulkan object caches
using VulkanCacheStats = angle::PackedEnumMap<VulkanCacheType, CacheStats>;
VulkanCacheStats mVulkanCacheStats;
}; };
} // namespace rx } // namespace rx
......
...@@ -573,54 +573,54 @@ void UtilsVk::destroy(RendererVk *renderer) ...@@ -573,54 +573,54 @@ void UtilsVk::destroy(RendererVk *renderer)
for (vk::ShaderProgramHelper &program : mConvertIndexPrograms) for (vk::ShaderProgramHelper &program : mConvertIndexPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mConvertIndirectLineLoopPrograms) for (vk::ShaderProgramHelper &program : mConvertIndirectLineLoopPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mConvertIndexIndirectLineLoopPrograms) for (vk::ShaderProgramHelper &program : mConvertIndexIndirectLineLoopPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mConvertVertexPrograms) for (vk::ShaderProgramHelper &program : mConvertVertexPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
mImageClearProgramVSOnly.destroy(device); mImageClearProgramVSOnly.destroy(renderer);
for (vk::ShaderProgramHelper &program : mImageClearProgram) for (vk::ShaderProgramHelper &program : mImageClearProgram)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mImageCopyPrograms) for (vk::ShaderProgramHelper &program : mImageCopyPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mBlitResolvePrograms) for (vk::ShaderProgramHelper &program : mBlitResolvePrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mBlitResolveStencilNoExportPrograms) for (vk::ShaderProgramHelper &program : mBlitResolveStencilNoExportPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mOverlayCullPrograms) for (vk::ShaderProgramHelper &program : mOverlayCullPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mOverlayDrawPrograms) for (vk::ShaderProgramHelper &program : mOverlayDrawPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (vk::ShaderProgramHelper &program : mGenerateMipmapPrograms) for (vk::ShaderProgramHelper &program : mGenerateMipmapPrograms)
{ {
program.destroy(device); program.destroy(renderer);
} }
for (auto &programIter : mUnresolvePrograms) for (auto &programIter : mUnresolvePrograms)
{ {
vk::ShaderProgramHelper &program = programIter.second; vk::ShaderProgramHelper &program = programIter.second;
program.destroy(device); program.destroy(renderer);
} }
mUnresolvePrograms.clear(); mUnresolvePrograms.clear();
......
...@@ -3199,8 +3199,15 @@ RenderPassCache::~RenderPassCache() ...@@ -3199,8 +3199,15 @@ RenderPassCache::~RenderPassCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void RenderPassCache::destroy(VkDevice device) void RenderPassCache::destroy(RendererVk *rendererVk)
{ {
rendererVk->accumulateCacheStats(VulkanCacheType::CompatibleRenderPass,
mCompatibleRenderPassCacheStats);
rendererVk->accumulateCacheStats(VulkanCacheType::RenderPassWithOps,
mRenderPassWithOpsCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &outerIt : mPayload) for (auto &outerIt : mPayload)
{ {
for (auto &innerIt : outerIt.second) for (auto &innerIt : outerIt.second)
...@@ -3306,8 +3313,12 @@ GraphicsPipelineCache::~GraphicsPipelineCache() ...@@ -3306,8 +3313,12 @@ GraphicsPipelineCache::~GraphicsPipelineCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void GraphicsPipelineCache::destroy(VkDevice device) void GraphicsPipelineCache::destroy(RendererVk *rendererVk)
{ {
rendererVk->accumulateCacheStats(VulkanCacheType::GraphicsPipeline, mCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &item : mPayload) for (auto &item : mPayload)
{ {
vk::PipelineHelper &pipeline = item.second; vk::PipelineHelper &pipeline = item.second;
...@@ -3382,8 +3393,12 @@ DescriptorSetLayoutCache::~DescriptorSetLayoutCache() ...@@ -3382,8 +3393,12 @@ DescriptorSetLayoutCache::~DescriptorSetLayoutCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void DescriptorSetLayoutCache::destroy(VkDevice device) void DescriptorSetLayoutCache::destroy(RendererVk *rendererVk)
{ {
rendererVk->accumulateCacheStats(VulkanCacheType::DescriptorSetLayout, mCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &item : mPayload) for (auto &item : mPayload)
{ {
vk::RefCountedDescriptorSetLayout &layout = item.second; vk::RefCountedDescriptorSetLayout &layout = item.second;
...@@ -3439,8 +3454,12 @@ PipelineLayoutCache::~PipelineLayoutCache() ...@@ -3439,8 +3454,12 @@ PipelineLayoutCache::~PipelineLayoutCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void PipelineLayoutCache::destroy(VkDevice device) void PipelineLayoutCache::destroy(RendererVk *rendererVk)
{ {
rendererVk->accumulateCacheStats(VulkanCacheType::PipelineLayout, mCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &item : mPayload) for (auto &item : mPayload)
{ {
vk::RefCountedPipelineLayout &layout = item.second; vk::RefCountedPipelineLayout &layout = item.second;
...@@ -3526,9 +3545,11 @@ SamplerYcbcrConversionCache::~SamplerYcbcrConversionCache() ...@@ -3526,9 +3545,11 @@ SamplerYcbcrConversionCache::~SamplerYcbcrConversionCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void SamplerYcbcrConversionCache::destroy(RendererVk *renderer) void SamplerYcbcrConversionCache::destroy(RendererVk *rendererVk)
{ {
VkDevice device = renderer->getDevice(); rendererVk->accumulateCacheStats(VulkanCacheType::SamplerYcbcrConversion, mCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &iter : mPayload) for (auto &iter : mPayload)
{ {
...@@ -3536,7 +3557,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *renderer) ...@@ -3536,7 +3557,7 @@ void SamplerYcbcrConversionCache::destroy(RendererVk *renderer)
ASSERT(!yuvSampler.isReferenced()); ASSERT(!yuvSampler.isReferenced());
yuvSampler.get().destroy(device); yuvSampler.get().destroy(device);
renderer->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion); rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::SamplerYcbcrConversion);
} }
mPayload.clear(); mPayload.clear();
...@@ -3595,9 +3616,11 @@ SamplerCache::~SamplerCache() ...@@ -3595,9 +3616,11 @@ SamplerCache::~SamplerCache()
ASSERT(mPayload.empty()); ASSERT(mPayload.empty());
} }
void SamplerCache::destroy(RendererVk *renderer) void SamplerCache::destroy(RendererVk *rendererVk)
{ {
VkDevice device = renderer->getDevice(); rendererVk->accumulateCacheStats(VulkanCacheType::Sampler, mCacheStats);
VkDevice device = rendererVk->getDevice();
for (auto &iter : mPayload) for (auto &iter : mPayload)
{ {
...@@ -3605,7 +3628,7 @@ void SamplerCache::destroy(RendererVk *renderer) ...@@ -3605,7 +3628,7 @@ void SamplerCache::destroy(RendererVk *renderer)
ASSERT(!sampler.isReferenced()); ASSERT(!sampler.isReferenced());
sampler.get().get().destroy(device); sampler.get().get().destroy(device);
renderer->getActiveHandleCounts().onDeallocate(vk::HandleType::Sampler); rendererVk->getActiveHandleCounts().onDeallocate(vk::HandleType::Sampler);
} }
mPayload.clear(); mPayload.clear();
...@@ -3639,6 +3662,12 @@ angle::Result SamplerCache::getSampler(ContextVk *contextVk, ...@@ -3639,6 +3662,12 @@ angle::Result SamplerCache::getSampler(ContextVk *contextVk,
} }
// FramebufferCache implementation. // FramebufferCache implementation.
void FramebufferCache::destroy(RendererVk *rendererVk)
{
rendererVk->accumulateCacheStats(VulkanCacheType::Framebuffer, mCacheStats);
mPayload.clear();
}
bool FramebufferCache::get(ContextVk *contextVk, bool FramebufferCache::get(ContextVk *contextVk,
const vk::FramebufferDesc &desc, const vk::FramebufferDesc &desc,
vk::FramebufferHelper **framebufferHelperOut) vk::FramebufferHelper **framebufferHelperOut)
...@@ -3670,4 +3699,26 @@ void FramebufferCache::clear(ContextVk *contextVk) ...@@ -3670,4 +3699,26 @@ void FramebufferCache::clear(ContextVk *contextVk)
} }
mPayload.clear(); mPayload.clear();
} }
// DriverUniformsDescriptorSetCache implementation.
void DriverUniformsDescriptorSetCache::destroy(RendererVk *rendererVk)
{
rendererVk->accumulateCacheStats(VulkanCacheType::DescriptorSet, mCacheStats);
mPayload.clear();
}
// DescriptorSetCache implementation.
template <typename key, VulkanCacheType cacheType>
void DescriptorSetCache<key, cacheType>::destroy(RendererVk *rendererVk)
{
rendererVk->accumulateCacheStats(cacheType, mCacheStats);
mPayload.clear();
}
// RendererVk's methods are not accessible in vk_cache_utils.h
// Below declarations are needed to avoid linker errors.
template class DescriptorSetCache<vk::TextureDescriptorDesc, VulkanCacheType::TextureDescriptors>;
template class DescriptorSetCache<vk::UniformsAndXfbDesc,
VulkanCacheType::UniformsAndXfbDescriptorSet>;
} // namespace rx } // namespace rx
...@@ -1312,6 +1312,23 @@ ANGLE_VK_SERIAL_OP(ANGLE_HASH_VK_SERIAL) ...@@ -1312,6 +1312,23 @@ ANGLE_VK_SERIAL_OP(ANGLE_HASH_VK_SERIAL)
namespace rx namespace rx
{ {
// Cache types for various Vulkan objects
enum class VulkanCacheType
{
CompatibleRenderPass,
RenderPassWithOps,
GraphicsPipeline,
PipelineLayout,
Sampler,
SamplerYcbcrConversion,
DescriptorSet,
DescriptorSetLayout,
TextureDescriptors,
UniformsAndXfbDescriptorSet,
Framebuffer,
EnumCount
};
// Base class for all caches. Provides cache hit and miss counters. // Base class for all caches. Provides cache hit and miss counters.
class CacheStats final : angle::NonCopyable class CacheStats final : angle::NonCopyable
{ {
...@@ -1321,6 +1338,12 @@ class CacheStats final : angle::NonCopyable ...@@ -1321,6 +1338,12 @@ class CacheStats final : angle::NonCopyable
ANGLE_INLINE void hit() { mHitCount++; } ANGLE_INLINE void hit() { mHitCount++; }
ANGLE_INLINE void miss() { mMissCount++; } ANGLE_INLINE void miss() { mMissCount++; }
ANGLE_INLINE void accumulate(const CacheStats &stats)
{
mHitCount += stats.mHitCount;
mMissCount += stats.mMissCount;
}
ANGLE_INLINE double getHitRatio() const ANGLE_INLINE double getHitRatio() const
{ {
if (mHitCount + mMissCount == 0) if (mHitCount + mMissCount == 0)
...@@ -1345,7 +1368,7 @@ class RenderPassCache final : angle::NonCopyable ...@@ -1345,7 +1368,7 @@ class RenderPassCache final : angle::NonCopyable
RenderPassCache(); RenderPassCache();
~RenderPassCache(); ~RenderPassCache();
void destroy(VkDevice device); void destroy(RendererVk *rendererVk);
ANGLE_INLINE angle::Result getCompatibleRenderPass(ContextVk *contextVk, ANGLE_INLINE angle::Result getCompatibleRenderPass(ContextVk *contextVk,
const vk::RenderPassDesc &desc, const vk::RenderPassDesc &desc,
...@@ -1400,7 +1423,7 @@ class GraphicsPipelineCache final : angle::NonCopyable ...@@ -1400,7 +1423,7 @@ class GraphicsPipelineCache final : angle::NonCopyable
GraphicsPipelineCache(); GraphicsPipelineCache();
~GraphicsPipelineCache(); ~GraphicsPipelineCache();
void destroy(VkDevice device); void destroy(RendererVk *rendererVk);
void release(ContextVk *context); void release(ContextVk *context);
void populate(const vk::GraphicsPipelineDesc &desc, vk::Pipeline &&pipeline); void populate(const vk::GraphicsPipelineDesc &desc, vk::Pipeline &&pipeline);
...@@ -1460,7 +1483,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable ...@@ -1460,7 +1483,7 @@ class DescriptorSetLayoutCache final : angle::NonCopyable
DescriptorSetLayoutCache(); DescriptorSetLayoutCache();
~DescriptorSetLayoutCache(); ~DescriptorSetLayoutCache();
void destroy(VkDevice device); void destroy(RendererVk *rendererVk);
angle::Result getDescriptorSetLayout( angle::Result getDescriptorSetLayout(
vk::Context *context, vk::Context *context,
...@@ -1478,7 +1501,7 @@ class PipelineLayoutCache final : angle::NonCopyable ...@@ -1478,7 +1501,7 @@ class PipelineLayoutCache final : angle::NonCopyable
PipelineLayoutCache(); PipelineLayoutCache();
~PipelineLayoutCache(); ~PipelineLayoutCache();
void destroy(VkDevice device); void destroy(RendererVk *rendererVk);
angle::Result getPipelineLayout(vk::Context *context, angle::Result getPipelineLayout(vk::Context *context,
const vk::PipelineLayoutDesc &desc, const vk::PipelineLayoutDesc &desc,
...@@ -1496,7 +1519,7 @@ class SamplerCache final : angle::NonCopyable ...@@ -1496,7 +1519,7 @@ class SamplerCache final : angle::NonCopyable
SamplerCache(); SamplerCache();
~SamplerCache(); ~SamplerCache();
void destroy(RendererVk *renderer); void destroy(RendererVk *rendererVk);
angle::Result getSampler(ContextVk *contextVk, angle::Result getSampler(ContextVk *contextVk,
const vk::SamplerDesc &desc, const vk::SamplerDesc &desc,
...@@ -1514,7 +1537,7 @@ class SamplerYcbcrConversionCache final : angle::NonCopyable ...@@ -1514,7 +1537,7 @@ class SamplerYcbcrConversionCache final : angle::NonCopyable
SamplerYcbcrConversionCache(); SamplerYcbcrConversionCache();
~SamplerYcbcrConversionCache(); ~SamplerYcbcrConversionCache();
void destroy(RendererVk *render); void destroy(RendererVk *rendererVk);
angle::Result getYuvConversion( angle::Result getYuvConversion(
vk::Context *context, vk::Context *context,
...@@ -1535,6 +1558,8 @@ class FramebufferCache final : angle::NonCopyable ...@@ -1535,6 +1558,8 @@ class FramebufferCache final : angle::NonCopyable
FramebufferCache() = default; FramebufferCache() = default;
~FramebufferCache() { ASSERT(mPayload.empty()); } ~FramebufferCache() { ASSERT(mPayload.empty()); }
void destroy(RendererVk *rendererVk);
bool get(ContextVk *contextVk, bool get(ContextVk *contextVk,
const vk::FramebufferDesc &desc, const vk::FramebufferDesc &desc,
vk::FramebufferHelper **framebufferOut); vk::FramebufferHelper **framebufferOut);
...@@ -1553,6 +1578,8 @@ class DriverUniformsDescriptorSetCache final : angle::NonCopyable ...@@ -1553,6 +1578,8 @@ class DriverUniformsDescriptorSetCache final : angle::NonCopyable
DriverUniformsDescriptorSetCache() = default; DriverUniformsDescriptorSetCache() = default;
~DriverUniformsDescriptorSetCache() { ASSERT(mPayload.empty()); } ~DriverUniformsDescriptorSetCache() { ASSERT(mPayload.empty()); }
void destroy(RendererVk *rendererVk);
ANGLE_INLINE bool get(uint32_t serial, VkDescriptorSet *descriptorSet) ANGLE_INLINE bool get(uint32_t serial, VkDescriptorSet *descriptorSet)
{ {
if (mPayload.get(serial, descriptorSet)) if (mPayload.get(serial, descriptorSet))
...@@ -1577,13 +1604,15 @@ class DriverUniformsDescriptorSetCache final : angle::NonCopyable ...@@ -1577,13 +1604,15 @@ class DriverUniformsDescriptorSetCache final : angle::NonCopyable
}; };
// Templated Descriptors Cache // Templated Descriptors Cache
template <typename key> template <typename key, VulkanCacheType cacheType>
class DescriptorSetCache final : angle::NonCopyable class DescriptorSetCache final : angle::NonCopyable
{ {
public: public:
DescriptorSetCache() = default; DescriptorSetCache() = default;
~DescriptorSetCache() { ASSERT(mPayload.empty()); } ~DescriptorSetCache() { ASSERT(mPayload.empty()); }
void destroy(RendererVk *rendererVk);
ANGLE_INLINE bool get(const key &desc, VkDescriptorSet *descriptorSet) ANGLE_INLINE bool get(const key &desc, VkDescriptorSet *descriptorSet)
{ {
auto iter = mPayload.find(desc); auto iter = mPayload.find(desc);
...@@ -1602,8 +1631,6 @@ class DescriptorSetCache final : angle::NonCopyable ...@@ -1602,8 +1631,6 @@ class DescriptorSetCache final : angle::NonCopyable
mPayload.emplace(desc, descriptorSet); mPayload.emplace(desc, descriptorSet);
} }
ANGLE_INLINE void clear() { mPayload.clear(); }
private: private:
angle::HashMap<key, VkDescriptorSet> mPayload; angle::HashMap<key, VkDescriptorSet> mPayload;
CacheStats mCacheStats; CacheStats mCacheStats;
......
...@@ -7044,10 +7044,10 @@ bool ShaderProgramHelper::valid(const gl::ShaderType shaderType) const ...@@ -7044,10 +7044,10 @@ bool ShaderProgramHelper::valid(const gl::ShaderType shaderType) const
return mShaders[shaderType].valid(); return mShaders[shaderType].valid();
} }
void ShaderProgramHelper::destroy(VkDevice device) void ShaderProgramHelper::destroy(RendererVk *rendererVk)
{ {
mGraphicsPipelines.destroy(device); mGraphicsPipelines.destroy(rendererVk);
mComputePipeline.destroy(device); mComputePipeline.destroy(rendererVk->getDevice());
for (BindingPointer<ShaderAndSerial> &shader : mShaders) for (BindingPointer<ShaderAndSerial> &shader : mShaders)
{ {
shader.reset(); shader.reset();
......
...@@ -2288,7 +2288,7 @@ class ShaderProgramHelper : angle::NonCopyable ...@@ -2288,7 +2288,7 @@ class ShaderProgramHelper : angle::NonCopyable
~ShaderProgramHelper(); ~ShaderProgramHelper();
bool valid(const gl::ShaderType shaderType) const; bool valid(const gl::ShaderType shaderType) const;
void destroy(VkDevice device); void destroy(RendererVk *rendererVk);
void release(ContextVk *contextVk); void release(ContextVk *contextVk);
ShaderAndSerial &getShader(gl::ShaderType shaderType) { return mShaders[shaderType].get(); } ShaderAndSerial &getShader(gl::ShaderType shaderType) { return mShaders[shaderType].get(); }
......
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