[Mesa-dev] [PATCH 1/2] st/mesa: fix max_offset computation for base vertex

Brian Paul brianp at vmware.com
Tue Apr 3 09:13:25 PDT 2012


On 04/03/2012 10:02 AM, Marek Olšák wrote:
> On Mon, Apr 2, 2012 at 8:12 PM, Brian Paul<brianp at vmware.com>  wrote:
>> Fixes a failed assertion in the u_upload_mgr.c code with the VMware
>> svga driver.  Note that we have to remove the !new_array test because
>> the VBO module always sets _NEW_ARRAY when setting up the draw call.
>>
>> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=48141
>> ---
>>   src/mesa/state_tracker/st_draw.c |    6 ++++--
>>   1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
>> index eb18751..487be84 100644
>> --- a/src/mesa/state_tracker/st_draw.c
>> +++ b/src/mesa/state_tracker/st_draw.c
>> @@ -979,6 +979,7 @@ st_draw_vbo(struct gl_context *ctx,
>>     struct pipe_index_buffer ibuffer;
>>     struct pipe_draw_info info;
>>     unsigned i, num_instances = 1;
>> +   int max_base_vertex = 0;
>>     GLboolean new_array =
>>        st->dirty.st&&
>>        (st->dirty.mesa&  (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT)) != 0;
>> @@ -995,6 +996,7 @@ st_draw_vbo(struct gl_context *ctx,
>>
>>        for (i = 0; i<  nr_prims; i++) {
>>           num_instances = MAX2(num_instances, prims[i].num_instances);
>> +         max_base_vertex = MAX2(max_base_vertex, prims[i].basevertex);
>>        }
>>     }
>>     else {
>> @@ -1041,13 +1043,13 @@ st_draw_vbo(struct gl_context *ctx,
>>     /* Notify the driver that the content of user buffers may have been
>>      * changed. */
>>     assert(max_index>= min_index);
>> -   if (!new_array&&  st->num_user_attribs) {
>> +   if (st->num_user_attribs) {
>
> Hi Brian,
>
> the !new_array test should stay there, because redefine_user_buffer
> should only be called if st_validate_varrays wasn't. If new_array is
> TRUE, we call st_validate_varrays. If it's FALSE, we call
> redefine_user_buffer. We shouldn't and don't need to call both.

That's not what I found.  To fix the piglit test in question we have 
to call pipe->redefine_user_buffer() for both drawing calls since 
we're accessing different ranges of user-space memory for the two calls.

IIRC, st_validate_varrays() is invoked for the second drawing call, 
but it doesn't call pipe->redefine_user_buffer()


> The vbo module doesn't always set _NEW_ARRAY. For example, I get
> new_array==FALSE with the game Torcs.

The piglit test causes _NEW_ARRAY to be set for both drawing calls.

-Brian


More information about the mesa-dev mailing list