aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-06-26 11:26:44 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-26 17:30:53 +0000
commit21580ba3aeefe661bab5a16135e8e5bb986556e5 (patch)
treec9ca69cd2e67401783c78c5aa77df420755cb6ac
parenta57488a1f5c14c2114c57880b85c1bbc90024973 (diff)
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>
-rw-r--r--src/gpu/vk/GrVkResource.h14
-rw-r--r--src/gpu/vk/GrVkResourceProvider.cpp1
-rw-r--r--src/gpu/vk/GrVkSemaphore.cpp2
-rw-r--r--src/gpu/vk/GrVkSemaphore.h14
4 files changed, 19 insertions, 12 deletions
diff --git a/src/gpu/vk/GrVkResource.h b/src/gpu/vk/GrVkResource.h
index 9ddde474c1..4b42ecbf3e 100644
--- a/src/gpu/vk/GrVkResource.h
+++ b/src/gpu/vk/GrVkResource.h
@@ -59,7 +59,6 @@ public:
private:
SkTHashSet<const GrVkResource*, GrVkResource::Hash> fHashSet;
};
- static Trace fTrace;
static uint32_t fKeyCounter;
#endif
@@ -69,7 +68,7 @@ public:
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 @@ public:
#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 @@ private:
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 @@ private:
void internal_dispose() const {
this->abandonGPUData();
#ifdef SK_TRACE_VK_RESOURCES
- fTrace.remove(this);
+ GetTrace()->remove(this);
#endif
SkASSERT(0 == fRefCnt);
fRefCnt = 1;
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp
index b4290ce6f0..10b41d6f76 100644
--- a/src/gpu/vk/GrVkResourceProvider.cpp
+++ b/src/gpu/vk/GrVkResourceProvider.cpp
@@ -18,7 +18,6 @@
#include "GrVkUtil.h"
#ifdef SK_TRACE_VK_RESOURCES
-GrVkResource::Trace GrVkResource::fTrace;
uint32_t GrVkResource::fKeyCounter = 0;
#endif
diff --git a/src/gpu/vk/GrVkSemaphore.cpp b/src/gpu/vk/GrVkSemaphore.cpp
index 4a23c43eea..c794f7a818 100644
--- a/src/gpu/vk/GrVkSemaphore.cpp
+++ b/src/gpu/vk/GrVkSemaphore.cpp
@@ -16,8 +16,6 @@
#undef CreateSemaphore
#endif
-SkMutex GrVkSemaphore::Resource::gMutex;
-
sk_sp<GrVkSemaphore> GrVkSemaphore::Make(const GrVkGpu* gpu, bool isOwned) {
VkSemaphoreCreateInfo createInfo;
memset(&createInfo, 0, sizeof(VkSemaphoreCreateInfo));
diff --git a/src/gpu/vk/GrVkSemaphore.h b/src/gpu/vk/GrVkSemaphore.h
index 36d1e6ee5d..8f39e1785e 100644
--- a/src/gpu/vk/GrVkSemaphore.h
+++ b/src/gpu/vk/GrVkSemaphore.h
@@ -44,8 +44,8 @@ public:
VkSemaphore semaphore() const { return fSemaphore; }
- static void AcquireMutex() { gMutex.acquire(); }
- static void ReleaseMutex() { gMutex.release(); }
+ static void AcquireMutex() { GetMutex()->acquire(); }
+ static void ReleaseMutex() { GetMutex()->release(); }
bool shouldSignal() const {
return !fHasBeenSubmittedToQueueForSignal;
@@ -55,11 +55,11 @@ public:
}
void markAsSignaled() {
- gMutex.assertHeld();
+ GetMutex()->assertHeld();
fHasBeenSubmittedToQueueForSignal = true;
}
void markAsWaited() {
- gMutex.assertHeld();
+ GetMutex()->assertHeld();
fHasBeenSubmittedToQueueForWait = true;
}
@@ -71,7 +71,11 @@ public:
private:
void freeGPUData(const GrVkGpu* gpu) const override;
- static SkMutex gMutex;
+ static SkMutex* GetMutex() {
+ static SkMutex kMutex;
+ return &kMutex;
+ }
+
VkSemaphore fSemaphore;
bool fHasBeenSubmittedToQueueForSignal;
bool fHasBeenSubmittedToQueueForWait;