From 5029906c344ea39c13c9875d89da0f6b4a8595aa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 6 Apr 2025 21:52:15 +0200 Subject: Fallback to graphics shader instead of compute shader if the gpu doesn't support compute shader (either glsl 420 or opengl es glsl 310) --- include/color_conversion.h | 21 +++++++++++++++++---- include/shader.h | 4 ++++ 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/color_conversion.h b/include/color_conversion.h index 4c3b615..a8462c0 100644 --- a/include/color_conversion.h +++ b/include/color_conversion.h @@ -6,7 +6,8 @@ #include "vec2.h" #include -#define GSR_COLOR_CONVERSION_MAX_SHADERS 12 +#define GSR_COLOR_CONVERSION_MAX_COMPUTE_SHADERS 12 +#define GSR_COLOR_CONVERSION_MAX_GRAPHICS_SHADERS 6 #define GSR_COLOR_CONVERSION_MAX_FRAMEBUFFERS 2 typedef enum { @@ -37,12 +38,17 @@ typedef enum { GSR_ROT_270 } gsr_rotation; +typedef struct { + int rotation_matrix; + int offset; +} gsr_color_graphics_uniforms; + typedef struct { int rotation_matrix; int source_position; int target_position; int scale; -} gsr_color_uniforms; +} gsr_color_compute_uniforms; typedef struct { gsr_egl *egl; @@ -58,8 +64,15 @@ typedef struct { typedef struct { gsr_color_conversion_params params; - gsr_color_uniforms uniforms[GSR_COLOR_CONVERSION_MAX_SHADERS]; - gsr_shader shaders[GSR_COLOR_CONVERSION_MAX_SHADERS]; + gsr_color_compute_uniforms compute_uniforms[GSR_COLOR_CONVERSION_MAX_COMPUTE_SHADERS]; + gsr_shader compute_shaders[GSR_COLOR_CONVERSION_MAX_COMPUTE_SHADERS]; + + /* These are only loader if compute shaders (of the same type) fail to load */ + gsr_color_graphics_uniforms graphics_uniforms[GSR_COLOR_CONVERSION_MAX_GRAPHICS_SHADERS]; + gsr_shader graphics_shaders[GSR_COLOR_CONVERSION_MAX_GRAPHICS_SHADERS]; + + bool compute_shaders_failed_to_load; + bool external_compute_shaders_failed_to_load; unsigned int framebuffers[GSR_COLOR_CONVERSION_MAX_FRAMEBUFFERS]; diff --git a/include/shader.h b/include/shader.h index 8bc1104..285758d 100644 --- a/include/shader.h +++ b/include/shader.h @@ -1,6 +1,8 @@ #ifndef GSR_SHADER_H #define GSR_SHADER_H +#include + typedef struct gsr_egl gsr_egl; typedef struct { @@ -16,4 +18,6 @@ int gsr_shader_bind_attribute_location(gsr_shader *self, const char *attribute, void gsr_shader_use(gsr_shader *self); void gsr_shader_use_none(gsr_shader *self); +void gsr_shader_enable_debug_output(bool enable); + #endif /* GSR_SHADER_H */ -- cgit v1.2.3-70-g09d2