-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[rcore][drm] Replace DRM swap buffer implementation with asynchronous page-flipping and triple framebuffer caching #4988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ge-flipping and framebuffer caching The original implementation created/destroyed framebuffers (FBs) per-frame, leading to kernel overhead and screen tearing. This commit replaces it with a different approach using: - Asynchronous `drmModePageFlip()` with vblank sync - Framebuffer caching to reduce repeated FB creation/removal operations - Proper resource management through BO callbacks and buffer release synchronization - Added error handling for busy displays, cache overflows, and flip failures - Event-driven cleanup via page_flip_handler to prevent GPU/scanout conflicts Co-authored-by: rob-bits
src/platforms/rcore_drm.c
Outdated
@@ -910,7 +1099,8 @@ int InitPlatform(void) | |||
EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) | |||
EGL_ALPHA_SIZE, 8, // ALPHA bit depth (required for transparent framebuffer) | |||
//EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI) | |||
EGL_DEPTH_SIZE, 24, // Depth buffer size (Required to use Depth testing!) | |||
//ToDo: verify this. In 5.5 it is 16, in master it was 24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct, it was increased to address some z-fighting isssues. Afaik, most devies already support 24bit depth buffers.
@rob-bits Thanks for the improvement, it would be nie to keep both methods to be selected with a compilation flag. Please, could you first review the code to follow raylib coding conventions? |
Yeah, will review it and revisit the code if it brokes any convention. And will add a compiler define to have control which one should be used. |
Added compilation config flag and reimplemented some variable names to be compatible with coding conventions. The default code points to the original implementation. With additional testing, benchmarking later we can move on with this. |
The original implementation created/destroyed framebuffers (FBs) per-frame, leading to kernel overhead and screen tearing. This commit replaces it with a different approach using:
drmModePageFlip()
with vblank syncWould you please review this code?
In my case it works better, has less framedrop or tearing.
Tested it on a Raspberry Pi Zero 2W.
Maybe this implementation should be handled as a compiler option for the user. To select if he wants the minimal DRM or the page-flipping, cached DRM.
Summary: Key Differences
SwapScreenBuffer - Original
)SwapScreenBuffer new
)drmModePageFlip()
with vblank sync to prevent tearing.