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

Work around broken Android garbage. #1732

Merged

Conversation

Sonicadvance1
Copy link
Contributor

This fixes running Dolphin on the Nexus 9.

Android's EGL stack has internal arrays that they use for tracking OpenGL function usage. Probably has something to do with their OpenGL profiling
garbage that used to be in ADT.

Android has three of these arrays, each statically allocated.
One array is for all GLES 1.x functions
One array is for all GLES 2.0/3.0/3.1 and a couple of extensions they deem worthy of being in this array.
The last array is for all function pointers grabbed via eglGetProcAddress that isn't in the other two arrays.

The last array is the issue that we are having problems with. This array is 256 members in length.
So if you are pulling more than 256 function pointers that Google doesn't track in their internal array, the function will return NULL and yell at you
in logcat.

The Nvidia Shield Tablet gets around this by replacing part of the EGL stack with their own implementation that doesn't have this garbage.
The Nexus 9 on the other hand doesn't get away with this. So we pull >100 more function pointers than the array can handle, and some of those we need
to use.

The workaround for this is to grab OpenGL 1.1 functions last because we won't actually be using those functions, so we get away with not grabbing the
function pointers.

@unknownbrackets
Copy link
Contributor

If they're not going to work and not going to be used anyway, wouldn't it be better to #ifdef them out or remove them entirely (if not used on any platform)? This will still give garbage for those funcs right?

-[Unknown]

@Sonicadvance1
Copy link
Contributor Author

Once we start using an OpenGL core context I plan on removing all of the old functions.
This is really temporary until we do that.

@degasus
Copy link
Member

degasus commented Dec 20, 2014

If it's just until we use core profiles, then change your code to get a core profile :D Everything else but glx/wgl and maybe egl is already done.

@BhaaLseN
Copy link
Member

If possible without changing a lot, I'd also opt to only fetch pointers to those funcs we actually use.

@@ -1579,6 +1244,341 @@ const GLFunc gl_function_array[] =

// EXT_geometry_shader
GLFUNC_SUFFIX(glFramebufferTexture, EXT, "GL_EXT_geometry_shader !VERSION_3_2"),

// gl_1_1

This comment was marked as off-topic.

@delroth
Copy link
Member

delroth commented Dec 20, 2014

@Sonicadvance1: This comment grants you the permission to merge this pull request whenever you think it is ready. After addressing the remaining comments, click this link to merge.


Other than this comment, LGTM. @dolphin-emu-bot allowmerge

This fixes running Dolphin on the Nexus 9.

Android's EGL stack has internal arrays that they use for tracking OpenGL function usage. Probably has something to do with their OpenGL profiling
garbage that used to be in ADT.

Android has three of these arrays, each statically allocated.
One array is for all GLES 1.x functions
One array is for all GLES 2.0/3.0/3.1 and a couple of extensions they deem worthy of being in this array.
The last array is for all function pointers grabbed via eglGetProcAddress that isn't in the other two arrays.

The last array is the issue that we are having problems with. This array is 256 members in length.
So if you are pulling more than 256 function pointers that Google doesn't track in their internal array, the function will return NULL and yell at you
in logcat.

The Nvidia Shield Tablet gets around this by replacing part of the EGL stack with their own implementation that doesn't have this garbage.
The Nexus 9 on the other hand doesn't get away with this. So we pull >100 more function pointers than the array can handle, and some of those we need
to use.

The workaround for this is to grab OpenGL 1.1 functions last because we won't actually be using those functions, so we get away with not grabbing the
function pointers.
Sonicadvance1 added a commit that referenced this pull request Dec 20, 2014
@Sonicadvance1 Sonicadvance1 merged commit 829132d into dolphin-emu:master Dec 20, 2014
@Sonicadvance1 Sonicadvance1 deleted the stupid_android_garbage branch December 20, 2014 21:29
@feilen feilen mentioned this pull request Dec 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants