[Bug 97441] Render error in Wasteland 2

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Jun 8 09:40:08 UTC 2017


--- Comment #20 from Jakub Szuppe <jakub+mesa at streamcomputing.eu> ---
There are black rectangles instead of blood splashes. They are rendered in call
1570549, for example:

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:

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):

How the screen looks like with this workaround:

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

You are receiving this mail because:
You are the assignee for the bug.
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20170608/54701d69/attachment.html>

More information about the intel-3d-bugs mailing list