[Mesa-dev] [PATCH] i965: Make sure we always compute valid index bounds before drawing.

Ian Romanick idr at freedesktop.org
Thu Mar 27 10:05:53 PDT 2014


On 03/27/2014 02:18 AM, Iago Toral Quiroga wrote:
> Calling _tnl_draw_prims() with invalid index bounds can crash and
> in some cases where vbo_all_varyings_in_vbos() is TRUE but we
> don't have valid index bounds, this happens. This was producing
> a crash in Blender when rendering to the selection buffer.

Presumably the crash happens much later when we fall back to software
(because we don't do GL_SELECTION in hardware).  The vast majority of
applications pass all data in VBOs and stay on the hardware path, so I
really don't want to take the performance hit in those cases.

> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59455
> ---
>  src/mesa/drivers/dri/i965/brw_draw.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
> index d684c17..967923b 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
> @@ -554,7 +554,7 @@ void brw_draw_prims( struct gl_context *ctx,
>      * get the minimum and maximum of their index buffer so we know what range
>      * to upload.
>      */
> -   if (!vbo_all_varyings_in_vbos(arrays) && !index_bounds_valid) {
> +   if (!index_bounds_valid) {

Looking at the surrounding code, I think changing this to

   /* If any of the data comes from user memory or we're going to fallback
    * to software TNL, we need to have valid indices to prevent crashes.
    */
   if ((!vbo_all_varyings_in_vbos(arrays) || ctx->RenderMode != GL_RENDER)
       && !index_bounds_valid) {

should also fix the crash without punishing other applications.

>        perf_debug("Scanning index buffer to compute index buffer bounds.  "
>                   "Use glDrawRangeElements() to avoid this.\n");
>        vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
> 



More information about the mesa-dev mailing list