Emulator Issues #13198


Shader Error + crash on Orange Pi 5 w Panfrost - sampler2DMSArray

Added by 24 days ago. Updated 3 days ago.

% Done:


Operating system:
Issue type:
Relates to usability:
Relates to performance:
Relates to maintainability:
Regression start:
Fixed in:


Game Name?

Resi 4 GC

Game ID? (right click the game in the game list, Properties, Info tab)

[Put Game ID here]

MD5 Hash? (right click the game in the game list, Properties, Verify tab, Verify Integrity button)


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 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:

[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]

Actions #1

Updated by 24 days ago

Oops something sent the message before I was done.

Here's the issue at Mesa

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

Actions #2

Updated by 24 days 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

Actions #3

Updated by 24 days 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.

Actions #4

Updated by pokechu22 24 days 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).

Actions #5

Updated by 24 days ago

I do have menu options for Anti Aliasing, Texture Filtering and different render resolutions.

Actions #6

Updated by pokechu22 24 days 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.

Actions #7

Updated by 24 days ago

I can confirm Fullscreen is actually working for me now.

Actions #8

Updated by pokechu22 24 days ago

Can you check whether works (and also lets you use multisampling correctly)?

Actions #9

Updated by 23 days 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

Actions #10

Updated by pokechu22 23 days ago

You want this:

git fetch origin 674690b1aaba82861f6ce7f112c99318fbbfa850
git switch --detach 674690b1aaba82861f6ce7f112c99318fbbfa850

(to return to master afterwards, use git switch master)

Actions #11

Updated by 23 days 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! :)

Actions #12

Updated by 23 days 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.

Actions #13

Updated by pokechu22 23 days 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?

Actions #14

Updated by 23 days 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?

Actions #15

Updated by pokechu22 23 days 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).

Actions #16

Updated by pokechu22 3 days ago

If you have time, can you check whether 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.)


Also available in: Atom PDF