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 <airlied@redhat.com>
This commit is contained in:
Eduardo Lima Mitev 2015-12-16 17:32:19 +01:00
parent 1f0b2ce8ec
commit 25ee5c60dc

View file

@ -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;
}