feat: video auto reconnect
Clang Lint CI / lint-no-video (push) Successful in 56s
Clang Build CI / run-no-video (push) Successful in 59s
Clang Build CI / run-video (push) Successful in 1m15s
Clang Build CI / build-release (push) Successful in 2m23s
Clang Lint CI / lint-video (push) Successful in 2m14s

This commit is contained in:
2026-05-14 13:16:55 +02:00
parent 25b7134a43
commit d4565fa507
18 changed files with 305 additions and 328 deletions
+29 -29
View File
@@ -134,8 +134,7 @@ static bool init_gl(ShaderProgram *program) {
!check_eglerror(program, "init_gl");
}
static bool init_textures(ShaderProgram *program,
const SharedContext *context) {
static bool init_textures(ShaderProgram *program, const Context *context) {
glGenTextures(program->tex_count, program->textures);
if (check_glerror(program, "init_textures/glGenTextures")) {
return false;
@@ -639,8 +638,7 @@ static bool init_programs(ShaderProgram *program, const ConfigFile *config,
return true;
}
static void update_viewport(ShaderProgram *program,
const SharedContext *context) {
static void update_viewport(ShaderProgram *program, const Context *context) {
// viewport changed
if (context->resolution[0] != program->last_resolution[0] ||
context->resolution[1] != program->last_resolution[1]) {
@@ -685,7 +683,7 @@ static void write_uniform_multi_3f(GLuint location, unsigned int count,
}
static void use_program(const ShaderProgram *program, int i, bool output,
const SharedContext *context) {
const Context *context) {
unsigned int k;
unsigned int offset;
unsigned int subcount;
@@ -728,17 +726,21 @@ static void use_program(const ShaderProgram *program, int i, bool output,
context->active[j] + 1);
}
#ifdef VIDEO_IN
for (unsigned int j = 0; j < program->in_count; j++) {
write_uniform_2f(program->iinres_locations[i * program->in_count + j],
&context->input_resolutions[j]);
write_uniform_1i(program->iinfmt_locations[i * program->in_count + j],
context->inputs.values[j].pixelformat);
context->input_formats[j]);
write_uniform_1i(program->iinfps_locations[i * program->in_count + j],
context->inputs.values[j].fps);
context->input_fps[j]);
write_uniform_1i(program->iinswap_locations[i * program->in_count + j],
context->inputs.values[j].swap ? 1 : 0);
context->input_swap[j] ? 1 : 0);
}
#endif /* VIDEO_IN */
// set seeds uniforms
for (unsigned int j = 0; j < program->frag_count; j++) {
write_uniform_1i(program->iseed_locations[i * program->frag_count + j],
@@ -788,7 +790,7 @@ static void use_program(const ShaderProgram *program, int i, bool output,
}
void shaders_init(ShaderProgram *program, const Project *project,
const SharedContext *context, bool rebind) {
const Context *context, bool rebind) {
if (!rebind) {
program->error = false;
program->last_resolution[0] = context->resolution[0];
@@ -841,23 +843,36 @@ void shaders_init(ShaderProgram *program, const Project *project,
}
}
#ifdef VIDEO_IN
void shaders_relink_input(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs, unsigned int i) {
#ifdef VIDEO_IN
// shaders_free_input(program, i);
init_input(program, &project->config, inputs, i, true);
#endif /* VIDEO_IN */
}
void shaders_link_inputs(ShaderProgram *program, const Project *project,
VideoCaptureArray *inputs) {
#ifdef VIDEO_IN
for (unsigned int i = 0; i < program->in_count; i++) {
init_input(program, &project->config, inputs, i, false);
}
#endif /* VIDEO_IN */
}
void shaders_free_input(ShaderProgram *program, unsigned int input_index) {
if (program->dma_images[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display, program->dma_images[input_index]);
program->dma_images[input_index] = EGL_NO_IMAGE_KHR;
}
if (program->dma_images_swap[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display,
program->dma_images_swap[input_index]);
program->dma_images_swap[input_index] = EGL_NO_IMAGE_KHR;
}
check_eglerror_ro("shaders_free_input/eglDestroyImageKHR");
}
#endif /* VIDEO_IN */
void shaders_update(ShaderProgram *program, const File *fragment_shader,
unsigned int i, const Project *project) {
if (compile_shader(program->fragment_shaders[i], fragment_shader->path,
@@ -868,7 +883,7 @@ void shaders_update(ShaderProgram *program, const File *fragment_shader,
}
}
void shaders_compute(ShaderProgram *program, const SharedContext *context,
void shaders_compute(ShaderProgram *program, const Context *context,
bool monitor, bool output_only) {
if (!output_only) {
glBindVertexArray(program->vertex_array[0]);
@@ -914,18 +929,3 @@ void shaders_free_window(const ShaderProgram *program, bool secondary) {
glDeleteVertexArrays(1, &program->vertex_array[secondary ? 1 : 0]);
check_glerror_ro("shaders_free_window/glDeleteVertexArrays");
}
void shaders_free_input(ShaderProgram *program, unsigned int input_index) {
#ifdef VIDEO_IN
if (program->dma_images[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display, program->dma_images[input_index]);
program->dma_images[input_index] = EGL_NO_IMAGE_KHR;
}
if (program->dma_images_swap[input_index] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(program->egl_display,
program->dma_images_swap[input_index]);
program->dma_images_swap[input_index] = EGL_NO_IMAGE_KHR;
}
check_eglerror_ro("shaders_free_input/eglDestroyImageKHR");
#endif /* VIDEO_IN */
}