Fix some static intializers in Vulkan code.
Bug: skia:
Change-Id: Ia5160376ff456874459430e51c2f57acdb1a4de1
Reviewed-on: https://skia-review.googlesource.com/137584
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Chris Blume <cblume@chromium.org>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/vk/GrVkResource.h b/src/gpu/vk/GrVkResource.h
index 9ddde47..4b42ecb 100644
--- a/src/gpu/vk/GrVkResource.h
+++ b/src/gpu/vk/GrVkResource.h
@@ -59,7 +59,6 @@
private:
SkTHashSet<const GrVkResource*, GrVkResource::Hash> fHashSet;
};
- static Trace fTrace;
static uint32_t fKeyCounter;
#endif
@@ -69,7 +68,7 @@
GrVkResource() : fRefCnt(1) {
#ifdef SK_TRACE_VK_RESOURCES
fKey = sk_atomic_fetch_add(&fKeyCounter, 1u, sk_memory_order_relaxed);
- fTrace.add(this);
+ GetTrace()->add(this);
#endif
}
@@ -148,6 +147,13 @@
#endif
private:
+#ifdef SK_TRACE_VK_RESOURCES
+ static Trace* GetTrace() {
+ static Trace kTrace;
+ return &kTrace;
+ }
+#endif
+
/** Must be implemented by any subclasses.
* Deletes any Vk data associated with this resource
*/
@@ -166,7 +172,7 @@
void internal_dispose(const GrVkGpu* gpu) const {
this->freeGPUData(gpu);
#ifdef SK_TRACE_VK_RESOURCES
- fTrace.remove(this);
+ GetTrace()->remove(this);
#endif
SkASSERT(0 == fRefCnt);
fRefCnt = 1;
@@ -179,7 +185,7 @@
void internal_dispose() const {
this->abandonGPUData();
#ifdef SK_TRACE_VK_RESOURCES
- fTrace.remove(this);
+ GetTrace()->remove(this);
#endif
SkASSERT(0 == fRefCnt);
fRefCnt = 1;