mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 05:43:34 +00:00
Create gl_query_core_context_in_use
This commit is contained in:
parent
c28b4da58c
commit
e2cc3bc08d
@ -215,7 +215,6 @@ typedef struct gl
|
|||||||
bool has_srgb_fbo_gles3;
|
bool has_srgb_fbo_gles3;
|
||||||
#endif
|
#endif
|
||||||
bool hw_render_use;
|
bool hw_render_use;
|
||||||
bool shared_context_use;
|
|
||||||
|
|
||||||
bool should_resize;
|
bool should_resize;
|
||||||
bool quitting;
|
bool quitting;
|
||||||
@ -286,7 +285,6 @@ typedef struct gl
|
|||||||
unsigned fence_count;
|
unsigned fence_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool core_context;
|
|
||||||
GLuint vao;
|
GLuint vao;
|
||||||
} gl_t;
|
} gl_t;
|
||||||
|
|
||||||
@ -339,6 +337,7 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gl_query_core_context_in_use(void);
|
||||||
void gl_ff_vertex(const struct video_coords *coords);
|
void gl_ff_vertex(const struct video_coords *coords);
|
||||||
void gl_ff_matrix(const math_matrix_4x4 *mat);
|
void gl_ff_matrix(const math_matrix_4x4 *mat);
|
||||||
|
|
||||||
|
@ -112,11 +112,17 @@ static const GLfloat white_color[] = {
|
|||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool gl_core_context = false;
|
static bool gl_core_context = false;
|
||||||
|
static bool gl_shared_context_use = false;
|
||||||
|
|
||||||
static INLINE void context_bind_hw_render(gl_t *gl, bool enable)
|
bool gl_query_core_context_in_use(void)
|
||||||
{
|
{
|
||||||
if (gl && gl->shared_context_use)
|
return gl_core_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE void context_bind_hw_render(bool enable)
|
||||||
|
{
|
||||||
|
if (gl_shared_context_use)
|
||||||
video_context_driver_bind_hw_render(&enable);
|
video_context_driver_bind_hw_render(&enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +757,7 @@ static void gl_deinit_hw_render(gl_t *gl)
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
|
|
||||||
if (gl->hw_render_fbo_init)
|
if (gl->hw_render_fbo_init)
|
||||||
glDeleteFramebuffers(gl->textures, gl->hw_render_fbo);
|
glDeleteFramebuffers(gl->textures, gl->hw_render_fbo);
|
||||||
@ -759,7 +765,7 @@ static void gl_deinit_hw_render(gl_t *gl)
|
|||||||
glDeleteRenderbuffers(gl->textures, gl->hw_render_depth);
|
glDeleteRenderbuffers(gl->textures, gl->hw_render_depth);
|
||||||
gl->hw_render_fbo_init = false;
|
gl->hw_render_fbo_init = false;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
|
static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
|
||||||
@ -775,7 +781,7 @@ static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
|
|||||||
|
|
||||||
/* We can only share texture objects through contexts.
|
/* We can only share texture objects through contexts.
|
||||||
* FBOs are "abstract" objects and are not shared. */
|
* FBOs are "abstract" objects and are not shared. */
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
|
|
||||||
RARCH_LOG("[GL]: Initializing HW render (%u x %u).\n", width, height);
|
RARCH_LOG("[GL]: Initializing HW render (%u x %u).\n", width, height);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_fbo_size);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_fbo_size);
|
||||||
@ -855,7 +861,7 @@ static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height)
|
|||||||
gl_bind_backbuffer();
|
gl_bind_backbuffer();
|
||||||
gl->hw_render_fbo_init = true;
|
gl->hw_render_fbo_init = true;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1773,7 +1779,7 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
|
|
||||||
video_driver_get_size(&width, &height);
|
video_driver_get_size(&width, &height);
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
#ifndef HAVE_OPENGLES
|
#ifndef HAVE_OPENGLES
|
||||||
if (gl_core_context)
|
if (gl_core_context)
|
||||||
@ -2043,7 +2049,7 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2079,7 +2085,8 @@ static void gl_destroy_resources(gl_t *gl)
|
|||||||
free(gl);
|
free(gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_core_context = false;
|
gl_shared_context_use = false;
|
||||||
|
gl_core_context = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_free(void *data)
|
static void gl_free(void *data)
|
||||||
@ -2088,7 +2095,7 @@ static void gl_free(void *data)
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
#ifdef HAVE_GL_SYNC
|
#ifdef HAVE_GL_SYNC
|
||||||
if (gl->have_sync)
|
if (gl->have_sync)
|
||||||
@ -2168,13 +2175,13 @@ static void gl_set_nonblock_state(void *data, bool state)
|
|||||||
|
|
||||||
RARCH_LOG("[GL]: VSync => %s\n", state ? "off" : "on");
|
RARCH_LOG("[GL]: VSync => %s\n", state ? "off" : "on");
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
interval = settings->video.swap_interval;
|
interval = settings->video.swap_interval;
|
||||||
|
|
||||||
video_context_driver_swap_interval(&interval);
|
video_context_driver_swap_interval(&interval);
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool resolve_extensions(gl_t *gl, const char *context_ident)
|
static bool resolve_extensions(gl_t *gl, const char *context_ident)
|
||||||
@ -2470,11 +2477,11 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl)
|
|||||||
|
|
||||||
(void)api_name;
|
(void)api_name;
|
||||||
|
|
||||||
gl->shared_context_use = settings->video.shared_context
|
gl_shared_context_use = settings->video.shared_context
|
||||||
&& hwr->context_type != RETRO_HW_CONTEXT_NONE;
|
&& hwr->context_type != RETRO_HW_CONTEXT_NONE;
|
||||||
|
|
||||||
return video_context_driver_init_first(gl, settings->video.context_driver,
|
return video_context_driver_init_first(gl, settings->video.context_driver,
|
||||||
api, major, minor, gl->shared_context_use);
|
api, major, minor, gl_shared_context_use);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GL_DEBUG
|
#ifdef GL_DEBUG
|
||||||
@ -2743,9 +2750,9 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
* create textures. */
|
* create textures. */
|
||||||
gl->textures = 1;
|
gl->textures = 1;
|
||||||
#ifdef GL_DEBUG
|
#ifdef GL_DEBUG
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
gl_begin_debug(gl);
|
gl_begin_debug(gl);
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -2877,7 +2884,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
if (!gl_check_error())
|
if (!gl_check_error())
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
return gl;
|
return gl;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -2949,7 +2956,7 @@ static void gl_update_tex_filter_frame(gl_t *gl)
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
shader_filter.index = 1;
|
shader_filter.index = 1;
|
||||||
shader_filter.smooth = &smooth;
|
shader_filter.smooth = &smooth;
|
||||||
@ -2990,7 +2997,7 @@ static void gl_update_tex_filter_frame(gl_t *gl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_set_shader(void *data,
|
static bool gl_set_shader(void *data,
|
||||||
@ -3005,7 +3012,7 @@ static bool gl_set_shader(void *data,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
if (type == RARCH_SHADER_NONE)
|
if (type == RARCH_SHADER_NONE)
|
||||||
return false;
|
return false;
|
||||||
@ -3086,7 +3093,7 @@ static bool gl_set_shader(void *data,
|
|||||||
/* Apparently need to set viewport for passes when we aren't using FBOs. */
|
/* Apparently need to set viewport for passes when we aren't using FBOs. */
|
||||||
gl_set_shader_viewport(gl, 0);
|
gl_set_shader_viewport(gl, 0);
|
||||||
gl_set_shader_viewport(gl, 1);
|
gl_set_shader_viewport(gl, 1);
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
shader_dlg_params_reload();
|
shader_dlg_params_reload();
|
||||||
#endif
|
#endif
|
||||||
@ -3096,7 +3103,7 @@ static bool gl_set_shader(void *data,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3128,7 +3135,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
rarch_perf_init(&read_viewport, "read_viewport");
|
rarch_perf_init(&read_viewport, "read_viewport");
|
||||||
retro_perf_start(&read_viewport);
|
retro_perf_start(&read_viewport);
|
||||||
@ -3213,11 +3220,11 @@ static bool gl_read_viewport(void *data, uint8_t *buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
retro_perf_stop(&read_viewport);
|
retro_perf_stop(&read_viewport);
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -3419,14 +3426,14 @@ static bool gl_overlay_load(void *data,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
gl_free_overlay(gl);
|
gl_free_overlay(gl);
|
||||||
gl->overlay_tex = (GLuint*)calloc(num_images, sizeof(*gl->overlay_tex));
|
gl->overlay_tex = (GLuint*)calloc(num_images, sizeof(*gl->overlay_tex));
|
||||||
|
|
||||||
if (!gl->overlay_tex)
|
if (!gl->overlay_tex)
|
||||||
{
|
{
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3464,7 +3471,7 @@ static bool gl_overlay_load(void *data,
|
|||||||
gl->overlay_color_coord[16 * i + j] = 1.0f;
|
gl->overlay_color_coord[16 * i + j] = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3705,7 +3712,7 @@ static void gl_set_texture_frame(void *data,
|
|||||||
if (!gl)
|
if (!gl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
context_bind_hw_render(gl, false);
|
context_bind_hw_render(false);
|
||||||
|
|
||||||
menu_filter = settings->menu.linear_filter ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST;
|
menu_filter = settings->menu.linear_filter ? TEXTURE_FILTER_LINEAR : TEXTURE_FILTER_NEAREST;
|
||||||
|
|
||||||
@ -3722,7 +3729,7 @@ static void gl_set_texture_frame(void *data,
|
|||||||
gl->menu_texture_alpha = alpha;
|
gl->menu_texture_alpha = alpha;
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
|
||||||
|
|
||||||
context_bind_hw_render(gl, true);
|
context_bind_hw_render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_set_texture_enable(void *data, bool state, bool full_screen)
|
static void gl_set_texture_enable(void *data, bool state, bool full_screen)
|
||||||
|
@ -71,7 +71,7 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(GL_VERSION_3_0)
|
#if defined(GL_VERSION_3_0)
|
||||||
if (font->gl->core_context ||
|
if (gl_query_core_context_in_use() ||
|
||||||
(hwr->context_type == RETRO_HW_CONTEXT_OPENGL &&
|
(hwr->context_type == RETRO_HW_CONTEXT_OPENGL &&
|
||||||
hwr->version_major >= 3))
|
hwr->version_major >= 3))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user