[Mesa-dev] [PATCH 1/4] vbo: Remove pedantic warning about 'end' beind out of bounds.

Ian Romanick idr at freedesktop.org
Wed Feb 15 14:23:40 PST 2012


On 02/08/2012 11:41 AM, Kenneth Graunke wrote:
> On 02/08/2012 06:59 AM, Brian Paul wrote:
>> On 02/08/2012 06:08 AM, Kenneth Graunke wrote:
>>> The application supplied [start, end] range is merely a conservative
>>> hint of the ranges of index values inside the index buffer. There is no
>>> requirement that all vertices in the range [start, end] be referenced.
>>>
>>> Passing an 'end' value larger than the maximum legal index is perfectly
>>> acceptible; applications can legally pass 0xffffffff when they don't
>>> have a tighter bound readily available.
>>>
>>> Thus, the warning doesn't indicate a correctness issue; it could only
>>> indicate a performance issue. However, it does not even do that.
>>>
>>> glDrawRangeElements is designed to optimize non-VBO vertex data uploads
>>> by providing an upper bound on the size of buffers a driver would need
>>> to allocate. With VBOs, the data is already in an uploaded buffer, so
>>> the range doesn't help.
>>>
>>> The clincher is: we only know _MaxElement for VBOs. For user-space
>>> arrays, we just set it to 2,000,000,000 (see mesa/main/varray.h:63.)
>>> So we can only check this in the case where it is not useful.
>>>
>>> Many applications, including the Unigine demos, currently trigger this
>>> warning, which suggests the applications are buggy when they're actually
>>> fine. Eliminating the warning should confuse users less while not
>>> actually losing any benefit to application developers.
>>>
>>> NOTE: This is a candidate for release branches.
>>>
>>> Suggested-by: Jose Fonseca<jfonseca at vmware.com>
>>> Signed-off-by: Kenneth Graunke<kenneth at whitecape.org>
>>> ---
>>> src/mesa/vbo/vbo_exec_array.c | 49
>>> +---------------------------------------
>>> 1 files changed, 2 insertions(+), 47 deletions(-)
>>>
>>> diff --git a/src/mesa/vbo/vbo_exec_array.c
>>> b/src/mesa/vbo/vbo_exec_array.c
>>> index d6b4d61..ec4cb4f 100644
>>> --- a/src/mesa/vbo/vbo_exec_array.c
>>> +++ b/src/mesa/vbo/vbo_exec_array.c
>>> @@ -708,6 +708,7 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint
>>> start, GLsizei count,
>>> * Map GL_ELEMENT_ARRAY_BUFFER and print contents.
>>> * For debugging.
>>> */
>>> +#if 0
>>> static void
>>> dump_element_buffer(struct gl_context *ctx, GLenum type)
>>> {
>>> @@ -759,6 +760,7 @@ dump_element_buffer(struct gl_context *ctx, GLenum
>>> type)
>>>
>>> ctx->Driver.UnmapBuffer(ctx,
>>> ctx->Array.ArrayObj->ElementArrayBufferObj);
>>> }
>>> +#endif
>>
>> Not a big deal, but someday I might wind up removing the #if 0 / #endif
>> so that I can use this in gdb when debugging something.
>
> Yeah, it looked like useful functionality, so I wanted to keep it, but I
> was getting an "unused function" warning.

You could make it non-static and surround it with #ifdef DEBUG or some 
such.  That could be a follow-on patch.


More information about the mesa-dev mailing list