[Mesa-dev] [Bug 80115] New: MESA_META_DRAW_BUFFERS induced GL_INVALID_VALUE errors

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Jun 16 17:57:41 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=80115

          Priority: medium
            Bug ID: 80115
          Assignee: mesa-dev at lists.freedesktop.org
           Summary: MESA_META_DRAW_BUFFERS induced GL_INVALID_VALUE errors
          Severity: normal
    Classification: Unclassified
                OS: Linux (All)
          Reporter: jpsinthemix at verizon.net
          Hardware: x86 (IA32)
            Status: NEW
           Version: 10.2
         Component: Mesa core
           Product: Mesa

Hi,

After upgrading to mesa-10.2.1, I began to see a lot of GL_INVALID_VALUE errors
under kde, eg,

kwin(982) KWin::checkGLError: GL error ( PostPaint ):  "GL_INVALID_VALUE"

With mesa-10.1.5, no such errors occur. Modifying a MESA_DEBUG message in
mesa-10.2.1/src/mesa/main/buffers.c:_mesa_DrawBuffers():303 to print actual
values, gives

Mesa: User error: GL_INVALID_VALUE in glDrawBuffersARB(n: 8
Const.MaxDrawBuffers: 1)
kwin(908) KWin::checkGLError: GL error ( update texture ):  "GL_INVALID_VALUE"

It turns out that the problem appears in the mesa-10.2.1-rc1 ->
mesa-10.2.1-rc2, transition, with this set of commits:

2014-05-07 meta: Only clear the requested color buffers.                       
Kenneth Graunke 1 -2/+49
2014-05-07 meta: Add infrastructure for saving/restoring the DrawBuffers state.
Kenneth Graunke 2 -0/+42
2014-05-07 meta: Add a new MESA_META_DRAW_BUFFERS bit.                         
Kenneth Graunke 4 -4/+6


I have a bunch of laptops, mostly kinda old, and several have radeon graphics
controllers, eg, RV200/M7 [Mobility Radeon 7500]. It turns out that the
MESA_META_DRAW_BUFFERS commit (specifically, the "Add infrastructure for
saving/restoring .." commit) uses MAX_DRAW_BUFFERS, and passes this value to
_mesa_DrawBuffers():

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 36150a5..7c84c33 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1176,6 +1211,10 @@ _mesa_meta_end(struct gl_context *ctx)
        ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
       _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);

+   if (state & MESA_META_DRAW_BUFFERS) {
+      _mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
+   }
+
    ctx->Meta->SaveStackDepth--;


Then, in mesa-10.2.1/src/mesa/main/buffers.c:_mesa_DrawBuffers():303, we have

315     * From the OpenGL 3.0 specification, page 258:
316     * "An INVALID_VALUE error is generated if n is greater than
317     *  MAX_DRAW_BUFFERS."
318     */
319    if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
320       _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
321       return;
322    }

For the radeon case, ctx->Const.MaxDrawBuffers = 1, while MAX_DRAW_BUFFERS = 8,
hence the error.


As a quick "fix" to have mesa-10.2.1 usable for radeon controllers, I use a
simple patch:

---
Attempting to draw MAX_DRAW_BUFFERS here results in many INVALID_VALUE errors
in _mesa_DrawBuffers(), at least for [AMD/ATI] RV200/M7 [Mobility Radeon 7500]
chips (Radeon driver) where ctx->Const.MaxDrawBuffers=1 is less than
MAX_DRAW_BUFFERS.

Do not try to draw more saved color buffers than we actually have saved.

diff -Npur mesa-10.2.1.old/src/mesa/drivers/common/meta.c
mesa-10.2.1.new/src/mesa/drivers/common/meta.c
--- mesa-10.2.1.old/src/mesa/drivers/common/meta.c      2014-05-30
18:09:47.000000000 -0400
+++ mesa-10.2.1.new/src/mesa/drivers/common/meta.c      2014-06-16
19:57:14.505961190 -0400
@@ -1213,7 +1213,10 @@ _mesa_meta_end(struct gl_context *ctx)
       _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);

    if (state & MESA_META_DRAW_BUFFERS) {
-      _mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
+      int c = 0;
+      while (save->ColorDrawBuffers[c] && c < sizeof(save->ColorDrawBuffers))
+          ++c;
+      _mesa_DrawBuffers(c, save->ColorDrawBuffers);
    }

    ctx->Meta->SaveStackDepth--;
---

As long as memset() is used
(mesa-10.2.1/src/mesa/drivers/common/meta.c:_mesa_meta_begin():796):

802       memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));

this appears to be safe, however, maybe it would be more efficient to save the
actual number of saved buffers (real_color_buffers in meta.c) in a new
parameter under ctx?

thanks much for your time, and the great software,
John
john at juluka: ~
$ cat 00-mesa-10.2.1-GL_INVALID_VALUE.br
Hi,

After upgrading to mesa-10.2.1, I began to see a lot of GL_INVALID_VALUE errors
under kde, eg,

kwin(982) KWin::checkGLError: GL error ( PostPaint ):  "GL_INVALID_VALUE"

With mesa-10.1.5, no such errors occur. Modifying a MESA_DEBUG message in
mesa-10.2.1/src/mesa/main/buffers.c:_mesa_DrawBuffers():303 to print actual
values, gives

Mesa: User error: GL_INVALID_VALUE in glDrawBuffersARB(n: 8
Const.MaxDrawBuffers: 1)
kwin(908) KWin::checkGLError: GL error ( update texture ):  "GL_INVALID_VALUE"

It turns out that the problem appears in the mesa-10.2.1-rc1 ->
mesa-10.2.1-rc2, transition, with this set of commits:

2014-05-07 meta: Only clear the requested color buffers.                       
Kenneth Graunke 1 -2/+49
2014-05-07 meta: Add infrastructure for saving/restoring the DrawBuffers state.
Kenneth Graunke 2 -0/+42
2014-05-07 meta: Add a new MESA_META_DRAW_BUFFERS bit.                         
Kenneth Graunke 4 -4/+6


I have a bunch of laptops, mostly kinda old, and several have radeon graphics
controllers, eg, RV200/M7 [Mobility Radeon 7500]. It turns out that the
MESA_META_DRAW_BUFFERS commit (specifically, the "Add infrastructure for
saving/restoring .." commit) uses MAX_DRAW_BUFFERS, and passes this value to
_mesa_DrawBuffers():

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 36150a5..7c84c33 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1176,6 +1211,10 @@ _mesa_meta_end(struct gl_context *ctx)
        ctx->CurrentRenderbuffer->Name != save->RenderbufferName)
       _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);

+   if (state & MESA_META_DRAW_BUFFERS) {
+      _mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
+   }
+
    ctx->Meta->SaveStackDepth--;


Then, in mesa-10.2.1/src/mesa/main/buffers.c:_mesa_DrawBuffers():303, we have

315     * From the OpenGL 3.0 specification, page 258:
316     * "An INVALID_VALUE error is generated if n is greater than
317     *  MAX_DRAW_BUFFERS."
318     */
319    if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
320       _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
321       return;
322    }

For the radeon case, ctx->Const.MaxDrawBuffers = 1, while MAX_DRAW_BUFFERS = 8,
hence the error.


As a quick "fix" to have mesa-10.2.1 usable for radeon controllers, I use a
simple patch:

---
Attempting to draw MAX_DRAW_BUFFERS here results in many INVALID_VALUE errors
in _mesa_DrawBuffers(), at least for [AMD/ATI] RV200/M7 [Mobility Radeon 7500]
chips (Radeon driver) where ctx->Const.MaxDrawBuffers=1 is less than
MAX_DRAW_BUFFERS.

Do not try to draw more saved color buffers than we actually have saved.

diff -Npur mesa-10.2.1.old/src/mesa/drivers/common/meta.c
mesa-10.2.1.new/src/mesa/drivers/common/meta.c
--- mesa-10.2.1.old/src/mesa/drivers/common/meta.c      2014-05-30
18:09:47.000000000 -0400
+++ mesa-10.2.1.new/src/mesa/drivers/common/meta.c      2014-06-16
19:57:14.505961190 -0400
@@ -1213,7 +1213,10 @@ _mesa_meta_end(struct gl_context *ctx)
       _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);

    if (state & MESA_META_DRAW_BUFFERS) {
-      _mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
+      int c = 0;
+      while (save->ColorDrawBuffers[c] && c < sizeof(save->ColorDrawBuffers))
+          ++c;
+      _mesa_DrawBuffers(c, save->ColorDrawBuffers);
    }

    ctx->Meta->SaveStackDepth--;
---

As long as memset() is used
(mesa-10.2.1/src/mesa/drivers/common/meta.c:_mesa_meta_begin():796):

802       memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));

this appears to be safe, however, maybe it would be more efficient to save the
actual number of saved buffers (real_color_buffers in meta.c) in a new
parameter under ctx?

thanks much for your time, and the great software,
John

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140617/5810dfd0/attachment.html>


More information about the mesa-dev mailing list