27 bool validate()
const;
32 inline static constexpr GrGLenum GL_QUERY_RESULT = 0x8866;
33 inline static constexpr GrGLenum GL_QUERY_RESULT_AVAILABLE = 0x8867;
34 inline static constexpr GrGLenum GL_TIME_ELAPSED = 0x88bf;
35 inline static constexpr GrGLenum GL_GPU_DISJOINT = 0x8fbb;
45 GLGetIntegervProc fGLGetIntegerv;
46 GLGenQueriesProc fGLGenQueries;
47 GLDeleteQueriesProc fGLDeleteQueries;
48 GLBeginQueryProc fGLBeginQuery;
49 GLEndQueryProc fGLEndQuery;
50 GLGetQueryObjectuivProc fGLGetQueryObjectuiv;
51 GLGetQueryObjectui64vProc fGLGetQueryObjectui64v;
58 std::unique_ptr<GLGpuTimer> ret;
60 if (
gl->fExtensions.has(
"GL_EXT_disjoint_timer_query")) {
61 ret.reset(
new GLGpuTimer(
true, ctx,
"EXT"));
64 ret.reset(
new GLGpuTimer(
false, ctx));
65 }
else if (
gl->fExtensions.has(
"GL_EXT_timer_query")) {
66 ret.reset(
new GLGpuTimer(
false, ctx,
"EXT"));
68 if (ret && !ret->validate()) {
85bool GLGpuTimer::validate()
const {
86 return fGLGetIntegerv && fGLGenQueries && fGLDeleteQueries && fGLBeginQuery && fGLEndQuery &&
87 fGLGetQueryObjectuiv && fGLGetQueryObjectui64v;
92 fGLGenQueries(1, &queryID);
96 if (this->disjointSupport()) {
99 fGLGetIntegerv(GL_GPU_DISJOINT, &disjoint);
101 fGLBeginQuery(GL_TIME_ELAPSED, queryID);
109 fGLEndQuery(GL_TIME_ELAPSED);
119 fGLGetQueryObjectuiv(queryID, GL_QUERY_RESULT_AVAILABLE, &available);
121 return QueryStatus::kPending;
123 if (this->disjointSupport()) {
125 fGLGetIntegerv(GL_GPU_DISJOINT, &disjoint);
127 return QueryStatus::kDisjoint;
130 return QueryStatus::kAccurate;
134 SkASSERT(this->checkQueryStatus(platformTimer) >= QueryStatus::kDisjoint);
137 fGLGetQueryObjectui64v(queryID, GL_QUERY_RESULT, &nanoseconds);
138 return std::chrono::nanoseconds(nanoseconds);
143 fGLDeleteQueries(1, &queryID);
184 fGLInterface = std::move(
gl);
185 fOriginalGLInterface = fGLInterface;
187 fGpuTimer = GLGpuTimer::MakeIfSupported(
this);
191 fGLInterface.
reset();
192 fOriginalGLInterface.
reset();
198#if defined(GR_TEST_UTILS)
200 fGLInterface->abandon();
201 fOriginalGLInterface->abandon();
215 return reinterpret_cast<const GrGLubyte*
>(shadingLanguageVersion);
219 auto newInterface = sk_make_sp<GrGLInterface>(*fOriginalGLInterface);
220 newInterface->fFunctions.fGetString = getString;
221 fGLInterface = std::move(newInterface);
#define GR_GL_FUNCTION_TYPE
#define GR_GL_SHADING_LANGUAGE_VERSION
GrGLVersion GrGLGetVersion(const GrGLInterface *gl)
#define GR_GL_VER(major, minor)
#define INHERITED(method,...)
static constexpr bool SkToBool(const T &x)
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
~GLTestContext() override
void getGLProcAddress(Ret(GR_GL_FUNCTION_TYPE **out)(Args...), const char *name, const char *ext=nullptr) const
void testAbandon() override
const GrGLInterface * gl() const
void init(sk_sp< const GrGLInterface >)
sk_sp< GrDirectContext > makeContext(const GrContextOptions &options) override
void overrideVersion(const char *version, const char *shadingLanguageVersion)
virtual std::chrono::nanoseconds getTimeElapsed(PlatformTimerQuery)=0
virtual QueryStatus checkQueryStatus(PlatformTimerQuery)=0
virtual PlatformTimerQuery onQueueTimerStart() const =0
virtual void deleteQuery(PlatformTimerQuery)=0
virtual void onQueueTimerStop(PlatformTimerQuery) const =0
std::unique_ptr< GpuTimer > fGpuTimer
virtual void testAbandon()
void reset(T *ptr=nullptr)
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
DEF_SWITCHES_START aot vmservice shared library name
uint64_t PlatformTimerQuery
static constexpr PlatformTimerQuery kInvalidTimerQuery
static bool fence_is_supported(const GLTestContext *ctx)
GrGLFunction< GrGLGetStringFn > fGetString
bool hasExtension(const char ext[]) const
struct GrGLInterface::Functions fFunctions