mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-12 04:31:19 +00:00
Create gl_capabilities.c/gl_capabilities.h
This commit is contained in:
parent
cdf816b46b
commit
7af3b79416
@ -697,6 +697,7 @@ endif
|
||||
ifeq ($(HAVE_GL_CONTEXT), 1)
|
||||
DEFINES += -DHAVE_OPENGL -DHAVE_GLSL
|
||||
OBJ += gfx/drivers/gl.o \
|
||||
gfx/drivers/gl_capabilities.o \
|
||||
gfx/drivers/gl_renderchains/render_chain_gl_legacy.o \
|
||||
gfx/common/gl_common.o \
|
||||
gfx/drivers_font/gl_raster_font.o \
|
||||
|
290
gfx/drivers/gl.c
290
gfx/drivers/gl.c
@ -37,6 +37,7 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include "gl_capabilities.h"
|
||||
#include "gl_renderchains/render_chain_gl.h"
|
||||
|
||||
#include "../../driver.h"
|
||||
@ -118,51 +119,14 @@ static const GLfloat white_color[] = {
|
||||
1, 1, 1, 1,
|
||||
};
|
||||
|
||||
static bool gl_core_context = false;
|
||||
static bool gl_shared_context_use = false;
|
||||
|
||||
bool gl_query_core_context_in_use(void)
|
||||
{
|
||||
return gl_core_context;
|
||||
}
|
||||
|
||||
void context_bind_hw_render(bool enable)
|
||||
{
|
||||
if (gl_shared_context_use)
|
||||
video_context_driver_bind_hw_render(&enable);
|
||||
}
|
||||
|
||||
static INLINE bool gl_query_extension(const char *ext)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (gl_query_core_context_in_use())
|
||||
{
|
||||
#ifdef GL_NUM_EXTENSIONS
|
||||
GLint i;
|
||||
GLint exts = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &exts);
|
||||
for (i = 0; i < exts; i++)
|
||||
{
|
||||
const char *str = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if (str && strstr(str, ext))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *str = (const char*)glGetString(GL_EXTENSIONS);
|
||||
ret = str && strstr(str, ext);
|
||||
}
|
||||
|
||||
RARCH_LOG("Querying GL extension: %s => %s\n",
|
||||
ext, ret ? "exists" : "doesn't exist");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
static void gl_free_overlay(gl_t *gl)
|
||||
@ -300,246 +264,6 @@ static void gl_render_overlay(gl_t *gl)
|
||||
coords[5] = yamt; \
|
||||
coords[7] = yamt
|
||||
|
||||
#if defined(HAVE_FBO) && defined(HAVE_PSGL)
|
||||
#define glGenFramebuffers glGenFramebuffersOES
|
||||
#define glBindFramebuffer glBindFramebufferOES
|
||||
#define glFramebufferTexture2D glFramebufferTexture2DOES
|
||||
#define glCheckFramebufferStatus glCheckFramebufferStatusOES
|
||||
#define glDeleteFramebuffers glDeleteFramebuffersOES
|
||||
#define glGenRenderbuffers glGenRenderbuffersOES
|
||||
#define glBindRenderbuffer glBindRenderbufferOES
|
||||
#define glFramebufferRenderbuffer glFramebufferRenderbufferOES
|
||||
#define glRenderbufferStorage glRenderbufferStorageOES
|
||||
#define glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||
#endif
|
||||
|
||||
bool gl_check_capability(enum gl_capability_enum enum_idx)
|
||||
{
|
||||
unsigned major = 0;
|
||||
unsigned minor = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *vendor = (const char*)glGetString(GL_VENDOR);
|
||||
const char *renderer = (const char*)glGetString(GL_RENDERER);
|
||||
const char *version = (const char*)glGetString(GL_VERSION);
|
||||
#ifdef HAVE_OPENGLES
|
||||
bool gles3 = false;
|
||||
|
||||
if (version && sscanf(version, "OpenGL ES %u.%u", &major, &minor) != 2)
|
||||
major = minor = 0;
|
||||
|
||||
if (major >= 3)
|
||||
gles3 = true;
|
||||
#else
|
||||
if (version && sscanf(version, "%u.%u", &major, &minor) != 2)
|
||||
major = minor = 0;
|
||||
#endif
|
||||
|
||||
(void)vendor;
|
||||
|
||||
switch (enum_idx)
|
||||
{
|
||||
case GL_CAPS_EGLIMAGE:
|
||||
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES)
|
||||
if (glEGLImageTargetTexture2DOES != NULL)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_SYNC:
|
||||
#ifdef HAVE_GL_SYNC
|
||||
if (gl_query_extension("ARB_sync") &&
|
||||
glFenceSync && glDeleteSync && glClientWaitSync)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_MIPMAP:
|
||||
{
|
||||
static bool extension_queried = false;
|
||||
static bool extension = false;
|
||||
|
||||
if (!extension_queried)
|
||||
{
|
||||
extension = gl_query_extension("ARB_framebuffer_object");
|
||||
extension_queried = true;
|
||||
}
|
||||
|
||||
if (extension)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case GL_CAPS_VAO:
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (!gl_query_core_context_in_use() && !gl_query_extension("ARB_vertex_array_object"))
|
||||
return false;
|
||||
|
||||
if (glGenVertexArrays && glBindVertexArray && glDeleteVertexArrays)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FBO:
|
||||
#if defined(HAVE_PSGL) || defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2)
|
||||
return true;
|
||||
#elif defined(HAVE_FBO)
|
||||
if (!gl_query_core_context_in_use() && !gl_query_extension("ARB_framebuffer_object")
|
||||
&& !gl_query_extension("EXT_framebuffer_object"))
|
||||
return false;
|
||||
|
||||
if (glGenFramebuffers
|
||||
&& glBindFramebuffer
|
||||
&& glFramebufferTexture2D
|
||||
&& glCheckFramebufferStatus
|
||||
&& glDeleteFramebuffers
|
||||
&& glGenRenderbuffers
|
||||
&& glBindRenderbuffer
|
||||
&& glFramebufferRenderbuffer
|
||||
&& glRenderbufferStorage
|
||||
&& glDeleteRenderbuffers)
|
||||
return true;
|
||||
break;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case GL_CAPS_ARGB8:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gl_query_extension("OES_rgb8_rgba8")
|
||||
|| gl_query_extension("ARM_argb8"))
|
||||
return true;
|
||||
#else
|
||||
/* TODO/FIXME - implement this for non-GLES? */
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_DEBUG:
|
||||
if (gl_query_extension("KHR_debug"))
|
||||
return true;
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (gl_query_extension("ARB_debug_output"))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_PACKED_DEPTH_STENCIL:
|
||||
{
|
||||
struct retro_hw_render_callback *hwr =
|
||||
video_driver_get_hw_context();
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
#else
|
||||
if (major >= 3)
|
||||
return true;
|
||||
#endif
|
||||
if (hwr->stencil
|
||||
&& !gl_query_extension("OES_packed_depth_stencil")
|
||||
&& !gl_query_extension("EXT_packed_depth_stencil"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case GL_CAPS_ES2_COMPAT:
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (vendor && renderer && (strstr(vendor, "ATI") || strstr(renderer, "ATI")))
|
||||
{
|
||||
RARCH_LOG("[GL]: ATI card detected, skipping check for GL_RGB565 support.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gl_query_extension("ARB_ES2_compatibility"))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_UNPACK_ROW_LENGTH:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
|
||||
if (gl_query_extension("GL_EXT_unpack_subimage"))
|
||||
{
|
||||
RARCH_LOG("[GL]: Extension GL_EXT_unpack_subimage, can copy textures faster using UNPACK_ROW_LENGTH.\n");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FULL_NPOT_SUPPORT:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
|
||||
if (gl_query_extension("ARB_texture_non_power_of_two") ||
|
||||
gl_query_extension("OES_texture_npot"))
|
||||
return true;
|
||||
#else
|
||||
{
|
||||
GLint max_texture_size = 0;
|
||||
GLint max_native_instr = 0;
|
||||
bool arb_npot = false;
|
||||
bool arb_frag_program = false;
|
||||
|
||||
if (major >= 3)
|
||||
return true;
|
||||
|
||||
/* try to detect actual npot support. might fail for older cards. */
|
||||
arb_npot = gl_query_extension("ARB_texture_non_power_of_two");
|
||||
arb_frag_program = gl_query_extension("ARB_fragment_program");
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
||||
#ifdef GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
|
||||
if (arb_frag_program && glGetProgramivARB)
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
|
||||
GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &max_native_instr);
|
||||
#endif
|
||||
|
||||
if (arb_npot && arb_frag_program &&
|
||||
(max_texture_size >= 8192) && (max_native_instr >= 4096))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_SRGB_FBO_ES3:
|
||||
#ifdef HAVE_OPENGLES
|
||||
return gles3;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case GL_CAPS_SRGB_FBO:
|
||||
if (settings->video.force_srgb_disable)
|
||||
return false;
|
||||
#if defined(HAVE_OPENGLES)
|
||||
if (gles3 || gl_query_extension("EXT_sRGB"))
|
||||
return true;
|
||||
#elif defined(HAVE_FBO)
|
||||
if (gl_query_core_context_in_use() ||
|
||||
(gl_query_extension("EXT_texture_sRGB")
|
||||
&& gl_query_extension("ARB_framebuffer_sRGB")))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FP_FBO:
|
||||
/* GLES - No extensions for float FBO currently. */
|
||||
#ifndef HAVE_OPENGLES
|
||||
#ifdef HAVE_FBO
|
||||
/* Float FBO is core in 3.2. */
|
||||
if (gl_query_core_context_in_use() || gl_query_extension("ARB_texture_float"))
|
||||
return true;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_BGRA8888:
|
||||
#ifdef HAVE_OPENGLES
|
||||
/* There are both APPLE and EXT variants. */
|
||||
/* Videocore hardware supports BGRA8888 extension, but
|
||||
* should be purposefully avoided. */
|
||||
if (gl_query_extension("BGRA8888") && !strstr(renderer, "VideoCore"))
|
||||
return true;
|
||||
#else
|
||||
/* TODO/FIXME - implement this for non-GLES? */
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void gl_set_projection(gl_t *gl,
|
||||
struct video_ortho *ortho, bool allow_rotate)
|
||||
{
|
||||
@ -1661,7 +1385,7 @@ static void gl_destroy_resources(gl_t *gl)
|
||||
}
|
||||
|
||||
gl_shared_context_use = false;
|
||||
gl_core_context = false;
|
||||
gl_query_core_context_unset();
|
||||
}
|
||||
|
||||
static void gl_free(void *data)
|
||||
@ -1767,8 +1491,7 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident)
|
||||
struct retro_hw_render_callback *hwr =
|
||||
video_driver_get_hw_context();
|
||||
|
||||
gl_core_context =
|
||||
(hwr->context_type == RETRO_HW_CONTEXT_OPENGL_CORE);
|
||||
gl_query_core_context_set(hwr->context_type == RETRO_HW_CONTEXT_OPENGL_CORE);
|
||||
|
||||
if (gl_query_core_context_in_use())
|
||||
{
|
||||
@ -1816,8 +1539,11 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident)
|
||||
/* TODO/FIXME - No extensions for float FBO currently. */
|
||||
#endif
|
||||
|
||||
gl->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO);
|
||||
gl->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO);
|
||||
gl->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO);
|
||||
if (settings->video.force_srgb_disable)
|
||||
gl->has_srgb_fbo = false;
|
||||
else
|
||||
gl->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO);
|
||||
|
||||
#ifdef GL_DEBUG
|
||||
/* Useful for debugging, but kinda obnoxious otherwise. */
|
||||
|
313
gfx/drivers/gl_capabilities.c
Normal file
313
gfx/drivers/gl_capabilities.c
Normal file
@ -0,0 +1,313 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <retro_inline.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#include "gl_capabilities.h"
|
||||
#include "../common/gl_common.h"
|
||||
|
||||
#if defined(HAVE_FBO) && defined(HAVE_PSGL)
|
||||
#define glGenFramebuffers glGenFramebuffersOES
|
||||
#define glBindFramebuffer glBindFramebufferOES
|
||||
#define glFramebufferTexture2D glFramebufferTexture2DOES
|
||||
#define glCheckFramebufferStatus glCheckFramebufferStatusOES
|
||||
#define glDeleteFramebuffers glDeleteFramebuffersOES
|
||||
#define glGenRenderbuffers glGenRenderbuffersOES
|
||||
#define glBindRenderbuffer glBindRenderbufferOES
|
||||
#define glFramebufferRenderbuffer glFramebufferRenderbufferOES
|
||||
#define glRenderbufferStorage glRenderbufferStorageOES
|
||||
#define glDeleteRenderbuffers glDeleteRenderbuffersOES
|
||||
#endif
|
||||
|
||||
static bool gl_core_context = false;
|
||||
|
||||
bool gl_query_core_context_in_use(void)
|
||||
{
|
||||
return gl_core_context;
|
||||
}
|
||||
|
||||
void gl_query_core_context_set(bool set)
|
||||
{
|
||||
gl_core_context = set;
|
||||
}
|
||||
|
||||
void gl_query_core_context_unset(void)
|
||||
{
|
||||
gl_core_context = false;
|
||||
}
|
||||
|
||||
static INLINE bool gl_query_extension(const char *ext)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if (gl_query_core_context_in_use())
|
||||
{
|
||||
#ifdef GL_NUM_EXTENSIONS
|
||||
GLint i;
|
||||
GLint exts = 0;
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, &exts);
|
||||
for (i = 0; i < exts; i++)
|
||||
{
|
||||
const char *str = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if (str && strstr(str, ext))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *str = (const char*)glGetString(GL_EXTENSIONS);
|
||||
ret = str && strstr(str, ext);
|
||||
}
|
||||
|
||||
RARCH_LOG("Querying GL extension: %s => %s\n",
|
||||
ext, ret ? "exists" : "doesn't exist");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool gl_check_capability(enum gl_capability_enum enum_idx)
|
||||
{
|
||||
unsigned major = 0;
|
||||
unsigned minor = 0;
|
||||
const char *vendor = (const char*)glGetString(GL_VENDOR);
|
||||
const char *renderer = (const char*)glGetString(GL_RENDERER);
|
||||
const char *version = (const char*)glGetString(GL_VERSION);
|
||||
#ifdef HAVE_OPENGLES
|
||||
bool gles3 = false;
|
||||
|
||||
if (version && sscanf(version, "OpenGL ES %u.%u", &major, &minor) != 2)
|
||||
major = minor = 0;
|
||||
|
||||
if (major >= 3)
|
||||
gles3 = true;
|
||||
#else
|
||||
if (version && sscanf(version, "%u.%u", &major, &minor) != 2)
|
||||
major = minor = 0;
|
||||
#endif
|
||||
|
||||
(void)vendor;
|
||||
|
||||
switch (enum_idx)
|
||||
{
|
||||
case GL_CAPS_EGLIMAGE:
|
||||
#if defined(HAVE_EGL) && defined(HAVE_OPENGLES)
|
||||
if (glEGLImageTargetTexture2DOES != NULL)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_SYNC:
|
||||
#ifdef HAVE_GL_SYNC
|
||||
if (gl_query_extension("ARB_sync") &&
|
||||
glFenceSync && glDeleteSync && glClientWaitSync)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_MIPMAP:
|
||||
{
|
||||
static bool extension_queried = false;
|
||||
static bool extension = false;
|
||||
|
||||
if (!extension_queried)
|
||||
{
|
||||
extension = gl_query_extension("ARB_framebuffer_object");
|
||||
extension_queried = true;
|
||||
}
|
||||
|
||||
if (extension)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case GL_CAPS_VAO:
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (!gl_query_core_context_in_use() && !gl_query_extension("ARB_vertex_array_object"))
|
||||
return false;
|
||||
|
||||
if (glGenVertexArrays && glBindVertexArray && glDeleteVertexArrays)
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FBO:
|
||||
#if defined(HAVE_PSGL) || defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2)
|
||||
return true;
|
||||
#elif defined(HAVE_FBO)
|
||||
if (!gl_query_core_context_in_use() && !gl_query_extension("ARB_framebuffer_object")
|
||||
&& !gl_query_extension("EXT_framebuffer_object"))
|
||||
return false;
|
||||
|
||||
if (glGenFramebuffers
|
||||
&& glBindFramebuffer
|
||||
&& glFramebufferTexture2D
|
||||
&& glCheckFramebufferStatus
|
||||
&& glDeleteFramebuffers
|
||||
&& glGenRenderbuffers
|
||||
&& glBindRenderbuffer
|
||||
&& glFramebufferRenderbuffer
|
||||
&& glRenderbufferStorage
|
||||
&& glDeleteRenderbuffers)
|
||||
return true;
|
||||
break;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case GL_CAPS_ARGB8:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gl_query_extension("OES_rgb8_rgba8")
|
||||
|| gl_query_extension("ARM_argb8"))
|
||||
return true;
|
||||
#else
|
||||
/* TODO/FIXME - implement this for non-GLES? */
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_DEBUG:
|
||||
if (gl_query_extension("KHR_debug"))
|
||||
return true;
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (gl_query_extension("ARB_debug_output"))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_PACKED_DEPTH_STENCIL:
|
||||
{
|
||||
struct retro_hw_render_callback *hwr =
|
||||
video_driver_get_hw_context();
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
#else
|
||||
if (major >= 3)
|
||||
return true;
|
||||
#endif
|
||||
if (hwr->stencil
|
||||
&& !gl_query_extension("OES_packed_depth_stencil")
|
||||
&& !gl_query_extension("EXT_packed_depth_stencil"))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case GL_CAPS_ES2_COMPAT:
|
||||
#ifndef HAVE_OPENGLES
|
||||
if (vendor && renderer && (strstr(vendor, "ATI") || strstr(renderer, "ATI")))
|
||||
{
|
||||
RARCH_LOG("[GL]: ATI card detected, skipping check for GL_RGB565 support.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gl_query_extension("ARB_ES2_compatibility"))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_UNPACK_ROW_LENGTH:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
|
||||
if (gl_query_extension("GL_EXT_unpack_subimage"))
|
||||
{
|
||||
RARCH_LOG("[GL]: Extension GL_EXT_unpack_subimage, can copy textures faster using UNPACK_ROW_LENGTH.\n");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FULL_NPOT_SUPPORT:
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gles3)
|
||||
return true;
|
||||
|
||||
if (gl_query_extension("ARB_texture_non_power_of_two") ||
|
||||
gl_query_extension("OES_texture_npot"))
|
||||
return true;
|
||||
#else
|
||||
{
|
||||
GLint max_texture_size = 0;
|
||||
GLint max_native_instr = 0;
|
||||
bool arb_npot = false;
|
||||
bool arb_frag_program = false;
|
||||
|
||||
if (major >= 3)
|
||||
return true;
|
||||
|
||||
/* try to detect actual npot support. might fail for older cards. */
|
||||
arb_npot = gl_query_extension("ARB_texture_non_power_of_two");
|
||||
arb_frag_program = gl_query_extension("ARB_fragment_program");
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
||||
#ifdef GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
|
||||
if (arb_frag_program && glGetProgramivARB)
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB,
|
||||
GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, &max_native_instr);
|
||||
#endif
|
||||
|
||||
if (arb_npot && arb_frag_program &&
|
||||
(max_texture_size >= 8192) && (max_native_instr >= 4096))
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_SRGB_FBO_ES3:
|
||||
#ifdef HAVE_OPENGLES
|
||||
return gles3;
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
case GL_CAPS_SRGB_FBO:
|
||||
#if defined(HAVE_OPENGLES)
|
||||
if (gles3 || gl_query_extension("EXT_sRGB"))
|
||||
return true;
|
||||
#elif defined(HAVE_FBO)
|
||||
if (gl_query_core_context_in_use() ||
|
||||
(gl_query_extension("EXT_texture_sRGB")
|
||||
&& gl_query_extension("ARB_framebuffer_sRGB")))
|
||||
return true;
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_FP_FBO:
|
||||
/* GLES - No extensions for float FBO currently. */
|
||||
#ifndef HAVE_OPENGLES
|
||||
#ifdef HAVE_FBO
|
||||
/* Float FBO is core in 3.2. */
|
||||
if (gl_query_core_context_in_use() || gl_query_extension("ARB_texture_float"))
|
||||
return true;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_BGRA8888:
|
||||
#ifdef HAVE_OPENGLES
|
||||
/* There are both APPLE and EXT variants. */
|
||||
/* Videocore hardware supports BGRA8888 extension, but
|
||||
* should be purposefully avoided. */
|
||||
if (gl_query_extension("BGRA8888") && !strstr(renderer, "VideoCore"))
|
||||
return true;
|
||||
#else
|
||||
/* TODO/FIXME - implement this for non-GLES? */
|
||||
#endif
|
||||
break;
|
||||
case GL_CAPS_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
56
gfx/drivers/gl_capabilities.h
Normal file
56
gfx/drivers/gl_capabilities.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2015 - Michael Lelli
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef GL_CAPABILITIES_H
|
||||
#define GL_CAPABILITIES_H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
enum gl_capability_enum
|
||||
{
|
||||
GL_CAPS_NONE = 0,
|
||||
GL_CAPS_EGLIMAGE,
|
||||
GL_CAPS_SYNC,
|
||||
GL_CAPS_MIPMAP,
|
||||
GL_CAPS_VAO,
|
||||
GL_CAPS_FBO,
|
||||
GL_CAPS_ARGB8,
|
||||
GL_CAPS_DEBUG,
|
||||
GL_CAPS_PACKED_DEPTH_STENCIL,
|
||||
GL_CAPS_ES2_COMPAT,
|
||||
GL_CAPS_UNPACK_ROW_LENGTH,
|
||||
GL_CAPS_FULL_NPOT_SUPPORT,
|
||||
GL_CAPS_SRGB_FBO,
|
||||
GL_CAPS_SRGB_FBO_ES3,
|
||||
GL_CAPS_FP_FBO,
|
||||
GL_CAPS_BGRA8888
|
||||
};
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
bool gl_query_core_context_in_use(void);
|
||||
|
||||
void gl_query_core_context_set(bool set);
|
||||
|
||||
void gl_query_core_context_unset(void);
|
||||
|
||||
bool gl_check_capability(enum gl_capability_enum enum_idx);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
@ -26,26 +26,6 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum gl_capability_enum
|
||||
{
|
||||
GL_CAPS_NONE = 0,
|
||||
GL_CAPS_EGLIMAGE,
|
||||
GL_CAPS_SYNC,
|
||||
GL_CAPS_MIPMAP,
|
||||
GL_CAPS_VAO,
|
||||
GL_CAPS_FBO,
|
||||
GL_CAPS_ARGB8,
|
||||
GL_CAPS_DEBUG,
|
||||
GL_CAPS_PACKED_DEPTH_STENCIL,
|
||||
GL_CAPS_ES2_COMPAT,
|
||||
GL_CAPS_UNPACK_ROW_LENGTH,
|
||||
GL_CAPS_FULL_NPOT_SUPPORT,
|
||||
GL_CAPS_SRGB_FBO,
|
||||
GL_CAPS_SRGB_FBO_ES3,
|
||||
GL_CAPS_FP_FBO,
|
||||
GL_CAPS_BGRA8888
|
||||
};
|
||||
|
||||
void gl_renderchain_convert_geometry(gl_t *gl,
|
||||
struct video_fbo_rect *fbo_rect,
|
||||
struct gfx_fbo_scale *fbo_scale,
|
||||
@ -96,8 +76,6 @@ void gl_renderchain_free(gl_t *gl);
|
||||
|
||||
bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height);
|
||||
|
||||
bool gl_check_capability(enum gl_capability_enum enum_idx);
|
||||
|
||||
void context_bind_hw_render(bool enable);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include "../gl_capabilities.h"
|
||||
|
||||
#include "../../../driver.h"
|
||||
#include "../../../configuration.h"
|
||||
#include "../../../record/record_driver.h"
|
||||
|
@ -299,6 +299,7 @@ VIDEO DRIVER
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "../gfx/common/gl_common.c"
|
||||
#include "../gfx/drivers/gl.c"
|
||||
#include "../gfx/drivers/gl_capabilities.c"
|
||||
#include "../gfx/drivers/gl_renderchains/render_chain_gl_legacy.c"
|
||||
|
||||
#ifndef HAVE_PSGL
|
||||
|
Loading…
x
Reference in New Issue
Block a user