aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tools/gpu/FenceSync.h2
-rw-r--r--tools/gpu/gl/GLTestContext.cpp63
2 files changed, 61 insertions, 4 deletions
diff --git a/tools/gpu/FenceSync.h b/tools/gpu/FenceSync.h
index b430f5dfa9..4fe724a15b 100644
--- a/tools/gpu/FenceSync.h
+++ b/tools/gpu/FenceSync.h
@@ -26,6 +26,8 @@ public:
virtual bool waitFence(PlatformFence) const = 0;
virtual void deleteFence(PlatformFence) const = 0;
+ virtual bool validate() const { return true; }
+
virtual ~FenceSync() {}
};
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp
index 4375346892..76e38b71b4 100644
--- a/tools/gpu/gl/GLTestContext.cpp
+++ b/tools/gpu/gl/GLTestContext.cpp
@@ -15,7 +15,7 @@ namespace {
class GLFenceSync : public sk_gpu_test::FenceSync {
public:
- static std::unique_ptr<GLFenceSync> MakeIfSupported(const sk_gpu_test::GLTestContext*);
+ static std::unique_ptr<FenceSync> MakeIfSupported(const sk_gpu_test::GLTestContext*);
sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override;
bool waitFence(sk_gpu_test::PlatformFence fence) const override;
@@ -24,7 +24,7 @@ public:
private:
GLFenceSync(const sk_gpu_test::GLTestContext*, const char* ext = "");
- bool validate() { return fGLFenceSync && fGLClientWaitSync && fGLDeleteSync; }
+ bool validate() const override { return fGLFenceSync && fGLClientWaitSync && fGLDeleteSync; }
static constexpr GrGLenum GL_SYNC_GPU_COMMANDS_COMPLETE = 0x9117;
static constexpr GrGLenum GL_WAIT_FAILED = 0x911d;
@@ -44,8 +44,37 @@ private:
typedef FenceSync INHERITED;
};
-std::unique_ptr<GLFenceSync> GLFenceSync::MakeIfSupported(const sk_gpu_test::GLTestContext* ctx) {
- std::unique_ptr<GLFenceSync> ret;
+class GLNVFenceSync : public sk_gpu_test::FenceSync {
+public:
+ GLNVFenceSync(const sk_gpu_test::GLTestContext*);
+
+ sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override;
+ bool waitFence(sk_gpu_test::PlatformFence fence) const override;
+ void deleteFence(sk_gpu_test::PlatformFence fence) const override;
+
+private:
+ bool validate() const override {
+ return fGLGenFencesNV && fGLDeleteFencesNV && fGLSetFenceNV && fGLFinishFenceNV;
+ }
+
+ static constexpr GrGLenum GL_ALL_COMPLETED_NV = 0x84F2;
+
+ typedef GrGLvoid(GR_GL_FUNCTION_TYPE* GLGenFencesNVProc) (GrGLsizei, GrGLuint*);
+ typedef GrGLvoid(GR_GL_FUNCTION_TYPE* GLDeleteFencesNVProc) (GrGLsizei, const GrGLuint*);
+ typedef GrGLvoid(GR_GL_FUNCTION_TYPE* GLSetFenceNVProc) (GrGLuint, GrGLenum);
+ typedef GrGLvoid(GR_GL_FUNCTION_TYPE* GLFinishFenceNVProc) (GrGLuint);
+
+ GLGenFencesNVProc fGLGenFencesNV;
+ GLDeleteFencesNVProc fGLDeleteFencesNV;
+ GLSetFenceNVProc fGLSetFenceNV;
+ GLFinishFenceNVProc fGLFinishFenceNV;
+
+ typedef FenceSync INHERITED;
+};
+
+std::unique_ptr<sk_gpu_test::FenceSync> GLFenceSync::MakeIfSupported(
+ const sk_gpu_test::GLTestContext* ctx) {
+ std::unique_ptr<FenceSync> ret;
if (kGL_GrGLStandard == ctx->gl()->fStandard) {
if (GrGLGetVersion(ctx->gl()) < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) {
return nullptr;
@@ -54,6 +83,8 @@ std::unique_ptr<GLFenceSync> GLFenceSync::MakeIfSupported(const sk_gpu_test::GLT
} else {
if (ctx->gl()->hasExtension("GL_APPLE_sync")) {
ret.reset(new GLFenceSync(ctx, "APPLE"));
+ } else if (ctx->gl()->hasExtension("GL_NV_fence")) {
+ ret.reset(new GLNVFenceSync(ctx));
} else if (GrGLGetVersion(ctx->gl()) >= GR_GL_VER(3, 0)) {
ret.reset(new GLFenceSync(ctx));
} else {
@@ -87,6 +118,30 @@ void GLFenceSync::deleteFence(sk_gpu_test::PlatformFence fence) const {
fGLDeleteSync(glsync);
}
+GLNVFenceSync::GLNVFenceSync(const sk_gpu_test::GLTestContext* ctx) {
+ ctx->getGLProcAddress(&fGLGenFencesNV, "glGenFencesNV");
+ ctx->getGLProcAddress(&fGLDeleteFencesNV, "glDeleteFencesNV");
+ ctx->getGLProcAddress(&fGLSetFenceNV, "glSetFenceNV");
+ ctx->getGLProcAddress(&fGLFinishFenceNV, "glFinishFenceNV");
+}
+
+sk_gpu_test::PlatformFence GLNVFenceSync::insertFence() const {
+ GrGLuint fence;
+ fGLGenFencesNV(1, &fence);
+ fGLSetFenceNV(fence, GL_ALL_COMPLETED_NV);
+ return fence;
+}
+
+bool GLNVFenceSync::waitFence(sk_gpu_test::PlatformFence fence) const {
+ fGLFinishFenceNV(fence);
+ return true;
+}
+
+void GLNVFenceSync::deleteFence(sk_gpu_test::PlatformFence fence) const {
+ GrGLuint glFence = static_cast<GrGLuint>(fence);
+ fGLDeleteFencesNV(1, &glFence);
+}
+
class GLGpuTimer : public sk_gpu_test::GpuTimer {
public:
static std::unique_ptr<GLGpuTimer> MakeIfSupported(const sk_gpu_test::GLTestContext*);