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

EGL_BAD_MATCH (0x3009) on Mali G52 #11839

Closed
shantigilbert opened this issue Feb 25, 2019 · 14 comments
Closed

EGL_BAD_MATCH (0x3009) on Mali G52 #11839

shantigilbert opened this issue Feb 25, 2019 · 14 comments

Comments

@shantigilbert
Copy link

I've been trying to make PPSSPP run on an Odroid N2, I-ve compiled it and it runs but it gives me this error

/SDL/SDLGLGraphicsContext.cpp at line 187: EGL_BAD_MATCH (0x3009)
EGL ERROR: Unable to create EGL surface!
I: gpu_features.cpp:171: GPU Vendor : ARM ; renderer: Mali-G52 version str: OpenGL ES 3.2 git.db77a4c.74502ed16b0fc2da36c811f236840b85 ; GLSL version str: OpenGL ES GLSL ES 3.20
I: gpu_features.cpp:288: OpenGL ES 3.1 support detected!

I can hear the game playing in the background but nothing on the screen.
Other emulators seem to run with GLES 2.0 but PPSSPP doesn't even show it on that line.
is there a way to force PPSSPP to use GLES 2.0? so I can test if this is the problem?

Not sure what EGL_BAD_MATCH means but any help will be appreciated.

What happens?

Black screen on Mali-G52

What should happen?

Run the game or display the PPSSPP GUI

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

CoreELEC running on Odroid N2 , GPU mali-G52

@unknownbrackets
Copy link
Collaborator

See #11714, at least one other user has used USING_FBDEV instead. This basically means you don't run it inside a windowing system, and it's forced full screen.

EGL_BAD_MATCH means eglCreateWindowSurface failed. It's possible this is a bug.

Make sure you're using the latest git, and try editing SDL/SDLGLGraphicsContext.cpp. Look for this code:

		EGLint caveat = readConfig(EGL_CONFIG_CAVEAT);
		int caveatScore = caveat == EGL_NONE ? 100 : (caveat == EGL_NON_CONFORMANT_CONFIG ? 50 : 0);

And add below it:

#ifndef USING_FBDEV
		EGLint surfaceType = readConfig(EGL_SURFACE_TYPE);
		int surfaceScore = (surfaceType & EGL_WINDOW_BIT) ? 100 : (caveat == EGL_NON_CONFORMANT_CONFIG ? 50 : 0);
#endif

Next find this line:

	score += caveatScore + renderableScoreGLES + renderableScoreGL;

And add immediately after it:

#ifndef USING_FBDEV
	score += surfaceScore;
#endif

This may fix things so you can use PPSSPP within a windowing system. If it doesn't, it may mean you have to use FBDEV.

-[Unknown]

@shantigilbert
Copy link
Author

Thanks for the reply, I forgot to mention that I am using FBDEV, as there is no window manager on CoreELEC. These are my params

-DUSE_SYSTEM_FFMPEG=ON -DARMV7=ON -DUSING_FBDEV=ON -DUSING_EGL=ON -DUSING_GLES2=ON -DUSING_X11_VULKAN=OFF"

I am going to try implementing your suggestions and I will get back with the results.

@unknownbrackets
Copy link
Collaborator

Hm, those code changes shouldn't do anything useful with USING_FBDEV....

By the way, I don't recommend using system FFmpeg, you may get bugs or glitches in video, or iirc the wrong video may play in a few games.

It might be that your framebuffer doesn't support the bitdepth we're getting configs for. You could try adjusting the weights or debug using the method described here:
#10534 (comment)

-[Unknown]

@shantigilbert
Copy link
Author

shantigilbert commented Feb 25, 2019

Adding those printf lines resulted in this:

Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 0, stencilScore: 0
Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 0
Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 0
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 15, alphaScore: 7
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 15, alphaScore: 7
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 12, alphaScore: 4
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 12, alphaScore: 4
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:
  * colorScore: 48, alphaScore: -8
  * depthScore: 24, stencilScore: 8
Possible config:
  * colorScore: 30, alphaScore: 6
  * depthScore: 24, stencilScore: 8

But after that I get the same error:

ERROR: EGL Error detected in file /mnt/Core/CoreELEC/build.CoreELEC-Amlogic.arm-9.0-devel/PPSSPPSDL-f742b7917489536f12401277995df05b8404b3d1/SDL/SDLGLGraphicsContext.cpp at line 191: EGL_BAD_MATCH (0x3009)
EGL ERROR: Unable to create EGL surface!
I: gpu_features.cpp:171: GPU Vendor : ARM ; renderer: Mali-G52 version str: OpenGL ES 3.2 git.db77a4c.74502ed16b0fc2da36c811f236840b85 ; GLSL version str: OpenGL ES GLSL ES 3.20
I: gpu_features.cpp:288: OpenGL ES 3.1 support detected!


@hrydgard
Copy link
Owner

Last two look very odd heh, HDR modes? We should probably avoid those, if we aren't already...

@unknownbrackets
Copy link
Collaborator

I think we don't dodge large color depths, so maybe try replacing...

int colorScore = readConfig(EGL_RED_SIZE) + readConfig(EGL_BLUE_SIZE) + readConfig(EGL_GREEN_SIZE);

With:

auto readConfigMax = [&](EGLint attr, EGLint m) -> EGLint {
	EGLint val = readConfig(attr);
	return val > m ? 1 : val;
};
int colorScore = readConfigMax(EGL_RED_SIZE, 8) + readConfigMax(EGL_BLUE_SIZE, 8) + readConfigMax(EGL_GREEN_SIZE, 8);

You can also try putting 5/6/5 or 4/4/4 for those numbers instead of 8/8/8 and see if any of that helps.

-[Unknown]

@shantigilbert
Copy link
Author

I think we don't dodge large color depths, so maybe try replacing...

int colorScore = readConfig(EGL_RED_SIZE) + readConfig(EGL_BLUE_SIZE) + readConfig(EGL_GREEN_SIZE);

With:

auto readConfigMax = [&](EGLint attr, EGLint m) -> EGLint {
	EGLint val = readConfig(attr);
	return val > m ? 1 : val;
};
int colorScore = readConfigMax(EGL_RED_SIZE, 8) + readConfigMax(EGL_BLUE_SIZE, 8) + readConfigMax(EGL_GREEN_SIZE, 8);

You can also try putting 5/6/5 or 4/4/4 for those numbers instead of 8/8/8 and see if any of that helps.

-[Unknown]

With this change it now works :) Thank you very much!

@shantigilbert
Copy link
Author

This is solved, Thanks @unknownbrackets

@hrydgard
Copy link
Owner

Lets not close until the changes are merged

@hrydgard hrydgard reopened this Feb 26, 2019
@hrydgard hrydgard added this to the v1.8.0 milestone Feb 26, 2019
hrydgard added a commit that referenced this issue Feb 26, 2019
EGL: Avoid HDR mode. Uses unknownbrackets' changes from #11839.
@shantigilbert
Copy link
Author

shantigilbert commented Feb 27, 2019

@unknownbrackets @hrydgard

Unfortunately after my kernel was updated, this fails again, I tried forcing a configuration, but I couldn't make it work :(

These are my results now:

Possible config:790/0/0
  * colorScore: 24, alphaScore: 0
  * depthScore: 0, stencilScore: 0
Possible config:910/790/16189032
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 0
Possible config:918/910/16189192
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:718/918/16189352
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:790/918/16189352
  * colorScore: 16, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:910/918/16189352
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 0
Possible config:918/918/16189352
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:718/918/16189352
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:870/918/16189352
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:998/918/16189352
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:670/998/16190472
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:798/998/16190472
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:898/998/16190472
  * colorScore: 15, alphaScore: 7
  * depthScore: 24, stencilScore: 8
Possible config:698/998/16190472
  * colorScore: 15, alphaScore: 7
  * depthScore: 24, stencilScore: 8
Possible config:838/998/16190472
  * colorScore: 12, alphaScore: 4
  * depthScore: 24, stencilScore: 8
Possible config:638/998/16190472
  * colorScore: 12, alphaScore: 4
  * depthScore: 24, stencilScore: 8
Possible config:718/998/16190472
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:718/998/16190472
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:798/998/16190472
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:718/998/16190472
  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8
Possible config:718/998/16190472
  * colorScore: 16, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:798/998/16190472
  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8
Possible config:870/998/16190472
  * colorScore: 24, alphaScore: 8
  * depthScore: 0, stencilScore: 0
Possible config:778/998/16190472
  * colorScore: 3, alphaScore: 7
  * depthScore: 24, stencilScore: 8
Possible config:768/998/16190472
  * colorScore: 3, alphaScore: 6
  * depthScore: 24, stencilScore: 8
Best config:16190472
ERROR: EGL Error detected in file /mnt/core/CoreELEC/build.CoreELEC-Amlogic.arm-9.0-devel/PPSSPPSDL-b689c682217d32e74769091f27c1dde8ab74b905/SDL/SDLGLGraphicsContext.cpp at line 207: EGL_BAD_MATCH (0x3009)
EGL ERROR: Unable to create EGL surface!
I: gpu_features.cpp:174: GPU Vendor : ARM ; renderer: Mali-G52 version str: OpenGL ES 3.2 git.db77a4c.74502ed16b0fc2da36c811f236840b85 ; GLSL version str: OpenGL ES GLSL ES 3.20
I: gpu_features.cpp:291: OpenGL ES 3.1 support detected! 

as you can see it seems to be selecting this:

  * colorScore: 24, alphaScore: 8
  * depthScore: 24, stencilScore: 8 

Which seem to be correct but it might also be

  * colorScore: 24, alphaScore: 0
  * depthScore: 24, stencilScore: 8 

but I don't know how to force it to choose that one so I can test.

@hrydgard
Copy link
Owner

It's very odd that your driver would return a config that it would then not want to create a context with...

@shantigilbert
Copy link
Author

I know, that is why I want to try and force a config, but not sure how to do that

@hrydgard
Copy link
Owner

We definitely need to add some better debug printing and logic, and eventually I want to get the EGL path working on desktop linux as well. Won't have time to really work on this until I've gotten 1.8.0 out the door though, it's the highest priority right now (since 1.7 is broken on many Android devices due to Vulkan driver bugs on PowerVR).

@shantigilbert
Copy link
Author

No rush, thanks for all of your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants