mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-03-31 09:07:13 +09:00
Reapply "WIP: use compute shader instead of graphics shader for better performance (especially on amd)"
This reverts commit f85a7ab205.
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
#define GSR_COLOR_CONVERSION_H
|
||||
|
||||
#include "shader.h"
|
||||
#include "defs.h"
|
||||
#include "vec2.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define GSR_COLOR_CONVERSION_MAX_SHADERS 3
|
||||
|
||||
typedef enum {
|
||||
GSR_COLOR_RANGE_LIMITED,
|
||||
GSR_COLOR_RANGE_FULL
|
||||
@@ -26,9 +29,18 @@ typedef enum {
|
||||
GSR_DESTINATION_COLOR_RGB8
|
||||
} gsr_destination_color;
|
||||
|
||||
typedef enum {
|
||||
GSR_ROT_0,
|
||||
GSR_ROT_90,
|
||||
GSR_ROT_180,
|
||||
GSR_ROT_270
|
||||
} gsr_rotation;
|
||||
|
||||
typedef struct {
|
||||
int offset;
|
||||
int rotation;
|
||||
int rotation_matrix;
|
||||
int source_position;
|
||||
int target_position;
|
||||
int scale;
|
||||
} gsr_color_uniforms;
|
||||
|
||||
typedef struct {
|
||||
@@ -45,19 +57,23 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
gsr_color_conversion_params params;
|
||||
gsr_color_uniforms uniforms[4];
|
||||
gsr_shader shaders[4];
|
||||
gsr_color_uniforms uniforms[GSR_COLOR_CONVERSION_MAX_SHADERS];
|
||||
gsr_shader shaders[GSR_COLOR_CONVERSION_MAX_SHADERS];
|
||||
|
||||
unsigned int framebuffers[2];
|
||||
|
||||
unsigned int vertex_array_object_id;
|
||||
unsigned int vertex_buffer_object_id;
|
||||
|
||||
int max_local_size_dim;
|
||||
} 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);
|
||||
|
||||
void gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i source_pos, vec2i source_size, vec2i texture_pos, vec2i texture_size, float rotation, bool external_texture, gsr_source_color source_color);
|
||||
void gsr_color_conversion_draw(gsr_color_conversion *self, unsigned int texture_id, vec2i destination_pos, vec2i destination_size, vec2i texture_pos, vec2i texture_size, gsr_rotation rotation, bool external_texture, gsr_source_color source_color);
|
||||
void gsr_color_conversion_clear(gsr_color_conversion *self);
|
||||
|
||||
gsr_rotation gsr_monitor_rotation_to_rotation(gsr_monitor_rotation monitor_rotation);
|
||||
|
||||
#endif /* GSR_COLOR_CONVERSION_H */
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef void(*__GLXextFuncPtr)(void);
|
||||
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||
#define GL_RED 0x1903
|
||||
#define GL_GREEN 0x1904
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_ALPHA 0x1906
|
||||
#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
|
||||
#define GL_RG 0x8227
|
||||
@@ -111,6 +111,7 @@ typedef void(*__GLXextFuncPtr)(void);
|
||||
#define GL_R16 0x822A
|
||||
#define GL_RG16 0x822C
|
||||
#define GL_RGB16 0x8054
|
||||
#define GL_RGBA32F 0x8814
|
||||
#define GL_UNSIGNED_BYTE 0x1401
|
||||
#define GL_COLOR_BUFFER_BIT 0x00004000
|
||||
#define GL_TEXTURE_WRAP_S 0x2802
|
||||
@@ -134,6 +135,10 @@ typedef void(*__GLXextFuncPtr)(void);
|
||||
#define GL_SCISSOR_TEST 0x0C11
|
||||
#define GL_PACK_ALIGNMENT 0x0D05
|
||||
#define GL_UNPACK_ALIGNMENT 0x0CF5
|
||||
#define GL_READ_ONLY 0x88B8
|
||||
#define GL_WRITE_ONLY 0x88B9
|
||||
#define GL_READ_WRITE 0x88BA
|
||||
#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS 0x90EB
|
||||
|
||||
#define GL_VENDOR 0x1F00
|
||||
#define GL_RENDERER 0x1F01
|
||||
@@ -143,6 +148,7 @@ typedef void(*__GLXextFuncPtr)(void);
|
||||
#define GL_INFO_LOG_LENGTH 0x8B84
|
||||
#define GL_FRAGMENT_SHADER 0x8B30
|
||||
#define GL_VERTEX_SHADER 0x8B31
|
||||
#define GL_COMPUTE_SHADER 0x91B9
|
||||
#define GL_COMPILE_STATUS 0x8B81
|
||||
#define GL_LINK_STATUS 0x8B82
|
||||
|
||||
@@ -231,6 +237,7 @@ struct gsr_egl {
|
||||
void (*glGenTextures)(int n, unsigned int *textures);
|
||||
void (*glDeleteTextures)(int n, const unsigned int *texture);
|
||||
void (*glBindTexture)(unsigned int target, unsigned int texture);
|
||||
void (*glBindImageTexture)(unsigned int unit, unsigned int texture, int level, unsigned char layered, int layer, unsigned int access, unsigned int format);
|
||||
void (*glTexParameteri)(unsigned int target, unsigned int pname, int param);
|
||||
void (*glTexParameteriv)(unsigned int target, unsigned int pname, const int *params);
|
||||
void (*glGetTexLevelParameteriv)(unsigned int target, int level, unsigned int pname, int *params);
|
||||
@@ -240,6 +247,8 @@ struct gsr_egl {
|
||||
void (*glGenFramebuffers)(int n, unsigned int *framebuffers);
|
||||
void (*glBindFramebuffer)(unsigned int target, unsigned int framebuffer);
|
||||
void (*glDeleteFramebuffers)(int n, const unsigned int *framebuffers);
|
||||
void (*glDispatchCompute)(unsigned int num_groups_x, unsigned int num_groups_y, unsigned int num_groups_z);
|
||||
void (*glMemoryBarrier)(unsigned int barriers);
|
||||
void (*glViewport)(int x, int y, int width, int height);
|
||||
void (*glFramebufferTexture2D)(unsigned int target, unsigned int attachment, unsigned int textarget, unsigned int texture, int level);
|
||||
void (*glDrawBuffers)(int n, const unsigned int *bufs);
|
||||
@@ -276,11 +285,14 @@ struct gsr_egl {
|
||||
int (*glGetUniformLocation)(unsigned int program, const char *name);
|
||||
void (*glUniform1f)(int location, float v0);
|
||||
void (*glUniform2f)(int location, float v0, float v1);
|
||||
void (*glUniform2i)(int location, int v0, int v1);
|
||||
void (*glUniformMatrix2fv)(int location, int count, unsigned char transpose, const float *value);
|
||||
void (*glDebugMessageCallback)(GLDEBUGPROC callback, const void *userParam);
|
||||
void (*glScissor)(int x, int y, int width, int height);
|
||||
void (*glReadPixels)(int x, int y, int width, int height, unsigned int format, unsigned int type, void *pixels);
|
||||
void* (*glMapBuffer)(unsigned int target, unsigned int access);
|
||||
unsigned char (*glUnmapBuffer)(unsigned int target);
|
||||
void (*glGetIntegerv)(unsigned int pname, int *params);
|
||||
};
|
||||
|
||||
bool gsr_egl_load(gsr_egl *self, gsr_window *window, bool is_monitor_capture, bool enable_debug);
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef struct {
|
||||
} gsr_image_writer;
|
||||
|
||||
bool gsr_image_writer_init_opengl(gsr_image_writer *self, gsr_egl *egl, int width, int height);
|
||||
/* |memory| is taken as a reference */
|
||||
/* |memory| is taken as a reference. The data is expected to be in rgba8 format (8 bit rgba) */
|
||||
bool gsr_image_writer_init_memory(gsr_image_writer *self, const void *memory, int width, int height);
|
||||
void gsr_image_writer_deinit(gsr_image_writer *self);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ typedef struct {
|
||||
} gsr_shader;
|
||||
|
||||
/* |vertex_shader| or |fragment_shader| may be NULL */
|
||||
int gsr_shader_init(gsr_shader *self, gsr_egl *egl, const char *vertex_shader, const char *fragment_shader);
|
||||
int gsr_shader_init(gsr_shader *self, gsr_egl *egl, const char *vertex_shader, const char *fragment_shader, const char *compute_shader);
|
||||
void gsr_shader_deinit(gsr_shader *self);
|
||||
|
||||
int gsr_shader_bind_attribute_location(gsr_shader *self, const char *attribute, int location);
|
||||
|
||||
@@ -64,8 +64,6 @@ int create_directory_recursive(char *path);
|
||||
/* |img_attr| needs to be at least 44 in size */
|
||||
void setup_dma_buf_attrs(intptr_t *img_attr, uint32_t format, uint32_t width, uint32_t height, const int *fds, const uint32_t *offsets, const uint32_t *pitches, const uint64_t *modifiers, int num_planes, bool use_modifier);
|
||||
bool video_codec_context_is_vaapi(AVCodecContext *video_codec_context);
|
||||
bool vaapi_copy_drm_planes_to_video_surface(AVCodecContext *video_codec_context, AVFrame *video_frame, vec2i source_pos, vec2i source_size, vec2i dest_pos, vec2i dest_size, uint32_t format, vec2i size, const int *fds, const uint32_t *offsets, const uint32_t *pitches, const uint64_t *modifiers, int num_planes);
|
||||
bool vaapi_copy_egl_image_to_video_surface(gsr_egl *egl, EGLImage image, vec2i source_pos, vec2i source_size, vec2i dest_pos, vec2i dest_size, AVCodecContext *video_codec_context, AVFrame *video_frame);
|
||||
|
||||
vec2i scale_keep_aspect_ratio(vec2i from, vec2i to);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user