[Mesa-dev] [PATCH] i965: allow unsourced enabled VAO

Ian Romanick idr at freedesktop.org
Thu Dec 22 21:06:56 UTC 2016


On 11/03/2016 03:02 AM, Juan A. Suarez Romero wrote:
> The GL 4.5 spec says:
>     "If any enabled array’s buffer binding is zero when DrawArrays
>     or one of the other drawing commands defined in section 10.4 is
>     called, the result is undefined."
> 
> This commits avoids crashing the code, which is not a very good
> "undefined result".
> 
> This fixes spec/!opengl 3.1/vao-broken-attrib piglit test.
> ---
>  src/mesa/drivers/dri/i965/brw_draw_upload.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
> index ab2fc50..3925b6e 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
> @@ -421,13 +421,22 @@ copy_array_to_vbo_array(struct brw_context *brw,
>     uint8_t *dst = intel_upload_space(brw, size, dst_stride,
>                                       &buffer->bo, &buffer->offset);
>  
> -   if (dst_stride == src_stride) {
> -      memcpy(dst, src, size);
> -   } else {
> -      while (count--) {
> -	 memcpy(dst, src, dst_stride);
> -	 src += src_stride;
> -	 dst += dst_stride;
> +   /* The GL 4.5 spec says:
> +    *      "If any enabled array’s buffer binding is zero when DrawArrays or
> +    *      one of the other drawing commands defined in section 10.4 is called,
> +    *      the result is undefined."
> +    *
> +    * In this case, let's the dst with undefined values
> +    */

   /* Section ##.## (Section name) of the OpenGL 4.5 Core Profile spec says:
    *
    *    If any enabled array’s buffer binding is zero when DrawArrays or
    *    one of the other drawing commands defined in section 10.4 is called,
    *    the result is undefined.
    *
    * In this case, leave dst filled with undefined values
    */

With that fixed (you'll have to fill in the section number and name),

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> +   if (src != NULL) {
> +      if (dst_stride == src_stride) {
> +         memcpy(dst, src, size);
> +      } else {
> +         while (count--) {
> +            memcpy(dst, src, dst_stride);
> +            src += src_stride;
> +            dst += dst_stride;
> +         }
>        }
>     }
>     buffer->stride = dst_stride;
> 



More information about the mesa-dev mailing list