Skip to content

Commit

Permalink
Remove unnecessary glGetError calls hitting performance. They were al…
Browse files Browse the repository at this point in the history
…so badly implemented in that glGetError is a stack and the first one pulled off may have been from elsewhere in the program.
  • Loading branch information
dwilliamson committed Apr 10, 2018
1 parent c66d2e8 commit 1b2314d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
14 changes: 0 additions & 14 deletions lib/Remotery.c
Original file line number Diff line number Diff line change
Expand Up @@ -6538,12 +6538,7 @@ static void OpenGLTimestamp_Destructor(OpenGLTimestamp* stamp)

// Destroy queries
if (stamp->queries[0] != 0)
{
int error;
rmtglDeleteQueries(2, stamp->queries);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
}
}


Expand Down Expand Up @@ -6571,7 +6566,6 @@ static rmtBool OpenGLTimestamp_GetData(OpenGLTimestamp* stamp, rmtU64* out_start
{
GLuint64 start = 0, end = 0;
GLint startAvailable = 0, endAvailable = 0;
int error;

assert(g_Remotery != NULL);

Expand All @@ -6581,22 +6575,14 @@ static rmtBool OpenGLTimestamp_GetData(OpenGLTimestamp* stamp, rmtU64* out_start
// Check to see if all queries are ready
// If any fail to arrive, wait until later
rmtglGetQueryObjectiv(stamp->queries[0], GL_QUERY_RESULT_AVAILABLE, &startAvailable);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
if (!startAvailable)
return RMT_FALSE;
rmtglGetQueryObjectiv(stamp->queries[1], GL_QUERY_RESULT_AVAILABLE, &endAvailable);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
if (!endAvailable)
return RMT_FALSE;

rmtglGetQueryObjectui64v(stamp->queries[0], GL_QUERY_RESULT, &start);
error = rmtglGetError();
assert(error == GL_NO_ERROR);
rmtglGetQueryObjectui64v(stamp->queries[1], GL_QUERY_RESULT, &end);
error = rmtglGetError();
assert(error == GL_NO_ERROR);

// Mark the first timestamp. We may resync if we detect the GPU timestamp is in the
// past (i.e. happened before the CPU command) since it should be impossible.
Expand Down
5 changes: 4 additions & 1 deletion sample/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ void sigintHandler(int sig_num) {

int main( ) {
Remotery *rmt;
rmtError error;

signal(SIGINT, sigintHandler);

if( RMT_ERROR_NONE != rmt_CreateGlobalInstance(&rmt) ) {
error = rmt_CreateGlobalInstance(&rmt);
if( RMT_ERROR_NONE != error) {
printf("Error launching Remotery %d\n", error);
return -1;
}

Expand Down

0 comments on commit 1b2314d

Please sign in to comment.