Bug 47201

Summary: Absolute modifier does not work with 3-source TGSI instructions
Product: Mesa Reporter: Vic Lee <llyzs>
Component: Drivers/Gallium/r600Assignee: Default DRI bug account <dri-devel>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: 8.0   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: test program to reproduce the bug
r600g patch to fix dropped abs() modifier on op3 alu operations.

Description Vic Lee 2012-03-11 05:40:45 UTC
Recently I found a TGSI fragment shader does not render correctly with r600 driver and I further identified the issue down to instructions in this form:

CMP TEMP[0].yz, -|TEMP[1].xxxx|, TEMP[2].xxxx, CONST[0].xyxw

If I covert all those instructions to the equivalents:

ABS TEMP[5], TEMP[1].xxxx
CMP TEMP[0].yz, -TEMP[5], TEMP[2].xxxx, CONST[0].xyxw

It then works fine. However, the original instructions work just fine with nouveau and swrast driver, so it should be a r600 bug. Any clue on this issue?
Comment 1 Vic Lee 2012-03-11 06:24:37 UTC
The issue might be related to r600_bytecode_alu_build() in r600_asm.c. In the codes below:

    if (alu->is_op3) {
        // in this code branch it does not use absolute modifier at all.
    } else {
    ...

Looks like whenever is_op3 is true (which is the case of CMP), absolute modifier is just ignored.
Comment 2 Vic Lee 2012-03-11 06:47:32 UTC
OK I found the reference info in r600 instruction document and this is a hardware limitation. So this probably has to be solved in higher level rather than in driver.

Sorry for the noise.
Comment 3 Tom Stellard 2012-03-11 18:07:27 UTC
The is a bug in the r600 driver.  The shader compiler should be lowering this to the hardware equivalent of this sequence:

ABS TEMP[5], TEMP[1].xxxx
CMP TEMP[0].yz, -TEMP[5], TEMP[2].xxxx, CONST[0].xyxw

Is there a piglit test or application that is hitting this bug?
Comment 4 Vic Lee 2012-03-12 06:33:54 UTC
Thanks for concerning this bug. It will be great if this can be fixed at driver level. I created a smallest possible test program which will be able to test the shader I am having problem with.

Please see the file header for test info.
Comment 5 Vic Lee 2012-03-12 06:34:57 UTC
Created attachment 58317 [details]
test program to reproduce the bug
Comment 6 xbx 2015-01-28 20:10:49 UTC
Created attachment 112920 [details] [review]
r600g patch to fix dropped abs() modifier on op3 alu operations.
Comment 7 xbx 2015-01-28 20:11:23 UTC
I stumbled upon this bug while testing and debugging a game using the st/nine.

And I made a tentative fix that works for me. 
(caveat: I know nothing about mesa/gallium/graphic cards, but hey..)

Here is the proposed patch:

https://github.com/xxxbxxx/Mesa-3D/commit/0722d721f8e5ec496bf8ce4591a3b8a5bf87745d

or attached.
Comment 8 Gert Wollny 2018-03-06 18:29:30 UTC
This was fixed with ad84689f737edefe.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.