don't write unused uniforms
This commit is contained in:
+41
-18
@@ -418,6 +418,30 @@ static void update_viewport(ShaderProgram program, SharedContext *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_uniform_1f(GLuint location, float value) {
|
||||||
|
if (location != -1) {
|
||||||
|
glUniform1f(location, (const GLfloat)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_uniform_1i(GLuint location, unsigned int value) {
|
||||||
|
if (location != -1) {
|
||||||
|
glUniform1i(location, (const GLint)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_uniform_2f(GLuint location, vec2 *value) {
|
||||||
|
if (location != -1) {
|
||||||
|
glUniform2fv(location, 1, (const GLfloat *)value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// static void write_uniform_3f(GLuint location, vec3 *value) {
|
||||||
|
// if (location != -1) {
|
||||||
|
// glUniform3fv(location, 1, (const GLfloat *)value);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
static void use_program(ShaderProgram program, int i, bool output,
|
static void use_program(ShaderProgram program, int i, bool output,
|
||||||
SharedContext *context) {
|
SharedContext *context) {
|
||||||
unsigned int j, k;
|
unsigned int j, k;
|
||||||
@@ -448,30 +472,29 @@ static void use_program(ShaderProgram program, int i, bool output,
|
|||||||
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
glDrawBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
}
|
}
|
||||||
// set fragment uniforms
|
// set fragment uniforms
|
||||||
glUniform1f(program.itime_locations[i], (const GLfloat)context->time);
|
write_uniform_1f(program.itime_locations[i], context->time);
|
||||||
glUniform1f(program.itempo_locations[i], (const GLfloat)context->tempo);
|
write_uniform_1f(program.itempo_locations[i], context->tempo);
|
||||||
glUniform1i(program.ifps_locations[i], (const GLint)context->fps);
|
write_uniform_1i(program.ifps_locations[i], context->fps);
|
||||||
glUniform1i(program.idemo_locations[i], (const GLint)(context->demo ? 1 : 0));
|
write_uniform_1i(program.idemo_locations[i], context->demo ? 1 : 0);
|
||||||
glUniform2fv(program.ires_locations[i], 1, (const GLfloat *)&resolution);
|
write_uniform_2f(program.ires_locations[i], &resolution);
|
||||||
glUniform2fv(program.itexres_locations[i], 1,
|
write_uniform_2f(program.itexres_locations[i], &tex_resolution);
|
||||||
(const GLfloat *)&tex_resolution);
|
|
||||||
|
|
||||||
for (j = 0; j < program.in_count; j++) {
|
for (j = 0; j < program.in_count; j++) {
|
||||||
in_resolution[0] = context->input_widths[j];
|
in_resolution[0] = context->input_widths[j];
|
||||||
in_resolution[1] = context->input_heights[j];
|
in_resolution[1] = context->input_heights[j];
|
||||||
|
|
||||||
glUniform2fv(program.iinres_locations[i * program.in_count + j], 1,
|
write_uniform_2f(program.iinres_locations[i * program.in_count + j],
|
||||||
(const GLfloat *)&in_resolution);
|
&in_resolution);
|
||||||
glUniform1i(program.iinfmt_locations[i * program.in_count + j],
|
write_uniform_1i(program.iinfmt_locations[i * program.in_count + j],
|
||||||
(const GLint)context->input_formats[j]);
|
context->input_formats[j]);
|
||||||
glUniform1i(program.iinfps_locations[i * program.in_count + j],
|
write_uniform_1i(program.iinfps_locations[i * program.in_count + j],
|
||||||
(const GLint)context->input_fps[j]);
|
context->input_fps[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set seeds uniforms
|
// set seeds uniforms
|
||||||
for (j = 0; j < program.frag_count; j++) {
|
for (j = 0; j < program.frag_count; j++) {
|
||||||
glUniform1i(program.iseed_locations[i * program.frag_count + j],
|
write_uniform_1i(program.iseed_locations[i * program.frag_count + j],
|
||||||
(const GLint)context->seeds[j]);
|
context->seeds[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set subroutines for fragment and update state uniforms
|
// set subroutines for fragment and update state uniforms
|
||||||
@@ -483,8 +506,8 @@ static void use_program(ShaderProgram program, int i, bool output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < program.frag_count; j++) {
|
for (j = 0; j < program.frag_count; j++) {
|
||||||
glUniform1i(program.istate_locations[i * program.frag_count + j],
|
write_uniform_1i(program.istate_locations[i * program.frag_count + j],
|
||||||
(const GLint)context->state[j]);
|
context->state[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, program.sub_type_count,
|
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, program.sub_type_count,
|
||||||
@@ -492,7 +515,7 @@ static void use_program(ShaderProgram program, int i, bool output,
|
|||||||
|
|
||||||
// set GL_TEXTURE(X) to uniform sampler2D texX
|
// set GL_TEXTURE(X) to uniform sampler2D texX
|
||||||
for (j = 0; j < program.tex_count; j++) {
|
for (j = 0; j < program.tex_count; j++) {
|
||||||
glUniform1i(program.textures_locations[i * program.tex_count + j], j);
|
write_uniform_1i(program.textures_locations[i * program.tex_count + j], j);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw output
|
// draw output
|
||||||
|
|||||||
Reference in New Issue
Block a user