aboutsummaryrefslogtreecommitdiff
path: root/include/color_conversion.h
diff options
context:
space:
mode:
authordec05eba <dec05eba®protonmail.com>2023-04-14 09:36:24 +0200
committerdec05eba <dec05eba@protonmail.com>2023-04-15 19:06:08 +0200
commitf6107a0c5d41aa9fbaa41d64e2f6a5681f9237cc (patch)
tree8fae2bf69dd325d1da0ab1e475a58f32435768cf /include/color_conversion.h
parent5c714ea7142272b7b95b95019501df1d49691db1 (diff)
Fix AMD single monitor rotated display being rotated in recording
If there is only one monitor connected and it's rotated then the drm buf will also be rotated. This only the case with AMD and only when using one monitor! To fix this, we perform color conversion with an opengl shader which allows us to also rotate the texture. VAAPI supports rotation but it's not implemented by AMD at least. Performance seems to be the same as when using VAAPI, even when GPU usage is 100%.
Diffstat (limited to 'include/color_conversion.h')
-rw-r--r--include/color_conversion.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/color_conversion.h b/include/color_conversion.h
new file mode 100644
index 0000000..de83d1e
--- /dev/null
+++ b/include/color_conversion.h
@@ -0,0 +1,51 @@
+#ifndef GSR_COLOR_CONVERSION_H
+#define GSR_COLOR_CONVERSION_H
+
+#include "shader.h"
+#include "vec2.h"
+
+typedef enum {
+ GSR_SOURCE_COLOR_RGB
+} gsr_source_color;
+
+typedef enum {
+ GSR_DESTINATION_COLOR_NV12
+} gsr_destination_color;
+
+typedef struct {
+ gsr_egl *egl;
+
+ gsr_source_color source_color;
+ gsr_destination_color destination_color;
+
+ unsigned int source_textures[2];
+ int num_source_textures;
+
+ unsigned int destination_textures[2];
+ int num_destination_textures;
+
+ float rotation;
+
+ vec2f position;
+ vec2f size;
+} gsr_color_conversion_params;
+
+typedef struct {
+ gsr_egl *egl;
+ gsr_shader shaders[2];
+
+ unsigned int source_textures[2];
+ unsigned int destination_textures[2];
+
+ unsigned int framebuffers[2];
+
+ unsigned int vertex_array_object_id;
+ unsigned int vertex_buffer_object_id;
+} gsr_color_conversion;
+
+int gsr_color_conversion_init(gsr_color_conversion *self, const gsr_color_conversion_params *params);
+void gsr_color_conversion_deinit(gsr_color_conversion *self);
+
+int gsr_color_conversion_update(gsr_color_conversion *self, int width, int height);
+
+#endif /* GSR_COLOR_CONVERSION_H */