Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsx: Implement shader interpreters #8106

Merged
merged 9 commits into from
Apr 30, 2020
Merged

Conversation

kd-11
Copy link
Contributor

@kd-11 kd-11 commented Apr 26, 2020

Overview

This PR adds shader interpreters to rpcs3 to take over for the normal rendering pipeline when no shader is available and the compiler has yet to finish generating one. In this case, the interpreter is invoked to render the missing graphics while the compilation is ongoing in the background.

How to test

A new config option is added called "Shader Interpreter Mode". It takes 3 values, "Enabled", "Disabled" and "Forced". For this initial testing phase, it will default to "Disabled" for reasons I will discuss briefly which means everything should work the same as master. "Enabled" enables hybrid rendering and "Forced" is for developers only and redirects all rendering to the interpreters. Note that "Forced" mode will likely pin your GPU usage at 100% at very poor performance.

Known issues

Currently there are two major problems keeping things from moving forward:

  • Due to how vulkan works, we have to either seed all the possible pipeline combinations or maintain a second shader cache for the interpreters. This is unreasonable; it makes more sense to restructure the one compiler system we already have instead of maintaining a second async compiler system. This is a major blocker to having this feature enabled as it can cause a long freeze the first time interpreter is invoked. Note however that this is not persistent stutter, it will typically be one or two very long freezes the first time the interpreter system is invoked and the problem goes away on subsequent playthroughs.
  • Performance is not the best, although recent optimizations have made the interpreters viable to begin with. I am working on this, but it requires some re-structuring of the rpcs3 code before this code can be added in.

Notes

Accuracy of the interpreters is intentionally kept lower than the properly recompiled shaders. This is to keep performance from taking too much of a hit.

@xddxd
Copy link
Contributor

xddxd commented Apr 26, 2020

Works like a charm on GT5 BCES00569 with Shader Interpreter set to Enabled. When the shaders are being interpreted performance is low as expected, but the graphics are all there. Once the shaders have been compiled (or some specific heavy shader?) performance goes back to normal. RX 580 on Windows 10.

@JohnHolmesII
Copy link
Contributor

Well I fired up Demon's Souls on my laptop just to see. You weren't kidding about those long pauses!
But yeah, everything Just Werked:tm:. Very impressive stuff. On RADV + iGPU.

@toccata10
Copy link
Contributor

Archlinux, r9 fury, mesa.
Teken Tag Tournament 2 [BLES01702]
With Ogl: works rather well: slows down at the beginning of a stage but everything is displayed (otherwise, characters start naked/have black textures on them). Nice improvement.
With Vulkan (radv), after character selection, the music continues but the screen is black.
Here's the log:
RPCS3-TekenTag2.zip

@ghost
Copy link

ghost commented Apr 27, 2020

GOW OF WAR 3 all Games Crash and boot compiler Cache New
SharedScreenshot2
RPCS3.log

@kd-11
Copy link
Contributor Author

kd-11 commented Apr 27, 2020

@toccata10 Are you using ACO? ACO is known to have problems with complex shaders.

@toccata10
Copy link
Contributor

Yes, I was using ACO. With the traditionnal llvm radv, it works fine on teken tag tournament 2 (and a few other games I tested). Some stalls of course, but looks like a very nice improvement.

@kd-11 kd-11 changed the title [VERY WIP][TESTERS NEEDED] rsx: Implement shader interpreters [TESTERS NEEDED] rsx: Implement shader interpreters Apr 28, 2020
@toccata10
Copy link
Contributor

On SoulCalibur IV [BLES00296], with Ogl, with hybrid: the screen displays either garbage or is dark.
I have to log on another screen. The dmesg contains things like:
amdgpu 0000:01:00.0: GPU fault detected: 147 0x0ac90802 for process rpcs3 pid 1827 thread rpcs3:cs0 pid 1852
I'm always a bit surprised that a problem in a game crashes the entire graphical sytem (I then have to reboot), but it probably means that amdgpu driver has still some room for improvement...
Anyway:

  • ogl async multithreaded is still ok

  • vulkan with hybrid is ok
    Here comes my dmesg and the rpcs3 logs:
    gpu3.zip
    RPCS3-sc4.zip

kd-11 and others added 9 commits April 30, 2020 14:02
- Adds basic interpreter functionality.
- Flow control and other instructions not yet implemented.
- Must statically write the gl_ClipDistance registers else you get uninitialized trash.
  This problem is more readily apparent on NVIDIA technology but even AMD is not completely immune.
- Fix DIV instruction
- Add EXP_TEX modifier
- Implement WPOS register read
- Swap 3D and Cubemap enums to match RSX ids
- Adds two extra instruction classes: flow control and packing control
- Implement remaining FP instructions with exception of the rare projected texture lookups
- Fix typo causing output color index > 0 to not work
- Fix KIL instruction
- Implement conditional vertex program writes
- merge disable_asynchronous_shader_compiler and interpreter_mode
- removes disable_asynchronous_shader_compiler setting
- Adds the resulting settings as radio buttons to the gui tab
@kd-11 kd-11 changed the title [TESTERS NEEDED] rsx: Implement shader interpreters rsx: Implement shader interpreters Apr 30, 2020
@Nekotekina Nekotekina merged commit 8f0af6a into RPCS3:master Apr 30, 2020
@MsDarkLow MsDarkLow mentioned this pull request Apr 30, 2020
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants