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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "GLFenceSync.h"
9
10 #include "GLTestContext.h"
11 #include "gl/GrGLUtil.h"
12
13 namespace sk_gpu_test {
14
15 GLFenceSync* GLFenceSync::CreateIfSupported(const GLTestContext* ctx) {
16 SkAutoTDelete<GLFenceSync> ret(new GLFenceSync);
17
18 if (kGL_GrGLStandard == ctx->gl()->fStandard) {
19 const GrGLubyte* versionStr;
20 GR_GL_CALL_RET(ctx->gl(), versionStr, GetString(GR_GL_VERSION));
21 if (GrGLGetVersion(ctx->gl()) < GR_GL_VER(3,2) && !ctx->gl()->hasExtensi on("GL_ARB_sync")) {
22 return nullptr;
23 }
24 ret->fGLFenceSync = reinterpret_cast<GLFenceSyncProc>(
25 ctx->onPlatformGetProcAddress("glFenceSync"));
26 ret->fGLClientWaitSync = reinterpret_cast<GLClientWaitSyncProc>(
27 ctx->onPlatformGetProcAddress("glClientWaitSync"));
28 ret->fGLDeleteSync = reinterpret_cast<GLDeleteSyncProc>(
29 ctx->onPlatformGetProcAddress("glDeleteSync"));
30 } else {
31 if (!ctx->gl()->hasExtension("GL_APPLE_sync")) {
32 return nullptr;
33 }
34 ret->fGLFenceSync = reinterpret_cast<GLFenceSyncProc>(
35 ctx->onPlatformGetProcAddress("glFenceSyncAPPLE"));
36 ret->fGLClientWaitSync = reinterpret_cast<GLClientWaitSyncProc>(
37 ctx->onPlatformGetProcAddress("glClientWaitSyncAPPLE"));
38 ret->fGLDeleteSync = reinterpret_cast<GLDeleteSyncProc>(
39 ctx->onPlatformGetProcAddress("glDeleteSyncAPPLE"));
40 }
41
42 if (!ret->fGLFenceSync || !ret->fGLClientWaitSync || !ret->fGLDeleteSync) {
43 return nullptr;
44 }
45
46 return ret.release();
47 }
48
49 PlatformFence GLFenceSync::insertFence() const {
50 return reinterpret_cast<PlatformFence>(fGLFenceSync(GL_SYNC_GPU_COMMANDS_COM PLETE, 0));
51 }
52
53 bool GLFenceSync::waitFence(PlatformFence fence) const {
54 GLsync glsync = reinterpret_cast<GLsync>(fence);
55 return GL_WAIT_FAILED != fGLClientWaitSync(glsync, GL_SYNC_FLUSH_COMMANDS_BI T, -1);
56 }
57
58 void GLFenceSync::deleteFence(PlatformFence fence) const {
59 GLsync glsync = reinterpret_cast<GLsync>(fence);
60 fGLDeleteSync(glsync);
61 }
62
63 } // namespace sk_gpu_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698