mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-14 14:28:47 +00:00
Add SHADER_CTL_SET_COORDS
This commit is contained in:
parent
20441299e1
commit
6c1b96f50d
@ -1124,6 +1124,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
const struct gfx_tex_info *feedback_info)
|
||||
{
|
||||
unsigned mip_level;
|
||||
video_shader_ctx_coords_t coords;
|
||||
video_shader_ctx_params_t params;
|
||||
unsigned width, height;
|
||||
const struct gfx_fbo_rect *prev_rect;
|
||||
@ -1143,6 +1144,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
* and render all passes from FBOs, to another FBO. */
|
||||
for (i = 1; i < gl->fbo_pass; i++)
|
||||
{
|
||||
video_shader_ctx_coords_t coords;
|
||||
video_shader_ctx_params_t params;
|
||||
const struct gfx_fbo_rect *rect = &gl->fbo_rect[i];
|
||||
|
||||
@ -1194,7 +1196,12 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms);
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
|
||||
coords.handle_data = NULL;
|
||||
coords.data = &gl->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
@ -1255,7 +1262,11 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
gl->coords.vertex = gl->vertex_ptr;
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
|
||||
coords.handle_data = NULL;
|
||||
coords.data = &gl->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
@ -1675,6 +1686,7 @@ static void gl_pbo_async_readback(gl_t *gl)
|
||||
#if defined(HAVE_MENU)
|
||||
static INLINE void gl_draw_texture(gl_t *gl)
|
||||
{
|
||||
video_shader_ctx_coords_t coords;
|
||||
unsigned width, height;
|
||||
GLfloat color[16];
|
||||
|
||||
@ -1706,8 +1718,14 @@ static INLINE void gl_draw_texture(gl_t *gl)
|
||||
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
|
||||
|
||||
video_shader_driver_use(gl, GL_SHADER_STOCK_BLEND);
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
|
||||
coords.handle_data = NULL;
|
||||
coords.data = &gl->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp_no_rot);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
@ -1734,6 +1752,7 @@ static bool gl_frame(void *data, const void *frame,
|
||||
uint64_t frame_count,
|
||||
unsigned pitch, const char *msg)
|
||||
{
|
||||
video_shader_ctx_coords_t coords;
|
||||
video_shader_ctx_params_t params;
|
||||
bool is_slowmotion, is_paused;
|
||||
unsigned width, height;
|
||||
@ -1891,7 +1910,11 @@ static bool gl_frame(void *data, const void *frame,
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms);
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
coords.handle_data = NULL;
|
||||
coords.data = &gl->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
@ -3393,8 +3416,8 @@ static void gl_overlay_set_alpha(void *data, unsigned image, float mod)
|
||||
|
||||
static void gl_render_overlay(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned width, height;
|
||||
video_shader_ctx_coords_t coords;
|
||||
unsigned i, width, height;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
if (!gl)
|
||||
return;
|
||||
@ -3414,7 +3437,10 @@ static void gl_render_overlay(void *data)
|
||||
gl->coords.color = gl->overlay_color_coord;
|
||||
gl->coords.vertices = 4 * gl->overlays;
|
||||
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
coords.handle_data = NULL;
|
||||
coords.data = &gl->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp_no_rot);
|
||||
|
||||
for (i = 0; i < gl->overlays; i++)
|
||||
|
@ -227,7 +227,12 @@ static int gl_get_message_width(void *data, const char *msg,
|
||||
|
||||
static void gl_raster_font_draw_vertices(gl_t *gl, const gfx_coords_t *coords)
|
||||
{
|
||||
video_shader_driver_set_coords(NULL, coords);
|
||||
video_shader_ctx_coords_t coords_data;
|
||||
|
||||
coords_data.handle_data = NULL;
|
||||
coords_data.data = coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords_data);
|
||||
video_shader_driver_set_mvp(gl, &gl->mvp_no_rot);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, coords->vertices);
|
||||
|
@ -108,13 +108,6 @@ unsigned video_shader_driver_get_prev_textures(void)
|
||||
return current_shader->get_prev_textures(shader_data);
|
||||
}
|
||||
|
||||
bool video_shader_driver_set_coords(void *handle_data, const void *data)
|
||||
{
|
||||
if (!current_shader || !current_shader->set_coords)
|
||||
return false;
|
||||
return current_shader->set_coords(handle_data, shader_data, data);
|
||||
}
|
||||
|
||||
bool video_shader_driver_set_mvp(void *data, const math_matrix_4x4 *mat)
|
||||
{
|
||||
if (!current_shader || !current_shader->set_mvp || !mat)
|
||||
@ -210,7 +203,8 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat
|
||||
case SHADER_CTL_GET_FEEDBACK_PASS:
|
||||
if (!current_shader || !current_shader->get_feedback_pass)
|
||||
return false;
|
||||
return current_shader->get_feedback_pass(shader_data, (unsigned*)data);
|
||||
return current_shader->get_feedback_pass(shader_data,
|
||||
(unsigned*)data);
|
||||
case SHADER_CTL_MIPMAP_INPUT:
|
||||
if (!current_shader)
|
||||
return false;
|
||||
@ -219,6 +213,15 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat
|
||||
return current_shader->mipmap_input(shader_data, *index);
|
||||
}
|
||||
break;
|
||||
case SHADER_CTL_SET_COORDS:
|
||||
{
|
||||
video_shader_ctx_coords_t *coords = (video_shader_ctx_coords_t*)
|
||||
data;
|
||||
if (!current_shader || !current_shader->set_coords)
|
||||
return false;
|
||||
return current_shader->set_coords(coords->handle_data,
|
||||
shader_data, coords->data);
|
||||
}
|
||||
case SHADER_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
|
@ -39,7 +39,8 @@ enum video_shader_driver_ctl_state
|
||||
SHADER_CTL_INIT_FIRST,
|
||||
SHADER_CTL_SET_PARAMS,
|
||||
SHADER_CTL_GET_FEEDBACK_PASS,
|
||||
SHADER_CTL_MIPMAP_INPUT
|
||||
SHADER_CTL_MIPMAP_INPUT,
|
||||
SHADER_CTL_SET_COORDS
|
||||
};
|
||||
|
||||
typedef struct shader_backend
|
||||
@ -102,6 +103,12 @@ 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;
|
||||
|
||||
extern const shader_backend_t gl_glsl_backend;
|
||||
extern const shader_backend_t hlsl_backend;
|
||||
extern const shader_backend_t gl_cg_backend;
|
||||
@ -152,8 +159,6 @@ const char *video_shader_driver_get_ident(void);
|
||||
|
||||
unsigned video_shader_driver_num_shaders(void);
|
||||
|
||||
bool video_shader_driver_set_coords(void *handle_data, const void *data);
|
||||
|
||||
bool video_shader_driver_set_mvp(void *data, const math_matrix_4x4 *mat);
|
||||
|
||||
unsigned video_shader_driver_get_prev_textures(void);
|
||||
|
@ -88,6 +88,7 @@ static void menu_display_gl_blend_end(void)
|
||||
|
||||
static void menu_display_gl_draw(void *data)
|
||||
{
|
||||
video_shader_ctx_coords_t coords;
|
||||
gl_t *gl = gl_get_ptr();
|
||||
math_matrix_4x4 *mat = NULL;
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
@ -113,7 +114,10 @@ static void menu_display_gl_draw(void *data)
|
||||
glViewport(draw->x, draw->y, draw->width, draw->height);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture);
|
||||
|
||||
video_shader_driver_set_coords(gl, draw->coords);
|
||||
coords.handle_data = gl;
|
||||
coords.data = draw->coords;
|
||||
|
||||
video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords);
|
||||
video_shader_driver_set_mvp(gl, mat);
|
||||
|
||||
glDrawArrays(menu_display_prim_to_gl_enum(
|
||||
|
Loading…
Reference in New Issue
Block a user