Add support for GLES 3.1+.

This commit is contained in:
Themaister 2014-05-03 15:21:14 +02:00
parent f6a578ce4e
commit 583514ae95
7 changed files with 46 additions and 18 deletions

View File

@ -753,6 +753,13 @@ bool rarch_environment_cb(unsigned cmd, void *data)
cb->context_type == RETRO_HW_CONTEXT_OPENGLES2 ? 2 : 3);
break;
#if defined(HAVE_OPENGLES3)
case RETRO_HW_CONTEXT_OPENGLES_VERSION:
#endif
RARCH_LOG("Requesting OpenGLES%u.%u context.\n",
cb->version_major, cb->version_minor);
break;
case RETRO_HW_CONTEXT_OPENGL:
case RETRO_HW_CONTEXT_OPENGL_CORE:
RARCH_ERR("Requesting OpenGL context, but RetroArch is compiled against OpenGLES2. Cannot use HW context.\n");
@ -764,6 +771,11 @@ bool rarch_environment_cb(unsigned cmd, void *data)
cb->context_type == RETRO_HW_CONTEXT_OPENGLES2 ? 2 : 3);
return false;
case RETRO_HW_CONTEXT_OPENGLES_VERSION:
RARCH_ERR("Requesting OpenGLES%u.%u context, but RetroArch is compiled against OpenGL. Cannot use HW context.\n",
cb->version_major, cb->version_minor);
return false;
case RETRO_HW_CONTEXT_OPENGL:
RARCH_LOG("Requesting OpenGL context.\n");
break;

View File

@ -493,6 +493,13 @@ static EGLint *egl_fill_attribs(EGLint *attr)
case GFX_CTX_OPENGL_ES_API:
*attr++ = EGL_CONTEXT_CLIENT_VERSION;
*attr++ = g_major ? (EGLint)g_major : 2;
#ifdef EGL_KHR_create_context
if (g_minor > 0)
{
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
*attr++ = g_minor;
}
#endif
break;
default:

View File

@ -391,8 +391,15 @@ static EGLint *egl_fill_attribs(EGLint *attr)
#endif
case GFX_CTX_OPENGL_ES_API:
*attr++ = EGL_CONTEXT_CLIENT_VERSION;
*attr++ = EGL_CONTEXT_CLIENT_VERSION; // Same as EGL_CONTEXT_MAJOR_VERSION
*attr++ = g_major ? (EGLint)g_major : 2;
#ifdef EGL_KHR_create_context
if (g_minor > 0)
{
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
*attr++ = g_minor;
}
#endif
break;
default:

View File

@ -1921,6 +1921,8 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
minor = 0;
api_name = "OpenGL ES 3.0";
}
else if (cb->context_type == RETRO_HW_CONTEXT_OPENGLES_VERSION)
api_name = "OpenGL ES 3.1+";
#endif
#else
enum gfx_ctx_api api = GFX_CTX_OPENGL_API;
@ -2162,14 +2164,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
// but still need multiple textures with PREV.
gl->textures = 4;
#ifdef HAVE_FBO
#if defined(HAVE_OPENGLES3)
gl->hw_render_use = hw_render->context_type == RETRO_HW_CONTEXT_OPENGLES2 || hw_render->context_type == RETRO_HW_CONTEXT_OPENGLES3;
#elif defined(HAVE_OPENGLES2)
gl->hw_render_use = hw_render->context_type == RETRO_HW_CONTEXT_OPENGLES2;
#else
gl->hw_render_use = hw_render->context_type == RETRO_HW_CONTEXT_OPENGL ||
g_extern.system.hw_render_callback.context_type == RETRO_HW_CONTEXT_OPENGL_CORE;
#endif
gl->hw_render_use = hw_render->context_type != RETRO_HW_CONTEXT_NONE;
if (gl->hw_render_use)
{
gl->textures = 1; // All on GPU, no need to excessively create textures.

View File

@ -101,7 +101,9 @@ CFLAGS += -Wall -pedantic $(fpic)
ifeq ($(GLES), 1)
CFLAGS += -DGLES -DHAVE_OPENGLES2
ifeq ($(GLES3), 1)
ifeq ($(GLES31), 1)
CFLAGS += -DHAVE_OPENGLES3 -DGLES31 -DGLES3
else ifeq ($(GLES3), 1)
CFLAGS += -DHAVE_OPENGLES3 -DGLES3
endif
LIBS += -lGLESv2 # Still link against GLESv2 when using GLES3 API, at least on desktop Linux.

View File

@ -448,7 +448,11 @@ bool retro_load_game(const struct retro_game_info *info)
}
#ifdef GLES
#ifdef GLES3
#if defined(GLES31)
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES_VERSION;
hw_render.version_major = 3;
hw_render.version_minor = 1;
#elif defined(GLES3)
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES3;
#else
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES2;

View File

@ -997,11 +997,12 @@ typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym);
enum retro_hw_context_type
{
RETRO_HW_CONTEXT_NONE = 0,
RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context.
RETRO_HW_CONTEXT_OPENGLES2, // GLES 2.0
RETRO_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version.
RETRO_HW_CONTEXT_OPENGLES3, // GLES 3.0
RETRO_HW_CONTEXT_NONE = 0,
RETRO_HW_CONTEXT_OPENGL = 1, // OpenGL 2.x. Driver can choose to use latest compatibility context.
RETRO_HW_CONTEXT_OPENGLES2 = 2, // GLES 2.0
RETRO_HW_CONTEXT_OPENGL_CORE = 3, // Modern desktop core GL context. Use version_major/version_minor fields to set GL version.
RETRO_HW_CONTEXT_OPENGLES3 = 4, // GLES 3.0
RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, // GLES 3.1+. Set version_major/version_minor. For GLES2 and GLES3, use the corresponding enums directly.
RETRO_HW_CONTEXT_DUMMY = INT_MAX
};
@ -1026,8 +1027,8 @@ struct retro_hw_render_callback
bool stencil; // Set if stencil buffers should be attached.
// If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored.
bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used.
unsigned version_major; // Major version number for core GL context.
unsigned version_minor; // Minor version number for core GL context.
unsigned version_major; // Major version number for core GL context or GLES 3.1+.
unsigned version_minor; // Minor version number for core GL context or GLES 3.1+.
bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc.
// The reset callback might still be called in extreme situations such as if the context is lost beyond recovery.