<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Render error in Wasteland 2"
href="https://bugs.freedesktop.org/show_bug.cgi?id=97441#c20">Comment # 20</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Render error in Wasteland 2"
href="https://bugs.freedesktop.org/show_bug.cgi?id=97441">bug 97441</a>
from <span class="vcard"><a class="email" href="mailto:jakub+mesa@streamcomputing.eu" title="Jakub Szuppe <jakub+mesa@streamcomputing.eu>"> <span class="fn">Jakub Szuppe</span></a>
</span></b>
<pre>There are black rectangles instead of blood splashes. They are rendered in call
1570549, for example:
<a href="https://drive.google.com/open?id=0B1fY17pW39ZebG9Dd05QNnFMM0E">https://drive.google.com/open?id=0B1fY17pW39ZebG9Dd05QNnFMM0E</a>
Fragments' color values are NaNs. The fragment shader (1337, call 1080782)
receives NaN values for two inputs: xlv_TEXCOORD2 and xlv_TEXCOORD2_1.
The vertex shader (1336, call 1080779) produces these values by calling
normalize on TANGENT attribute.
TANGENT is mapped to 1 generic vertex attribute. There is 1570545 @1
glDisableVertexAttribArrayARB(index = 1) before 1570549 @1 glDrawElements. I.e.
the attribute uses the current value, but this value is never set directly
(using glVertexAttrib4f, for example), so its value is (0, 0, 0, 1) according
to the OpenGL specification.
[!] normalize(x) is not defined for zero vectors. The spec only says that it
"returns a vector in the same direction as x but with a length of 1."
Any behavior is correct:
* Mesa (not only i965) returns NaNs
* NVIDIA proprietary driver returns NaNs
* AMD proprietary driver returns zeros
Why it works on NVIDIA: although normalize returns NaNs for zero vectors, for
some reason GL_CURRENT_VERTEX_ATTRIB is (1, 0, 0, 1), this behavior violates
the specification:
<a href="https://drive.google.com/open?id=0B1fY17pW39ZeMFhrWEM4Q2lCUkU">https://drive.google.com/open?id=0B1fY17pW39ZeMFhrWEM4Q2lCUkU</a>
Why it works on AMD: normalize returns zeros for zero vectors, so other values
are not "damaged". Catalyst uses v_mul_legacy here which treats NaNs as zeros
(Mesa uses v_mul).
Here is a workaround that makes Mesa return zeros for zeros vectors (as AMD on
Catalyst does):
<a href="https://bugs.freedesktop.org/attachment.cgi?id=131795">https://bugs.freedesktop.org/attachment.cgi?id=131795</a>
How the screen looks like with this workaround:
<a href="https://drive.google.com/open?id=0B1fY17pW39ZeTlAyam0wVzhzclk">https://drive.google.com/open?id=0B1fY17pW39ZeTlAyam0wVzhzclk</a>
This workaround also fixes megamaggots' trails.
Anyway, in our opinion the bug is in the game engine, not in Mesa.
glVertexAttrib4(1, ...) should be added after glDisableVertexAttribArray(1) to
set correct values for TANGENT attribute. That's a coincidence that it works
well on proprietary NVIDIA (because of its weird behavior) and AMD (because of
its normalize implementation).
Kind regards,
Stream HPC Team
<a href="https://streamhpc.com/">https://streamhpc.com/</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>