Bug 109204 - [regression, bisected] retroarch's crt-royale shader crash radv
Summary: [regression, bisected] retroarch's crt-royale shader crash radv
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/radeon (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-01 14:31 UTC by oschowa
Modified: 2019-01-08 00:39 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
bisect log (2.31 KB, text/plain)
2019-01-01 14:31 UTC, oschowa
Details
backtrace (4.99 KB, text/plain)
2019-01-01 14:33 UTC, oschowa
Details
crt-royale-geometry-aa-last-pass.spirv (58.92 KB, text/plain)
2019-01-02 20:46 UTC, oschowa
Details
Fragment shader GLSL (460.09 KB, text/plain)
2019-01-02 21:28 UTC, Brandon Wright
Details
Fragment shader SPV (25.58 KB, application/octet-stream)
2019-01-02 21:28 UTC, Brandon Wright
Details
Vertex shader GLSL (459.95 KB, text/plain)
2019-01-02 21:29 UTC, Brandon Wright
Details
Vertex shader SPV (7.58 KB, application/octet-stream)
2019-01-02 21:29 UTC, Brandon Wright
Details

Note You need to log in before you can comment on or make changes to this bug.
Description oschowa 2019-01-01 14:31:41 UTC
Created attachment 142933 [details]
bisect log

When running retroarch with any of the crt-royale shaders applied, it crashed within libvulkan_radeon.so.
This affects Mesa 18.3.1 and current -git 8c93ef5de98a90a93, 18.2.8 works fine. LLVM version doesn't seem to make a difference. AMDVLK also works as expected.
Bisecting produced the first bad commit as: 

commit a45b6fb45246f6b8e2b4a06977f199cc77452289
Author: Jason Ekstrand <jason.ekstrand@intel.com>
Date:   Sat Sep 22 09:46:26 2018 -0500

    spirv: Pass SSA values through functions
    
    Previously, we would create temporary variables and fill them out.
    Instead, we create as many function parameters as we need and pass them
    through as SSA defs.
    
    Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>

The crt-royale slang shader can be found here: https://github.com/libretro/slang-shaders/tree/master/crt
I'll attach the bisect log, a gdb backtrace, and a coredump.

coredump: https://drive.google.com/open?id=13weXQtqouPYlJeER0kYXDJHDJGK7AZl9
Comment 1 oschowa 2019-01-01 14:33:03 UTC
Created attachment 142934 [details]
backtrace
Comment 2 Brandon Wright 2019-01-02 17:14:03 UTC
I was just about to post this as well.

Seems to be caused by the last pass:
https://github.com/libretro/slang-shaders/blob/master/crt/shaders/crt-royale/src/crt-royale-geometry-aa-last-pass.h

I can't pinpoint an exact cause. It might just be crashing because the number of constants is overflowing something.

Swapping out the last stage for the no-geom version works fine.
Comment 3 Bas Nieuwenhuizen 2019-01-02 17:24:46 UTC
It would be appreciated if someone could get me the SPIR-V for a failing shader, instead of me having to figure out how to get the retroarch build system to spit one out myself.
Comment 4 oschowa 2019-01-02 20:46:54 UTC
Created attachment 142941 [details]
crt-royale-geometry-aa-last-pass.spirv

It seems to be indeed the shader mentioned in #2 which causes the crash.
I believe i managed to get a dump of the spirv via RADV_DEBUG=spirv.
Comment 5 Brandon Wright 2019-01-02 21:28:30 UTC
Created attachment 142942 [details]
Fragment shader GLSL
Comment 6 Brandon Wright 2019-01-02 21:28:55 UTC
Created attachment 142943 [details]
Fragment shader SPV
Comment 7 Brandon Wright 2019-01-02 21:29:23 UTC
Created attachment 142944 [details]
Vertex shader GLSL
Comment 8 Brandon Wright 2019-01-02 21:29:42 UTC
Created attachment 142945 [details]
Vertex shader SPV
Comment 9 Brandon Wright 2019-01-02 21:34:43 UTC
I added the full generated GLSL for the vertex and fragment shaders and the SPV produced. The glsl is in the form it's passed to the glslang compiler, and it compiles with the command-line compiler. I believe it's the vertex shader that's causing the crash, but since it occurs on pipeline creation I don't really know.
Comment 10 Bas Nieuwenhuizen 2019-01-02 22:47:10 UTC
Thanks, was able to reproduce with src/compiler/spirv2nir on the fragment shader.
Comment 11 Bas Nieuwenhuizen 2019-01-03 00:55:35 UTC
I think the issue is that a matrix being passed to a function is not handled correctly in vtn_ssa_value_add_to_call_params .

I'll continue debugging later.
Comment 12 Bas Nieuwenhuizen 2019-01-06 11:59:06 UTC
https://gitlab.freedesktop.org/mesa/mesa/merge_requests/67

fixes the crash parsing the fragment shader for me.
Comment 13 oschowa 2019-01-06 13:19:04 UTC
(In reply to Bas Nieuwenhuizen from comment #12)
> https://gitlab.freedesktop.org/mesa/mesa/merge_requests/67
> 
> fixes the crash parsing the fragment shader for me.

With this patch applied it works correctly again, thanks!
Comment 14 Brandon Wright 2019-01-07 20:43:03 UTC
(In reply to oschowa from comment #13)
> With this patch applied it works correctly again, thanks!

Also confirmed here.


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.