aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-07-07 08:21:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-07 08:21:48 -0700
commitd5f6e9a759891473b8211efb90f665b14a85b830 (patch)
treefc7a47e8c29943d38687c72334b5dcfe59b4cd7b /src/gpu
parent6e46eea63efdede18525ff7b7097e611d3986d0d (diff)
Only check resource tracking on program shutdown, not context shutdown
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/vk/GrVkBuffer.cpp2
-rw-r--r--src/gpu/vk/GrVkResource.h25
-rw-r--r--src/gpu/vk/GrVkResourceProvider.cpp22
3 files changed, 24 insertions, 25 deletions
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp
index e8fe619a43..85d6de8b01 100644
--- a/src/gpu/vk/GrVkBuffer.cpp
+++ b/src/gpu/vk/GrVkBuffer.cpp
@@ -153,7 +153,7 @@ void GrVkBuffer::vkUnmap(GrVkGpu* gpu) {
VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory));
} else {
gpu->updateBuffer(this, fMapPtr, this->size());
- delete (unsigned char*) fMapPtr;
+ delete [] (unsigned char*)fMapPtr;
}
fMapPtr = nullptr;
diff --git a/src/gpu/vk/GrVkResource.h b/src/gpu/vk/GrVkResource.h
index d42ec70d76..3999749b6e 100644
--- a/src/gpu/vk/GrVkResource.h
+++ b/src/gpu/vk/GrVkResource.h
@@ -40,7 +40,26 @@ public:
#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; }
- static SkTDynamicHash<GrVkResource, uint32_t> fTrace;
+
+ class Trace {
+ public:
+ ~Trace() {
+ if (fHash.count()) {
+ SkTDynamicHash<GrVkResource, uint32_t>::Iter iter(&fHash);
+ for (; !iter.done(); ++iter) {
+ (*iter).dumpInfo();
+ }
+ }
+ SkASSERT(0 == fHash.count());
+ }
+ void add(GrVkResource* r) { fHash.add(r); }
+ void remove(const GrVkResource* r) { fHash.remove(GetKey(*r)); }
+
+ private:
+ SkTDynamicHash<GrVkResource, uint32_t> fHash;
+ };
+ static Trace fTrace;
+
static SkRandom fRandom;
#endif
@@ -144,7 +163,7 @@ private:
void internal_dispose(const GrVkGpu* gpu) const {
this->freeGPUData(gpu);
#ifdef SK_TRACE_VK_RESOURCES
- fTrace.remove(GetKey(*this));
+ fTrace.remove(this);
#endif
SkASSERT(0 == fRefCnt);
fRefCnt = 1;
@@ -157,7 +176,7 @@ private:
void internal_dispose() const {
this->abandonSubResources();
#ifdef SK_TRACE_VK_RESOURCES
- fTrace.remove(GetKey(*this));
+ fTrace.remove(this);
#endif
SkASSERT(0 == fRefCnt);
fRefCnt = 1;
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index c7a66caf4e..c83c6a4711 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -15,7 +15,7 @@
#include "GrVkUtil.h"
#ifdef SK_TRACE_VK_RESOURCES
-SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace;
+GrVkResource::Trace GrVkResource::fTrace;
SkRandom GrVkResource::fRandom;
#endif
@@ -314,16 +314,6 @@ void GrVkResourceProvider::destroyResources() {
fUniformDescLayout = VK_NULL_HANDLE;
}
fUniformDescPool->unref(fGpu);
-
-#ifdef SK_TRACE_VK_RESOURCES
- if (GrVkResource::fTrace.count()) {
- SkTDynamicHash<GrVkResource, uint32_t>::Iter iter(&GrVkResource::fTrace);
- for (; !iter.done(); ++iter) {
- (*iter).dumpInfo();
- }
- }
- SkASSERT(0 == GrVkResource::fTrace.count());
-#endif
}
void GrVkResourceProvider::abandonResources() {
@@ -368,16 +358,6 @@ void GrVkResourceProvider::abandonResources() {
fUniformDescLayout = VK_NULL_HANDLE;
fUniformDescPool->unrefAndAbandon();
-
-#ifdef SK_TRACE_VK_RESOURCES
- if (GrVkResource::fTrace.count()) {
- SkTDynamicHash<GrVkResource, uint32_t>::Iter iter(&GrVkResource::fTrace);
- for (; !iter.done(); ++iter) {
- (*iter).dumpInfo();
- }
- }
- SkASSERT(0 == GrVkResource::fTrace.count());
-#endif
}
////////////////////////////////////////////////////////////////////////////////