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. --- src/mesa/main/formatquery.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c index 4f18b00..b55abcd 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 (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalformat)) { @@ -154,7 +155,6 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, * for such formats. */ buffer[0] = 0; - count = 1; } else { size_t num_samples; @@ -179,7 +179,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; } @@ -203,7 +202,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; } -- 2.5.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev