Skip to content

Commit

Permalink
iOS/tvOS: create gl context as gles3 (#15958)
Browse files Browse the repository at this point in the history
iOS 7+ supports gles3, which is backwards compatible with gles2. This
doesn't enable the glcore driver (which isn't working on ios yet), it
just changes the underlying context.

This fixes some of the rendering performance problems on mupen64plus_next.
  • Loading branch information
warmenhoven authored Nov 30, 2023
1 parent 36d9bdc commit d2253c3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions gfx/drivers_context/cocoa_gl_ctx.m
Original file line number Diff line number Diff line change
Expand Up @@ -473,16 +473,17 @@ static bool cocoa_gl_gfx_ctx_set_video_mode(void *data,
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;

if (cocoa_ctx->flags & COCOA_CTX_FLAG_USE_HW_CTX)
g_hw_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
g_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
glk_view.context = g_ctx;
g_hw_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
g_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];

#ifdef OSX
[g_ctx makeCurrentContext];
#else
[EAGLContext setCurrentContext:g_ctx];
#endif

glk_view.context = g_ctx;

/* TODO: Maybe iOS users should be able to
* show/hide the status bar here? */
return true;
Expand Down
2 changes: 1 addition & 1 deletion griffin/griffin_objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#if defined(HAVE_COCOATOUCH) || defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)

#include "../ui/drivers/cocoa/cocoa_common.m"
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL_ES)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
#include "../gfx/drivers_context/cocoa_gl_ctx.m"
#endif
#if defined(HAVE_VULKAN)
Expand Down
4 changes: 2 additions & 2 deletions pkg/apple/RetroArch_iOS13.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@
"-DHAVE_ONLINE_UPDATER",
"-DHAVE_OPENGL",
"-DHAVE_OPENGLES",
"-DHAVE_OPENGLES2",
"-DHAVE_OPENGLES3",
"-DHAVE_OZONE",
"-DHAVE_PATCH",
"-DHAVE_RBMP",
Expand Down Expand Up @@ -2204,7 +2204,7 @@
"-DHAVE_ONLINE_UPDATER",
"-DHAVE_OPENGL",
"-DHAVE_OPENGLES",
"-DHAVE_OPENGLES2",
"-DHAVE_OPENGLES3",
"-DHAVE_OZONE",
"-DHAVE_PATCH",
"-DHAVE_RBMP",
Expand Down
4 changes: 2 additions & 2 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -6525,7 +6525,7 @@ bool retroarch_main_init(int argc, char *argv[])
{
RARCH_ERR("%s: \"%s\"\n",
msg_hash_to_str(MSG_FATAL_ERROR_RECEIVED_IN),
global->error_string);
global_get_ptr()->error_string);
goto error;
}

Expand Down Expand Up @@ -6835,7 +6835,7 @@ bool retroarch_main_init(int argc, char *argv[])

error:
command_event(CMD_EVENT_CORE_DEINIT, NULL);
runloop_st->flags &= ~RUNLOOP_FLAG_IS_INITED;
runloop_state_get_ptr()->flags &= ~RUNLOOP_FLAG_IS_INITED;

return false;
}
Expand Down

6 comments on commit d2253c3

@illando
Copy link

@illando illando commented on d2253c3 Dec 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @warmenhoven this one fixes also the rendering problem in Flycast and the Rewind function in PSCX ReARMed too! THANKS A LOT!!!
Unfortunately it broke the video output of some other cores like: MAME, Beetle Saturn, BeetlePSX and Beetle VB causing a black screen problem with all the roms I tried.
Would you be able to fix it please?

@warmenhoven
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce the problem with Beetle Saturn or Beetle PSX unfortunately. I haven't tried yet with MAME but as that's a software rendered core I think it's very unlikely that this commit would be causing problems for that core. If it's consistently reproducible, can you please send a log file?

@illando
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @warmenhoven You are right. I deleted my retroach.cfg file and the cores are working fine.
But I'm absolutely sure it's something related to this commit, because I tried the daily build od the Nov29 and there's no black screen.
Any idea about what kind of setting in my retroach.cfg file could cause the problem?

@illando
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved! I removed all the settings that starts with video_ in the retroach.cfg file.
Everything works fine now!
Thanks again!

@warmenhoven
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad it's working for you. You wouldn't happen to have a copy of the broken retroarch.cfg file or the values you deleted so I can try and reproduce it myself?

@warmenhoven
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's broken for me as well. The problem is in gl2_load_texture_image, but I don't understand why yet. If I change it to force it down the glTexImage2D everything works again.

Please sign in to comment.