Skip to content

Commit

Permalink
Add FinalViewportSize support to GLSL (#15891)
Browse files Browse the repository at this point in the history
* Change rotation type to int to maximize compatibility and to match glUniform1i

* Change to C style comment; Make comment more useful (hopefully)

* Add support for FinalViewportSize in GLSL
  • Loading branch information
fishcu authored Nov 11, 2023
1 parent 833c4b5 commit 1b50470
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions gfx/drivers_shader/shader_glsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ struct shader_uniforms
int input_size;
int output_size;
int texture_size;
int final_vp_size;

int frame_count;
int frame_direction;
unsigned rotation;
/* Use int for maximal compatibility despite other drivers using uint. */
int rotation;

int lut_texture[GFX_MAX_TEXTURES];
unsigned frame_count_mod;
Expand Down Expand Up @@ -734,6 +736,7 @@ static void gl_glsl_find_uniforms(glsl_shader_data_t *glsl,
uni->input_size = gl_glsl_get_uniform(glsl, prog, "InputSize");
uni->output_size = gl_glsl_get_uniform(glsl, prog, "OutputSize");
uni->texture_size = gl_glsl_get_uniform(glsl, prog, "TextureSize");
uni->final_vp_size = gl_glsl_get_uniform(glsl, prog, "FinalViewportSize");

uni->frame_count = gl_glsl_get_uniform(glsl, prog, "FrameCount");
uni->frame_direction = gl_glsl_get_uniform(glsl, prog, "FrameDirection");
Expand Down Expand Up @@ -1266,8 +1269,11 @@ static void gl_glsl_set_params(void *dat, void *shader_data)
unsigned i;
GLfloat buffer[512];
struct glsl_attrib attribs[32];
float input_size[2], output_size[2], texture_size[2];
float input_size[2], output_size[2], texture_size[2], final_vp_size[2];
video_shader_ctx_params_t *params = (video_shader_ctx_params_t*)dat;
gl2_t *gl_data = (gl2_t*)params->data;
unsigned vp_width = gl_data->vp_out_width;
unsigned vp_height = gl_data->vp_out_height;
unsigned width = params->width;
unsigned height = params->height;
unsigned tex_width = params->tex_width;
Expand Down Expand Up @@ -1299,12 +1305,14 @@ static void gl_glsl_set_params(void *dat, void *shader_data)
if (glsl->prg[glsl->active_idx].id == 0)
return;

input_size [0] = (float)width;
input_size [1] = (float)height;
output_size[0] = (float)out_width;
output_size[1] = (float)out_height;
texture_size[0] = (float)tex_width;
texture_size[1] = (float)tex_height;
input_size [0] = (float)width;
input_size [1] = (float)height;
output_size[0] = (float)out_width;
output_size[1] = (float)out_height;
texture_size[0] = (float)tex_width;
texture_size[1] = (float)tex_height;
final_vp_size[0] = (float)vp_width;
final_vp_size[1] = (float)vp_height;

if (uni->input_size >= 0)
glUniform2fv(uni->input_size, 1, input_size);
Expand All @@ -1315,6 +1323,9 @@ static void gl_glsl_set_params(void *dat, void *shader_data)
if (uni->texture_size >= 0)
glUniform2fv(uni->texture_size, 1, texture_size);

if (uni->final_vp_size >= 0)
glUniform2fv(uni->final_vp_size, 1, final_vp_size);

if (uni->frame_count >= 0 && glsl->active_idx)
{
unsigned modulo = glsl->shader->pass[glsl->active_idx - 1].frame_count_mod;
Expand Down

0 comments on commit 1b50470

Please sign in to comment.