don't write unused uniforms
This commit is contained in:
@@ -13,6 +13,9 @@ UNIFORM_SEED_PREFIX=seed
|
|||||||
UNIFORM_STATE_PREFIX=state
|
UNIFORM_STATE_PREFIX=state
|
||||||
UNIFORM_TEX_PREFIX=tex
|
UNIFORM_TEX_PREFIX=tex
|
||||||
UNIFORM_SRC_PREFIX=midi
|
UNIFORM_SRC_PREFIX=midi
|
||||||
|
UNIFORM_PAGE=iPage
|
||||||
|
UNIFORM_SELECTED=iSelected
|
||||||
|
UNIFORM_ACTIVE_PREFIX=active
|
||||||
|
|
||||||
SUB_TYPE_COUNT=2
|
SUB_TYPE_COUNT=2
|
||||||
SUB_1_PREFIX=src_
|
SUB_1_PREFIX=src_
|
||||||
|
|||||||
+16
-16
@@ -14,6 +14,8 @@ uniform vec2 iTexResolution;
|
|||||||
uniform vec2 iInputResolution1;
|
uniform vec2 iInputResolution1;
|
||||||
uniform vec2 iInputResolution2;
|
uniform vec2 iInputResolution2;
|
||||||
uniform int iDemo;
|
uniform int iDemo;
|
||||||
|
uniform int iPage;
|
||||||
|
uniform int iSelected;
|
||||||
|
|
||||||
uniform int seed1;
|
uniform int seed1;
|
||||||
uniform int seed2;
|
uniform int seed2;
|
||||||
@@ -28,9 +30,11 @@ uniform int state3;
|
|||||||
uniform int state4;
|
uniform int state4;
|
||||||
uniform int state5;
|
uniform int state5;
|
||||||
uniform int state6;
|
uniform int state6;
|
||||||
uniform int state7;
|
|
||||||
uniform int state8;
|
uniform int state8;
|
||||||
|
|
||||||
|
uniform int active1;
|
||||||
|
uniform int active2;
|
||||||
|
|
||||||
// 2. textures
|
// 2. textures
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
@@ -1239,10 +1243,6 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
|
|||||||
|
|
||||||
// inputs
|
// inputs
|
||||||
|
|
||||||
int selected = 0; // TODO debug selected
|
|
||||||
int page = 0; // TODO debug page
|
|
||||||
int selected_src = 0; // TODO debug selected
|
|
||||||
int selected_fx = 0; // TODO debug selected
|
|
||||||
int selected_srca = state3;
|
int selected_srca = state3;
|
||||||
int selected_srcb = state4;
|
int selected_srcb = state4;
|
||||||
int selected_fxa = state5;
|
int selected_fxa = state5;
|
||||||
@@ -1298,18 +1298,18 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
|
|||||||
f += char_at(uv2, vec2(-2.4, -2.55), hex_chars[selected_mfx]);
|
f += char_at(uv2, vec2(-2.4, -2.55), hex_chars[selected_mfx]);
|
||||||
|
|
||||||
// show current selected
|
// show current selected
|
||||||
f += selected == 0 ? h_rect(uv2, vec2(-5, 2), vec2(1.2), 0.1) : 0;
|
f += iSelected == 3 ? h_rect(uv2, vec2(-5, 2), vec2(1.2), 0.1) : 0;
|
||||||
f += selected == 1 ? h_rect(uv2, vec2(-5, -2), vec2(1.2), 0.1) : 0;
|
f += iSelected == 4 ? h_rect(uv2, vec2(-5, -2), vec2(1.2), 0.1) : 0;
|
||||||
f += selected == 2 ? h_rect(uv2, vec2(-2, 2), vec2(1.2), 0.1) : 0;
|
f += iSelected == 5 ? h_rect(uv2, vec2(-2, 2), vec2(1.2), 0.1) : 0;
|
||||||
f += selected == 3 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0;
|
f += iSelected == 6 ? h_rect(uv2, vec2(5, 0), vec2(1.2), 0.1) : 0;
|
||||||
f += selected == 4 ? h_rect(uv2, vec2(-2, -2), vec2(1.2), 0.1) : 0;
|
f += iSelected == 8 ? h_rect(uv2, vec2(-2, -2), vec2(1.2), 0.1) : 0;
|
||||||
|
|
||||||
// show selected src/fx
|
// show selected src/fx
|
||||||
f += selected_src == 0 ? h_rect(uv2, vec2(-5, 0.8), vec2(1, 0), 0.1) : 0;
|
f += active1 == 1 ? h_rect(uv2, vec2(-5, 0.8), vec2(1, 0), 0.1) : 0;
|
||||||
f += selected_src == 1 ? h_rect(uv2, vec2(-5, -3.2), vec2(1, 0), 0.1) : 0;
|
f += active1 == 2 ? h_rect(uv2, vec2(-5, -3.2), vec2(1, 0), 0.1) : 0;
|
||||||
f += selected_fx == 2 ? h_rect(uv2, vec2(-2, 0.8), vec2(1.2, 0), 0.1) : 0;
|
f += active2 == 1 ? h_rect(uv2, vec2(-2, 0.8), vec2(1.2, 0), 0.1) : 0;
|
||||||
f += selected_fx == 3 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0;
|
f += active2 == 2 ? h_rect(uv2, vec2(5, -1.2), vec2(1, 0), 0.1) : 0;
|
||||||
f += selected_fx == 4 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0;
|
f += active2 == 3 ? h_rect(uv2, vec2(-2, -3.2), vec2(1, 0), 0.1) : 0;
|
||||||
|
|
||||||
// show inputs / feedback
|
// show inputs / feedback
|
||||||
float line_a_a = rect(uv2, vec2(-8, 2), vec2(2, 0.1));
|
float line_a_a = rect(uv2, vec2(-8, 2), vec2(2, 0.1));
|
||||||
@@ -1334,7 +1334,7 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show page
|
// show page
|
||||||
f += char_at(uv2, vec2(-9.2, -4.3), hex_chars[page]);
|
f += char_at(uv2, vec2(-9.2, -4.3), hex_chars[iPage]);
|
||||||
|
|
||||||
// show fx values
|
// show fx values
|
||||||
f = mix(f, 1 - f, rect(uv2, vec2(-2, 1.1 + 0.9 * fxa_value), vec2(0.9, 0.9 * fxa_value)));
|
f = mix(f, 1 - f, rect(uv2, vec2(-2, 1.1 + 0.9 * fxa_value), vec2(0.9, 0.9 * fxa_value)));
|
||||||
|
|||||||
+8
-2
@@ -67,6 +67,11 @@ static void init_context(Parameters params, unsigned int in_count,
|
|||||||
state_randomize(context, state_config, frag_count);
|
state_randomize(context, state_config, frag_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(context->active, 0, sizeof(context->active));
|
||||||
|
|
||||||
|
context->page = 0;
|
||||||
|
context->selected = 0;
|
||||||
|
|
||||||
memset(context->seeds, 0, sizeof(context->seeds));
|
memset(context->seeds, 0, sizeof(context->seeds));
|
||||||
|
|
||||||
for (i = 0; i < frag_count; i++) {
|
for (i = 0; i < frag_count; i++) {
|
||||||
@@ -285,7 +290,8 @@ void forge_run(Parameters params) {
|
|||||||
|
|
||||||
program = shaders_init(
|
program = shaders_init(
|
||||||
fragment_shaders, config, context, inputs, params.video_in_count,
|
fragment_shaders, config, context, inputs, params.video_in_count,
|
||||||
state_config.select_page_count * state_config.select_item_count, NULL);
|
state_config.select_page_count * state_config.select_item_count,
|
||||||
|
state_config.src_count, NULL);
|
||||||
} else {
|
} else {
|
||||||
window_output = NULL;
|
window_output = NULL;
|
||||||
}
|
}
|
||||||
@@ -300,7 +306,7 @@ void forge_run(Parameters params) {
|
|||||||
program = shaders_init(
|
program = shaders_init(
|
||||||
fragment_shaders, config, context, inputs, params.video_in_count,
|
fragment_shaders, config, context, inputs, params.video_in_count,
|
||||||
state_config.select_page_count * state_config.select_item_count,
|
state_config.select_page_count * state_config.select_item_count,
|
||||||
window_output != NULL ? &program : NULL);
|
state_config.src_count, window_output != NULL ? &program : NULL);
|
||||||
} else {
|
} else {
|
||||||
window_monitor = NULL;
|
window_monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-4
@@ -260,6 +260,12 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
|
|||||||
program->idemo_locations[i] = glGetUniformLocation(
|
program->idemo_locations[i] = glGetUniformLocation(
|
||||||
program->programs[i],
|
program->programs[i],
|
||||||
config_file_get_str(config, "UNIFORM_DEMO", "iDemo"));
|
config_file_get_str(config, "UNIFORM_DEMO", "iDemo"));
|
||||||
|
program->ipage_locations[i] = glGetUniformLocation(
|
||||||
|
program->programs[i],
|
||||||
|
config_file_get_str(config, "UNIFORM_PAGE", "iPage"));
|
||||||
|
program->iselected_locations[i] = glGetUniformLocation(
|
||||||
|
program->programs[i],
|
||||||
|
config_file_get_str(config, "UNIFORM_SELECTED", "iSelected"));
|
||||||
|
|
||||||
prefix = config_file_get_str(config, "UNIFORM_IN_RESOLUTION_PREFIX",
|
prefix = config_file_get_str(config, "UNIFORM_IN_RESOLUTION_PREFIX",
|
||||||
"iInputResolution");
|
"iInputResolution");
|
||||||
@@ -310,6 +316,13 @@ static void init_single_program(ShaderProgram *program, unsigned int i,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefix = config_file_get_str(config, "UNIFORM_ACTIVE_PREFIX", "active");
|
||||||
|
for (j = 0; j < program->active_count; j++) {
|
||||||
|
sprintf(name, "%s%d", prefix, j + 1);
|
||||||
|
program->iactive_locations[i * program->active_count + j] =
|
||||||
|
glGetUniformLocation(program->programs[i], name);
|
||||||
|
}
|
||||||
|
|
||||||
// create texX uniforms pointer
|
// create texX uniforms pointer
|
||||||
prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "tex");
|
prefix = config_file_get_str(config, "UNIFORM_TEX_PREFIX", "tex");
|
||||||
for (j = 0; j < program->tex_count; j++) {
|
for (j = 0; j < program->tex_count; j++) {
|
||||||
@@ -337,7 +350,7 @@ ShaderProgram shaders_init(File *fragment_shaders, ConfigFile config,
|
|||||||
SharedContext *context, VideoCapture *inputs,
|
SharedContext *context, VideoCapture *inputs,
|
||||||
unsigned int input_count,
|
unsigned int input_count,
|
||||||
unsigned int sub_variant_count,
|
unsigned int sub_variant_count,
|
||||||
ShaderProgram *previous) {
|
unsigned int active_count, ShaderProgram *previous) {
|
||||||
ShaderProgram program;
|
ShaderProgram program;
|
||||||
|
|
||||||
if (previous == NULL) {
|
if (previous == NULL) {
|
||||||
@@ -351,8 +364,9 @@ ShaderProgram shaders_init(File *fragment_shaders, ConfigFile config,
|
|||||||
program.frag_monitor_index =
|
program.frag_monitor_index =
|
||||||
config_file_get_int(config, "FRAG_MONITOR", 1) - 1;
|
config_file_get_int(config, "FRAG_MONITOR", 1) - 1;
|
||||||
program.sub_type_count = config_file_get_int(config, "SUB_TYPE_COUNT", 0);
|
program.sub_type_count = config_file_get_int(config, "SUB_TYPE_COUNT", 0);
|
||||||
program.sub_variant_count = sub_variant_count;
|
|
||||||
program.in_count = config_file_get_int(config, "IN_COUNT", 0);
|
program.in_count = config_file_get_int(config, "IN_COUNT", 0);
|
||||||
|
program.sub_variant_count = sub_variant_count;
|
||||||
|
program.active_count = active_count;
|
||||||
|
|
||||||
if (program.frag_count > MAX_FRAG) {
|
if (program.frag_count > MAX_FRAG) {
|
||||||
log_error("FRAG_COUNT over %d", MAX_FRAG);
|
log_error("FRAG_COUNT over %d", MAX_FRAG);
|
||||||
@@ -378,8 +392,8 @@ ShaderProgram shaders_init(File *fragment_shaders, ConfigFile config,
|
|||||||
|
|
||||||
init_vertices(&program);
|
init_vertices(&program);
|
||||||
|
|
||||||
log_debug("Error after init: %04x",
|
// log_debug("Error after init: %04x",
|
||||||
glGetError()); // TODO check error at each step
|
// glGetError()); // TODO check error at each step
|
||||||
} else {
|
} else {
|
||||||
program = *previous;
|
program = *previous;
|
||||||
}
|
}
|
||||||
@@ -476,9 +490,16 @@ static void use_program(ShaderProgram program, int i, bool output,
|
|||||||
write_uniform_1f(program.itempo_locations[i], context->tempo);
|
write_uniform_1f(program.itempo_locations[i], context->tempo);
|
||||||
write_uniform_1i(program.ifps_locations[i], context->fps);
|
write_uniform_1i(program.ifps_locations[i], context->fps);
|
||||||
write_uniform_1i(program.idemo_locations[i], context->demo ? 1 : 0);
|
write_uniform_1i(program.idemo_locations[i], context->demo ? 1 : 0);
|
||||||
|
write_uniform_1i(program.ipage_locations[i], context->page);
|
||||||
|
write_uniform_1i(program.iselected_locations[i], context->page);
|
||||||
write_uniform_2f(program.ires_locations[i], &resolution);
|
write_uniform_2f(program.ires_locations[i], &resolution);
|
||||||
write_uniform_2f(program.itexres_locations[i], &tex_resolution);
|
write_uniform_2f(program.itexres_locations[i], &tex_resolution);
|
||||||
|
|
||||||
|
for (j = 0; j < program.active_count; j++) {
|
||||||
|
write_uniform_1i(program.iactive_locations[i * program.active_count + j],
|
||||||
|
context->active[i] + 1);
|
||||||
|
}
|
||||||
|
|
||||||
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];
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ ShaderProgram shaders_init(File *fragment_shaders, ConfigFile config,
|
|||||||
SharedContext *context, VideoCapture *inputs,
|
SharedContext *context, VideoCapture *inputs,
|
||||||
unsigned int input_count,
|
unsigned int input_count,
|
||||||
unsigned int sub_variant_count,
|
unsigned int sub_variant_count,
|
||||||
ShaderProgram *previous);
|
unsigned int active_count, ShaderProgram *previous);
|
||||||
|
|
||||||
void shaders_update(ShaderProgram program, File *fragment_shaders,
|
void shaders_update(ShaderProgram program, File *fragment_shaders,
|
||||||
unsigned int i);
|
unsigned int i);
|
||||||
|
|||||||
+8
-10
@@ -14,16 +14,6 @@
|
|||||||
#ifndef TYPES_H
|
#ifndef TYPES_H
|
||||||
#define TYPES_H
|
#define TYPES_H
|
||||||
|
|
||||||
typedef struct SharedUint {
|
|
||||||
int fd;
|
|
||||||
unsigned int value;
|
|
||||||
} SharedUint;
|
|
||||||
|
|
||||||
typedef struct SharedBool {
|
|
||||||
int fd;
|
|
||||||
bool value;
|
|
||||||
} SharedBool;
|
|
||||||
|
|
||||||
typedef struct Parameters {
|
typedef struct Parameters {
|
||||||
bool hot_reload;
|
bool hot_reload;
|
||||||
bool output;
|
bool output;
|
||||||
@@ -86,6 +76,9 @@ typedef struct ShaderProgram {
|
|||||||
GLuint idemo_locations[ARRAY_SIZE];
|
GLuint idemo_locations[ARRAY_SIZE];
|
||||||
GLuint iseed_locations[ARRAY_SIZE];
|
GLuint iseed_locations[ARRAY_SIZE];
|
||||||
GLuint istate_locations[ARRAY_SIZE];
|
GLuint istate_locations[ARRAY_SIZE];
|
||||||
|
GLuint ipage_locations[ARRAY_SIZE];
|
||||||
|
GLuint iselected_locations[ARRAY_SIZE];
|
||||||
|
GLuint iactive_locations[ARRAY_SIZE];
|
||||||
|
|
||||||
GLuint vpos_locations[ARRAY_SIZE];
|
GLuint vpos_locations[ARRAY_SIZE];
|
||||||
|
|
||||||
@@ -95,6 +88,8 @@ typedef struct ShaderProgram {
|
|||||||
unsigned int sub_variant_count;
|
unsigned int sub_variant_count;
|
||||||
GLuint sub_locations[ARRAY_SIZE];
|
GLuint sub_locations[ARRAY_SIZE];
|
||||||
|
|
||||||
|
unsigned int active_count;
|
||||||
|
|
||||||
unsigned int in_count;
|
unsigned int in_count;
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
} ShaderProgram;
|
} ShaderProgram;
|
||||||
@@ -126,6 +121,9 @@ typedef struct SharedContext {
|
|||||||
unsigned int fps;
|
unsigned int fps;
|
||||||
float tempo;
|
float tempo;
|
||||||
unsigned int state[MAX_FRAG];
|
unsigned int state[MAX_FRAG];
|
||||||
|
unsigned int page;
|
||||||
|
unsigned int selected;
|
||||||
|
unsigned int active[ARRAY_SIZE];
|
||||||
bool demo;
|
bool demo;
|
||||||
unsigned int seeds[MAX_FRAG];
|
unsigned int seeds[MAX_FRAG];
|
||||||
bool monitor;
|
bool monitor;
|
||||||
|
|||||||
Reference in New Issue
Block a user