Fix GLES rotation on 3566 devices.

This commit is contained in:
fewtarius 2024-01-30 18:23:25 +00:00
parent f61c6f9496
commit 98f842ad90
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
4 changed files with 60 additions and 1736 deletions

View file

@ -6,7 +6,6 @@ Subject: [PATCH 3/7] Implement librga framebuffer rotation.
---
CMakeLists.txt | 2 +-
Makefile.in | 2 +-
src/video/kmsdrm/SDL_kmsdrmopengles.c | 26 +++++++++-
src/video/kmsdrm/SDL_kmsdrmsym.h | 2 +-
src/video/kmsdrm/SDL_kmsdrmvideo.c | 75 +++++++++++++++++++++++----
src/video/kmsdrm/SDL_kmsdrmvideo.h | 8 +++
@ -38,62 +37,6 @@ index eb4c4bc1a..5cd04eeec 100644
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
LIBTOOL = @LIBTOOL@
INSTALL = @INSTALL@
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 487168203..47db85ef1 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -29,11 +29,15 @@
#include "SDL_kmsdrmopengles.h"
#include "SDL_kmsdrmdyn.h"
#include <errno.h>
+#include<stdbool.h>
#ifndef EGL_PLATFORM_GBM_MESA
#define EGL_PLATFORM_GBM_MESA 0x31D7
#endif
+extern rga_info_t src_info;
+extern rga_info_t dst_info;
+
/* EGL implementation of SDL OpenGL support */
void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor)
@@ -93,6 +97,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window)
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
KMSDRM_FBInfo *fb_info;
int ret = 0;
+ struct gbm_bo* rga_buffer = NULL;
/* Always wait for the previous issued flip before issuing a new one,
even if you do async flips. */
@@ -136,7 +141,26 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window)
}
/* Get an actual usable fb for the next front buffer. */
- fb_info = KMSDRM_FBFromBO(_this, windata->next_bo);
+ if (src_info.fd) {
+ close(src_info.fd);
+ }
+ src_info.fd = KMSDRM_gbm_bo_get_fd(windata->next_bo);
+ dst_info.fd = viddata->rga_buffer_prime_fds[viddata->rga_buffer_index];
+ if (c_RkRgaBlit(&src_info, &dst_info, NULL) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO,
+ "Failed to rga blit\n");
+ }
+
+ rga_buffer = viddata->rga_buffers[viddata->rga_buffer_index];
+ fb_info = KMSDRM_FBFromBO(_this, rga_buffer);
+
+ if (!fb_info) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer");
+ return 0;
+ }
+
+ viddata->rga_buffer_index = (viddata->rga_buffer_index + 1) % RGA_BUFFERS_MAX;
+
if (fb_info == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer");
return 0;
diff --git a/src/video/kmsdrm/SDL_kmsdrmsym.h b/src/video/kmsdrm/SDL_kmsdrmsym.h
index 8b9e7b257..b33373805 100644
--- a/src/video/kmsdrm/SDL_kmsdrmsym.h

View file

@ -0,0 +1,59 @@
diff -rupN SDL2-2.28.5.orig/src/video/kmsdrm/SDL_kmsdrmopengles.c SDL2-2.28.5/src/video/kmsdrm/SDL_kmsdrmopengles.c
--- SDL2-2.28.5.orig/src/video/kmsdrm/SDL_kmsdrmopengles.c 2024-01-30 16:22:00.475039122 +0000
+++ SDL2-2.28.5/src/video/kmsdrm/SDL_kmsdrmopengles.c 2024-01-30 17:56:52.799111194 +0000
@@ -29,11 +29,15 @@
#include "SDL_kmsdrmopengles.h"
#include "SDL_kmsdrmdyn.h"
#include <errno.h>
+#include<stdbool.h>
#ifndef EGL_PLATFORM_GBM_MESA
#define EGL_PLATFORM_GBM_MESA 0x31D7
#endif
+extern rga_info_t src_info;
+extern rga_info_t dst_info;
+
/* EGL implementation of SDL OpenGL support */
void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor)
@@ -92,6 +96,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Wi
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
KMSDRM_FBInfo *fb_info;
int ret = 0;
+ struct gbm_bo* rga_buffer = NULL;
/* Always wait for the previous issued flip before issuing a new one,
even if you do async flips. */
@@ -135,7 +140,30 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Wi
}
/* Get an actual usable fb for the next front buffer. */
- fb_info = KMSDRM_FBFromBO(_this, windata->next_bo);
+ if (dispdata->orientation == 0) {
+ fb_info = KMSDRM_FBFromBO(_this, windata->next_bo);
+ } else {
+ if (src_info.fd) {
+ close(src_info.fd);
+ }
+ src_info.fd = KMSDRM_gbm_bo_get_fd(windata->next_bo);
+ dst_info.fd = viddata->rga_buffer_prime_fds[viddata->rga_buffer_index];
+ if (c_RkRgaBlit(&src_info, &dst_info, NULL) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO,
+ "Failed to rga blit\n");
+ }
+
+ rga_buffer = viddata->rga_buffers[viddata->rga_buffer_index];
+ fb_info = KMSDRM_FBFromBO(_this, rga_buffer);
+
+ if (!fb_info) {
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer");
+ return 0;
+ }
+
+ viddata->rga_buffer_index = (viddata->rga_buffer_index + 1) % RGA_BUFFERS_MAX;
+ }
+
if (fb_info == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer");
return 0;

View file

@ -25,7 +25,7 @@ case ${DEVICE} in
;;
RK3566)
PKG_URL="${PKG_SITE}/rk356x-kernel.git"
PKG_VERSION="d346337a7b3e3e7e0d12dbdcc4fc62efc86cbda3"
PKG_VERSION="7284f2a43"
GET_HANDLER_SUPPORT="git"
PKG_GIT_CLONE_BRANCH="main"
;;