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: Shader decompiler improvements #5860
Conversation
- Emulating f16 with f32 is not ideal and requires a lot of value clamping - Using native data type can significantly improve performance and accuracy - With openGL, check for the compatible extensions NV_gpu_shader5 and AMD_gpu_shader_half_float - With Vulkan, enable this functionality in the deviceFeatures if applicable. (VK_KHR_shader_float16_int8 extension) - Temporarily disable hw fp16 for vulkan
- Improve support for float16_t by minimizing mixed inputs to functions (ambiguous overloads) - Minimize amount of downcasts in code by using opcode flags - Re-enable float16_t support for vulkan
…rmats are used - The fixed-point D24S8 format does special Z clamping during compare which matches PS3 behaviour - D32S8 is a floating point format and comparison with Dref > 1 always fails causing black edges/borders
- The hw generates inaccurate values when doing perspective-correct interpolation of vertex output attributes and makes the comparison (a == b) fail even when they are a fixed constant value. - Increase equality tolerance when doing comparisons in fragment shaders for NV cards only to work around this issue. - Teepo fix
- While mul(0, nan) = nan and 0 / 0 = nan, 0 / sqrt(0) = 0 because of hw gremlins. normalize(0) is also nan so this behaviour does not work around that particular case either which makes it even more baffling.
One Piece: Pirate Warriors has regressed. Now shows black textures in Vulkan and throw a shader compilation error with OpenGL. This PRPR OpenGL:
PR Vulkan: In Grand Theft Auto IV, there's a weird circle around lights. In Grand Theft Auto V, there's a weird shading on characters with Vulkan (with OpenGL it's the same as Vulkan in master). |
Thanks for your great work! All of Nvidia card's graphic issue have been fixed. |
Progression and regression other games. -GT5/6 no more flickering on car anymore, even still present rainbow, but more or less. Log: |
Regression with Sonic's model in Sonic Unleashed |
Need some kind of trace to debug any of these. RRC or RDC will do. |
@slashiee Don't worry about RSX capture not looking correct in replay, it usually still draws stuff properly but breaks post-processing which often relies on Cell-side intervention to look right. |
- Properly test for NaN and Inf when clamping down to fp16 - Optimize divsq a bit; mix(vec, vec, bvec) emits OpSelect which is what we want here, instead of component-wise selection which is much slower.
Retest, improved clamp16 and divsq a bit. |
…d implicit conversions
Check the OpenGL crash; should be fixed now. For GTA4 I'll need comparison RDC to debug further. Vulkan vs master should be enough. |
Sonic Unleashed regression fixed |
RDC Vulkan GTA IV Master OPPW crash with OpenGL is now fixed, by the way. |
Added a workaround for the problematic instruction. It no longer behaves like real hardware but we cannot match exactly the PS3's TMU so I think going out of spec there is fine. Basically the texture filtering does not seem to match the PS3 exactly pixel-for-pixel which is expected. Since texturing is completely fixed function (non-programmable) a workaround is the only way to get around this. I can make the hotspots dance around the screen by altering the filtering even very slightly causes the hotspots to migrate. More research on this topic will be carried out at a later date, but likely only for academic curiosity rather than improving any games (NaNs are rather useless as they are often substituted with 0 anyway). |
Glowy things are fixed with this PR but now shooting with a weapon causes a fatal error. PR error: |
51007d7
to
e939e3a
Compare
Battlefield Bad Company fatal error is now fixed. |
Since u are working on shaders, I leave this here if u wanted to look in to that too even tho its regression from another time.
Let it be if its completly different issue or hard to fix. |
If you don't have the shaderlog then you have to submit an opengl log. Vulkan backend does not write any shader info in the log file. |
OGL log RPCS3.log.gz |
Enable 'Log shader programs' in debug settings and then after the crash (disable async shader compiler beforehand) attach shaderlog/vp_analyser.bin file. |
TODO: Investigate the _s input modifier behaviour further, in case it can avoid generating zeroes from a MAD instruction. x = MAD(+ve, -ve, -ve) with _s input modifier in BFBC expects result to be Non-zero
OGL, strict enabled, async shaders disabled vulkan, strict enabled, async shaders disabled |
- When moving to CC, the operation has VEC flag disabled and also temp regs disabled. Looks to be the catch-all ELSE in the selection logic.
Far Cry 2 crash should be fixed now. |
Has someone benchmarked this PR on a Nvidia Turing (GTX 16 or RTX 20 series) or AMD Vega (Radeon Vega 56/64 or VII) yet? Those GPUs offer double the FP16 performance, would be interesting to see the gains. |
The version of glslang we use to emit SPIR-V may not have the optimizations built in to properly support fp16 as it is a relatively recent thing in the vulkan core spec, although the older AMD extension VK_AMD_gpu_shader_half_float seems to work correctly (there should be no difference to the emitter in theory, but you never know). A Vulkan tools update is coming soon to bring us to newer SDK versions, but it could be a few weeks before that is done. |
Far Cry 2 fixed, n1 thanks |
Confirm Far Cry 2 fixed |
Fixes:
#5830
#4174
#5343
#4799
#5567