(gfx/drivers) Cleanups

This commit is contained in:
libretroadmin 2023-01-08 19:22:48 +01:00
parent 490fb75905
commit af9f946019
10 changed files with 282 additions and 301 deletions

View File

@ -24,8 +24,6 @@
#define CINTERFACE
#define COBJMACROS
#include <assert.h>
#include <string/stdstring.h>
#include <file/file_path.h>
#include <encodings/utf.h>
@ -79,7 +77,7 @@ static void d3d10_clear_scissor(d3d10_video_t *d3d10, unsigned width, unsigned h
#ifdef HAVE_OVERLAY
static void d3d10_free_overlays(d3d10_video_t* d3d10)
{
unsigned i;
int i;
for (i = 0; i < (unsigned)d3d10->overlays.count; i++)
d3d10_release_texture(&d3d10->overlays.textures[i]);
@ -149,8 +147,8 @@ static void d3d10_overlay_set_alpha(void* data, unsigned index, float mod)
static bool d3d10_overlay_load(void* data, const void* image_data, unsigned num_images)
{
int i;
D3D10_BUFFER_DESC desc;
unsigned i = 0;
d3d10_sprite_t* sprites = NULL;
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
const struct texture_image* images = (const struct texture_image*)image_data;
@ -252,7 +250,7 @@ static void d3d10_get_overlay_interface(void* data, const video_overlay_interfac
static void d3d10_render_overlay(d3d10_video_t *d3d10)
{
unsigned i;
int i;
if (d3d10->flags & D3D10_ST_FLAG_OVERLAYS_FULLSCREEN)
d3d10->device->lpVtbl->RSSetViewports(d3d10->device, 1, &d3d10->viewport);
@ -266,7 +264,7 @@ static void d3d10_render_overlay(d3d10_video_t *d3d10)
d3d10->device->lpVtbl->PSSetSamplers(d3d10->device, 0, 1,
&d3d10->samplers[RARCH_FILTER_UNSPEC][RARCH_WRAP_DEFAULT]);
for (i = 0; i < (unsigned)d3d10->overlays.count; i++)
for (i = 0; i < d3d10->overlays.count; i++)
{
d3d10->device->lpVtbl->PSSetShaderResources(d3d10->device, 0, 1, &d3d10->overlays.textures[i].view);
d3d10->device->lpVtbl->Draw(d3d10->device, 1, i);
@ -276,7 +274,7 @@ static void d3d10_render_overlay(d3d10_video_t *d3d10)
static void d3d10_set_filtering(void* data, unsigned index, bool smooth, bool ctx_scaling)
{
unsigned i;
int i;
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
if (smooth)
@ -346,13 +344,13 @@ static void d3d10_update_viewport(d3d10_video_t *d3d10, bool force_full)
static void d3d10_free_shader_preset(d3d10_video_t* d3d10)
{
unsigned i;
int i;
if (!d3d10->shader_preset)
return;
for (i = 0; i < d3d10->shader_preset->passes; i++)
{
unsigned j;
int j;
free(d3d10->shader_preset->pass[i].source.string.vertex);
free(d3d10->shader_preset->pass[i].source.string.fragment);
@ -1154,8 +1152,6 @@ static void d3d10_init_history(d3d10_video_t* d3d10,
/* TODO/FIXME: should we init history to max_width/max_height instead ?
* to prevent out of memory errors happening several frames later
* and to reduce memory fragmentation */
assert(d3d10->shader_preset);
for (i = 0; i < (int)d3d10->shader_preset->history_size + 1; i++)
{
d3d10->frame.texture[i].desc.Width = width;
@ -1172,10 +1168,7 @@ static void d3d10_init_history(d3d10_video_t* d3d10,
static void d3d10_init_render_targets(d3d10_video_t* d3d10,
unsigned width, unsigned height)
{
unsigned i;
assert(d3d10->shader_preset);
int i;
for (i = 0; i < d3d10->shader_preset->passes; i++)
{
struct video_shader_pass* pass = &d3d10->shader_preset->pass[i];
@ -1415,7 +1408,7 @@ static bool d3d10_gfx_frame(
for (i = 0; i < d3d10->shader_preset->passes; i++)
{
unsigned j;
int j;
d3d10_set_shader(context, &d3d10->pass[i].shader);

View File

@ -24,8 +24,6 @@
#define CINTERFACE
#define COBJMACROS
#include <assert.h>
#include <string/stdstring.h>
#include <gfx/scaler/pixconv.h>
#include <retro_miscellaneous.h>
@ -1733,11 +1731,9 @@ static void d3d11_init_history(d3d11_video_t* d3d11, unsigned width, unsigned he
{
int i;
/* TODO/FIXME: should we init history to max_width/max_height instead ?
/* TODO/FIXME: Should we init history to max_width/max_height instead ?
* to prevent out of memory errors happening several frames later
* and to reduce memory fragmentation */
assert(d3d11->shader_preset);
for (i = 0; i < d3d11->shader_preset->history_size + 1; i++)
{
d3d11->frame.texture[i].desc.Width = width;
@ -1755,8 +1751,6 @@ static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsi
{
int i;
assert(d3d11->shader_preset);
for (i = 0; i < (int)d3d11->shader_preset->passes; i++)
{
struct video_shader_pass* pass = &d3d11->shader_preset->pass[i];

View File

@ -23,7 +23,6 @@
#define CINTERFACE
#include <assert.h>
#include <boolean.h>
#include <string/stdstring.h>
#include <file/file_path.h>
@ -111,7 +110,7 @@ static void d3d12_gfx_sync(d3d12_video_t* d3d12)
#ifdef HAVE_OVERLAY
static void d3d12_free_overlays(d3d12_video_t* d3d12)
{
unsigned i;
int i;
for (i = 0; i < (unsigned)d3d12->overlays.count; i++)
d3d12_release_texture(&d3d12->overlays.textures[i]);
@ -190,8 +189,8 @@ static void d3d12_overlay_set_alpha(void* data, unsigned index, float mod)
static bool d3d12_overlay_load(void* data, const void* image_data, unsigned num_images)
{
int i;
D3D12_RANGE range;
unsigned i;
d3d12_sprite_t* sprites = NULL;
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
const struct texture_image* images = (const struct texture_image*)image_data;
@ -290,7 +289,7 @@ static void d3d12_get_overlay_interface(void* data, const video_overlay_interfac
static void d3d12_render_overlay(d3d12_video_t *d3d12)
{
unsigned i;
int i;
if (d3d12->flags & D3D12_ST_FLAG_OVERLAYS_FULLSCREEN)
{
@ -433,7 +432,7 @@ static void d3d12_set_hdr10(d3d12_video_t* d3d12, bool hdr10)
static void d3d12_set_filtering(void* data, unsigned index, bool smooth, bool ctx_scaling)
{
int i;
int i;
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
for (i = 0; i < RARCH_WRAP_MAX; i++)
@ -512,13 +511,13 @@ static void d3d12_update_viewport(d3d12_video_t *d3d12, bool force_full)
static void d3d12_free_shader_preset(d3d12_video_t* d3d12)
{
unsigned i;
int i;
if (!d3d12->shader_preset)
return;
for (i = 0; i < d3d12->shader_preset->passes; i++)
{
unsigned j;
int j;
free(d3d12->shader_preset->pass[i].source.string.vertex);
free(d3d12->shader_preset->pass[i].source.string.fragment);
@ -613,7 +612,7 @@ static void d3d12_init_pipeline(
static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path)
{
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
unsigned i;
int i;
d3d12_texture_t* source = NULL;
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
@ -1964,13 +1963,10 @@ error:
static void d3d12_init_history(d3d12_video_t* d3d12, unsigned width, unsigned height)
{
unsigned i;
int i;
/* TODO/FIXME: should we init history to max_width/max_height instead ?
* to prevent out of memory errors happening several frames later
* and to reduce memory fragmentation */
assert(d3d12->shader_preset);
for (i = 0; i < (unsigned)d3d12->shader_preset->history_size + 1; i++)
{
d3d12->frame.texture[i].desc.Width = width;
@ -1987,10 +1983,7 @@ static void d3d12_init_history(d3d12_video_t* d3d12, unsigned width, unsigned he
static void d3d12_init_render_targets(d3d12_video_t* d3d12, unsigned width, unsigned height)
{
unsigned i;
assert(d3d12->shader_preset);
int i;
for (i = 0; i < d3d12->shader_preset->passes; i++)
{
struct video_shader_pass* pass = &d3d12->shader_preset->pass[i];

View File

@ -103,7 +103,7 @@ typedef struct cg_renderchain
static INLINE bool d3d9_cg_validate_param_name(const char *name)
{
unsigned i;
int i;
static const char *illegal[] = {
"PREV.",
"PREV1.",
@ -672,7 +672,7 @@ static void d3d9_cg_renderchain_bind_pass(
static void d3d9_cg_deinit_progs(cg_renderchain_t *chain)
{
unsigned i;
int i;
if (chain->chain.passes->count >= 1)
{
@ -702,7 +702,7 @@ static void d3d9_cg_deinit_progs(cg_renderchain_t *chain)
static void d3d9_cg_destroy_resources(cg_renderchain_t *chain)
{
unsigned i;
int i;
for (i = 0; i < TEXTURES; i++)
{
@ -1804,7 +1804,7 @@ static bool d3d9_cg_frame(void *data, const void *frame,
if (black_frame_insertion && !d3d->menu->enabled)
{
unsigned n;
int n;
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
bool ret = (IDirect3DDevice9_Present(d3d->dev,

View File

@ -293,7 +293,7 @@ static bool hlsl_d3d9_renderchain_create_first_pass(
const struct LinkInfo *info,
unsigned _fmt)
{
unsigned i;
int i;
struct shader_pass pass = { 0 };
unsigned fmt =
(_fmt == RETRO_PIXEL_FORMAT_RGB565)
@ -465,7 +465,7 @@ static void d3d9_hlsl_deinit_progs(hlsl_renderchain_t *chain)
{
if (chain->chain.passes->count >= 1)
{
unsigned i;
int i;
d3d9_vertex_buffer_free(NULL,
chain->chain.passes->data[0].vertex_decl);
@ -484,7 +484,7 @@ static void d3d9_hlsl_deinit_progs(hlsl_renderchain_t *chain)
static void d3d9_hlsl_destroy_resources(hlsl_renderchain_t *chain)
{
unsigned i;
int i;
for (i = 0; i < TEXTURES; i++)
{

View File

@ -105,7 +105,7 @@ static void gl1_render_overlay(gl1_t *gl,
unsigned width,
unsigned height)
{
unsigned i;
int i;
glEnable(GL_BLEND);
@ -825,10 +825,12 @@ static bool gl1_gfx_frame(void *data, const void *frame,
{
if (bits == 32)
{
unsigned y;
int y;
/* copy lines into top-left portion of larger (power-of-two) buffer */
for (y = 0; y < height; y++)
memcpy(gl1->video_buf + ((pot_width * (bits / 8)) * y), (const unsigned char*)frame + (pitch * y), width * (bits / 8));
memcpy(gl1->video_buf + ((pot_width * (bits / 8)) * y),
(const unsigned char*)frame + (pitch * y),
width * (bits / 8));
}
else if (bits == 16)
conv_rgb565_argb8888(gl1->video_buf, frame, width, height, pot_width * sizeof(unsigned), pitch);
@ -986,8 +988,7 @@ static bool gl1_gfx_frame(void *data, const void *frame,
&& !video_info->runloop_is_paused
&& !gl1->menu_texture_enable)
{
unsigned n;
int n;
for (n = 0; n < video_info->black_frame_insertion; ++n)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -1556,7 +1557,7 @@ static unsigned gl1_get_alignment(unsigned pitch)
static bool gl1_overlay_load(void *data,
const void *image_data, unsigned num_images)
{
unsigned i, j;
int i, j;
gl1_t *gl = (gl1_t*)data;
const struct texture_image *images =
(const struct texture_image*)image_data;

View File

@ -95,6 +95,11 @@
coords[5] = yamt; \
coords[7] = yamt
typedef struct video_shader_ctx_scale
{
struct gfx_fbo_scale *scale;
} video_shader_ctx_scale_t;
static const shader_backend_t *gl2_shader_ctx_drivers[] = {
#ifdef HAVE_GLSL
&gl_glsl_backend,
@ -108,7 +113,7 @@ static const shader_backend_t *gl2_shader_ctx_drivers[] = {
static struct video_ortho default_ortho = {0, 1, 0, 1, -1, 1};
/* Used for the last pass when rendering to the back buffer. */
static const GLfloat vertexes_flipped[] = {
static const GLfloat vertexes_flipped[8] = {
0, 1,
1, 1,
0, 0,
@ -118,31 +123,27 @@ static const GLfloat vertexes_flipped[] = {
/* Used when rendering to an FBO.
* Texture coords have to be aligned
* with vertex coordinates. */
static const GLfloat vertexes[] = {
static const GLfloat vertexes[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat tex_coords[] = {
static const GLfloat tex_coords[8] = {
0, 0,
1, 0,
0, 1,
1, 1
};
static const GLfloat white_color[] = {
static const GLfloat white_color[16] = {
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
};
#define gl2_context_bind_hw_render(gl, enable) \
if (gl->shared_context_use) \
gl->ctx_driver->bind_hw_render(gl->ctx_data, enable)
#define MAX_FENCES 4
#if !defined(HAVE_PSGL)
@ -260,28 +261,15 @@ static unsigned gl2_get_alignment(unsigned pitch)
return 8;
}
static bool gl2_shader_info(gl2_t *gl,
video_shader_ctx_info_t *shader_info)
static void gl2_shader_scale(gl2_t *gl,
video_shader_ctx_scale_t *scaler, unsigned idx)
{
if (!shader_info)
return false;
shader_info->num = gl->shader->num_shaders(gl->shader_data);
return true;
}
static bool gl2_shader_scale(gl2_t *gl,
video_shader_ctx_scale_t *scaler)
{
if (!scaler || !scaler->scale)
return false;
scaler->scale->flags &= ~FBO_SCALE_FLAG_VALID;
gl->shader->shader_scale(gl->shader_data,
scaler->idx, scaler->scale);
return true;
if (scaler->scale)
{
scaler->scale->flags &= ~FBO_SCALE_FLAG_VALID;
gl->shader->shader_scale(gl->shader_data,
idx, scaler->scale);
}
}
static void gl2_size_format(GLint* internalFormat)
@ -694,7 +682,8 @@ static void gl2_renderchain_deinit_hw_render(
if (!gl)
return;
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
if (gl->hw_render_fbo_init)
gl2_delete_fb(gl->textures, gl->hw_render_fbo);
@ -702,12 +691,13 @@ static void gl2_renderchain_deinit_hw_render(
gl2_delete_rb(gl->textures, chain->hw_render_depth);
gl->hw_render_fbo_init = false;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
}
static bool gl2_create_fbo_targets(gl2_t *gl, gl2_renderchain_data_t *chain)
{
unsigned i;
int i;
glBindTexture(GL_TEXTURE_2D, 0);
gl2_gen_fb(chain->fbo_pass, chain->fbo);
@ -945,7 +935,7 @@ static void gl2_renderchain_recompute_pass_sizes(
unsigned width, unsigned height,
unsigned vp_width, unsigned vp_height)
{
unsigned i;
int i;
bool size_modified = false;
GLint max_size = 0;
unsigned last_width = width;
@ -1084,30 +1074,27 @@ static void gl2_renderchain_init(
int i;
unsigned width, height;
video_shader_ctx_scale_t scaler;
video_shader_ctx_info_t shader_info;
unsigned shader_info_num;
struct gfx_fbo_scale scale, scale_last;
if (!gl2_shader_info(gl, &shader_info))
return;
shader_info_num = gl->shader->num_shaders(gl->shader_data);
if (!gl || shader_info.num == 0)
if (!gl || shader_info_num == 0)
return;
width = gl->video_width;
height = gl->video_height;
scaler.idx = 1;
scaler.scale = &scale;
gl2_shader_scale(gl, &scaler);
gl2_shader_scale(gl, &scaler, 1);
scaler.idx = shader_info.num;
scaler.scale = &scale_last;
gl2_shader_scale(gl, &scaler);
gl2_shader_scale(gl, &scaler, shader_info_num);
/* we always want FBO to be at least initialized on startup for consoles */
if ( shader_info.num == 1
if ( shader_info_num == 1
&& (!(scale.flags & FBO_SCALE_FLAG_VALID)))
return;
@ -1117,7 +1104,7 @@ static void gl2_renderchain_init(
return;
}
chain->fbo_pass = shader_info.num - 1;
chain->fbo_pass = shader_info_num - 1;
if (scale_last.flags & FBO_SCALE_FLAG_VALID)
chain->fbo_pass++;
@ -1134,10 +1121,9 @@ static void gl2_renderchain_init(
for (i = 1; i < chain->fbo_pass; i++)
{
scaler.idx = i + 1;
scaler.scale = &chain->fbo_scale[i];
gl2_shader_scale(gl, &scaler);
gl2_shader_scale(gl, &scaler, i + 1);
if (!(chain->fbo_scale[i].flags & FBO_SCALE_FLAG_VALID))
{
@ -1203,7 +1189,8 @@ static bool gl2_renderchain_init_hw_render(
/* We can only share texture objects through contexts.
* FBOs are "abstract" objects and are not shared. */
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
RARCH_LOG("[GL]: Initializing HW render (%ux%u).\n", width, height);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_fbo_size);
@ -1284,7 +1271,8 @@ static bool gl2_renderchain_init_hw_render(
gl2_renderchain_bind_backbuffer();
gl->hw_render_fbo_init = true;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
return true;
}
@ -1317,7 +1305,8 @@ static bool gl2_renderchain_read_viewport(
{
unsigned num_pixels = 0;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
num_pixels = gl->vp.width * gl->vp.height;
@ -1342,7 +1331,7 @@ static bool gl2_renderchain_read_viewport(
if (ptr)
{
unsigned y;
int y;
for (y = 0; y < gl->vp.height; y++)
{
video_frame_convert_rgba_to_bgr(
@ -1401,11 +1390,13 @@ static bool gl2_renderchain_read_viewport(
gl->readback_buffer_screenshot = NULL;
}
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
error:
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return false;
}
@ -1433,7 +1424,7 @@ static void gl2_renderchain_copy_frame(
{
#if defined(HAVE_PSGL)
{
unsigned h;
int h;
size_t buffer_addr = gl->tex_w * gl->tex_h *
gl->tex_index * gl->base_size;
size_t buffer_stride = gl->tex_w * gl->base_size;
@ -1507,8 +1498,7 @@ static void gl2_renderchain_copy_frame(
{
/* Slow path - conv_buffer is preallocated
* just in case we hit this path. */
unsigned h;
int h;
const unsigned line_bytes = width * gl->base_size;
uint8_t *dst = (uint8_t*)gl->conv_buffer;
const uint8_t *src = (const uint8_t*)frame;
@ -1614,8 +1604,7 @@ static void gl2_renderchain_fence_free(void *data,
{
#ifndef HAVE_OPENGLES
#ifdef HAVE_GL_SYNC
unsigned i;
int i;
for (i = 0; i < chain->fence_count; i++)
{
glClientWaitSync(chain->fences[i],
@ -1820,7 +1809,7 @@ bool gl2_load_luts(
const void *shader_data,
GLuint *textures_lut)
{
unsigned i;
int i;
const struct video_shader *shader =
(const struct video_shader*)shader_data;
unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES);
@ -1982,7 +1971,7 @@ static void gl2_set_viewport_wrapper(void *data, unsigned viewport_width,
static enum rarch_shader_type gl2_get_fallback_shader_type(enum rarch_shader_type type)
{
#if defined(HAVE_GLSL) || defined(HAVE_CG)
unsigned i;
int i;
if (type != RARCH_SHADER_CG && type != RARCH_SHADER_GLSL)
{
@ -2209,7 +2198,7 @@ static void gl2_update_input_size(gl2_t *gl, unsigned width,
static void gl2_init_textures_data(gl2_t *gl)
{
unsigned i;
int i;
for (i = 0; i < gl->textures; i++)
{
@ -2285,7 +2274,7 @@ static void gl2_init_textures(gl2_t *gl)
static INLINE void gl2_set_shader_viewports(gl2_t *gl)
{
unsigned i;
int i;
unsigned width = gl->video_width;
unsigned height = gl->video_height;
@ -2310,7 +2299,8 @@ static void gl2_set_texture_frame(void *data,
if (!gl)
return;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (!gl->menu_texture)
glGenTextures(1, &gl->menu_texture);
@ -2324,7 +2314,8 @@ static void gl2_set_texture_frame(void *data,
gl->menu_texture_alpha = alpha;
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
}
static void gl2_set_texture_enable(void *data, bool state, bool full_screen)
@ -2548,14 +2539,15 @@ static void gl2_pbo_async_readback(gl2_t *gl)
}
#ifdef HAVE_VIDEO_LAYOUT
static float video_layout_layer_tex_coord[] = {
static float video_layout_layer_tex_coord[8] = {
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 0.0f,
};
static void gl2_video_layout_fbo_init(gl2_t *gl, unsigned width, unsigned height)
static void gl2_video_layout_fbo_init(gl2_t *gl,
unsigned width, unsigned height)
{
glGenTextures(1, &gl->video_layout_fbo_texture);
glBindTexture(GL_TEXTURE_2D, gl->video_layout_fbo_texture);
@ -2597,9 +2589,6 @@ static void gl2_video_layout_fbo_free(gl2_t *gl)
static void gl2_video_layout_viewport(gl2_t *gl)
{
if (!video_layout_valid())
return;
if (gl->video_layout_resize)
{
if (gl->video_layout_fbo)
@ -2894,7 +2883,8 @@ static bool gl2_frame(void *data, const void *frame,
if (!gl)
return false;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
#ifndef HAVE_OPENGLES
if (gl->core_context_in_use)
@ -2930,7 +2920,7 @@ static bool gl2_frame(void *data, const void *frame,
{
/* On resize, we might have to recreate our FBOs
* due to "Viewport" scale, and set a new viewport. */
unsigned i;
int i;
/* Check if we have to recreate our FBO textures. */
for (i = 0; i < (unsigned)chain->fbo_pass; i++)
@ -2989,7 +2979,8 @@ static bool gl2_frame(void *data, const void *frame,
}
#ifdef HAVE_VIDEO_LAYOUT
gl2_video_layout_viewport(gl);
if (video_layout_valid())
gl2_video_layout_viewport(gl);
#endif
if (frame)
@ -3173,7 +3164,7 @@ static bool gl2_frame(void *data, const void *frame,
&& !runloop_is_paused
&& !gl->menu_texture_enable)
{
unsigned n;
int n;
for (n = 0; n < black_frame_insertion; ++n)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -3202,7 +3193,8 @@ static bool gl2_frame(void *data, const void *frame,
if (gl->core_context_in_use)
glBindVertexArray(0);
#endif
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
}
@ -3240,7 +3232,8 @@ static void gl2_free(void *data)
gl2_video_layout_free(gl);
#endif
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (gl->have_sync)
gl2_renderchain_fence_free(gl,
@ -3308,7 +3301,8 @@ static void gl2_set_nonblock_state(
if (!gl)
return;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (!state)
interval = swap_interval;
@ -3319,7 +3313,8 @@ static void gl2_set_nonblock_state(
interval = -1;
gl->ctx_driver->swap_interval(gl->ctx_data, interval);
}
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
}
static bool gl2_resolve_extensions(gl2_t *gl, const char *context_ident, const video_info_t *video)
@ -3437,7 +3432,7 @@ static INLINE void gl2_set_texture_fmts(gl2_t *gl, bool rgb32)
static bool gl2_init_pbo_readback(gl2_t *gl)
{
#if !defined(HAVE_OPENGLES2) && !defined(HAVE_PSGL)
unsigned i;
int i;
glGenBuffers(4, gl->pbo_readback);
@ -3657,7 +3652,7 @@ static void *gl2_init(const video_info_t *video,
{
enum gfx_wrap_type wrap_type;
unsigned full_x, full_y;
video_shader_ctx_info_t shader_info;
unsigned shader_info_num;
settings_t *settings = config_get_ptr();
bool video_gpu_record = settings->bools.video_gpu_record;
int interval = 0;
@ -3893,9 +3888,14 @@ static void *gl2_init(const video_info_t *video,
* create textures. */
gl->textures = 1;
#ifdef GL_DEBUG
gl2_context_bind_hw_render(gl, true);
gl2_begin_debug(gl);
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
{
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
gl2_begin_debug(gl);
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
}
else
gl2_begin_debug(gl);
#endif
}
@ -3923,15 +3923,11 @@ static void *gl2_init(const video_info_t *video,
gl->textures = MAX(minimum + 1, gl->textures);
}
if (!gl2_shader_info(gl, &shader_info))
{
RARCH_ERR("[GL]: Shader driver info check failed.\n");
goto error;
}
shader_info_num = gl->shader->num_shaders(gl->shader_data);
RARCH_LOG("[GL]: Using %u textures.\n", gl->textures);
RARCH_LOG("[GL]: Loaded %u program(s).\n",
shader_info.num);
shader_info_num);
gl->tex_w = gl->tex_h = (RARCH_SCALE_BASE * video->input_scale);
gl->keep_aspect = video->force_aspect;
@ -4039,7 +4035,8 @@ static void *gl2_init(const video_info_t *video,
gl2_video_layout_init(gl);
#endif
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return gl;
@ -4111,7 +4108,8 @@ static void gl2_update_tex_filter_frame(gl2_t *gl)
video_smooth = false;
#endif
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (!gl->shader->filter_type(gl->shader_data,
1, &smooth))
@ -4143,7 +4141,8 @@ static void gl2_update_tex_filter_frame(gl2_t *gl)
}
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
}
static bool gl2_set_shader(void *data,
@ -4158,7 +4157,8 @@ static bool gl2_set_shader(void *data,
if (!gl)
return false;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
fallback = gl2_get_fallback_shader_type(type);
@ -4246,12 +4246,14 @@ static bool gl2_set_shader(void *data,
/* Apparently need to set viewport for passes when we aren't using FBOs. */
gl2_set_shader_viewports(gl);
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
error:
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
#endif
return false;
}
@ -4324,8 +4326,7 @@ unsigned *height_p, size_t *pitch_p)
if (gl->hw_render_use)
{
unsigned i;
int i;
for (i = 0; i < height ; i++)
memcpy((uint8_t*)buffer + i * pitch,
(uint8_t*)buffer_texture + (height - 1 - i) * pitch, pitch);
@ -4350,7 +4351,8 @@ static bool gl2_overlay_load(void *data,
if (!gl)
return false;
gl2_context_bind_hw_render(gl, false);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
gl2_free_overlay(gl);
gl->overlay_tex = (GLuint*)
@ -4358,7 +4360,8 @@ static bool gl2_overlay_load(void *data,
if (!gl->overlay_tex)
{
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return false;
}
@ -4396,7 +4399,8 @@ static bool gl2_overlay_load(void *data,
gl->overlay_color_coord[16 * i + j] = 1.0f;
}
gl2_context_bind_hw_render(gl, true);
if (gl->shared_context_use)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
}

View File

@ -54,7 +54,6 @@
#include "../gfx_widgets.h"
#endif
static const struct video_ortho gl3_default_ortho = {0, 1, 0, 1, -1, 1};
void gl3_framebuffer_copy(
@ -117,11 +116,11 @@ void gl3_framebuffer_copy_partial(
float rx, float ry)
{
GLuint vbo;
const float quad_data[] = {
const float quad_data[16] = {
0.0f, 0.0f, 0.0f, 0.0f,
1.0f, 0.0f, rx, 0.0f,
1.0f, 0.0f, rx, 0.0f,
0.0f, 1.0f, 0.0f, ry,
1.0f, 1.0f, rx, ry,
1.0f, 1.0f, rx, ry,
};
glBindFramebuffer(GL_FRAMEBUFFER, fb_id);
@ -172,7 +171,7 @@ void gl3_framebuffer_copy_partial(
static void gl3_deinit_fences(gl3_t *gl)
{
unsigned i;
int i;
for (i = 0; i < gl->fence_count; i++)
{
if (gl->fences[i])
@ -184,7 +183,7 @@ static void gl3_deinit_fences(gl3_t *gl)
static bool gl3_init_pbo_readback(gl3_t *gl)
{
unsigned i;
int i;
struct scaler_ctx *scaler = NULL;
glGenBuffers(GL_CORE_NUM_PBOS, gl->pbo_readback);
@ -192,7 +191,9 @@ static bool gl3_init_pbo_readback(gl3_t *gl)
for (i = 0; i < GL_CORE_NUM_PBOS; i++)
{
glBindBuffer(GL_PIXEL_PACK_BUFFER, gl->pbo_readback[i]);
glBufferData(GL_PIXEL_PACK_BUFFER, gl->vp.width * gl->vp.height * sizeof(uint32_t), NULL, GL_STREAM_READ);
glBufferData(GL_PIXEL_PACK_BUFFER,
gl->vp.width * gl->vp.height * sizeof(uint32_t),
NULL, GL_STREAM_READ);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
@ -222,7 +223,7 @@ static bool gl3_init_pbo_readback(gl3_t *gl)
static void gl3_deinit_pbo_readback(gl3_t *gl)
{
unsigned i;
int i;
for (i = 0; i < GL_CORE_NUM_PBOS; i++)
if (gl->pbo_readback[i] != 0)
glDeleteBuffers(1, &gl->pbo_readback[i]);
@ -246,7 +247,8 @@ static void gl3_slow_readback(gl3_t *gl, void *buffer)
static void gl3_pbo_async_readback(gl3_t *gl)
{
glBindBuffer(GL_PIXEL_PACK_BUFFER, gl->pbo_readback[gl->pbo_readback_index++]);
glBindBuffer(GL_PIXEL_PACK_BUFFER,
gl->pbo_readback[gl->pbo_readback_index++]);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
#ifndef HAVE_OPENGLES
@ -276,7 +278,8 @@ static void gl3_fence_iterate(gl3_t *gl, unsigned hard_sync_frames)
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
gl->fences[gl->fence_count++] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
gl->fences[gl->fence_count++] = glFenceSync(
GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
while (gl->fence_count > hard_sync_frames)
@ -291,8 +294,8 @@ static void gl3_fence_iterate(gl3_t *gl, unsigned hard_sync_frames)
uint32_t gl3_get_cross_compiler_target_version(void)
{
const char *version = (const char*)glGetString(GL_VERSION);
unsigned major = 0;
unsigned minor = 0;
unsigned major = 0;
unsigned minor = 0;
#ifdef HAVE_OPENGLES3
if (!version || sscanf(version, "OpenGL ES %u.%u", &major, &minor) != 2)
@ -404,7 +407,7 @@ static void gl3_free_overlay(gl3_t *gl)
static void gl3_free_scratch_vbos(gl3_t *gl)
{
unsigned i;
int i;
for (i = 0; i < GL_CORE_NUM_VBOS; i++)
if (gl->scratch_vbos[i])
glDeleteBuffers(1, &gl->scratch_vbos[i]);
@ -422,10 +425,7 @@ static void gl3_overlay_vertex_geom(void *data,
return;
if (image > gl->overlays)
{
RARCH_ERR("[GLCore]: Invalid overlay id: %u\n", image);
return;
}
vertex = (GLfloat*)&gl->overlay_vertex_coord[image * 8];
@ -449,7 +449,7 @@ static void gl3_overlay_tex_geom(void *data,
GLfloat w, GLfloat h)
{
GLfloat *tex = NULL;
gl3_t *gl = (gl3_t*)data;
gl3_t *gl = (gl3_t*)data;
if (!gl)
return;
@ -469,7 +469,7 @@ static void gl3_overlay_tex_geom(void *data,
static void gl3_render_overlay(gl3_t *gl,
unsigned width, unsigned height)
{
unsigned i;
int i;
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
@ -514,13 +514,10 @@ static void gl3_render_overlay(gl3_t *gl,
}
#endif
#define gl3_context_bind_hw_render(gl, enable) \
if (gl->use_shared_context) \
gl->ctx_driver->bind_hw_render(gl->ctx_data, enable)
static void gl3_deinit_hw_render(gl3_t *gl)
{
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
if (gl->hw_render_fbo)
glDeleteFramebuffers(1, &gl->hw_render_fbo);
@ -529,11 +526,14 @@ static void gl3_deinit_hw_render(gl3_t *gl)
if (gl->hw_render_texture)
glDeleteTextures(1, &gl->hw_render_texture);
gl->hw_render_fbo = 0;
gl->hw_render_rb_ds = 0;
gl->hw_render_fbo = 0;
gl->hw_render_rb_ds = 0;
gl->hw_render_texture = 0;
gl3_context_bind_hw_render(gl, false);
gl->hw_render_enable = false;
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
gl->hw_render_enable = false;
}
static void gl3_destroy_resources(gl3_t *gl)
@ -542,7 +542,8 @@ static void gl3_destroy_resources(gl3_t *gl)
if (!gl)
return;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (gl->filter_chain)
gl3_filter_chain_free(gl->filter_chain);
@ -593,7 +594,8 @@ 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();
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
RARCH_LOG("[GLCore]: Initializing HW render (%ux%u).\n", width, height);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_fbo_size);
@ -637,7 +639,8 @@ 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");
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
return false;
}
@ -648,12 +651,14 @@ 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->hw_render_max_width = width;
gl->hw_render_enable = true;
gl->hw_render_max_width = width;
gl->hw_render_max_height = height;
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
return true;
}
@ -1221,7 +1226,9 @@ static void *gl3_init(const video_info_t *video,
win_width, win_height, video->fullscreen))
goto error;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
rglgen_resolve_symbols(ctx_driver->get_proc_address);
if (hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE)
@ -1229,11 +1236,19 @@ static void *gl3_init(const video_info_t *video,
#ifdef GL_DEBUG
gl3_begin_debug(gl);
if (gl->hw_render_enable)
if (gl->use_shared_context)
{
gl3_context_bind_hw_render(gl, true);
gl3_begin_debug(gl);
gl3_context_bind_hw_render(gl, false);
if (gl->hw_render_enable)
{
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
gl3_begin_debug(gl);
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
}
}
else
{
if (gl->hw_render_enable)
gl3_begin_debug(gl);
}
#endif
@ -1350,7 +1365,8 @@ static void *gl3_init(const video_info_t *video,
glBindVertexArray(gl->vao);
glBindVertexArray(0);
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return gl;
error:
@ -1543,7 +1559,8 @@ static void gl3_free(void *data)
if (!gl)
return;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
font_driver_free_osd();
gl3_destroy_resources(gl);
if (gl->ctx_driver && gl->ctx_driver->destroy)
@ -1594,13 +1611,14 @@ static void gl3_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
int interval = 0;
gl3_t *gl = (gl3_t*)data;
if (!gl)
return;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (!state)
interval = swap_interval;
@ -1611,7 +1629,8 @@ static void gl3_set_nonblock_state(void *data, bool state,
gl->ctx_driver->swap_interval(gl->ctx_data, interval);
}
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
}
static bool gl3_suppress_screensaver(void *data, bool enable)
@ -1624,13 +1643,14 @@ static bool gl3_suppress_screensaver(void *data, bool enable)
}
static bool gl3_set_shader(void *data,
enum rarch_shader_type type, const char *path)
enum rarch_shader_type type, const char *path)
{
gl3_t *gl = (gl3_t *)data;
if (!gl)
return false;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (gl->filter_chain)
gl3_filter_chain_free(gl->filter_chain);
@ -1645,19 +1665,21 @@ static bool gl3_set_shader(void *data,
if (string_is_empty(path))
{
gl3_init_default_filter_chain(gl);
gl3_context_bind_hw_render(gl, true);
return true;
goto end;
}
if (!gl3_init_filter_chain_preset(gl, path))
{
RARCH_ERR("[GLCore]: Failed to create filter chain: \"%s\". Falling back to stock.\n", path);
gl3_init_default_filter_chain(gl);
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return false;
}
gl3_context_bind_hw_render(gl, true);
end:
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
}
@ -1698,7 +1720,8 @@ static bool gl3_read_viewport(void *data, uint8_t *buffer, bool is_idle)
if (!gl)
return false;
gl3_context_bind_hw_render(gl, false);
if (gl->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)
@ -1750,17 +1773,19 @@ static bool gl3_read_viewport(void *data, uint8_t *buffer, bool is_idle)
gl->readback_buffer_screenshot = NULL;
}
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
error:
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return false;
}
static void gl3_update_cpu_texture(gl3_t *gl,
struct gl3_streamed_texture *streamed,
const void *frame, unsigned width, unsigned height, unsigned pitch)
struct gl3_streamed_texture *streamed,
const void *frame, unsigned width, unsigned height, unsigned pitch)
{
if (width != streamed->width || height != streamed->height)
{
@ -1768,8 +1793,11 @@ static void gl3_update_cpu_texture(gl3_t *gl,
glDeleteTextures(1, &streamed->tex);
glGenTextures(1, &streamed->tex);
glBindTexture(GL_TEXTURE_2D, streamed->tex);
glTexStorage2D(GL_TEXTURE_2D, 1, gl->video_info.rgb32 ? GL_RGBA8 : GL_RGB565,
width, height);
glTexStorage2D(GL_TEXTURE_2D, 1,
gl->video_info.rgb32
? GL_RGBA8
: GL_RGB565,
width, height);
streamed->width = width;
streamed->height = height;
@ -1803,7 +1831,7 @@ static void gl3_update_cpu_texture(gl3_t *gl,
static void gl3_draw_menu_texture(gl3_t *gl,
unsigned width, unsigned height)
{
const float vbo_data[] = {
const float vbo_data[32] = {
0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, gl->menu_texture_alpha,
1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, gl->menu_texture_alpha,
0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, gl->menu_texture_alpha,
@ -1832,9 +1860,12 @@ static void gl3_draw_menu_texture(gl3_t *gl,
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
gl3_bind_scratch_vbo(gl, vbo_data, sizeof(vbo_data));
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(uintptr_t)0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(uintptr_t)(2 * sizeof(float)));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(uintptr_t)(4 * sizeof(float)));
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
8 * sizeof(float), (void *)(uintptr_t)0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,
8 * sizeof(float), (void *)(uintptr_t)(2 * sizeof(float)));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE,
8 * sizeof(float), (void *)(uintptr_t)(4 * sizeof(float)));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
@ -1854,48 +1885,51 @@ static bool gl3_frame(void *data, const void *frame,
struct gl3_filter_chain_texture texture;
struct gl3_streamed_texture *streamed = NULL;
gl3_t *gl = (gl3_t*)data;
unsigned width = video_info->width;
unsigned height = video_info->height;
struct font_params *osd_params = (struct font_params*)
unsigned width = video_info->width;
unsigned height = video_info->height;
struct font_params *osd_params = (struct font_params*)
&video_info->osd_stat_params;
const char *stat_text = video_info->stat_text;
bool statistics_show = video_info->statistics_show;
const char *stat_text = video_info->stat_text;
bool statistics_show = video_info->statistics_show;
#if 0
bool msg_bgcolor_enable = video_info->msg_bgcolor_enable;
bool msg_bgcolor_enable = video_info->msg_bgcolor_enable;
#endif
unsigned black_frame_insertion = video_info->black_frame_insertion;
unsigned black_frame_insertion = video_info->black_frame_insertion;
unsigned hard_sync_frames = video_info->hard_sync_frames;
bool runloop_is_paused = video_info->runloop_is_paused;
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
unsigned hard_sync_frames = video_info->hard_sync_frames;
bool runloop_is_paused = video_info->runloop_is_paused;
bool runloop_is_slowmotion = video_info->runloop_is_slowmotion;
bool input_driver_nonblock_state = video_info->input_driver_nonblock_state;
#ifdef HAVE_MENU
bool menu_is_alive = video_info->menu_is_alive;
bool menu_is_alive = video_info->menu_is_alive;
#endif
#ifdef HAVE_GFX_WIDGETS
bool widgets_active = video_info->widgets_active;
bool widgets_active = video_info->widgets_active;
#endif
bool hard_sync = video_info->hard_sync;
bool overlay_behind_menu = video_info->overlay_behind_menu;
bool hard_sync = video_info->hard_sync;
bool overlay_behind_menu = video_info->overlay_behind_menu;
if (!gl)
return false;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
glBindVertexArray(gl->vao);
if (frame)
gl->textures_index = (gl->textures_index + 1) & (GL_CORE_NUM_TEXTURES - 1);
gl->textures_index = (gl->textures_index + 1)
& (GL_CORE_NUM_TEXTURES - 1);
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);
gl3_update_cpu_texture(gl, streamed, frame,
frame_width, frame_height, pitch);
else
{
streamed->width = frame_width;
streamed->height = frame_height;
streamed->width = frame_width;
streamed->height = frame_height;
}
}
@ -1904,7 +1938,7 @@ static bool gl3_frame(void *data, const void *frame,
if (gl->ctx_driver->set_resize)
gl->ctx_driver->set_resize(gl->ctx_data,
width, height);
gl->should_resize = false;
gl->should_resize = false;
}
gl3_set_viewport(gl, width, height, false, true);
@ -1941,13 +1975,17 @@ static bool gl3_frame(void *data, const void *frame,
gl3_filter_chain_set_frame_direction(gl->filter_chain, 1);
#endif
gl3_filter_chain_set_input_texture(gl->filter_chain, &texture);
gl3_filter_chain_build_offscreen_passes(gl->filter_chain, &gl->filter_chain_vp);
gl3_filter_chain_build_offscreen_passes(gl->filter_chain,
&gl->filter_chain_vp);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
gl3_filter_chain_build_viewport_pass(gl->filter_chain, &gl->filter_chain_vp,
gl->hw_render_bottom_left ? gl->mvp.data : gl->mvp_yflip.data);
gl3_filter_chain_build_viewport_pass(gl->filter_chain,
&gl->filter_chain_vp,
gl->hw_render_bottom_left
? gl->mvp.data
: gl->mvp_yflip.data);
gl3_filter_chain_end_frame(gl->filter_chain);
#ifdef HAVE_OVERLAY
@ -2021,7 +2059,7 @@ static bool gl3_frame(void *data, const void *frame,
&& !runloop_is_paused
&& !gl->menu_texture_enable)
{
unsigned n;
int n;
for (n = 0; n < black_frame_insertion; ++n)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -2039,7 +2077,8 @@ static bool gl3_frame(void *data, const void *frame,
gl3_fence_iterate(gl, hard_sync_frames);
glBindVertexArray(0);
gl3_context_bind_hw_render(gl, true);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, true);
return true;
}
@ -2123,7 +2162,7 @@ static uintptr_t gl3_load_texture(void *video_data, void *data,
#ifdef HAVE_THREADS
if (threaded)
{
gl3_t *gl = (gl3_t*)video_data;
gl3_t *gl = (gl3_t*)video_data;
custom_command_method_t func = video_texture_load_wrap_gl3;
if (gl->ctx_driver->make_current)
@ -2169,7 +2208,7 @@ static void gl3_unload_texture(void *data, bool threaded,
static void gl3_set_video_mode(void *data, unsigned width, unsigned height,
bool fullscreen)
{
gl3_t *gl = (gl3_t*)data;
gl3_t *gl = (gl3_t*)data;
if (gl->ctx_driver->set_video_mode)
gl->ctx_driver->set_video_mode(gl->ctx_data,
width, height, fullscreen);
@ -2177,8 +2216,7 @@ static void gl3_set_video_mode(void *data, unsigned width, unsigned height,
static void gl3_show_mouse(void *data, bool state)
{
gl3_t *gl = (gl3_t*)data;
gl3_t *gl = (gl3_t*)data;
if (gl && gl->ctx_driver->show_mouse)
gl->ctx_driver->show_mouse(gl->ctx_data, state);
}
@ -2191,11 +2229,12 @@ static void gl3_set_texture_frame(void *data,
GLenum menu_filter = settings->bools.menu_linear_filter
? GL_LINEAR : GL_NEAREST;
unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
gl3_t *gl = (gl3_t*)data;
gl3_t *gl = (gl3_t*)data;
if (!gl)
return;
gl3_context_bind_hw_render(gl, false);
if (gl->use_shared_context)
gl->ctx_driver->bind_hw_render(gl->ctx_data, false);
if (gl->menu_texture)
glDeleteTextures(1, &gl->menu_texture);
@ -2209,7 +2248,8 @@ static void gl3_set_texture_frame(void *data,
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
width, height, GL_RGBA, rgb32
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_4_4_4_4, frame);
? GL_UNSIGNED_BYTE
: GL_UNSIGNED_SHORT_4_4_4_4, frame);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, menu_filter);
@ -2223,7 +2263,8 @@ static void gl3_set_texture_frame(void *data,
glBindTexture(GL_TEXTURE_2D, 0);
gl->menu_texture_alpha = alpha;
gl3_context_bind_hw_render(gl, true);
if (gl->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)
@ -2241,27 +2282,24 @@ static void gl3_get_video_output_size(void *data,
unsigned *width, unsigned *height, char *desc, size_t desc_len)
{
gl3_t *gl = (gl3_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_size)
return;
gl->ctx_driver->get_video_output_size(
gl->ctx_data,
width, height, desc, desc_len);
if (gl && gl->ctx_driver && gl->ctx_driver->get_video_output_size)
gl->ctx_driver->get_video_output_size(
gl->ctx_data,
width, height, desc, desc_len);
}
static void gl3_get_video_output_prev(void *data)
{
gl3_t *gl = (gl3_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_prev)
return;
gl->ctx_driver->get_video_output_prev(gl->ctx_data);
if (gl && gl->ctx_driver && gl->ctx_driver->get_video_output_prev)
gl->ctx_driver->get_video_output_prev(gl->ctx_data);
}
static void gl3_get_video_output_next(void *data)
{
gl3_t *gl = (gl3_t*)data;
if (!gl || !gl->ctx_driver || !gl->ctx_driver->get_video_output_next)
return;
gl->ctx_driver->get_video_output_next(gl->ctx_data);
if (gl && gl->ctx_driver && gl->ctx_driver->get_video_output_next)
gl->ctx_driver->get_video_output_next(gl->ctx_data);
}
static uintptr_t gl3_get_current_framebuffer(void *data)
@ -2318,11 +2356,7 @@ static void gl3_get_poke_interface(void *data,
}
#ifdef HAVE_GFX_WIDGETS
static bool gl3_gfx_widgets_enabled(void *data)
{
(void)data;
return true;
}
static bool gl3_gfx_widgets_enabled(void *data) { return true; }
#endif
static unsigned gl3_wrap_type_to_enum(enum gfx_wrap_type type)

View File

@ -91,7 +91,7 @@ static void gfx_display_gl1_draw(gfx_display_ctx_draw_t *draw,
unsigned video_width,
unsigned video_height)
{
video_shader_ctx_mvp_t mvp;
const GLfloat *mvp_matrix;
gl1_t *gl1 = (gl1_t*)data;
if (!gl1 || !draw)
@ -112,13 +112,12 @@ static void gfx_display_gl1_draw(gfx_display_ctx_draw_t *draw,
glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture);
mvp.data = gl1;
mvp.matrix = draw->matrix_data ? (math_matrix_4x4*)draw->matrix_data
: (math_matrix_4x4*)&gl1->mvp_no_rot;
mvp_matrix = draw->matrix_data ? (const GLfloat*)draw->matrix_data
: (const GLfloat*)&gl1->mvp_no_rot;
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixf((const GLfloat*)mvp.matrix);
glLoadMatrixf(mvp_matrix);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();

View File

@ -308,48 +308,11 @@ typedef struct video_shader_ctx_params
unsigned fbo_info_cnt;
} video_shader_ctx_params_t;
typedef struct video_shader_ctx_coords
{
void *handle_data;
const void *data;
} video_shader_ctx_coords_t;
typedef struct video_shader_ctx_scale
{
struct gfx_fbo_scale *scale;
unsigned idx;
} video_shader_ctx_scale_t;
typedef struct video_shader_ctx_info
{
void *data;
unsigned num;
unsigned idx;
bool set_active;
} video_shader_ctx_info_t;
typedef struct video_shader_ctx_mvp
{
void *data;
const void *matrix;
} video_shader_ctx_mvp_t;
typedef struct video_shader_ctx_filter
{
bool *smooth;
unsigned index;
} video_shader_ctx_filter_t;
typedef struct video_shader_ctx
{
struct video_shader *data;
} video_shader_ctx_t;
typedef struct video_shader_ctx_texture
{
unsigned id;
} video_shader_ctx_texture_t;
typedef struct video_pixel_scaler
{
struct scaler_ctx *scaler;