2 Commits

Author SHA1 Message Date
9f3cadf1e6 docs: fix typo relase -> release (#6109)
Signed-off-by: Vaibhav Srivastava <vaibhavsri1712@gmail.com>
2026-08-29 12:39:21 +02:00
1948bdf3f7 [rcore][drm] Raise MAX_DRM_CACHED_BUFFERS to 4 and warn when the cache fills (#6107)
The cache has no eviction, so a driver rotating a fourth buffer never gets a
framebuffer for it and the display stops updating for good. Mesa rotates
three, ARM's Mali blob on RK3326 rotates four.

Verified on an R36S. See #6056.
2026-08-29 11:41:46 +02:00
2 changed files with 21 additions and 3 deletions

View File

@ -65,7 +65,7 @@ To run it we do:
zig build run -Dtarget=wasm32-emscripten zig build run -Dtarget=wasm32-emscripten
``` ```
And to make a relase build we do: And to make a release build we do:
```sh ```sh
zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast zig build -Dtarget=wasm32-emscripten -Doptimize=ReleaseFast

View File

@ -79,7 +79,11 @@
#include <poll.h> // Required for: drmHandleEvent() poll #include <poll.h> // Required for: drmHandleEvent() poll
#include <errno.h> // Required for: EBUSY, EAGAIN #include <errno.h> // Required for: EBUSY, EAGAIN
#define MAX_DRM_CACHED_BUFFERS 3 // NOTE: Some drivers rotate more buffers than others, mesa uses 3 but the
// ARM Mali blob on RK3326 uses 4. A buffer beyond this count can not get a
// framebuffer and the display stops updating for good, so this must not be
// lower than any driver in use
#define MAX_DRM_CACHED_BUFFERS 4
#endif #endif
#ifndef EGL_OPENGL_ES3_BIT #ifndef EGL_OPENGL_ES3_BIT
@ -110,6 +114,9 @@ typedef struct {
drmModeCrtc *crtc; // CRT Controller drmModeCrtc *crtc; // CRT Controller
int modeIndex; // Index of the used mode of connector->modes int modeIndex; // Index of the used mode of connector->modes
uint32_t prevFB; // Previous DRM framebufer (during frame swapping) uint32_t prevFB; // Previous DRM framebufer (during frame swapping)
#if defined(SUPPORT_DRM_CACHE)
bool fbCacheFullReported; // Framebuffer cache exhaustion already reported
#endif
#if !defined(GRAPHICS_API_OPENGL_SOFTWARE) #if !defined(GRAPHICS_API_OPENGL_SOFTWARE)
struct gbm_device *gbmDevice; // GBM device struct gbm_device *gbmDevice; // GBM device
@ -624,7 +631,18 @@ static uint32_t GetOrCreateFbForBo(struct gbm_bo *bo)
} }
// Create new entry if cache not full // Create new entry if cache not full
if (fbCacheCount >= MAX_DRM_CACHED_BUFFERS) return 0; // FB cache full if (fbCacheCount >= MAX_DRM_CACHED_BUFFERS)
{
// NOTE: Once this happens no page flip is ever scheduled again and the
// screen freezes while the game keeps running, so say it out loud once
if (!platform.fbCacheFullReported)
{
platform.fbCacheFullReported = true;
TRACELOG(LOG_WARNING, "DISPLAY: DRM: Framebuffer cache full (%i buffers), display will stop updating", MAX_DRM_CACHED_BUFFERS);
}
return 0; // FB cache full
}
uint32_t handle = gbm_bo_get_handle(bo).u32; uint32_t handle = gbm_bo_get_handle(bo).u32;
uint32_t stride = gbm_bo_get_stride(bo); uint32_t stride = gbm_bo_get_stride(bo);