Repository navigation
Conversation
c067222 to
8bea2fa
Compare
There was a problem hiding this comment.
Had a look though only the PS stuff
I was comparing against DX and VK shaders and seeing what differed code wise
I did notice that some of our constants vary across backends
I.e. 255.5f vs 255.0f, value255.5f instead of (value255f)+0.5f. etc
Perhaps we should consider what should be used instead of just using what Metal does, given that Metal is the least used backend and thus not as battle tested.
lightningterror
left a comment
There was a problem hiding this comment.
Currently gl is broken:
[ 38.2015] 0(489) : error C0000: syntax error, unexpected identifier, expecting reserved word or reserved word "in" or reserved word "out" or reserved word "uniform" at token "buffer"
[ 38.2018] 0(501) : error C0000: syntax error, unexpected identifier, expecting reserved word or reserved word "in" or reserved word "out" or reserved word "uniform" at token "buffer"
[ 38.2021] 0(511) : error C1503: undefined variable "index_buffer"
[ 38.2026] 0(516) : error C1503: undefined variable "vertex_buffer"
[ 38.2029] 0(548) : error C1503: undefined variable "index_buffer"
[ 38.2033] 0(553) : error C1503: undefined variable "vertex_buffer"
I also did a pass over the PS code and found a couple few other places that had some differences:
We should probably use a consistent constants throughout the shader, though for now it may be easier to match DX/VK to make checking the dump runs easier. |
7037169 to
d7e4176
Compare
Might be driver specific as I'm unable to repro on my end. The lines causing the issue appear to be the ones with but just to be sure could I have the full shader that is triggering the error? |
|
I had disable vertex shader expand toggled, that should break it. |
b31ddb0 to
daa3edb
Compare
Thanks, fixed it by only allowing the vertex/index SSBOs to be declared in shader if vertex expand shader is used. For the record: If VS expand shader is disabled we use GLSL 330 core on OpenGL, whereas SSBO needs 430 core (as noted by @JordanTheToaster) or ARB_shader_storage_buffer_object. |
5ebb352 to
5a87865
Compare
|
Last push separates pixel shader functions into different files as in #14583. Side note: we might want to look into using the constant buffer for alpha correction (selectors |
a78cd24 to
e13c50a
Compare
lightningterror
left a comment
There was a problem hiding this comment.
Leaving this for myself so I can test older gpus.
|
Fails to compile with different errors this time: Intel hd4000 |
Thanks. I think I fixed the signed/unsigned incompatibility errors and uninitialized warnings. However, the Intel hd4000 errors I'm totally stumped by. Some parts that are causing errors appear to be identical to the current parts in GL after macro substitution. |
|
So intel hd4000 is down to 1 error, unless there are more down the line: Mesa llvmpipe:
The intel one might be similar/the same as #15108, hopefully I am wrong. |
I think I got the Mesa one. The Intel one again I'm totally clueless but I tried something to reduce the nesting, hopefully it helps. |
|
Mesa is fine now. intel: |
|
Maybe Intel compilers don't like nested expressions inside macros. I tried the same trick there also. |
|
I don't see anymore shader errors but now the emu crashes: |
Looks like an ICE, unfortunately. I don't know if there would be an easy way to debug it. Even if we could, it might be a challenge to maintain given how sensitive it was to the new syntax. One option would be keep the GL shader and use unified shaders for the other APIs. Let me know if you or anyone else has alternative ideas. |
|
We could start stripping down the shaders to see which causes issues fragment shader or vertex shader, and also strip down function by function afterwards to pinpoint what causes it. |
|
So I did some digging and it depends how much the functions are nested: Moving the PS_FOG check out of void fog and in to a previous function like ps_main_impl seems to be fine. Note there are more functions that may need fixing up besides PS_STATIC void fog. Edit: It seems that if we have some condition check at the top just before the if also gets around the issue, this screams of a driver bug. |
|
Thanks for digging into the problem. Yes, we can try to remove some of nesting to work around the crash. It might take a bit of time to do this for the other functions and retest. |
|
Just to be safe make sure it's in separate/temp commits. |
|
Agreed, probably better to keep it as a separate commit even when merging so that we know what workarounds we used. |
|
@lightningterror I tried something new whenever you have a chance to test it again. |
|
Still crashes. |
|
Last push restores the original GL shaders and add an option in Graphics>Advanced to use the unified GL shader (testing purposes only). |
lightningterror
left a comment
There was a problem hiding this comment.
Needs rebase, need to add copyright headers to new shader files, need to update/implement shader changes from #15012
After rebase I will try to resolve the opengl issues on older intel/nvidia.
Kinda concerned if the nv issue is just hidden on other renderers/vendors.
Co-authored-by: TellowKrinkle <tellowkrinkle@gmail.com>
Thanks, rebased with changes from #15012 and smoked tested on VK/GL, added copyrights.
Are any of the issues reproducable on VK/DX? If not I wouldn't be too concerned. The byte code on VK/DX should (in theory) be identical on all platforms and more likely to expose real bugs with the shader. With OGL on the other hand we have much less control. Iirc there were some issue that were fixed with the unified shader on GL that were broken on master (also system dependent). Chasing issues on GL on older hardware may be difficult, though you can try. |
Status: draft until tested/reviewed.
Description of Changes
Unifies backend TFX (i.e. GS emulation) shaders:
tfx_defs.inc,tfx_vs.inc,tfx_ps.inc.tfx.fx(DX11/12),tfx.glsl(GL/VK),tfx.metal(Metal).The generic code was based on
tfx.metal(edit: updated to incorporate elements oftfx.fx/tfx.glslfrom DX/VK), as it uses dynamic branch for selectors, which can be used later for spec constants in VK and uber shaders in all backends.Outline for this approach was partly due to @TellowKrinkle.
Details
ps_main()into a new helperps_shuffle().PS_CHANNEL_FETCHtoPS_CHANNELandPS_ANISOTRIPIC_FILTERINGtoPS_SW_ANSIOon non-Metal backends.VS_PROVOING_VERTEX_LASTmacro in VK (was unused).GS_) since we no longer use geometry shaders.max_depthconstants in VS and PS tomax_depth_vsandmax_depth_ps, since GL has issues with constants with the same name in different constant buffers.bin/resources/shaders/dx11tobin/resources/shaders/dx, since it's used for both DX11/12.bin/resources/shaders/vulkan_openglfolder since the language specific TFX shader code is now shared between VK/GL.Todo:
DX has a several warnings about uninitialized variables that must be dealt with.Rationale behind Changes
Reduce the amount of duplicated code in TFX shaders and make it easier to make changes.
Possible drawbacks:
This seems to break renderdoc source level debugging on VK (although assembly debugging works).Edit: source debugging on VK seems to work now.Dump runs on VK/DX12 (so far) show many differences with master, likely due to small numerical difference in the shader code. The differences should not be visually apparent, however.Fixed by changing the rounding to match DX12.Suggested Testing Steps
Use any HW renderer and make sure it works identically to master.
We should make sure there aren't any performance impacts on GPU or shader compilation.
So far, I've checked a couple optimized DX12/VK vertex/pixels shaders in renderdoc and they seem to be around the same size as master.
WARNING:
Currently breaks SW blending with FB fetch on Intel OpenGL.(fixed)Did you use AI to help find, test, or implement this issue or feature?
Likely to ask general programming questions about C++, shading languages, etc.