[Mesa-dev] [PATCH] i965: Avoid dependency hints on math opcodes

Mike Stroyan mike at lunarg.com
Thu Feb 20 10:25:10 PST 2014


I apologize for the delay.  It took a while to distill the test case down
to something I could share.

Here is an example program that demonstrates the problem.  It is a
variation of a demos/src/glsl test.
This shows the problem in the rendered color of the 'z' or 'b' channel from
this series of operations.
R[2].x = exp2(R[1].xxxx).x;
R[2].y = exp2(R[1].yyyy + 0.00000001).y;
R[2].z = exp2(R[1].zzzz).z;
They turn into these instructions.

(assign (x) (var_ref R_2) (swiz x (expression vec4 exp2 (swiz xxxx (var_ref
R_1) )) ))
0x00000570: math exp(8) g8<1>.xF g7<4,4,1>.xF null { align16 WE_normal
NoDDClr 1Q };
(assign (y) (var_ref R_2) (swiz y (expression vec4 exp2 (expression vec4 +
(swiz yyyy (var_ref R_1) )(constant float (0x1.5798eep-27)) ) ) ))
0x00000580: add(8) g80<1>F g7<4,4,1>.yF 1e-08F { align16 WE_normal 1Q };
0x00000590: math exp(8) g8<1>.yF g80<4,4,1>F null { align16 WE_normal
NoDDClr,NoDDChk 1Q };
(assign (z) (var_ref R_2) (swiz z (expression vec4 exp2 (swiz zzzz (var_ref
R_1) )) ))
0x000005a0: math exp(8) g8<1>.zF g7<4,4,1>.zF null { align16 WE_normal
NoDDChk 1Q };

The z channel assignment usually results in 1.0 instead of a correct value
near 0.0.
That results in drawing an almost blue grid with a few correct values close
to black.
The results vary from frame to frame with the same inputs.  (Use
'a','z','Z' keys to step between frames.)
I suspect that the channel mask for math writes is not implemented cleanly.
The bad value for the z channel may come from the previous value being
preserved by one of the other two 'math exp' instructions.
(I had to tweak the expression for the y channel to prevent vectorization
from commit 4bd6e0d from hiding the problem by using a single math
instruction instead of three.)

The PRM doesn't say that math instructions mess up with data dependency
hinting.
But the silicon says that they do.



On Tue, Feb 18, 2014 at 2:08 PM, Eric Anholt <eric at anholt.net> wrote:

> mike at lunarg.com writes:
>
> > From: Mike Stroyan <mike at LunarG.com>
> >
> >   Putting NoDDClr and NoDDChk dependency control on instruction
> > sequences that include math opcodes can cause corruption of channels.
> > Treat math opcodes like send opcodes and suppress dependency hinting.
> >
> > Signed-off-by: Mike Stroyan <mike at LunarG.com>
> > Tested-by: Tony Bertapelli <anthony.p.bertapelli at intel.com>
>
> I think we need a testcase for this and some sort of explanation of
> what's going on.  Why is math special?
>



-- 

 Mike Stroyan - Software Architect
 LunarG, Inc.  - The Graphics Experts
 Cell:  (970) 219-7905
 Email: Mike at LunarG.com
 Website: http://www.lunarg.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140220/687a43b5/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: math_dependency.c
Type: text/x-csrc
Size: 6026 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140220/687a43b5/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DD_hinted_math_vs
Type: application/octet-stream
Size: 28388 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140220/687a43b5/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DD_no_hinted_math_vs
Type: application/octet-stream
Size: 28340 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140220/687a43b5/attachment-0003.obj>


More information about the mesa-dev mailing list