<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - MESA_META_DRAW_BUFFERS induced GL_INVALID_VALUE errors"
href="https://bugs.freedesktop.org/show_bug.cgi?id=80115">80115</a>
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Summary</th>
<td>MESA_META_DRAW_BUFFERS induced GL_INVALID_VALUE errors
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jpsinthemix@verizon.net
</td>
</tr>
<tr>
<th>Hardware</th>
<td>x86 (IA32)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Version</th>
<td>10.2
</td>
</tr>
<tr>
<th>Component</th>
<td>Mesa core
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr></table>
<p>
<div>
<pre>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@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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>