Bug 105613 - Compute shader locks up within nested "for" loop
Summary: Compute shader locks up within nested "for" loop
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/radeon (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: high critical
Assignee: mesa-dev
QA Contact: mesa-dev
Depends on:
Reported: 2018-03-20 01:38 UTC by Philip Rebohle
Modified: 2018-06-09 12:17 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Compute shader (SPIR-V version) (12.34 KB, application/octet-stream)
2018-03-20 01:38 UTC, Philip Rebohle
Compute shader (GLSL version) (8.05 KB, text/plain)
2018-03-20 01:39 UTC, Philip Rebohle
GPU hang report (95.88 KB, text/plain)
2018-03-20 01:40 UTC, Philip Rebohle
workaround (4.24 KB, patch)
2018-06-07 16:03 UTC, Samuel Pitoiset
Details | Splinter Review

Description Philip Rebohle 2018-03-20 01:38:46 UTC
Created attachment 138208 [details]
Compute shader (SPIR-V version)

Hellblade: Senua's Sacrifice (via wine+dxvk) locks up shortly after the intro videos before reaching the main menu because of an issue with the attached compute shader.

Tested on an RX 480 with mesa-git (e8d9b7ab0) and LLVM 6.0.0, as well as LLVM 7.0.0-svn.

The attached GLSL version of the shader can also be used to reproduce the hang when compiling it back to SPIR-V, and it contains a modified but functionally equivalent code path which works as expected.
Comment 1 Philip Rebohle 2018-03-20 01:39:24 UTC
Created attachment 138209 [details]
Compute shader (GLSL version)
Comment 2 Philip Rebohle 2018-03-20 01:40:31 UTC
Created attachment 138210 [details]
GPU hang report
Comment 3 Bas Nieuwenhuizen 2018-03-20 01:46:27 UTC
Random guess based on the title is that it is a regression with the following LLVM commit:

commit b0efc4fd6672f27ae2cbf28ef290d25a0da1dc08
Author: Alexander Timofeev <Alexander.Timofeev@amd.com>
Date:   Fri Dec 1 11:56:34 2017 +0000

    [AMDGPU] SiFixSGPRCopies should not modify non-divergent PHI
    Differential revision: https://reviews.llvm.org/D40556
    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319534 91177308-0d34-0410-b5e6-96231b3b80d8

Reverting or using LLVM 5 might fix it.
Comment 4 Philip Rebohle 2018-03-20 02:01:43 UTC
Reverting that specific commit did not fix the hang. It also happens with mesa 17.3.6 and LLVM 5.0.1.

Given that moving the loop counter to a separate variable fixes the hang, I wonder if this is related to https://bugs.freedesktop.org/show_bug.cgi?id=103743.
Comment 5 Axel Davy 2018-03-20 07:17:13 UTC
Maybe related to:

Comment 6 Samuel Pitoiset 2018-04-18 09:56:13 UTC
I can reproduce the hang with mesa-git (893e19efb74) and LLVM-git (f31b39d494d).
Comment 7 Samuel Pitoiset 2018-06-07 08:38:24 UTC
This also affects:
- Vampyr
- Tekken 7
- Final Fantasy XIV

and probably more games.
Comment 8 Samuel Pitoiset 2018-06-07 16:03:53 UTC
Created attachment 140068 [details] [review]

Not the best solution but that works.

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.