2019-03-02 10:53:14 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2019 - Hans-Kristian Arntzen
|
|
|
|
* copyright (c) 2011-2017 - Daniel De Matteis
|
|
|
|
*
|
|
|
|
* 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_CORE_COMMON_H
|
|
|
|
#define __GL_CORE_COMMON_H
|
|
|
|
|
|
|
|
#include <boolean.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <libretro.h>
|
|
|
|
#include <retro_common_api.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../../config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <retro_inline.h>
|
|
|
|
#include <gfx/math/matrix_4x4.h>
|
|
|
|
#include <gfx/scaler/scaler.h>
|
|
|
|
#include <glsym/glsym.h>
|
|
|
|
#include <formats/image.h>
|
|
|
|
|
2023-01-24 01:30:58 +00:00
|
|
|
#include "../video_driver.h"
|
2019-03-02 10:53:14 +00:00
|
|
|
#include "../video_coord_array.h"
|
2021-09-26 12:16:09 +00:00
|
|
|
#include "../drivers_shader/shader_gl3.h"
|
2019-03-02 10:53:14 +00:00
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GL_CORE_NUM_TEXTURES 4
|
|
|
|
#define GL_CORE_NUM_PBOS 4
|
|
|
|
#define GL_CORE_NUM_VBOS 256
|
|
|
|
#define GL_CORE_NUM_FENCES 8
|
2021-11-23 07:45:54 +00:00
|
|
|
struct gl3_streamed_texture
|
2019-03-02 10:53:14 +00:00
|
|
|
{
|
|
|
|
GLuint tex;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
};
|
|
|
|
|
2023-01-24 20:35:27 +00:00
|
|
|
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)
|
|
|
|
};
|
|
|
|
|
2021-11-23 07:45:54 +00:00
|
|
|
typedef struct gl3
|
2019-03-02 10:53:14 +00:00
|
|
|
{
|
|
|
|
const gfx_ctx_driver_t *ctx_driver;
|
|
|
|
void *ctx_data;
|
2021-11-23 07:45:54 +00:00
|
|
|
gl3_filter_chain_t *filter_chain;
|
2020-09-01 17:59:56 +00:00
|
|
|
GLuint *overlay_tex;
|
|
|
|
float *overlay_vertex_coord;
|
|
|
|
float *overlay_tex_coord;
|
|
|
|
float *overlay_color_coord;
|
|
|
|
GLsync fences[GL_CORE_NUM_FENCES];
|
|
|
|
void *readback_buffer_screenshot;
|
|
|
|
struct scaler_ctx pbo_readback_scaler;
|
2019-03-02 10:53:14 +00:00
|
|
|
|
|
|
|
video_info_t video_info;
|
|
|
|
video_viewport_t vp;
|
2021-11-23 07:45:54 +00:00
|
|
|
struct gl3_viewport filter_chain_vp;
|
|
|
|
struct gl3_streamed_texture textures[GL_CORE_NUM_TEXTURES];
|
2019-03-02 10:53:14 +00:00
|
|
|
|
2020-09-01 17:59:56 +00:00
|
|
|
GLuint vao;
|
2019-03-02 10:53:14 +00:00
|
|
|
GLuint menu_texture;
|
2020-09-01 17:59:56 +00:00
|
|
|
GLuint pbo_readback[GL_CORE_NUM_PBOS];
|
2019-03-02 10:53:14 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GLuint alpha_blend;
|
|
|
|
GLuint font;
|
|
|
|
GLuint ribbon;
|
|
|
|
GLuint ribbon_simple;
|
|
|
|
GLuint snow_simple;
|
|
|
|
GLuint snow;
|
|
|
|
GLuint bokeh;
|
2021-11-23 07:45:54 +00:00
|
|
|
struct gl3_buffer_locations alpha_blend_loc;
|
|
|
|
struct gl3_buffer_locations font_loc;
|
|
|
|
struct gl3_buffer_locations ribbon_loc;
|
|
|
|
struct gl3_buffer_locations ribbon_simple_loc;
|
|
|
|
struct gl3_buffer_locations snow_simple_loc;
|
|
|
|
struct gl3_buffer_locations snow_loc;
|
|
|
|
struct gl3_buffer_locations bokeh_loc;
|
2019-03-02 10:53:14 +00:00
|
|
|
} pipelines;
|
|
|
|
|
2020-09-01 17:59:56 +00:00
|
|
|
|
2019-08-13 10:23:02 +00:00
|
|
|
unsigned video_width;
|
|
|
|
unsigned video_height;
|
2019-03-02 10:53:14 +00:00
|
|
|
unsigned overlays;
|
2020-09-01 17:59:56 +00:00
|
|
|
unsigned version_major;
|
|
|
|
unsigned version_minor;
|
|
|
|
unsigned vp_out_width;
|
|
|
|
unsigned vp_out_height;
|
|
|
|
unsigned rotation;
|
|
|
|
unsigned textures_index;
|
2019-03-02 10:53:14 +00:00
|
|
|
unsigned scratch_vbo_index;
|
2020-09-01 17:59:56 +00:00
|
|
|
unsigned fence_count;
|
|
|
|
unsigned pbo_readback_index;
|
|
|
|
unsigned hw_render_max_width;
|
|
|
|
unsigned hw_render_max_height;
|
|
|
|
GLuint scratch_vbos[GL_CORE_NUM_VBOS];
|
2019-03-02 10:53:14 +00:00
|
|
|
GLuint hw_render_texture;
|
|
|
|
GLuint hw_render_fbo;
|
|
|
|
GLuint hw_render_rb_ds;
|
|
|
|
|
2020-09-01 17:59:56 +00:00
|
|
|
float menu_texture_alpha;
|
|
|
|
math_matrix_4x4 mvp; /* float alignment */
|
|
|
|
math_matrix_4x4 mvp_yflip;
|
|
|
|
math_matrix_4x4 mvp_no_rot;
|
|
|
|
math_matrix_4x4 mvp_no_rot_yflip;
|
2019-03-02 10:53:14 +00:00
|
|
|
|
2023-01-24 20:35:27 +00:00
|
|
|
uint16_t flags;
|
|
|
|
|
2019-03-02 10:53:14 +00:00
|
|
|
bool pbo_readback_valid[GL_CORE_NUM_PBOS];
|
2021-11-23 07:45:54 +00:00
|
|
|
} gl3_t;
|
2019-03-02 10:53:14 +00:00
|
|
|
|
2021-11-23 07:45:54 +00:00
|
|
|
void gl3_bind_scratch_vbo(gl3_t *gl, const void *data, size_t size);
|
2019-03-02 10:53:14 +00:00
|
|
|
|
|
|
|
RETRO_END_DECLS
|
|
|
|
|
|
|
|
#endif
|