diff options
author | Eduardo Lima Mitev <[email protected]> | 2015-12-16 17:32:19 +0100 |
---|---|---|
committer | Eduardo Lima Mitev <[email protected]> | 2016-03-03 15:14:05 +0100 |
commit | 25ee5c60dcb49e68c80eb5157769ccb655d647fa (patch) | |
tree | 91dec6d0335f55b52108e1576d3002191dc2efda /src/mesa/main/formatquery.c | |
parent | 1f0b2ce8ec139cfb54db014949db0345461aff94 (diff) |
mesa/formatquery: Remove tracking of number of elements in the response
Currently, the number of integers returned in the response to
GetInternalFormativ is being tracked by a 'count' variable.
This is so only the modified elements from the temporary buffer are copied into
the original user buffer.
However, with the introduction of ARB_internalformat_query2, keeping track
of 'count' would complicate the code a lot, considering the high number of
queries.
So, we propose to forget about tracking count, and move all the 16 elements
in the temporary buffer, back to the user buffer (clamped to user buffer size
of course). This is basically a trade-off between performance and code clarity.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main/formatquery.c')
-rw-r--r-- | src/mesa/main/formatquery.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c index c99dccbd40f..6ffa5534d7c 100644 --- a/src/mesa/main/formatquery.c +++ b/src/mesa/main/formatquery.c @@ -65,7 +65,6 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params) { GLint buffer[16]; - GLsizei count = 0; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -141,10 +140,12 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, return; } + /* initialize the contents of the temporary buffer */ + memcpy(buffer, params, MIN2(bufSize, 16) * sizeof(GLint)); + switch (pname) { case GL_SAMPLES: - count = ctx->Driver.QuerySamplesForFormat(ctx, target, - internalformat, buffer); + ctx->Driver.QuerySamplesForFormat(ctx, target, internalformat, buffer); break; case GL_NUM_SAMPLE_COUNTS: { if ((ctx->API == API_OPENGLES2 && ctx->Version == 30) && @@ -157,7 +158,6 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, * Such a restriction no longer exists in GL ES 3.1. */ buffer[0] = 0; - count = 1; } else { size_t num_samples; @@ -182,7 +182,6 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, * separately over-write it with the requested value. */ buffer[0] = (GLint) num_samples; - count = 1; } break; } @@ -206,7 +205,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, * application. Clamp the size of the copy to the size supplied by the * application. */ - memcpy(params, buffer, MIN2(count, bufSize) * sizeof(GLint)); + memcpy(params, buffer, MIN2(bufSize, 16) * sizeof(GLint)); return; } |