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

Unified Diff: src/gpu/vk/GrVkResource.h

Issue 2194823003: Use HashSet instead of Dynamic hash for tracking vulkan resources (Closed) Base URL: https://skia.googlesource.com/skia.git@mergeProgDesc
Patch Set: review cleanup Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkResource.h
diff --git a/src/gpu/vk/GrVkResource.h b/src/gpu/vk/GrVkResource.h
index fde3e377127b7a67a47ee654c860061bb0ca49d8..3bb5ff777de5507a075ba43dc4992d6676f81984 100644
--- a/src/gpu/vk/GrVkResource.h
+++ b/src/gpu/vk/GrVkResource.h
@@ -9,8 +9,8 @@
#define GrVkResource_DEFINED
#include "SkAtomics.h"
-#include "SkTDynamicHash.h"
#include "SkRandom.h"
+#include "SkTHash.h"
class GrVkGpu;
@@ -38,25 +38,26 @@ class GrVkResource : SkNoncopyable {
public:
// Simple refCount tracing, to ensure that everything ref'ed is unref'ed.
#ifdef SK_TRACE_VK_RESOURCES
- static const uint32_t& GetKey(const GrVkResource& r) { return r.fKey; }
- static uint32_t Hash(const uint32_t& k) { return k; }
+ struct Hash {
+ uint32_t operator()(const GrVkResource* const& r) const {
+ SkASSERT(r);
+ return r->fKey;
+ }
+ };
class Trace {
public:
~Trace() {
- if (fHash.count()) {
- SkTDynamicHash<GrVkResource, uint32_t>::Iter iter(&fHash);
- for (; !iter.done(); ++iter) {
- (*iter).dumpInfo();
- }
- }
- SkASSERT(0 == fHash.count());
+ fHashSet.foreach([](const GrVkResource* r) {
+ r->dumpInfo();
+ });
+ SkASSERT(0 == fHashSet.count());
}
- void add(GrVkResource* r) { fHash.add(r); }
- void remove(const GrVkResource* r) { fHash.remove(GetKey(*r)); }
+ void add(const GrVkResource* r) { fHashSet.add(r); }
+ void remove(const GrVkResource* r) { fHashSet.remove(r); }
private:
- SkTDynamicHash<GrVkResource, uint32_t> fHash;
+ SkTHashSet<const GrVkResource*, GrVkResource::Hash> fHashSet;
};
static Trace fTrace;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698