<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 7, 2019 at 1:42 PM Mario Kleiner <<a href="mailto:mario.kleiner.de@gmail.com" target="_blank">mario.kleiner.de@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">With Mesa 18.1, commit be973ed21f6e, si_llvm_load_input_vs()<br>
changed the number of source 32-bit wide dword components<br>
used for fetching vertex attributes into the vertex shader<br>
from a constant 4 to a variable num_channels number, depending<br>
on input data format, with some special case handling for<br>
input data formats like 64-Bit doubles.<br>
<br>
In the case of a GL_DOUBLE input data format with one<br>
or two components though, e.g, submitted via ...<br>
<br>
a) glTexCoordPointer(1, GL_DOUBLE, 0, buffer);<br>
b) glTexCoordPointer(2, GL_DOUBLE, 0, buffer);<br>
<br>
... the input format would be SI_FIX_FETCH_RG_64_FLOAT,<br>
but no special case handling was implemented for that<br>
case, so in the default path the number of 32-bit<br>
dwords would be set to the number of float input components<br>
derived from info->input_usage_mask. This ends with corrupted<br>
input to the vertex shader, because fetching a 64-bit double<br>
from the vbo requires fetching two 32-bit dwords instead of 1,<br>
and fetching a two double input requires 4 dword fetches<br>
instead of 2, so in these cases the vertex shader receives<br>
incomplete/truncated input data:<br>
<br>
a) float v = gl_MultiTexCoord0.x; -> v.x is corrupted.<br>
b) vec2 v = gl_MultiTexCoord0.xy; -> v.x is assigned<br>
correctly, but v.y is corrupted.<br>
<br>
This happens with the standard TGSI IR compiled shaders.<br>
Under NIR with R600_DEBUG=nir, we got correct behavior<br>
because the current radeonsi nir code always assigns<br>
info->input_usage_mask = TGSI_WRITEMASK_XYZW, thereby<br>
always fetches 4 dwords regardless of what the shader<br>
actually needs.<br>
<br>
Fix this by properly assigning 2 or 4 dword fetches for<br>
one or two component GL_DOUBLE input.<br>
<br>
Fixes: be973ed21f6e ("radeonsi: load the right number of<br>
components for VS inputs and TBOs")<br>
<br>
Signed-off-by: Mario Kleiner <<a href="mailto:mario.kleiner.de@gmail.com" target="_blank">mario.kleiner.de@gmail.com</a>><br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
Cc: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
---<br>
src/gallium/drivers/radeonsi/si_shader.c | 8 ++++++++<br>
1 file changed, 8 insertions(+)<br>
<br>
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c<br>
index 190edce..14bb875 100644<br>
--- a/src/gallium/drivers/radeonsi/si_shader.c<br>
+++ b/src/gallium/drivers/radeonsi/si_shader.c<br>
@@ -561,6 +561,14 @@ void si_llvm_load_input_vs(<br>
<br>
/* Do multiple loads for special formats. */<br>
switch (fix_fetch) {<br>
+ case SI_FIX_FETCH_RG_64_FLOAT:<br>
+ num_fetches = 1; /* 1 2-dword or 4-dword load */<br>
+ fetch_stride = 0;<br>
+ if (util_last_bit(info->input_usage_mask[input_index]) >= 2)<br>
+ num_channels = 4; /* 2 doubles in 4 dwords */<br>
+ else<br>
+ num_channels = 2; /* 1 double in 2 dwords */<br>
+ break;<br>
case SI_FIX_FETCH_RGB_64_FLOAT:<br>
num_fetches = 3; /* 3 2-dword loads */<br>
fetch_stride = 8;<br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
mesa-stable mailing list<br>
<a href="mailto:mesa-stable@lists.freedesktop.org" target="_blank">mesa-stable@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-stable" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-stable</a><br>
</blockquote></div>