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

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

Issue 2390383002: Revert of skpbench: add option for gpu timing (Closed)
Patch Set: 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
« no previous file with comments | « tools/gpu/TestContext.cpp ('k') | tools/skpbench/_benchresult.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gpu/gl/GLTestContext.cpp
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp
index dc8966b2969465977baa03525d28ce2f923afea1..1d53bbcd83f70ece2d3b9cd6c4b79c4698764450 100644
--- a/tools/gpu/gl/GLTestContext.cpp
+++ b/tools/gpu/gl/GLTestContext.cpp
@@ -6,8 +6,6 @@
*/
#include "GLTestContext.h"
-
-#include "GpuTimer.h"
#include "gl/GrGLUtil.h"
namespace {
@@ -79,133 +77,6 @@
fGLDeleteSync(glsync);
}
-class GLGpuTimer : public sk_gpu_test::GpuTimer {
-public:
- static GLGpuTimer* CreateIfSupported(const sk_gpu_test::GLTestContext*);
-
- QueryStatus checkQueryStatus(sk_gpu_test::PlatformTimerQuery) override;
- std::chrono::nanoseconds getTimeElapsed(sk_gpu_test::PlatformTimerQuery) override;
- void deleteQuery(sk_gpu_test::PlatformTimerQuery) override;
-
-private:
- GLGpuTimer(bool disjointSupport, const sk_gpu_test::GLTestContext*, const char* ext = "");
-
- bool validate() const;
-
- sk_gpu_test::PlatformTimerQuery onQueueTimerStart() const override;
- void onQueueTimerStop(sk_gpu_test::PlatformTimerQuery) const override;
-
- static constexpr GrGLenum GL_QUERY_RESULT = 0x8866;
- static constexpr GrGLenum GL_QUERY_RESULT_AVAILABLE = 0x8867;
- static constexpr GrGLenum GL_TIME_ELAPSED = 0x88bf;
- static constexpr GrGLenum GL_GPU_DISJOINT = 0x8fbb;
-
- typedef void (GR_GL_FUNCTION_TYPE* GLGetIntegervProc) (GrGLenum, GrGLint*);
- typedef void (GR_GL_FUNCTION_TYPE* GLGenQueriesProc) (GrGLsizei, GrGLuint*);
- typedef void (GR_GL_FUNCTION_TYPE* GLDeleteQueriesProc) (GrGLsizei, const GrGLuint*);
- typedef void (GR_GL_FUNCTION_TYPE* GLBeginQueryProc) (GrGLenum, GrGLuint);
- typedef void (GR_GL_FUNCTION_TYPE* GLEndQueryProc) (GrGLenum);
- typedef void (GR_GL_FUNCTION_TYPE* GLGetQueryObjectuivProc) (GrGLuint, GrGLenum, GrGLuint*);
- typedef void (GR_GL_FUNCTION_TYPE* GLGetQueryObjectui64vProc) (GrGLuint, GrGLenum, GrGLuint64*);
-
- GLGetIntegervProc fGLGetIntegerv;
- GLGenQueriesProc fGLGenQueries;
- GLDeleteQueriesProc fGLDeleteQueries;
- GLBeginQueryProc fGLBeginQuery;
- GLEndQueryProc fGLEndQuery;
- GLGetQueryObjectuivProc fGLGetQueryObjectuiv;
- GLGetQueryObjectui64vProc fGLGetQueryObjectui64v;
-
-
- typedef sk_gpu_test::GpuTimer INHERITED;
-};
-
-GLGpuTimer* GLGpuTimer::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) {
- SkAutoTDelete<GLGpuTimer> ret;
- const GrGLInterface* gl = ctx->gl();
- if (gl->fExtensions.has("GL_EXT_disjoint_timer_query")) {
- ret.reset(new GLGpuTimer(true, ctx, "EXT"));
- } else if (kGL_GrGLStandard == gl->fStandard &&
- (GrGLGetVersion(gl) > GR_GL_VER(3,3) || gl->fExtensions.has("GL_ARB_timer_query"))) {
- ret.reset(new GLGpuTimer(false, ctx));
- } else if (gl->fExtensions.has("GL_EXT_timer_query")) {
- ret.reset(new GLGpuTimer(false, ctx, "EXT"));
- }
- return ret && ret->validate() ? ret.release() : nullptr;
-}
-
-GLGpuTimer::GLGpuTimer(bool disjointSupport, const sk_gpu_test::GLTestContext* ctx, const char* ext)
- : INHERITED(disjointSupport) {
- ctx->getGLProcAddress(&fGLGetIntegerv, "glGetIntegerv");
- ctx->getGLProcAddress(&fGLGenQueries, "glGenQueries", ext);
- ctx->getGLProcAddress(&fGLDeleteQueries, "glDeleteQueries", ext);
- ctx->getGLProcAddress(&fGLBeginQuery, "glBeginQuery", ext);
- ctx->getGLProcAddress(&fGLEndQuery, "glEndQuery", ext);
- ctx->getGLProcAddress(&fGLGetQueryObjectuiv, "glGetQueryObjectuiv", ext);
- ctx->getGLProcAddress(&fGLGetQueryObjectui64v, "glGetQueryObjectui64v", ext);
-}
-
-bool GLGpuTimer::validate() const {
- return fGLGetIntegerv && fGLGenQueries && fGLDeleteQueries && fGLBeginQuery && fGLEndQuery &&
- fGLGetQueryObjectuiv && fGLGetQueryObjectui64v;
-}
-
-sk_gpu_test::PlatformTimerQuery GLGpuTimer::onQueueTimerStart() const {
- GrGLuint queryID;
- fGLGenQueries(1, &queryID);
- if (!queryID) {
- return sk_gpu_test::kInvalidTimerQuery;
- }
- if (this->disjointSupport()) {
- // Clear the disjoint flag.
- GrGLint disjoint;
- fGLGetIntegerv(GL_GPU_DISJOINT, &disjoint);
- }
- fGLBeginQuery(GL_TIME_ELAPSED, queryID);
- return static_cast<sk_gpu_test::PlatformTimerQuery>(queryID);
-}
-
-void GLGpuTimer::onQueueTimerStop(sk_gpu_test::PlatformTimerQuery platformTimer) const {
- if (sk_gpu_test::kInvalidTimerQuery == platformTimer) {
- return;
- }
- fGLEndQuery(GL_TIME_ELAPSED);
-}
-
-sk_gpu_test::GpuTimer::QueryStatus
-GLGpuTimer::checkQueryStatus(sk_gpu_test::PlatformTimerQuery platformTimer) {
- const GrGLuint queryID = static_cast<GrGLuint>(platformTimer);
- if (!queryID) {
- return QueryStatus::kInvalid;
- }
- GrGLuint available = 0;
- fGLGetQueryObjectuiv(queryID, GL_QUERY_RESULT_AVAILABLE, &available);
- if (!available) {
- return QueryStatus::kPending;
- }
- if (this->disjointSupport()) {
- GrGLint disjoint = 1;
- fGLGetIntegerv(GL_GPU_DISJOINT, &disjoint);
- if (disjoint) {
- return QueryStatus::kDisjoint;
- }
- }
- return QueryStatus::kAccurate;
-}
-
-std::chrono::nanoseconds GLGpuTimer::getTimeElapsed(sk_gpu_test::PlatformTimerQuery platformTimer) {
- SkASSERT(this->checkQueryStatus(platformTimer) >= QueryStatus::kDisjoint);
- const GrGLuint queryID = static_cast<GrGLuint>(platformTimer);
- GrGLuint64 nanoseconds;
- fGLGetQueryObjectui64v(queryID, GL_QUERY_RESULT, &nanoseconds);
- return std::chrono::nanoseconds(nanoseconds);
-}
-
-void GLGpuTimer::deleteQuery(sk_gpu_test::PlatformTimerQuery platformTimer) {
- const GrGLuint queryID = static_cast<GrGLuint>(platformTimer);
- fGLDeleteQueries(1, &queryID);
-}
-
} // anonymous namespace
namespace sk_gpu_test {
@@ -220,7 +91,6 @@
SkASSERT(!fGL.get());
fGL.reset(gl);
fFenceSync = fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this);
- fGpuTimer = GLGpuTimer::CreateIfSupported(this);
}
void GLTestContext::teardown() {
« no previous file with comments | « tools/gpu/TestContext.cpp ('k') | tools/skpbench/_benchresult.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698