[Mesa-dev] [PATCH] vbo: Set FLUSH_UPDATE_CURRENT when setting vertex attibutes

Ian Romanick idr at freedesktop.org
Mon Sep 13 15:54:29 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

keith whitwell wrote:
> Hey Kristian,
> 
> The first question is whether this is necessary - from vague memory I
> have an idea that current attributes need not be updated by vertex
> buffer rendering - ie. it's optional/implementation-dependent.
> 
> I assume you're concerned with the case where you have something like
> 
>    // ctx->Current.Color is xyz
> 
>    glDrawArrays();
> 
>    // has ctx->Current.Color been updated??
> 
> But assuming I'm wrong about that & we really do want to make
> DrawArrays set the current values, the patch looks good...

The OpenGL 2.1 spec says:

    "The effect of

          DrawArrays (mode, f irst, count);

    is the same as the effect of the command sequence

          if (mode or count is invalid )
             generate appropriate error
          else {
             Begin(mode);
             for (int i = 0; i < count ; i++)
                ArrayElement(f irst+ i);
             End();
          }

    with one exception: the current normal coordinates, color,
    secondary color, color index, edge flag, fog coordinate,
    texture coordinates, and generic attributes are each
    indeterminate after execution of DrawArrays, if the
    corresponding array is enabled. Current values corresponding
    to disabled arrays are not modified by the execution of
    DrawArrays."

So, after calling glDrawArrays, the current color is allowed to have any
value (if GL_COLOR_ARRAY was enabled).

> 2010/9/13 Kristian Høgsberg <krh at bitplanet.net>:
>> Setting constant vertex attributes with glDrawArrays() doesn't work right
>> because the last attribute isn't copied to ctx->Current.  Typically,
>> only the last attribute doesn't get set, since vbo_exec_wrap_upgrade_vertex()
>> ends up getting called when setting a new attribute, and it will copy all
>> previously set attributes to Current.
>> ---
>>  src/mesa/vbo/vbo_exec_api.c |    3 +++
>>  1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> I'm not too familiar with this code, so I'd appreciate if somebody who
>> knows the vbo code better could take a quick look.
>>
>> Kristian
>>
>> diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
>> index 9df75a8..90c3dd4 100644
>> --- a/src/mesa/vbo/vbo_exec_api.c
>> +++ b/src/mesa/vbo/vbo_exec_api.c
>> @@ -359,6 +359,9 @@ static void vbo_exec_fixup_vertex( GLcontext *ctx,
>>  do {                                                           \
>>    struct vbo_exec_context *exec = &vbo_context(ctx)->exec;    \
>>                                                                \
>> +   /* FLUSH_UPDATE_CURRENT needs to be set manually */         \
>> +   exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;                \
>> +                                                               \
>>    if (exec->vtx.active_sz[A] != N)                            \
>>       vbo_exec_fixup_vertex(ctx, A, N);                        \
>>                                                                \
>> --
>> 1.7.2.1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyOq6MACgkQX1gOwKyEAw/anwCcCl/dvqP31vjoQcqAcDm+PXi/
saYAoIRC5Ln/2j+p09Y7pbyBCaARCSsL
=6S78
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list