Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Unified Diff: src/gpu/vk/GrVkResourceProvider.cpp

Issue 1765523002: Add a cache of GrVkSamplers in GrVkResourceProvider. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nits Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkResourceProvider.h ('k') | src/gpu/vk/GrVkSampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkResourceProvider.cpp
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index 19bda4152514af6e38c3cd6788740cd52886c25d..44410eed0d48105073963f4d94ea1483318aeaa6 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -7,9 +7,11 @@
#include "GrVkResourceProvider.h"
+#include "GrTextureParams.h"
#include "GrVkCommandBuffer.h"
#include "GrVkPipeline.h"
#include "GrVkRenderPass.h"
+#include "GrVkSampler.h"
#include "GrVkUtil.h"
#ifdef SK_TRACE_VK_RESOURCES
@@ -81,6 +83,17 @@ GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool(
return new GrVkDescriptorPool(fGpu, typeCounts);
}
+GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(const GrTextureParams& params) {
+ GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params));
+ if (!sampler) {
+ sampler = GrVkSampler::Create(fGpu, params);
+ fSamplers.add(sampler);
+ }
+ SkASSERT(sampler);
+ sampler->ref();
+ return sampler;
+}
+
GrVkCommandBuffer* GrVkResourceProvider::createCommandBuffer() {
GrVkCommandBuffer* cmdBuffer = GrVkCommandBuffer::Create(fGpu, fGpu->cmdPool());
fActiveCommandBuffers.push_back(cmdBuffer);
@@ -112,6 +125,13 @@ void GrVkResourceProvider::destroyResources() {
}
fSimpleRenderPasses.reset();
+ // Iterate through all store GrVkSamplers and unref them before resetting the hash.
+ SkTDynamicHash<GrVkSampler, uint8_t>::Iter iter(&fSamplers);
+ for (; !iter.done(); ++iter) {
+ (*iter).unref(fGpu);
+ }
+ fSamplers.reset();
+
#ifdef SK_TRACE_VK_RESOURCES
SkASSERT(0 == GrVkResource::fTrace.count());
#endif
@@ -133,6 +153,13 @@ void GrVkResourceProvider::abandonResources() {
}
fSimpleRenderPasses.reset();
+ // Iterate through all store GrVkSamplers and unrefAndAbandon them before resetting the hash.
+ SkTDynamicHash<GrVkSampler, uint8_t>::Iter iter(&fSamplers);
+ for (; !iter.done(); ++iter) {
+ (*iter).unrefAndAbandon();
+ }
+ fSamplers.reset();
+
#ifdef SK_TRACE_VK_RESOURCES
SkASSERT(0 == GrVkResource::fTrace.count());
#endif
« no previous file with comments | « src/gpu/vk/GrVkResourceProvider.h ('k') | src/gpu/vk/GrVkSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698