mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 18:20:27 +00:00
Simplify video_shader_driver_set_params
This commit is contained in:
parent
bb0b6a6b68
commit
f9824dd53e
@ -129,6 +129,9 @@ static bool renderchain_create_first_pass(void *data,
|
||||
static void renderchain_set_vertices(void *data, unsigned pass,
|
||||
unsigned vert_width, unsigned vert_height, uint64_t frame_count)
|
||||
{
|
||||
#ifdef _XBOX
|
||||
video_shader_ctx_params_t params;
|
||||
#endif
|
||||
unsigned width, height;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
xdk_renderchain_t *chain = d3d ? (xdk_renderchain_t*)d3d->renderchain_data : NULL;
|
||||
@ -211,10 +214,22 @@ static void renderchain_set_vertices(void *data, unsigned pass,
|
||||
#ifdef _XBOX
|
||||
renderchain_set_mvp(d3d, width, height, d3d->dev_rotation);
|
||||
video_shader_driver_use(d3d, pass);
|
||||
video_shader_driver_set_params(
|
||||
d3d, vert_width, vert_height, chain->tex_w,
|
||||
chain->tex_h, width, height, frame_count,
|
||||
NULL, NULL, NULL, NULL, 0);
|
||||
|
||||
params.data = d3d;
|
||||
params.width = vert_width;
|
||||
params.height = vert_height;
|
||||
params.tex_width = chain->tex_w;
|
||||
params.tex_height = chain->tex_h;
|
||||
params.out_width = width;
|
||||
params.out_height = height;
|
||||
params.frame_counter = (unsigned int)frame_count;
|
||||
params.info = NULL;
|
||||
params.prev_info = NULL;
|
||||
params.feedback_info = NULL;
|
||||
params.fbo_info = NULL;
|
||||
params.fbo_info_cnt = 0;
|
||||
|
||||
video_shader_driver_set_params(¶ms);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -1112,6 +1112,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
const struct gfx_tex_info *tex_info,
|
||||
const struct gfx_tex_info *feedback_info)
|
||||
{
|
||||
video_shader_ctx_params_t params;
|
||||
unsigned width, height;
|
||||
const struct gfx_fbo_rect *prev_rect;
|
||||
struct gfx_tex_info *fbo_info;
|
||||
@ -1130,6 +1131,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_params_t params;
|
||||
const struct gfx_fbo_rect *rect = &gl->fbo_rect[i];
|
||||
|
||||
prev_rect = &gl->fbo_rect[i - 1];
|
||||
@ -1160,12 +1162,22 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
|
||||
/* Render to FBO with certain size. */
|
||||
gl_set_viewport(gl, rect->img_width, rect->img_height, true, false);
|
||||
video_shader_driver_set_params(gl,
|
||||
prev_rect->img_width, prev_rect->img_height,
|
||||
prev_rect->width, prev_rect->height,
|
||||
gl->vp.width, gl->vp.height, (unsigned int)frame_count,
|
||||
tex_info, gl->prev_info, feedback_info, fbo_tex_info,
|
||||
fbo_tex_info_cnt);
|
||||
|
||||
params.data = gl;
|
||||
params.width = prev_rect->img_width;
|
||||
params.height = prev_rect->img_height;
|
||||
params.tex_width = prev_rect->width;
|
||||
params.tex_height = prev_rect->height;
|
||||
params.out_width = gl->vp.width;
|
||||
params.out_height = gl->vp.height;
|
||||
params.frame_counter = (unsigned int)frame_count;
|
||||
params.info = tex_info;
|
||||
params.prev_info = gl->prev_info;
|
||||
params.feedback_info = feedback_info;
|
||||
params.fbo_info = fbo_tex_info;
|
||||
params.fbo_info_cnt = fbo_tex_info_cnt;
|
||||
|
||||
video_shader_driver_set_params(¶ms);
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
@ -1208,12 +1220,21 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
gl_set_viewport(gl, width, height, false, true);
|
||||
|
||||
video_shader_driver_set_params(gl,
|
||||
prev_rect->img_width, prev_rect->img_height,
|
||||
prev_rect->width, prev_rect->height,
|
||||
gl->vp.width, gl->vp.height, (unsigned int)frame_count,
|
||||
tex_info, gl->prev_info, feedback_info, fbo_tex_info,
|
||||
fbo_tex_info_cnt);
|
||||
params.data = gl;
|
||||
params.width = prev_rect->img_width;
|
||||
params.height = prev_rect->img_height;
|
||||
params.tex_width = prev_rect->width;
|
||||
params.tex_height = prev_rect->height;
|
||||
params.out_width = gl->vp.width;
|
||||
params.out_height = gl->vp.height;
|
||||
params.frame_counter = (unsigned int)frame_count;
|
||||
params.info = tex_info;
|
||||
params.prev_info = gl->prev_info;
|
||||
params.feedback_info = feedback_info;
|
||||
params.fbo_info = fbo_tex_info;
|
||||
params.fbo_info_cnt = fbo_tex_info_cnt;
|
||||
|
||||
video_shader_driver_set_params(¶ms);
|
||||
|
||||
gl->coords.vertex = gl->vertex_ptr;
|
||||
|
||||
@ -1697,6 +1718,7 @@ static bool gl_frame(void *data, const void *frame,
|
||||
uint64_t frame_count,
|
||||
unsigned pitch, const char *msg)
|
||||
{
|
||||
video_shader_ctx_params_t params;
|
||||
bool is_slowmotion, is_paused;
|
||||
unsigned width, height;
|
||||
struct gfx_tex_info feedback_info;
|
||||
@ -1836,13 +1858,21 @@ static bool gl_frame(void *data, const void *frame,
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
video_shader_driver_set_params(gl,
|
||||
frame_width, frame_height,
|
||||
gl->tex_w, gl->tex_h,
|
||||
gl->vp.width, gl->vp.height,
|
||||
(unsigned int)frame_count,
|
||||
&gl->tex_info, gl->prev_info, &feedback_info,
|
||||
NULL, 0);
|
||||
params.data = gl;
|
||||
params.width = frame_width;
|
||||
params.height = frame_height;
|
||||
params.tex_width = gl->tex_w;
|
||||
params.tex_height = gl->tex_h;
|
||||
params.out_width = gl->vp.width;
|
||||
params.out_height = gl->vp.height;
|
||||
params.frame_counter = (unsigned int)frame_count;
|
||||
params.info = &gl->tex_info;
|
||||
params.prev_info = gl->prev_info;
|
||||
params.feedback_info = &feedback_info;
|
||||
params.fbo_info = NULL;
|
||||
params.fbo_info_cnt = 0;
|
||||
|
||||
video_shader_driver_set_params(¶ms);
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
video_shader_driver_set_coords(NULL, &gl->coords);
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
static INLINE bool realloc_checked(void **ptr, size_t size)
|
||||
{
|
||||
void *nptr;
|
||||
void *nptr = NULL;
|
||||
|
||||
if (*ptr)
|
||||
nptr = realloc(*ptr, size);
|
||||
@ -49,10 +49,14 @@ bool gfx_coord_array_add(gfx_coord_array_t *ca,
|
||||
unsigned alloc_size = next_pow2(ca->coords.vertices + count);
|
||||
size_t base_size = sizeof(float) * alloc_size;
|
||||
|
||||
bool vert_ok = realloc_checked((void**)&ca->coords.vertex, 2 * base_size);
|
||||
bool color_ok = realloc_checked((void**)&ca->coords.color, 4 * base_size);
|
||||
bool tex_ok = realloc_checked((void**)&ca->coords.tex_coord, 2 * base_size);
|
||||
bool lut_ok = realloc_checked((void**)&ca->coords.lut_tex_coord, 2 * base_size);
|
||||
bool vert_ok = realloc_checked((void**)&ca->coords.vertex,
|
||||
2 * base_size);
|
||||
bool color_ok = realloc_checked((void**)&ca->coords.color,
|
||||
4 * base_size);
|
||||
bool tex_ok = realloc_checked((void**)&ca->coords.tex_coord,
|
||||
2 * base_size);
|
||||
bool lut_ok = realloc_checked((void**)&ca->coords.lut_tex_coord,
|
||||
2 * base_size);
|
||||
|
||||
if (vert_ok && color_ok && tex_ok && lut_ok)
|
||||
{
|
||||
@ -69,11 +73,19 @@ bool gfx_coord_array_add(gfx_coord_array_t *ca,
|
||||
base_size = count * sizeof(float);
|
||||
offset = ca->coords.vertices;
|
||||
|
||||
/* XXX: i wish we used interlaced arrays so we could call memcpy only once */
|
||||
memcpy(ca->coords.vertex + offset * 2, coords->vertex, base_size * 2);
|
||||
memcpy(ca->coords.color + offset * 4, coords->color, base_size * 4);
|
||||
memcpy(ca->coords.tex_coord + offset * 2, coords->tex_coord, base_size * 2);
|
||||
memcpy(ca->coords.lut_tex_coord + offset * 2, coords->lut_tex_coord, base_size * 2);
|
||||
/* XXX: I wish we used interlaced arrays so
|
||||
* we could call memcpy only once. */
|
||||
memcpy(ca->coords.vertex + offset * 2,
|
||||
coords->vertex, base_size * 2);
|
||||
|
||||
memcpy(ca->coords.color + offset * 4,
|
||||
coords->color, base_size * 4);
|
||||
|
||||
memcpy(ca->coords.tex_coord + offset * 2,
|
||||
coords->tex_coord, base_size * 2);
|
||||
|
||||
memcpy(ca->coords.lut_tex_coord + offset * 2,
|
||||
coords->lut_tex_coord, base_size * 2);
|
||||
|
||||
ca->coords.vertices += count;
|
||||
|
||||
|
@ -206,22 +206,24 @@ struct video_shader *video_shader_driver_direct_get_current_shader(void)
|
||||
return current_shader->get_current_shader(shader_data);
|
||||
}
|
||||
|
||||
void video_shader_driver_set_params(
|
||||
void *data, unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_counter,
|
||||
const void *info,
|
||||
const void *prev_info,
|
||||
const void *feedback_info,
|
||||
const void *fbo_info, unsigned fbo_info_cnt)
|
||||
void video_shader_driver_set_params(video_shader_ctx_params_t *params)
|
||||
{
|
||||
if (!current_shader || !current_shader->set_params)
|
||||
return;
|
||||
|
||||
current_shader->set_params(data, shader_data,
|
||||
width, height, tex_width, tex_height,
|
||||
out_width, out_height, frame_counter, info,
|
||||
prev_info, feedback_info,
|
||||
fbo_info, fbo_info_cnt);
|
||||
current_shader->set_params(
|
||||
params->data,
|
||||
shader_data,
|
||||
params->width,
|
||||
params->height,
|
||||
params->tex_width,
|
||||
params->tex_height,
|
||||
params->out_width,
|
||||
params->out_height,
|
||||
params->frame_counter,
|
||||
params->info,
|
||||
params->prev_info,
|
||||
params->feedback_info,
|
||||
params->fbo_info,
|
||||
params->fbo_info_cnt);
|
||||
}
|
||||
|
@ -66,6 +66,23 @@ typedef struct shader_backend
|
||||
const char *ident;
|
||||
} shader_backend_t;
|
||||
|
||||
typedef struct video_shader_ctx_params
|
||||
{
|
||||
void *data;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned tex_width;
|
||||
unsigned tex_height;
|
||||
unsigned out_width;
|
||||
unsigned out_height;
|
||||
unsigned frame_counter;
|
||||
const void *info;
|
||||
const void *prev_info;
|
||||
const void *feedback_info;
|
||||
const void *fbo_info;
|
||||
unsigned fbo_info_cnt;
|
||||
} video_shader_ctx_params_t;
|
||||
|
||||
extern const shader_backend_t gl_glsl_backend;
|
||||
extern const shader_backend_t hlsl_backend;
|
||||
extern const shader_backend_t gl_cg_backend;
|
||||
@ -145,15 +162,7 @@ bool video_shader_driver_get_feedback_pass(unsigned *pass);
|
||||
|
||||
struct video_shader *video_shader_driver_direct_get_current_shader(void);
|
||||
|
||||
void video_shader_driver_set_params(
|
||||
void *data, unsigned width, unsigned height,
|
||||
unsigned tex_width, unsigned tex_height,
|
||||
unsigned out_width, unsigned out_height,
|
||||
unsigned frame_counter,
|
||||
const void *info,
|
||||
const void *prev_info,
|
||||
const void *feedback_info,
|
||||
const void *fbo_info, unsigned fbo_info_cnt);
|
||||
void video_shader_driver_set_params(video_shader_ctx_params_t *params);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user