Commit 53f59f4e by Ian Ewell

Finish basic timer query support in GL backend

EXT_disjoint_timer_query is feature complete with the WebGL tests passing with Chromium using ANGLE as a backend. There is some flakiness in the timestamp query test on WebGL, but investigation revealed a bug on Chromium's end and a fix is being made there. Since the extension is feature complete, it is now enabled by default on OpenGL so that it can be regression tested. BUG=angleproject:1265 Change-Id: If018b7e3ae84aff7e40c73ff8e672a86689ae6c4 Reviewed-on: https://chromium-review.googlesource.com/324580 Tryjob-Request: Ian Ewell <ewell@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarIan Ewell <ewell@google.com>
parent 331c68a2
......@@ -1065,6 +1065,11 @@ void Context::getIntegerv(GLenum pname, GLint *params)
*params = mExtensions.maxLabelLength;
break;
// GL_EXT_disjoint_timer_query
case GL_GPU_DISJOINT_EXT:
*params = mRenderer->getGPUDisjoint();
break;
default:
mState.getIntegerv(getData(), pname, params);
break;
......@@ -1092,6 +1097,11 @@ void Context::getInteger64v(GLenum pname, GLint64 *params)
case GL_MAX_SERVER_WAIT_TIMEOUT:
*params = mCaps.maxServerWaitTimeout;
break;
// GL_EXT_disjoint_timer_query
case GL_TIMESTAMP_EXT:
*params = mRenderer->getTimestamp();
break;
default:
UNREACHABLE();
break;
......@@ -1312,6 +1322,22 @@ bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *nu
*type = GL_FLOAT;
*numParams = 1;
return true;
case GL_TIMESTAMP_EXT:
if (!mExtensions.disjointTimerQuery)
{
return false;
}
*type = GL_INT_64_ANGLEX;
*numParams = 1;
return true;
case GL_GPU_DISJOINT_EXT:
if (!mExtensions.disjointTimerQuery)
{
return false;
}
*type = GL_INT;
*numParams = 1;
return true;
}
if (mExtensions.debug)
......
......@@ -91,6 +91,9 @@ class Renderer : public ImplFactory
virtual void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) = 0;
virtual GLint getGPUDisjoint() = 0;
virtual GLint64 getTimestamp() = 0;
// Renderer capabilities
const gl::Caps &getRendererCaps() const;
const gl::TextureCapsMap &getRendererTextureCaps() const;
......
......@@ -665,6 +665,17 @@ void RendererD3D::popGroupMarker()
getAnnotator()->endEvent();
}
GLint RendererD3D::getGPUDisjoint()
{
return 0;
}
GLint64 RendererD3D::getTimestamp()
{
UNIMPLEMENTED();
return 0;
}
void RendererD3D::initializeDebugAnnotator()
{
createAnnotator();
......
......@@ -243,6 +243,9 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
GLint getGPUDisjoint() override;
GLint64 getTimestamp() override;
// In D3D11, faster than calling setTexture a jillion times
virtual gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd) = 0;
......
......@@ -416,4 +416,17 @@ void RendererGL::syncState(const gl::State &state, const gl::State::DirtyBits &d
{
mStateManager->syncState(state, dirtyBits);
}
GLint RendererGL::getGPUDisjoint()
{
// TODO(ewell): On GLES backends we should find a way to reliably query disjoint events
return 0;
}
GLint64 RendererGL::getTimestamp()
{
GLint64 result = 0;
mFunctions->getInteger64v(GL_TIMESTAMP, &result);
return result;
}
}
......@@ -104,6 +104,9 @@ class RendererGL : public Renderer
void syncState(const gl::State &state, const gl::State::DirtyBits &dirtyBits) override;
GLint getGPUDisjoint() override;
GLint64 getTimestamp() override;
const gl::Version &getMaxSupportedESVersion() const;
const FunctionsGL *getFunctions() const { return mFunctions; }
StateManagerGL *getStateManager() const { return mStateManager; }
......
......@@ -623,8 +623,7 @@ void GenerateCaps(const FunctionsGL *functions, gl::Caps *caps, gl::TextureCapsM
functions->hasGLExtension("GL_ARB_timer_query") ||
functions->hasGLESExtension("GL_EXT_disjoint_timer_query"))
{
// TODO(ewell): Extension is disabled by default until all functionality is implemented
extensions->disjointTimerQuery = false;
extensions->disjointTimerQuery = true;
extensions->queryCounterBitsTimeElapsed =
QueryQueryValue(functions, GL_TIME_ELAPSED, GL_QUERY_COUNTER_BITS);
extensions->queryCounterBitsTimestamp =
......
......@@ -287,9 +287,55 @@ TEST_P(TimerQueriesTest, Timestamp)
EXPECT_LT(result1, result2);
}
class TimerQueriesTestES3 : public TimerQueriesTest
{
};
// Tests getting timestamps via glGetInteger64v
TEST_P(TimerQueriesTestES3, TimestampGetInteger64)
{
if (!extensionEnabled("GL_EXT_disjoint_timer_query"))
{
std::cout << "Test skipped because GL_EXT_disjoint_timer_query is not available."
<< std::endl;
return;
}
GLint queryTimestampBits = 0;
glGetQueryivEXT(GL_TIMESTAMP_EXT, GL_QUERY_COUNTER_BITS_EXT, &queryTimestampBits);
ASSERT_GL_NO_ERROR();
std::cout << "Timestamp counter bits: " << queryTimestampBits << std::endl;
if (queryTimestampBits == 0)
{
std::cout << "Test skipped because of 0 counter bits" << std::endl;
return;
}
glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLint64 result1 = 0;
GLint64 result2 = 0;
glGetInteger64v(GL_TIMESTAMP_EXT, &result1);
drawQuad(mProgram, "position", 0.8f);
glGetInteger64v(GL_TIMESTAMP_EXT, &result2);
ASSERT_GL_NO_ERROR();
std::cout << "Timestamps (getInteger64v): " << result1 << " " << result2 << std::endl;
EXPECT_LT(0l, result1);
EXPECT_LT(0l, result2);
EXPECT_LT(result1, result2);
}
ANGLE_INSTANTIATE_TEST(TimerQueriesTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_OPENGL(),
ES3_OPENGL());
ANGLE_INSTANTIATE_TEST(TimerQueriesTestES3,
ES3_D3D11(),
ES3_OPENGL());
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment