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

Unified Diff: tools/gpu/gl/GLFenceSync.cpp

Issue 2383383002: Move GPU fences into sk_gpu_test (Closed)
Patch Set: Move GPU fences into sk_gpu_test Created 4 years, 2 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
Index: tools/gpu/gl/GLFenceSync.cpp
diff --git a/tools/gpu/gl/GLFenceSync.cpp b/tools/gpu/gl/GLFenceSync.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a4f9c65c8c6d5d4c866d7a46ff8e8857aaa3985c
--- /dev/null
+++ b/tools/gpu/gl/GLFenceSync.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GLFenceSync.h"
+
+#include "GLTestContext.h"
+#include "gl/GrGLUtil.h"
+
+namespace sk_gpu_test {
+
+GLFenceSync* GLFenceSync::CreateIfSupported(const GLTestContext* ctx) {
+ SkAutoTDelete<GLFenceSync> ret(new GLFenceSync);
+
+ if (kGL_GrGLStandard == ctx->gl()->fStandard) {
+ const GrGLubyte* versionStr;
+ GR_GL_CALL_RET(ctx->gl(), versionStr, GetString(GR_GL_VERSION));
+ if (GrGLGetVersion(ctx->gl()) < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) {
+ return nullptr;
+ }
+ ret->fGLFenceSync = reinterpret_cast<GLFenceSyncProc>(
+ ctx->onPlatformGetProcAddress("glFenceSync"));
+ ret->fGLClientWaitSync = reinterpret_cast<GLClientWaitSyncProc>(
+ ctx->onPlatformGetProcAddress("glClientWaitSync"));
+ ret->fGLDeleteSync = reinterpret_cast<GLDeleteSyncProc>(
+ ctx->onPlatformGetProcAddress("glDeleteSync"));
+ } else {
+ if (!ctx->gl()->hasExtension("GL_APPLE_sync")) {
+ return nullptr;
+ }
+ ret->fGLFenceSync = reinterpret_cast<GLFenceSyncProc>(
+ ctx->onPlatformGetProcAddress("glFenceSyncAPPLE"));
+ ret->fGLClientWaitSync = reinterpret_cast<GLClientWaitSyncProc>(
+ ctx->onPlatformGetProcAddress("glClientWaitSyncAPPLE"));
+ ret->fGLDeleteSync = reinterpret_cast<GLDeleteSyncProc>(
+ ctx->onPlatformGetProcAddress("glDeleteSyncAPPLE"));
+ }
+
+ if (!ret->fGLFenceSync || !ret->fGLClientWaitSync || !ret->fGLDeleteSync) {
+ return nullptr;
+ }
+
+ return ret.release();
+}
+
+PlatformFence GLFenceSync::insertFence() const {
+ return reinterpret_cast<PlatformFence>(fGLFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
+}
+
+bool GLFenceSync::waitFence(PlatformFence fence) const {
+ GLsync glsync = reinterpret_cast<GLsync>(fence);
+ return GL_WAIT_FAILED != fGLClientWaitSync(glsync, GL_SYNC_FLUSH_COMMANDS_BIT, -1);
+}
+
+void GLFenceSync::deleteFence(PlatformFence fence) const {
+ GLsync glsync = reinterpret_cast<GLsync>(fence);
+ fGLDeleteSync(glsync);
+}
+
+} // namespace sk_gpu_test

Powered by Google App Engine
This is Rietveld 408576698