mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
(GL3) Use flags instead of booleans
This commit is contained in:
parent
582ed9e9e8
commit
4c3fefa2be
@ -49,6 +49,23 @@ struct gl3_streamed_texture
|
||||
unsigned height;
|
||||
};
|
||||
|
||||
enum gl3_flags
|
||||
{
|
||||
GL3_FLAG_PBO_READBACK_ENABLE = (1 << 0),
|
||||
GL3_FLAG_HW_RENDER_BOTTOM_LEFT = (1 << 1),
|
||||
GL3_FLAG_HW_RENDER_ENABLE = (1 << 2),
|
||||
GL3_FLAG_USE_SHARED_CONTEXT = (1 << 3),
|
||||
GL3_FLAG_OVERLAY_ENABLE = (1 << 4),
|
||||
GL3_FLAG_OVERLAY_FULLSCREEN = (1 << 5),
|
||||
GL3_FLAG_MENU_TEXTURE_ENABLE = (1 << 6),
|
||||
GL3_FLAG_MENU_TEXTURE_FULLSCREEN= (1 << 7),
|
||||
GL3_FLAG_VSYNC = (1 << 8),
|
||||
GL3_FLAG_FULLSCREEN = (1 << 9),
|
||||
GL3_FLAG_QUITTING = (1 << 10),
|
||||
GL3_FLAG_SHOULD_RESIZE = (1 << 11),
|
||||
GL3_FLAG_KEEP_ASPECT = (1 << 12)
|
||||
};
|
||||
|
||||
typedef struct gl3
|
||||
{
|
||||
const gfx_ctx_driver_t *ctx_driver;
|
||||
@ -115,20 +132,9 @@ typedef struct gl3
|
||||
math_matrix_4x4 mvp_no_rot;
|
||||
math_matrix_4x4 mvp_no_rot_yflip;
|
||||
|
||||
uint16_t flags;
|
||||
|
||||
bool pbo_readback_valid[GL_CORE_NUM_PBOS];
|
||||
bool pbo_readback_enable;
|
||||
bool hw_render_bottom_left;
|
||||
bool hw_render_enable;
|
||||
bool use_shared_context;
|
||||
bool overlay_enable;
|
||||
bool overlay_full_screen;
|
||||
bool menu_texture_enable;
|
||||
bool menu_texture_full_screen;
|
||||
bool vsync;
|
||||
bool fullscreen;
|
||||
bool quitting;
|
||||
bool should_resize;
|
||||
bool keep_aspect;
|
||||
} gl3_t;
|
||||
|
||||
void gl3_bind_scratch_vbo(gl3_t *gl, const void *data, size_t size);
|
||||
|
@ -98,7 +98,7 @@ static bool gl3_init_pbo_readback(gl3_t *gl)
|
||||
|
||||
if (!scaler_ctx_gen_filter(scaler))
|
||||
{
|
||||
gl->pbo_readback_enable = false;
|
||||
gl->flags &= ~GL3_FLAG_PBO_READBACK_ENABLE;
|
||||
RARCH_ERR("[GLCore]: Failed to initialize pixel conversion for PBO.\n");
|
||||
glDeleteBuffers(4, gl->pbo_readback);
|
||||
memset(gl->pbo_readback, 0, sizeof(gl->pbo_readback));
|
||||
@ -264,7 +264,7 @@ static void gl3_render_overlay(gl3_t *gl,
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
if (gl->overlay_full_screen)
|
||||
if (gl->flags & GL3_FLAG_OVERLAY_FULLSCREEN)
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
/* Ensure that we reset the attrib array. */
|
||||
@ -296,14 +296,14 @@ static void gl3_render_overlay(gl3_t *gl,
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (gl->overlay_full_screen)
|
||||
if (gl->flags & GL3_FLAG_OVERLAY_FULLSCREEN)
|
||||
glViewport(gl->vp.x, gl->vp.y, gl->vp.width, gl->vp.height);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void gl3_deinit_hw_render(gl3_t *gl)
|
||||
{
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
|
||||
if (gl->hw_render_fbo)
|
||||
@ -317,10 +317,10 @@ static void gl3_deinit_hw_render(gl3_t *gl)
|
||||
gl->hw_render_rb_ds = 0;
|
||||
gl->hw_render_texture = 0;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
gl->hw_render_enable = false;
|
||||
gl->flags &= ~GL3_FLAG_HW_RENDER_ENABLE;
|
||||
}
|
||||
|
||||
static void gl3_destroy_resources(gl3_t *gl)
|
||||
@ -329,7 +329,7 @@ static void gl3_destroy_resources(gl3_t *gl)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
if (gl->filter_chain)
|
||||
@ -381,7 +381,7 @@ static bool gl3_init_hw_render(gl3_t *gl, unsigned width, unsigned height)
|
||||
GLenum status;
|
||||
struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
|
||||
RARCH_LOG("[GLCore]: Initializing HW render (%ux%u).\n", width, height);
|
||||
@ -407,7 +407,11 @@ static bool gl3_init_hw_render(gl3_t *gl, unsigned width, unsigned height)
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->hw_render_texture, 0);
|
||||
|
||||
gl->hw_render_rb_ds = 0;
|
||||
gl->hw_render_bottom_left = hwr->bottom_left_origin;
|
||||
if (hwr->bottom_left_origin)
|
||||
gl->flags |= GL3_FLAG_HW_RENDER_BOTTOM_LEFT;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_HW_RENDER_BOTTOM_LEFT;
|
||||
|
||||
if (hwr->depth)
|
||||
{
|
||||
glGenRenderbuffers(1, &gl->hw_render_rb_ds);
|
||||
@ -426,7 +430,7 @@ static bool gl3_init_hw_render(gl3_t *gl, unsigned width, unsigned height)
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
RARCH_ERR("[GLCore]: Framebuffer is not complete.\n");
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
return false;
|
||||
}
|
||||
@ -438,13 +442,13 @@ static bool gl3_init_hw_render(gl3_t *gl, unsigned width, unsigned height)
|
||||
else
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
gl->hw_render_enable = true;
|
||||
gl->flags |= GL3_FLAG_HW_RENDER_ENABLE;
|
||||
gl->hw_render_max_width = width;
|
||||
gl->hw_render_max_height = height;
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
return true;
|
||||
@ -497,18 +501,25 @@ static const gfx_ctx_driver_t *gl3_get_context(gl3_t *gl)
|
||||
|
||||
/* Force shared context. */
|
||||
if (hwr)
|
||||
gl->use_shared_context = hwr->context_type != RETRO_HW_CONTEXT_NONE;
|
||||
{
|
||||
if (hwr->context_type != RETRO_HW_CONTEXT_NONE)
|
||||
gl->flags |= GL3_FLAG_USE_SHARED_CONTEXT;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_USE_SHARED_CONTEXT;
|
||||
}
|
||||
|
||||
gfx_ctx = video_context_driver_init_first(gl,
|
||||
settings->arrays.video_context_driver,
|
||||
api, major, minor, gl->use_shared_context, &ctx_data);
|
||||
api, major, minor,
|
||||
gl->flags & GL3_FLAG_USE_SHARED_CONTEXT,
|
||||
&ctx_data);
|
||||
|
||||
if (ctx_data)
|
||||
gl->ctx_data = ctx_data;
|
||||
|
||||
/* Need to force here since video_context_driver_init also checks for global option. */
|
||||
if (gfx_ctx->bind_hw_render)
|
||||
gfx_ctx->bind_hw_render(ctx_data, gl->use_shared_context);
|
||||
gfx_ctx->bind_hw_render(ctx_data, gl->flags & GL3_FLAG_USE_SHARED_CONTEXT);
|
||||
return gfx_ctx;
|
||||
}
|
||||
|
||||
@ -576,11 +587,12 @@ static void gl3_set_viewport(gl3_t *gl,
|
||||
{
|
||||
video_viewport_get_scaled_integer(&gl->vp,
|
||||
viewport_width, viewport_height,
|
||||
video_driver_get_aspect_ratio(), gl->keep_aspect);
|
||||
video_driver_get_aspect_ratio(),
|
||||
gl->flags & GL3_FLAG_KEEP_ASPECT);
|
||||
viewport_width = gl->vp.width;
|
||||
viewport_height = gl->vp.height;
|
||||
}
|
||||
else if (gl->keep_aspect && !force_full)
|
||||
else if ((gl->flags & GL3_FLAG_KEEP_ASPECT) && !force_full)
|
||||
{
|
||||
float desired_aspect = video_driver_get_aspect_ratio();
|
||||
|
||||
@ -961,7 +973,7 @@ static void *gl3_init(const video_info_t *video,
|
||||
const char *renderer = NULL;
|
||||
const char *version = NULL;
|
||||
char *error_string = NULL;
|
||||
gl3_t *gl = (gl3_t*)calloc(1, sizeof(gl3_t));
|
||||
gl3_t *gl = (gl3_t*)calloc(1, sizeof(gl3_t));
|
||||
const gfx_ctx_driver_t *ctx_driver = gl3_get_context(gl);
|
||||
struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
|
||||
|
||||
@ -1013,7 +1025,7 @@ static void *gl3_init(const video_info_t *video,
|
||||
win_width, win_height, video->fullscreen))
|
||||
goto error;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
rglgen_resolve_symbols(ctx_driver->get_proc_address);
|
||||
@ -1023,7 +1035,7 @@ static void *gl3_init(const video_info_t *video,
|
||||
|
||||
#ifdef GL_DEBUG
|
||||
gl3_begin_debug(gl);
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
{
|
||||
if (gl->hw_render_enable)
|
||||
{
|
||||
@ -1082,12 +1094,15 @@ static void *gl3_init(const video_info_t *video,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
gl->vsync = video->vsync;
|
||||
gl->fullscreen = video->fullscreen;
|
||||
gl->keep_aspect = video->force_aspect;
|
||||
if (video->vsync)
|
||||
gl->flags |= GL3_FLAG_VSYNC;
|
||||
if (video->fullscreen)
|
||||
gl->flags |= GL3_FLAG_FULLSCREEN;
|
||||
if (video->force_aspect)
|
||||
gl->flags |= GL3_FLAG_KEEP_ASPECT;
|
||||
|
||||
mode_width = 0;
|
||||
mode_height = 0;
|
||||
mode_width = 0;
|
||||
mode_height = 0;
|
||||
|
||||
if (gl->ctx_driver->get_video_size)
|
||||
gl->ctx_driver->get_video_size(gl->ctx_data,
|
||||
@ -1125,21 +1140,23 @@ static void *gl3_init(const video_info_t *video,
|
||||
}
|
||||
|
||||
if (video->font_enable)
|
||||
{
|
||||
font_driver_init_osd(gl,
|
||||
video,
|
||||
false,
|
||||
video->is_threaded,
|
||||
FONT_DRIVER_RENDER_OPENGL_CORE_API);
|
||||
}
|
||||
|
||||
gl->pbo_readback_enable = video_gpu_record
|
||||
&& recording_state_get_ptr()->enable;
|
||||
|
||||
if (gl->pbo_readback_enable && gl3_init_pbo_readback(gl))
|
||||
if (video_gpu_record
|
||||
&& recording_state_get_ptr()->enable)
|
||||
{
|
||||
RARCH_LOG("[GLCore]: Async PBO readback enabled.\n");
|
||||
gl->flags |= GL3_FLAG_PBO_READBACK_ENABLE;
|
||||
if (gl3_init_pbo_readback(gl))
|
||||
{
|
||||
RARCH_LOG("[GLCore]: Async PBO readback enabled.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_PBO_READBACK_ENABLE;
|
||||
|
||||
if (!gl_check_error(&error_string))
|
||||
{
|
||||
@ -1152,7 +1169,7 @@ static void *gl3_init(const video_info_t *video,
|
||||
glBindVertexArray(gl->vao);
|
||||
glBindVertexArray(0);
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return gl;
|
||||
|
||||
@ -1295,9 +1312,12 @@ static void gl3_overlay_enable(void *data, bool state)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl->overlay_enable = state;
|
||||
if (state)
|
||||
gl->flags |= GL3_FLAG_OVERLAY_ENABLE;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_OVERLAY_ENABLE;
|
||||
|
||||
if (gl->fullscreen && gl->ctx_driver->show_mouse)
|
||||
if ((gl->flags & GL3_FLAG_FULLSCREEN) && gl->ctx_driver->show_mouse)
|
||||
gl->ctx_driver->show_mouse(gl->ctx_data, state);
|
||||
}
|
||||
|
||||
@ -1305,7 +1325,12 @@ static void gl3_overlay_full_screen(void *data, bool enable)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (gl)
|
||||
gl->overlay_full_screen = enable;
|
||||
{
|
||||
if (enable)
|
||||
gl->flags |= GL3_FLAG_OVERLAY_FULLSCREEN;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_OVERLAY_FULLSCREEN;
|
||||
}
|
||||
}
|
||||
|
||||
static void gl3_overlay_set_alpha(void *data, unsigned image, float mod)
|
||||
@ -1346,7 +1371,7 @@ static void gl3_free(void *data)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
font_driver_free_osd();
|
||||
gl3_destroy_resources(gl);
|
||||
@ -1378,11 +1403,11 @@ static bool gl3_alive(void *data)
|
||||
#endif
|
||||
|
||||
if (quit)
|
||||
gl->quitting = true;
|
||||
gl->flags |= GL3_FLAG_QUITTING;
|
||||
else if (resize)
|
||||
gl->should_resize = true;
|
||||
gl->flags |= GL3_FLAG_SHOULD_RESIZE;
|
||||
|
||||
ret = !gl->quitting;
|
||||
ret = !(gl->flags & GL3_FLAG_QUITTING);
|
||||
|
||||
if (temp_width != 0 && temp_height != 0)
|
||||
{
|
||||
@ -1404,7 +1429,7 @@ static void gl3_set_nonblock_state(void *data, bool state,
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
if (!state)
|
||||
interval = swap_interval;
|
||||
@ -1416,7 +1441,7 @@ static void gl3_set_nonblock_state(void *data, bool state,
|
||||
gl->ctx_driver->swap_interval(gl->ctx_data, interval);
|
||||
}
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
}
|
||||
|
||||
@ -1436,7 +1461,7 @@ static bool gl3_set_shader(void *data,
|
||||
if (!gl)
|
||||
return false;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
if (gl->filter_chain)
|
||||
@ -1459,13 +1484,13 @@ static bool gl3_set_shader(void *data,
|
||||
{
|
||||
RARCH_ERR("[GLCore]: Failed to create filter chain: \"%s\". Falling back to stock.\n", path);
|
||||
gl3_init_default_filter_chain(gl);
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
end:
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return true;
|
||||
}
|
||||
@ -1477,7 +1502,10 @@ static void gl3_set_rotation(void *data, unsigned rotation)
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl->rotation = video_driver_is_hw_context() && gl->hw_render_bottom_left ? 90 * rotation : 270 * rotation;
|
||||
if (video_driver_is_hw_context() && (gl->flags & GL3_FLAG_HW_RENDER_BOTTOM_LEFT))
|
||||
gl->rotation = 90 * rotation;
|
||||
else
|
||||
gl->rotation = 270 * rotation;
|
||||
gl3_set_projection(gl, &gl3_default_ortho, true);
|
||||
}
|
||||
|
||||
@ -1507,11 +1535,11 @@ static bool gl3_read_viewport(void *data, uint8_t *buffer, bool is_idle)
|
||||
if (!gl)
|
||||
return false;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
num_pixels = gl->vp.width * gl->vp.height;
|
||||
|
||||
if (gl->pbo_readback_enable)
|
||||
if (gl->flags & GL3_FLAG_PBO_READBACK_ENABLE)
|
||||
{
|
||||
const void *ptr = NULL;
|
||||
struct scaler_ctx *ctx = &gl->pbo_readback_scaler;
|
||||
@ -1560,12 +1588,12 @@ static bool gl3_read_viewport(void *data, uint8_t *buffer, bool is_idle)
|
||||
gl->readback_buffer_screenshot = NULL;
|
||||
}
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return true;
|
||||
|
||||
error:
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return false;
|
||||
}
|
||||
@ -1631,7 +1659,7 @@ static void gl3_draw_menu_texture(gl3_t *gl,
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
if (gl->menu_texture_full_screen)
|
||||
if (gl->flags & GL3_FLAG_MENU_TEXTURE_FULLSCREEN)
|
||||
glViewport(0, 0, width, height);
|
||||
else
|
||||
glViewport(gl->vp.x, gl->vp.y, gl->vp.width, gl->vp.height);
|
||||
@ -1699,7 +1727,7 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
if (!gl)
|
||||
return false;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
glBindVertexArray(gl->vao);
|
||||
|
||||
@ -1710,22 +1738,22 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
streamed = &gl->textures[gl->textures_index];
|
||||
if (frame)
|
||||
{
|
||||
if (!gl->hw_render_enable)
|
||||
gl3_update_cpu_texture(gl, streamed, frame,
|
||||
frame_width, frame_height, pitch);
|
||||
else
|
||||
if (gl->flags & GL3_FLAG_HW_RENDER_ENABLE)
|
||||
{
|
||||
streamed->width = frame_width;
|
||||
streamed->height = frame_height;
|
||||
}
|
||||
else
|
||||
gl3_update_cpu_texture(gl, streamed, frame,
|
||||
frame_width, frame_height, pitch);
|
||||
}
|
||||
|
||||
if (gl->should_resize)
|
||||
if (gl->flags & GL3_FLAG_SHOULD_RESIZE)
|
||||
{
|
||||
if (gl->ctx_driver->set_resize)
|
||||
gl->ctx_driver->set_resize(gl->ctx_data,
|
||||
width, height);
|
||||
gl->should_resize = false;
|
||||
gl->flags &= ~GL3_FLAG_SHOULD_RESIZE;
|
||||
}
|
||||
|
||||
gl3_set_viewport(gl, width, height, false, true);
|
||||
@ -1736,7 +1764,8 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
texture.padded_width = 0;
|
||||
texture.padded_height = 0;
|
||||
texture.format = 0;
|
||||
if (gl->hw_render_enable)
|
||||
|
||||
if (gl->flags & GL3_FLAG_HW_RENDER_ENABLE)
|
||||
{
|
||||
texture.image = gl->hw_render_texture;
|
||||
texture.format = GL_RGBA8;
|
||||
@ -1744,9 +1773,9 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
texture.padded_height = gl->hw_render_max_height;
|
||||
|
||||
if (texture.width == 0)
|
||||
texture.width = 1;
|
||||
texture.width = 1;
|
||||
if (texture.height == 0)
|
||||
texture.height = 1;
|
||||
texture.height = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1770,21 +1799,21 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl3_filter_chain_build_viewport_pass(gl->filter_chain,
|
||||
&gl->filter_chain_vp,
|
||||
gl->hw_render_bottom_left
|
||||
(gl->flags & GL3_FLAG_HW_RENDER_BOTTOM_LEFT)
|
||||
? gl->mvp.data
|
||||
: gl->mvp_yflip.data);
|
||||
gl3_filter_chain_end_frame(gl->filter_chain);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (gl->overlay_enable && overlay_behind_menu)
|
||||
if ((gl->flags & GL3_FLAG_OVERLAY_ENABLE) && overlay_behind_menu)
|
||||
gl3_render_overlay(gl, width, height);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
if (gl->menu_texture_enable)
|
||||
if (gl->flags & GL3_FLAG_MENU_TEXTURE_ENABLE)
|
||||
{
|
||||
menu_driver_frame(menu_is_alive, video_info);
|
||||
if (gl->menu_texture_enable && gl->menu_texture)
|
||||
if (gl->menu_texture)
|
||||
gl3_draw_menu_texture(gl, width, height);
|
||||
}
|
||||
else if (statistics_show)
|
||||
@ -1796,7 +1825,7 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (gl->overlay_enable && !overlay_behind_menu)
|
||||
if ((gl->flags & GL3_FLAG_OVERLAY_ENABLE) && !overlay_behind_menu)
|
||||
gl3_render_overlay(gl, width, height);
|
||||
#endif
|
||||
|
||||
@ -1831,11 +1860,11 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
gl->readback_buffer_screenshot);
|
||||
}
|
||||
else if (gl->pbo_readback_enable)
|
||||
else if (gl->flags & GL3_FLAG_PBO_READBACK_ENABLE)
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
/* Don't readback if we're in menu mode. */
|
||||
if (!gl->menu_texture_enable)
|
||||
if (!(gl->flags & GL3_FLAG_MENU_TEXTURE_ENABLE))
|
||||
#endif
|
||||
gl3_pbo_async_readback(gl);
|
||||
}
|
||||
@ -1853,7 +1882,7 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
&& !input_driver_nonblock_state
|
||||
&& !runloop_is_slowmotion
|
||||
&& !runloop_is_paused
|
||||
&& !gl->menu_texture_enable)
|
||||
&& (!(gl->flags & GL3_FLAG_MENU_TEXTURE_ENABLE)))
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < black_frame_insertion; ++n)
|
||||
@ -1873,7 +1902,7 @@ static bool gl3_frame(void *data, const void *frame,
|
||||
gl3_fence_iterate(gl, hard_sync_frames);
|
||||
|
||||
glBindVertexArray(0);
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
return true;
|
||||
}
|
||||
@ -1901,29 +1930,24 @@ static float gl3_get_refresh_rate(void *data)
|
||||
|
||||
static void gl3_set_aspect_ratio(void *data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl->keep_aspect = true;
|
||||
gl->should_resize = true;
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (gl)
|
||||
gl->flags |= (GL3_FLAG_KEEP_ASPECT | GL3_FLAG_SHOULD_RESIZE);
|
||||
}
|
||||
|
||||
static void gl3_apply_state_changes(void *data)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (gl)
|
||||
gl->should_resize = true;
|
||||
gl->flags |= GL3_FLAG_SHOULD_RESIZE;
|
||||
}
|
||||
|
||||
static struct video_shader *gl3_get_current_shader(void *data)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (!gl || !gl->filter_chain)
|
||||
return NULL;
|
||||
|
||||
return gl3_filter_chain_get_preset(gl->filter_chain);
|
||||
if (gl && gl->filter_chain)
|
||||
return gl3_filter_chain_get_preset(gl->filter_chain);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
@ -2029,7 +2053,7 @@ static void gl3_set_texture_frame(void *data,
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
|
||||
|
||||
if (gl->menu_texture)
|
||||
@ -2059,19 +2083,25 @@ static void gl3_set_texture_frame(void *data,
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
gl->menu_texture_alpha = alpha;
|
||||
if (gl->use_shared_context)
|
||||
if (gl->flags & GL3_FLAG_USE_SHARED_CONTEXT)
|
||||
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
|
||||
}
|
||||
|
||||
static void gl3_set_texture_enable(void *data, bool state, bool full_screen)
|
||||
static void gl3_set_texture_enable(void *data, bool state, bool fullscreen)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl->menu_texture_enable = state;
|
||||
gl->menu_texture_full_screen = full_screen;
|
||||
if (state)
|
||||
gl->flags |= GL3_FLAG_MENU_TEXTURE_ENABLE;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_MENU_TEXTURE_ENABLE;
|
||||
if (fullscreen)
|
||||
gl->flags |= GL3_FLAG_MENU_TEXTURE_FULLSCREEN;
|
||||
else
|
||||
gl->flags &= ~GL3_FLAG_MENU_TEXTURE_FULLSCREEN;
|
||||
}
|
||||
|
||||
static void gl3_get_video_output_size(void *data,
|
||||
@ -2101,9 +2131,9 @@ static void gl3_get_video_output_next(void *data)
|
||||
static uintptr_t gl3_get_current_framebuffer(void *data)
|
||||
{
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (!gl || !gl->hw_render_enable)
|
||||
return 0;
|
||||
return gl->hw_render_fbo;
|
||||
if (gl && (gl->flags & GL3_FLAG_HW_RENDER_ENABLE))
|
||||
return gl->hw_render_fbo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static retro_proc_address_t gl3_get_proc_address(
|
||||
@ -2112,7 +2142,6 @@ static retro_proc_address_t gl3_get_proc_address(
|
||||
gl3_t *gl = (gl3_t*)data;
|
||||
if (gl && gl->ctx_driver->get_proc_address)
|
||||
return gl->ctx_driver->get_proc_address(sym);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user