[Mesa-dev] [PATCH v2] mesa: Fix glDrawBuffer/glDrawBuffers logic in _mesa_drawbuffer.

Brian Paul brianp at vmware.com
Fri Aug 8 14:13:20 PDT 2014


I've come up with a simpler solution.  Patch coming soon.

-Brian

On 07/25/2014 04:00 AM, Popov, Pavel E wrote:
> Hi Brian,
>
> Could you commit the updated patch if it's ok?
>
> Regards,
> Pavel
>
> -----Original Message-----
> From: Popov, Pavel E
> Sent: Wednesday, July 23, 2014 4:58 PM
> To: mesa-dev at lists.freedesktop.org
> Cc: Popov, Pavel E
> Subject: [PATCH v2] mesa: Fix glDrawBuffer/glDrawBuffers logic in _mesa_drawbuffer.
>
> Piglit test 'gl30basic' fails on Debug Mesa with the assert:
>    'main/buffers.c:520: _mesa_drawbuffers:
>    Assertion `__builtin_popcount(destMask[buf]) == 1' failed.'.
>
> According to spec (OpenGL 4.0 specification, pages 254-255) we have a
>    different bits set for one buffer and for multiple buffers. For
>    glDrawBuffer we may have up to four bits set but for glDrawBuffers we
>    can only have one bit set.
>
> The _mesa_drawbuffers is called with ctx->Const.MaxDrawBuffers and NULL
>    arguments when _mesa_update_framebuffer or _mesa_update_draw_buffers
>    is called. In this case glDrawBuffers is always used if MaxDrawBuffers > 1.
>    But glDrawBuffer has to be used instead of glDrawBuffers if only
>    destMask[0] is set.
>
> v2 (Brian Paul): Only 0th entry requires special validation for (m == 1).
>
> Signed-off-by: Pavel Popov <pavel.e.popov at intel.com>
> ---
>   src/mesa/main/buffers.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c index b13a7af..95a8722 100644
> --- a/src/mesa/main/buffers.c
> +++ b/src/mesa/main/buffers.c
> @@ -480,6 +480,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
>      struct gl_framebuffer *fb = ctx->DrawBuffer;
>      GLbitfield mask[MAX_DRAW_BUFFERS];
>      GLuint buf;
> +   GLuint m = n;
>
>      if (!destMask) {
>         /* compute destMask values now */ @@ -489,15 +490,17 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
>            mask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]);
>            ASSERT(mask[output] != BAD_MASK);
>            mask[output] &= supportedMask;
> +         if (mask[output] == 0)
> +            m--;
>         }
>         destMask = mask;
>      }
>
>      /*
> -    * If n==1, destMask[0] may have up to four bits set.
> +    * If m==1, destMask[0] may have up to four bits set.
>       * Otherwise, destMask[x] can only have one bit set.
>       */
> -   if (n == 1) {
> +   if (m == 1 && destMask[0]) {
>         GLuint count = 0, destMask0 = destMask[0];
>         while (destMask0) {
>            GLint bufIndex = ffs(destMask0) - 1;
> --
> 1.9.1
>
>
> --------------------------------------------------------------------
> Closed Joint Stock Company Intel A/O
> Registered legal address: Krylatsky Hills Business Park,
> 17 Krylatskaya Str., Bldg 4, Moscow 121614,
> Russian Federation
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>



More information about the mesa-dev mailing list