mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
Restore glsl_set_params
This commit is contained in:
parent
c15ec92c83
commit
67d08f6790
@ -1015,7 +1015,6 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
GLfloat buffer[512];
|
GLfloat buffer[512];
|
||||||
struct glsl_attrib attribs[32];
|
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];
|
||||||
unsigned uniform_count = 0;
|
|
||||||
unsigned texunit = 1;
|
unsigned texunit = 1;
|
||||||
const struct shader_uniforms *uni = NULL;
|
const struct shader_uniforms *uni = NULL;
|
||||||
size_t size = 0, attribs_size = 0;
|
size_t size = 0, attribs_size = 0;
|
||||||
@ -1041,32 +1040,15 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
texture_size[0] = (float)tex_width;
|
texture_size[0] = (float)tex_width;
|
||||||
texture_size[1] = (float)tex_height;
|
texture_size[1] = (float)tex_height;
|
||||||
|
|
||||||
uniform_params[0].enabled = false;
|
|
||||||
uniform_params[0].location = uni->input_size;
|
|
||||||
uniform_params[0].type = UNIFORM_2FV;
|
|
||||||
uniform_params[0].result.floatv = input_size;
|
|
||||||
|
|
||||||
if (uni->input_size >= 0)
|
if (uni->input_size >= 0)
|
||||||
uniform_params[0].enabled = true;
|
glUniform2fv(uni->input_size, 1, input_size);
|
||||||
|
|
||||||
uniform_params[1].enabled = false;
|
|
||||||
uniform_params[1].location = uni->output_size;
|
|
||||||
uniform_params[1].type = UNIFORM_2FV;
|
|
||||||
uniform_params[1].result.floatv = output_size;
|
|
||||||
|
|
||||||
if (uni->output_size >= 0)
|
if (uni->output_size >= 0)
|
||||||
uniform_params[1].enabled = true;
|
glUniform2fv(uni->output_size, 1, output_size);
|
||||||
|
|
||||||
uniform_params[2].enabled = false;
|
|
||||||
uniform_params[2].location = uni->texture_size;
|
|
||||||
uniform_params[2].type = UNIFORM_2FV;
|
|
||||||
uniform_params[2].result.floatv = texture_size;
|
|
||||||
|
|
||||||
if (uni->texture_size >= 0)
|
if (uni->texture_size >= 0)
|
||||||
uniform_params[2].enabled = true;
|
glUniform2fv(uni->texture_size, 1, texture_size);
|
||||||
|
|
||||||
uniform_count += 3;
|
|
||||||
|
|
||||||
if (uni->frame_count >= 0 && glsl->active_idx)
|
if (uni->frame_count >= 0 && glsl->active_idx)
|
||||||
{
|
{
|
||||||
unsigned modulo = glsl->shader->pass[glsl->active_idx - 1].frame_count_mod;
|
unsigned modulo = glsl->shader->pass[glsl->active_idx - 1].frame_count_mod;
|
||||||
@ -1074,23 +1056,11 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
if (modulo)
|
if (modulo)
|
||||||
frame_count %= modulo;
|
frame_count %= modulo;
|
||||||
|
|
||||||
uniform_params[uniform_count].enabled = true;
|
glUniform1i(uni->frame_count, frame_count);
|
||||||
uniform_params[uniform_count].location = uni->frame_count;
|
|
||||||
uniform_params[uniform_count].type = UNIFORM_1I;
|
|
||||||
uniform_params[uniform_count].result.integer.v0 = frame_count;
|
|
||||||
|
|
||||||
uniform_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uniform_params[uniform_count].enabled = true;
|
if (uni->frame_direction >= 0)
|
||||||
uniform_params[uniform_count].location = uni->frame_direction;
|
glUniform1i(uni->frame_direction, state_manager_frame_is_reversed() ? -1 : 1);
|
||||||
uniform_params[uniform_count].type = UNIFORM_1I;
|
|
||||||
uniform_params[uniform_count].result.integer.v0 =
|
|
||||||
state_manager_frame_is_reversed() ? -1 : 1;
|
|
||||||
uniform_count++;
|
|
||||||
|
|
||||||
for (i = 0; i < uniform_count; i++)
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &uniform_params[i], NULL);
|
|
||||||
|
|
||||||
/* Set lookup textures. */
|
/* Set lookup textures. */
|
||||||
for (i = 0; i < glsl->shader->luts; i++)
|
for (i = 0; i < glsl->shader->luts; i++)
|
||||||
@ -1102,13 +1072,7 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
/* Have to rebind as HW render could override this. */
|
/* Have to rebind as HW render could override this. */
|
||||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
glBindTexture(GL_TEXTURE_2D, glsl->lut_textures[i]);
|
glBindTexture(GL_TEXTURE_2D, glsl->lut_textures[i]);
|
||||||
|
glUniform1i(uni->lut_texture[i], texunit);
|
||||||
lut_uniform.enabled = true;
|
|
||||||
lut_uniform.location = uni->lut_texture[i];
|
|
||||||
lut_uniform.type = UNIFORM_1I;
|
|
||||||
lut_uniform.result.integer.v0 = texunit;
|
|
||||||
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &lut_uniform, NULL);
|
|
||||||
texunit++;
|
texunit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,33 +1088,16 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
struct uniform_info orig_tex_uniform = {0};
|
struct uniform_info orig_tex_uniform = {0};
|
||||||
/* Bind original texture. */
|
/* Bind original texture. */
|
||||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
|
glUniform1i(uni->orig.texture, texunit);
|
||||||
orig_tex_uniform.enabled = true;
|
|
||||||
orig_tex_uniform.location = uni->orig.texture;
|
|
||||||
orig_tex_uniform.type = UNIFORM_1I;
|
|
||||||
orig_tex_uniform.result.integer.v0 = texunit;
|
|
||||||
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &orig_tex_uniform, NULL);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, info->tex);
|
glBindTexture(GL_TEXTURE_2D, info->tex);
|
||||||
texunit++;
|
texunit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_uniforms[0].enabled = false;
|
|
||||||
orig_uniforms[0].location = uni->orig.texture_size;
|
|
||||||
orig_uniforms[0].type = UNIFORM_2FV;
|
|
||||||
orig_uniforms[0].result.floatv = (float*)info->tex_size;
|
|
||||||
|
|
||||||
if (uni->orig.texture_size >= 0)
|
if (uni->orig.texture_size >= 0)
|
||||||
orig_uniforms[0].enabled = true;
|
glUniform2fv(uni->orig.texture_size, 1, info->tex_size);
|
||||||
|
|
||||||
orig_uniforms[1].enabled = false;
|
|
||||||
orig_uniforms[1].location = uni->orig.input_size;
|
|
||||||
orig_uniforms[1].type = UNIFORM_2FV;
|
|
||||||
orig_uniforms[1].result.floatv = (float*)info->input_size;
|
|
||||||
|
|
||||||
if (uni->orig.input_size >= 0)
|
if (uni->orig.input_size >= 0)
|
||||||
orig_uniforms[1].enabled = true;
|
glUniform2fv(uni->orig.input_size, 1, info->input_size);
|
||||||
|
|
||||||
for (j = 0; j < 2; j++)
|
for (j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
@ -1174,43 +1121,18 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
/* Set feedback texture. */
|
/* Set feedback texture. */
|
||||||
if (uni->feedback.texture >= 0)
|
if (uni->feedback.texture >= 0)
|
||||||
{
|
{
|
||||||
struct uniform_info feedback_texture_param = {0};
|
|
||||||
|
|
||||||
/* Bind original texture. */
|
/* Bind original texture. */
|
||||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
|
glUniform1i(uni->feedback.texture, texunit);
|
||||||
feedback_texture_param.enabled = true;
|
|
||||||
feedback_texture_param.location = uni->pass[i].texture;
|
|
||||||
feedback_texture_param.type = UNIFORM_1I;
|
|
||||||
feedback_texture_param.result.integer.v0 = texunit;
|
|
||||||
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &feedback_texture_param, NULL);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, feedback_info->tex);
|
glBindTexture(GL_TEXTURE_2D, feedback_info->tex);
|
||||||
texunit++;
|
texunit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
feedback_uniforms[0].enabled = false;
|
|
||||||
feedback_uniforms[0].location = uni->feedback.texture_size;
|
|
||||||
feedback_uniforms[0].type = UNIFORM_2FV;
|
|
||||||
feedback_uniforms[0].result.floatv = (float*)feedback_info->tex_size;
|
|
||||||
|
|
||||||
if (uni->feedback.texture_size >= 0)
|
if (uni->feedback.texture_size >= 0)
|
||||||
feedback_uniforms[0].enabled = true;
|
glUniform2fv(uni->feedback.texture_size, 1, feedback_info->tex_size);
|
||||||
|
|
||||||
feedback_uniforms[1].enabled = false;
|
|
||||||
feedback_uniforms[1].location = uni->feedback.input_size;
|
|
||||||
feedback_uniforms[1].type = UNIFORM_2FV;
|
|
||||||
feedback_uniforms[1].result.floatv = (float*)feedback_info->input_size;
|
|
||||||
|
|
||||||
if (uni->feedback.input_size >= 0)
|
if (uni->feedback.input_size >= 0)
|
||||||
feedback_uniforms[1].enabled = true;
|
glUniform2fv(uni->feedback.input_size, 1, feedback_info->input_size);
|
||||||
|
|
||||||
for (j = 0; j < 2; j++)
|
|
||||||
{
|
|
||||||
if (feedback_uniforms[j].enabled)
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pass texture coordinates. */
|
/* Pass texture coordinates. */
|
||||||
if (uni->feedback.tex_coord >= 0)
|
if (uni->feedback.tex_coord >= 0)
|
||||||
@ -1235,36 +1157,15 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
glBindTexture(GL_TEXTURE_2D, fbo_info[i].tex);
|
glBindTexture(GL_TEXTURE_2D, fbo_info[i].tex);
|
||||||
|
glUniform1i(uni->pass[i].texture, texunit);
|
||||||
fbo_tex_params[0].enabled = true;
|
|
||||||
fbo_tex_params[0].location = uni->pass[i].texture;
|
|
||||||
fbo_tex_params[0].type = UNIFORM_1I;
|
|
||||||
fbo_tex_params[0].result.integer.v0 = texunit;
|
|
||||||
|
|
||||||
texunit++;
|
texunit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fbo_tex_params[1].enabled = false;
|
if (uni->pass[i].texture_size >= 0)
|
||||||
fbo_tex_params[1].location = uni->pass[i].texture_size;
|
glUniform2fv(uni->pass[i].texture_size, 1, fbo_info[i].tex_size);
|
||||||
fbo_tex_params[1].type = UNIFORM_2FV;
|
|
||||||
fbo_tex_params[1].result.floatv = (float*)fbo_info[i].tex_size;
|
|
||||||
|
|
||||||
if (uni->pass[i].texture_size >= 0)
|
|
||||||
fbo_tex_params[1].enabled = true;
|
|
||||||
|
|
||||||
fbo_tex_params[2].enabled = false;
|
|
||||||
fbo_tex_params[2].location = uni->pass[i].input_size;
|
|
||||||
fbo_tex_params[2].type = UNIFORM_2FV;
|
|
||||||
fbo_tex_params[2].result.floatv = (float*)fbo_info[i].input_size;
|
|
||||||
|
|
||||||
if (uni->pass[i].input_size >= 0)
|
if (uni->pass[i].input_size >= 0)
|
||||||
fbo_tex_params[2].enabled = true;
|
glUniform2fv(uni->pass[i].input_size, 1, fbo_info[i].input_size);
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
if (fbo_tex_params[j].enabled)
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uni->pass[i].tex_coord >= 0)
|
if (uni->pass[i].tex_coord >= 0)
|
||||||
{
|
{
|
||||||
@ -1290,36 +1191,16 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0 + texunit);
|
glActiveTexture(GL_TEXTURE0 + texunit);
|
||||||
glBindTexture(GL_TEXTURE_2D, prev_info[i].tex);
|
glBindTexture(GL_TEXTURE_2D, prev_info[i].tex);
|
||||||
|
glUniform1i(uni->prev[i].texture, texunit);
|
||||||
prev_tex_params[0].enabled = true;
|
|
||||||
prev_tex_params[0].location = uni->prev[i].texture;
|
|
||||||
prev_tex_params[0].type = UNIFORM_1I;
|
|
||||||
prev_tex_params[0].result.integer.v0 = texunit;
|
|
||||||
|
|
||||||
texunit++;
|
texunit++;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_tex_params[1].enabled = false;
|
|
||||||
prev_tex_params[1].location = uni->prev[i].texture_size;
|
|
||||||
prev_tex_params[1].type = UNIFORM_2FV;
|
|
||||||
prev_tex_params[1].result.floatv = (float*)prev_info[i].tex_size;
|
|
||||||
|
|
||||||
if (uni->prev[i].texture_size >= 0)
|
if (uni->prev[i].texture_size >= 0)
|
||||||
prev_tex_params[1].enabled = true;
|
glUniform2fv(uni->prev[i].texture_size, 1, prev_info[i].tex_size);
|
||||||
|
|
||||||
prev_tex_params[2].enabled = false;
|
|
||||||
prev_tex_params[2].location = uni->prev[i].input_size;
|
|
||||||
prev_tex_params[2].type = UNIFORM_2FV;
|
|
||||||
prev_tex_params[2].result.floatv = (float*)prev_info[i].input_size;
|
|
||||||
|
|
||||||
if (uni->prev[i].input_size >= 0)
|
if (uni->prev[i].input_size >= 0)
|
||||||
prev_tex_params[2].enabled = true;
|
glUniform2fv(uni->prev[i].input_size, 1, prev_info[i].input_size);
|
||||||
|
|
||||||
for (j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
if (prev_tex_params[j].enabled)
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Pass texture coordinates. */
|
/* Pass texture coordinates. */
|
||||||
if (uni->prev[i].tex_coord >= 0)
|
if (uni->prev[i].tex_coord >= 0)
|
||||||
@ -1346,17 +1227,11 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
/* #pragma parameters. */
|
/* #pragma parameters. */
|
||||||
for (i = 0; i < glsl->shader->num_parameters; i++)
|
for (i = 0; i < glsl->shader->num_parameters; i++)
|
||||||
{
|
{
|
||||||
struct uniform_info pragma_param = {0};
|
|
||||||
|
int location = glGetUniformLocation(
|
||||||
pragma_param.lookup.enable = true;
|
glsl->prg[glsl->active_idx].id,
|
||||||
pragma_param.lookup.idx = glsl->active_idx;
|
glsl->shader->parameters[i].id);
|
||||||
pragma_param.lookup.ident = glsl->shader->parameters[i].id;
|
glUniform1f(location, glsl->shader->parameters[i].current);
|
||||||
pragma_param.lookup.type = SHADER_PROGRAM_COMBINED;
|
|
||||||
pragma_param.enabled = true;
|
|
||||||
pragma_param.type = UNIFORM_1F;
|
|
||||||
pragma_param.result.f.v0 = glsl->shader->parameters[i].current;
|
|
||||||
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &pragma_param, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set state parameters. */
|
/* Set state parameters. */
|
||||||
@ -1371,17 +1246,10 @@ static void gl_glsl_set_params(void *data, void *shader_data,
|
|||||||
|
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < cnt; i++)
|
||||||
{
|
{
|
||||||
struct uniform_info state_param = {0};
|
int location = glGetUniformLocation(
|
||||||
|
glsl->prg[glsl->active_idx].id,
|
||||||
state_param.lookup.enable = true;
|
state_info[i].id);
|
||||||
state_param.lookup.idx = glsl->active_idx;
|
glUniform1f(location, state_info[i].value);
|
||||||
state_param.lookup.ident = state_info[i].id;
|
|
||||||
state_param.lookup.type = SHADER_PROGRAM_COMBINED;
|
|
||||||
state_param.enabled = true;
|
|
||||||
state_param.type = UNIFORM_1F;
|
|
||||||
state_param.result.f.v0 = state_info[i].value;
|
|
||||||
|
|
||||||
gl_glsl_set_uniform_parameter(glsl, &state_param, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user