Emulator Issues #13198
openShader Error + crash on Orange Pi 5 w Panfrost - sampler2DMSArray
0%
Description
Game Name?
Resi 4 GC
Game ID? (right click the game in the game list, Properties, Info tab)
[Put Game ID here]
G4BE08
MD5 Hash? (right click the game in the game list, Properties, Verify tab, Verify Integrity button)
ca749757e3b9d119f3feb1f9f0f81bd7
What's the problem? Describe what went wrong.
I built Dolphin from HoT github using instructions.
Build went fine.
I edited the config file to launch Dolphin with PreferGLES = True.
The only setting I did was to make sure graphics backend was OpenGL.
When I double clock on the game I get a black window followed by an error dialog,
Failed to compile vs shader: /home/fred/.local/share/dolphin-emu/Dump/bad_vs_OGL_0.txt
Debug info (Panfrost, Mali-G610 (Panfrost), OpenGL ES 3.1 Mesa 23.0.0-devel):
0:36(17): error: illegal use of reserved word `sampler2DMSArray'
0:36(17): error: syntax error, unexpected ERROR_TOK
I also reported this to the Mesa git issues page and they say the shader is incorrect to state
#version 310 es
as sampler2DMSArray is an glsl 3.2 keyword.
see their reply here:
What steps will reproduce the problem?
[Reproduction steps here]
Is the issue present in the latest development version? For future reference, please also write down the version number of the latest development version.
[Version number here]
Is the issue present in the latest stable version?
[Yes/No and version number here]
If the issue isn't present in the latest stable version, which is the first broken version? (You can find the first broken version by bisecting. Windows users can use the tool https://forums.dolphin-emu.org/Thread-green-notice-development-thread-unofficial-dolphin-bisection-tool-for-finding-broken-builds and anyone who is building Dolphin on their own can use git bisect.)
[First broken version number here (if applicable)]
If your issue is a graphical issue, please attach screenshots and record a three frame fifolog of the issue if possible. Screenshots showing what it is supposed to look like from either console or older builds of Dolphin will help too. For more information on how to use the fifoplayer, please check here: https://wiki.dolphin-emu.org/index.php?title=FifoPlayer
[Attach any fifologs if possible, write a description of fifologs and screenshots here to assist people unfamiliar with the game.]
What are your PC specifications? (CPU, GPU, Operating System, more)
[PC specs here]
Is there anything else that can help developers narrow down the issue? (e.g. logs, screenshots,
configuration files, savefiles, savestates)
[Anything else here]
Updated by fred.sund@gmail.com almost 2 years ago
Oops something sent the message before I was done.
Here's the issue at Mesa
https://gitlab.freedesktop.org/mesa/mesa/-/issues/8405
Here's info about my system:
Hardware: Orange Pi 5
OS: Armbian (23.02.2) aarch64
GPU: Mali-G610
Kernel version: Linux orangepi5 5.10.110-rockchip-rk3588 #23.02.2 SMP Fri Feb 17 23:59:20 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
Mesa version:
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Panfrost (0xffffffff)
Device: Mali-G610 (Panfrost) (0xffffffff)
Version: 23.0.0
Accelerated: yes
Video memory: 7689MB
Unified memory: yes
Preferred profile: compat (0x2)
Max core profile version: 0.0
Max compat profile version: 3.0
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.1
OpenGL vendor string: Panfrost
OpenGL renderer string: Mali-G610 (Panfrost)
OpenGL version string: 3.0 Mesa 23.0.0-devel
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 23.0.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
Updated by fred.sund@gmail.com almost 2 years ago
Note that Panfrost Mesa installed report max cgsl of 310.
I just hacked and got the game to at least start by editing in ProgramShaderCache.cpp
around line 850
//~ v > GlslEs300 ? "precision highp sampler2DMSArray;" : "",
v > GlslEs300 ? "precision highp image2DArray;" : "",
v >= GlslEs310 ? "precision highp image2DArray;" : "");
Not sure how far I'll get as I can't get controller input to work now :P
Updated by fred.sund@gmail.com almost 2 years ago
It still crashes when I toggle full screen but maybe that's just something similar.
I did see something about this in FrameBufferShaderGen too.
Updated by pokechu22 almost 2 years ago
The code in FrameBufferShaderGen should only be used if the EFB is multisampled, which would require enabling multisampling in the first place, which shouldn't be possible if the platform doesn't support it (the menu for it shouldn't have any options, I think).
I'm going to submit a pull request to change the check to use v >= GlslEs320
since that seems to be correct based on what I see in the GLSL ES spec (though I don't have any way of testing directly).
Updated by fred.sund@gmail.com almost 2 years ago
I do have menu options for Anti Aliasing, Texture Filtering and different render resolutions.
Updated by pokechu22 almost 2 years ago
It looks like there's an additional complication: it's supported when using GL_OES_texture_storage_multisample_2d_array
, which is something we do check for, and only allow multisampling on GLES 3.1 if that extension is supported. That extension uses the same sampler2DMSArray
keyword in shaders (though it uses a different function outside of shaders; I believe this code enables calling glTexStorage3DMultisampleOES
instead of glTexStorage3DMultisample
when needed, but I'm not familiar with it.)
Mesa says it supports GL_OES_texture_storage_multisample_2d_array
, so that should theoretically work, but it seems like Dolphin isn't actually adding #extension GL_OES_texture_storage_multisample_2d_array : enable
. So I think that's the root cause.
For reference:
sampler2DMSArray
is a reserved keyword on GLSL ES 3.0 (see spec page 20 (PDF 27)) and 3.1 (see spec page 18 (PDF 25)). It only exists in GLSL ES 3.2 (see spec page 20).
Prior to 76b50855 (#10311) dolphin incorrectly specified sampler2DMS
here. That keyword was reserved in GLSL ES 3.0, but became valid in 3.1. Oddly, this is not mentioned in the spec with changes marked (there is no changes version for 3.2). The GLSL ES 1.00 spec (for GLES 2.0 - there does not seem to be a GLSL ES 2.0) does not mention either of these two keywords, but dolphin only supports GLES 3.0+ anyways.
The code that added sampler2DMS
was first introduced in 7650117c (#2934), which also added the other logic for stereo + multisampling. The GLES 3.1 path looks like it's written with a fallback path for supporting multisampling without using stereo (so it could use sampler2DMS
instead of sampler2DMSArray
), as it has separate checks for bSupports3DTextureStorage
and bSupports2DTextureStorage
then (renamed to bSupports2DTextureStorageMultisample
/bSupports3DTextureStorageMultisample
in a8876a29 (#4467)), but the actual path for sampler2DMS
was removed in f0391491 (#7753)).
Dolphin uses sampler2DMSArray
in FramebufferShaderGen
(EmitSamplerDeclarations
), but only from GenerateFormatConversionShader
when samples > 1
and from GenerateResolveColorPixelShader
and GenerateResolveDepthPixelShader
, which FramebufferManager
only calls if IsEFBMultisampled()
is true.
Lastly: Vulkan, D3D11, and D3D12 all detect the supported antialiasing modes, but OpenGL hardcodes the list as {1, 2, 4, 8}
. That probably should be changed to detect what modes are supported (though I'm not sure if/how that's done).
In summary: the fix is probably to add #extension GL_OES_texture_storage_multisample_2d_array : enable
on GLES 3.1 if supported, and only add precision highp sampler2DMSArray
if the extension is supported or GLES 3.2 is in use. Also, there is older code that supports falling back to sampler2DMS
on GLES 3.1 if sampler2DMSArray
is not supported so that either stereo or multisampling can be used, but that code got broken a while ago and needs to be either removed or fixed.
Updated by fred.sund@gmail.com almost 2 years ago
I can confirm Fullscreen is actually working for me now.
Updated by pokechu22 almost 2 years ago
Can you check whether https://github.com/dolphin-emu/dolphin/pull/11628 works (and also lets you use multisampling correctly)?
Updated by fred.sund@gmail.com almost 2 years ago
Hmm should I be able to pull those commits before they are merged?
Sorry I'm not that good with git.
I tried
git fetch origin
git cherry-pick 1c4d4abcc249914f2b384e37232e84805f08252a
but get
fatal: bad object 1c4d4abcc249914f2b384e37232e84805f08252a
Updated by pokechu22 almost 2 years ago
You want this:
git fetch origin 674690b1aaba82861f6ce7f112c99318fbbfa850
git switch --detach 674690b1aaba82861f6ce7f112c99318fbbfa850
(to return to master afterwards, use git switch master
)
Updated by fred.sund@gmail.com almost 2 years ago
Ok cool! Great to learn something new! There's always more to learn about git :)
SO I did those two command lines on the four different commits you linked to.
Re built. Then ran.
It worked!! :D No shader error.
For the AA I get six options listed,
2,4,8 of MSAA & SSAA respectively.
Not sure if that's what we should expect.
Nice one! Thank you so much that's extremely helpful! :)
Updated by fred.sund@gmail.com almost 2 years ago
Oh wait. Once I started a game and went back into the AA menu then all the SSAA options had disappeared.
Only the three MSAA ones remain.
Updated by pokechu22 almost 2 years ago
That behavior is somewhat expected; if SSAA isn't supported then it won't be listed, but we're not detecting features on OpenGL until rendering actually starts. It's not good behavior though and should be changed.
Do things look different if 8x MSAA is enabled versus no MSAA?
Updated by fred.sund@gmail.com almost 2 years ago
Its definitely doing the AA on 2 and 4.
But on 8 it turns the screen black.
For the extra options in the AA menu could it be remnants of settings config from runs before I took your commits?
Updated by pokechu22 almost 2 years ago
The GPU only presumably only supports up to 4x MSAA, but Dolphin isn't properly checking that and instead is hardcoding the options at None, 2x, 4x, and 8x (this also prevents using higher AA levels on OpenGL if supported, which I've confirmed applies to me on my machine (I should have 16x and 32x)). I've started looking into fixing that but don't have something working yet. SSAA showing up is probably a similar case; it's more likely to be an actual Dolphin bug than something weird caused by previous settings. I'll let you know when I have something else to test for that.
A git clarification: you didn't actually need to run the commands I listed for each commit. git fetch origin 674690b1aaba82861f6ce7f112c99318fbbfa850
downloads 674690b1aaba82861f6ce7f112c99318fbbfa850 and any parent commits that you don't already have, while git switch --detach 674690b1aaba82861f6ce7f112c99318fbbfa850
acts like switching to that commit as a branch (without actually creating a branch). git switch --detach
can also be used to go to older commits. You would need to list each commit one at a time for git cherry-pick
, though (but that also updates your master branch, which would be more complicated to clean up, and it (generally) doesn't make sense to cherry-pick an older commit).
Updated by pokechu22 over 1 year ago
If you have time, can you check whether https://github.com/dolphin-emu/dolphin/pull/11699 fixes the list of supported antialiasing modes? With that PR on your hardware it should only show None, 2x, and 4x, assuming everything works correctly. (That change doesn't include a copy of the other change, though, so you won't be able to actually run games with it as-is.)
Updated by fred.sund@gmail.com over 1 year ago
Sorry for taking time to get to this.
I just did,
git fetch origin ccafc6ab51ade22d7dba3029ca13be2e550670f9
git switch --detach ccafc6ab51ade22d7dba3029ca13be2e550670f9
(not sure if thats the right hash to use?)
And I get a limited selection of only one AA option
4xMSAA
But when I select it it doesn't take in the menu.
It just flips straight back to 'None'
No matter how many times I try.
Updated by pokechu22 over 1 year ago
Hmm, that's really odd. I don't think I changed anything with how the menu itself works, and it changing back doesn't seem like normal behavior. The hash you chose is the right one, though.
It only supporting 4x is also strange, but I think allowed; I'm not aware of a rule that says that the valid modes need to be sequential powers of 2 (or even powers of 2 at all).
You said that antialiasing did work with PR 11628 at 2x and 4x. Can you tell if 2x and 4x are giving different results? It's possible that it's just rounding 2x to 4x (which I believe is what the spec says is supposed to happen, though I haven't double-checked).
Updated by pokechu22 over 1 year ago
I was able to reproduce the behavior you mentioned on my machine, and also determined that 2x and 4x behave identically on Mesa (at least with my jank setup). It should be fixed now (4x and None being selectable without 2x).
Updated by fred.sund@gmail.com over 1 year ago
Cheers I will try it out soon!
One thing to consider is that Mesa is not yet officially supporting this GPU.
Armbian (which I use) is using a Panfrost fork called 'Panfork' which is a version made just for this SOC rk3588.
Hopefully eventually there will be more official Mesa support for this GPU. They have added a driver, 'pancsf' as a first step which is still wip but the actual Mesa Panfrost still does not seem to work.