chore: reduce debt

This commit is contained in:
2025-11-10 16:38:34 +01:00
parent 5532cbf53e
commit 1f727dc9b2
5 changed files with 21 additions and 20 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ static bool is_arg(const char *arg, const char *ref) {
return strcoll(arg, ref) == 0;
}
static char *split_arg_value(char *arg) {
static const char *split_arg_value(char *arg) {
char *rest;
strtok_r(arg, "=", &rest);
@@ -111,7 +111,7 @@ static unsigned int parse_uint(const char *arg, const char *value) {
void args_parse(Parameters *params, int argc, char **argv) {
char *arg;
char *value;
const char *value;
strlcpy(params->project_path, DATADIR "/default", STR_LEN);
strlcpy(params->config_file, "forge_project.cfg", STR_LEN);
+1 -1
View File
@@ -117,7 +117,7 @@ unsigned int config_file_get_int(const ConfigFile *config, const char *key,
return default_value;
}
if (!string_is_number((char *)item->value)) {
if (!string_is_number(item->value)) {
log_warn("Invalid number for %s: '%s'", item->key, item->value);
return default_value;
}
+2 -2
View File
@@ -14,8 +14,8 @@
static bool parse_fragment_shader_file(Project *project, unsigned int i) {
File tmp_file;
char file_path[STR_LEN];
char *include_pos;
char *include_end;
const char *include_pos;
const char *include_end;
char included_file[STR_LEN];
char *new_content;
+15 -14
View File
@@ -62,7 +62,7 @@ static void init_textures(ShaderProgram *program,
}
}
static void rebind_textures(ShaderProgram *program) {
static void rebind_textures(const ShaderProgram *program) {
for (unsigned int i = 0; i < program->tex_count; i++) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(GL_TEXTURE_2D, program->textures[i]);
@@ -88,9 +88,9 @@ static void link_input_to_texture(ShaderProgram *program, VideoCapture *input,
input->bytesperline,
EGL_NONE};
input->dma_image = eglCreateImageKHR(program->egl_display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
(EGLClientBuffer)NULL, attrib_list);
input->dma_image =
eglCreateImageKHR(program->egl_display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT, NULL, attrib_list);
if (input->dma_image == EGL_NO_IMAGE_KHR) {
log_error("(%s) eglCreateImageKHR failed %04x", input->name, eglGetError());
@@ -105,8 +105,7 @@ static void link_input_to_texture(ShaderProgram *program, VideoCapture *input,
GL_UNSIGNED_BYTE, 0);
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_EGL_image_storage.txt
glEGLImageTargetTexStorageEXT(GL_TEXTURE_2D, (GLeglImageOES)input->dma_image,
NULL);
glEGLImageTargetTexStorageEXT(GL_TEXTURE_2D, input->dma_image, NULL);
log_info("Texture %d linked to %s", texture_index, input->name);
}
@@ -192,7 +191,7 @@ static bool compile_shader(GLuint shader_id, const char *name,
log_info("Compiling '%s'...", name);
// update shader source code
glShaderSource(shader_id, 1, (const GLchar **)&source_code, NULL);
glShaderSource(shader_id, 1, &source_code, NULL);
// compile shader
glCompileShader(shader_id);
@@ -214,15 +213,17 @@ static bool compile_shader(GLuint shader_id, const char *name,
static void init_shaders(ShaderProgram *program, const Project *project) {
// compile vertex shader
program->vertex_shader = glCreateShader(GL_VERTEX_SHADER);
program->error |= !compile_shader(
program->vertex_shader, "internal vertex shader", vertex_shader_text);
program->error = program->error || !compile_shader(program->vertex_shader,
"internal vertex shader",
vertex_shader_text);
// compile fragment shaders
for (unsigned int i = 0; i < program->frag_count; i++) {
program->fragment_shaders[i] = glCreateShader(GL_FRAGMENT_SHADER);
program->error |= !compile_shader(program->fragment_shaders[i],
project->fragment_shaders[i][0].path,
project->fragment_shaders[i][0].content);
program->error = program->error ||
!compile_shader(program->fragment_shaders[i],
project->fragment_shaders[i][0].path,
project->fragment_shaders[i][0].content);
if (program->error) {
return;
@@ -422,7 +423,7 @@ void shaders_init(ShaderProgram *program, const Project *project,
;
}
void shaders_update(ShaderProgram *program, const File *fragment_shader,
void shaders_update(const ShaderProgram *program, const File *fragment_shader,
unsigned int i) {
bool result;
@@ -454,7 +455,7 @@ static void update_viewport(ShaderProgram *program,
static void write_uniform_1f(GLuint location, float value) {
if (location != unused_uniform) {
glUniform1f(location, (const GLfloat)value);
glUniform1f(location, value);
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ void shaders_init(ShaderProgram *program, const Project *project,
const SharedContext *context, VideoCaptureArray *inputs,
bool rebind);
void shaders_update(ShaderProgram *program, const File *fragment_shader,
void shaders_update(const ShaderProgram *program, const File *fragment_shader,
unsigned int i);
void shaders_compute(ShaderProgram *program, const SharedContext *context,