mirror of
https://repo.dec05eba.com/gpu-screen-recorder
synced 2026-05-04 22:10:42 +09:00
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%.
This commit is contained in:
43
src/utils.c
43
src/utils.c
@@ -1,6 +1,8 @@
|
||||
#include "../include/utils.h"
|
||||
#include "../include/egl.h"
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
double clock_get_monotonic_seconds(void) {
|
||||
struct timespec ts;
|
||||
@@ -60,3 +62,44 @@ bool get_monitor_by_name(Display *display, const char *name, gsr_monitor *monito
|
||||
for_each_active_monitor_output(display, get_monitor_by_name_callback, &userdata);
|
||||
return userdata.found_monitor;
|
||||
}
|
||||
|
||||
bool gl_get_gpu_info(Display *dpy, gsr_gpu_info *info) {
|
||||
gsr_egl gl;
|
||||
if(!gsr_egl_load(&gl, dpy)) {
|
||||
fprintf(stderr, "gsr error: failed to load opengl\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supported = true;
|
||||
const unsigned char *gl_vendor = gl.glGetString(GL_VENDOR);
|
||||
const unsigned char *gl_renderer = gl.glGetString(GL_RENDERER);
|
||||
|
||||
info->gpu_version = 0;
|
||||
|
||||
if(!gl_vendor) {
|
||||
fprintf(stderr, "gsr error: failed to get gpu vendor\n");
|
||||
supported = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(strstr((const char*)gl_vendor, "AMD"))
|
||||
info->vendor = GSR_GPU_VENDOR_AMD;
|
||||
else if(strstr((const char*)gl_vendor, "Intel"))
|
||||
info->vendor = GSR_GPU_VENDOR_INTEL;
|
||||
else if(strstr((const char*)gl_vendor, "NVIDIA"))
|
||||
info->vendor = GSR_GPU_VENDOR_NVIDIA;
|
||||
else {
|
||||
fprintf(stderr, "gsr error: unknown gpu vendor: %s\n", gl_vendor);
|
||||
supported = false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(gl_renderer) {
|
||||
if(info->vendor == GSR_GPU_VENDOR_NVIDIA)
|
||||
sscanf((const char*)gl_renderer, "%*s %*s %*s %d", &info->gpu_version);
|
||||
}
|
||||
|
||||
end:
|
||||
gsr_egl_unload(&gl);
|
||||
return supported;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user