Bug 105442 - Hang when running nine ff lighting shader with radeonsi
Summary: Hang when running nine ff lighting shader with radeonsi
Alias: None
Product: Mesa
Classification: Unclassified
Component: Other (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2018-03-11 22:25 UTC by Axel Davy
Modified: 2018-04-08 20:28 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

tgsi, llvm and asm (84.70 KB, text/plain)
2018-03-11 22:25 UTC, Axel Davy

Description Axel Davy 2018-03-11 22:25:23 UTC
Created attachment 138005 [details]
tgsi, llvm and asm

Any app/game running nine ff shader with lighting on hangs on my RX480 with mesa git/llvm 5.0.1

The shader works well under llvmpipe and works with mesa 17.2. sisched or not doesn't make a difference.

The shader features a loop over the lights. When the lights is the last (a constant is set to 1) the loop should stop.

The constants start at pos 32 and are then incremented by 8.

I suspect comparing the correct and the fauly generated shader that the increment happens at the beginning of the loop instead of at the end:

The faulty shader has:
s_branch BB0_2                                        ; BF820000
v_add_f32_e32 v20, 0x41000000, v20                    ; 022828FF 41000000

According to the s_branch encoding, it should do PC = PC + 4

Does that mean it is noop ?
Or could it be that it jumps in the middle of the the two word following instruction ? Thus causing the constant to be interpreted as an instruction ?

It could be an llvm bug or a mesa bug, thus I'm posting here in any case.
Comment 1 Axel Davy 2018-03-14 23:15:24 UTC
I tested with a slightly older version of llvm I had locally that was based on llvm git from june, and the same behaviour occurs. It could be a radeonsi bug introduced in the llvm asm generation or an llvm bug uncovered by a change in that asm.

I filled a bug on the llvm side as it's likely involved:
Comment 2 i.kalvachev 2018-03-26 11:25:40 UTC
Can you do a bisect between Mesa-17.2 and Mesa-17.3, using the same LLVM-5.0.1 ?
Comment 3 Axel Davy 2018-04-02 16:54:57 UTC
Patrick Rudolph bisected the radeonsi regression to:

Checking the attached TGSI, it seems the lighting constants were not declared properly (which is illegal), and in conjunction with the behaviour introduced by this commit (which is legal), it caused the shader to never stop.

The bug was thus a nine bug. Patch sent to the mailing list:

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.