@@ -48,34 +48,25 @@ class OpenGLDriver;
4848
4949// ------------------------------------------------------------------------------------------------
5050
51- bool TimerQueryFactory::mGpuTimeSupported = false ;
52-
5351TimerQueryFactoryInterface* TimerQueryFactory::init (
5452 OpenGLPlatform& platform, OpenGLContext& context) {
5553 (void )context;
5654
5755 TimerQueryFactoryInterface* impl = nullptr ;
5856
59- #if defined(BACKEND_OPENGL_VERSION_GL) || defined(GL_EXT_disjoint_timer_query)
60- if (context.ext .EXT_disjoint_timer_query ) {
61- // timer queries are available
62- if (context.bugs .dont_use_timer_query && platform.canCreateFence ()) {
63- // however, they don't work well, revert to using fences if we can.
64- impl = new (std::nothrow) TimerQueryFenceFactory (platform);
65- } else {
57+ switch (context.getGpuTimerType ()) {
58+ case Type::Fallback: {
59+ impl = new (std::nothrow) TimerQueryFallbackFactory ();
60+ break ;
61+ }
62+ case Type::Native: {
6663 impl = new (std::nothrow) TimerQueryNativeFactory (context);
64+ break ;
65+ }
66+ case Type::Fence: {
67+ impl = new (std::nothrow) TimerQueryFenceFactory (platform);
68+ break ;
6769 }
68- mGpuTimeSupported = true ;
69- } else
70- #endif
71- if (platform.canCreateFence ()) {
72- // no timer queries, but we can use fences
73- impl = new (std::nothrow) TimerQueryFenceFactory (platform);
74- mGpuTimeSupported = true ;
75- } else {
76- // no queries, no fences -- that's a problem
77- impl = new (std::nothrow) TimerQueryFallbackFactory ();
78- mGpuTimeSupported = false ;
7970 }
8071 assert_invariant (impl);
8172 return impl;
@@ -100,8 +91,6 @@ TimerQueryResult TimerQueryFactoryInterface::getTimerQueryValue(
10091
10192// ------------------------------------------------------------------------------------------------
10293
103- #if defined(BACKEND_OPENGL_VERSION_GL) || defined(GL_EXT_disjoint_timer_query)
104-
10594TimerQueryNativeFactory::TimerQueryNativeFactory (OpenGLContext& context)
10695 : mContext (context) {
10796}
@@ -165,8 +154,6 @@ void TimerQueryNativeFactory::endTimeElapsedQuery(OpenGLDriver& driver, GLTimerQ
165154 });
166155}
167156
168- #endif
169-
170157// ------------------------------------------------------------------------------------------------
171158
172159TimerQueryFenceFactory::TimerQueryFenceFactory (OpenGLPlatform& platform)
0 commit comments