Comments (5)
Excellent, thanks for merging 🏆
from sdl.
I've been trying to debug this problem and stepping through the KMSDRM and EGL code. Changing strides and such doesn't seem to have any effect at all.
However once thing I've noticed is that this platform (NVIDIA Tegra) reports having two displays, one of which seems to be a 640x480 display, possibly some internal or MIPI thing. If I look at the way the picture is garbled I'm beginning to suspect that somewhere in SDL the displays get mixed up and perhaps EGL is created using the dimensions of one screen while the GBM is using the other.
P.S. --fullscreen
does not seem to be working:
ERROR: Could not lock front buffer on GBM surface
ERROR: eglSwapBuffers failed
from sdl.
I've finally found the problem on this particular platform, after testing between drm*, GBM and EGL call differences between a known working app (https://github.com/embtom/kmscube) and SDL.
There seem to be three different variants of the drmModeAddFB
call: drmModeAddFB
, drmModeAddFB2
and drmModeAddFB2WithModifiers
. SDL uses the first variant as can be seen at https://github.com/libsdl-org/SDL/blob/release-2.30.x/src/video/kmsdrm/SDL_kmsdrmvideo.c#L360
When I replace that call with drmModeAddFB2WithModifiers
instead and use the GBM bo modifiers, the test cases start working:
uint32_t format, strides[4] = {0}, handles[4] = {0}, offsets[4] = {0}, flags = 0;
w = KMSDRM_gbm_bo_get_width(bo);
h = KMSDRM_gbm_bo_get_height(bo);
format = KMSDRM_gbm_bo_get_format(bo);
uint64_t modifiers[4] = {0};
modifiers[0] = gbm_bo_get_modifier(bo);
const int num_planes = gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; i++) {
strides[i] = gbm_bo_get_stride_for_plane(bo, i);
handles[i] = gbm_bo_get_handle(bo).u32;
offsets[i] = gbm_bo_get_offset(bo, i);
modifiers[i] = modifiers[0];
}
if (modifiers[0]) {
flags = DRM_MODE_FB_MODIFIERS;
}
ret = drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
The GBM modifier seems to be set at 0x3000000000fe014
so I'm suspecting that the modifier must be used when creating the frame buffer. It doesn't seem that strange, as these modifiers come from GBM itself.
Swapping in the above code seems to fix the display issue, tested with release-2.30.x. If helpful I could open a PR for this issue.
(Inversely, when I changed kmscube to use drmModeAddFB2
or drmModeAddFB
it showed the same display problem as SDL.)
🙊 I've also noticed that the fullscreen flag seems to be failing the test case, this seems to be due to the fullscreen logic causing a dirty surface and recreation at https://github.com/libsdl-org/SDL/blob/release-2.30.x/src/video/kmsdrm/SDL_kmsdrmopengles.c#L110 but I suspect something is not released properly as eglSwapBuffers
will fail with GL_FALSE
from that point on. Should probably keep this for a different issue, but just wanted to note it down for reference.
from sdl.
Sure, a PR would be helpful, thanks! Good sleuthing. :)
from sdl.
Great, a pull request was made in #10117. One thing to note is that drmModeAddFB2WithModifiers
and the newer gbm* modifier API calls seems to be a newer calls so this might break backwards compatibility with old versions of those libraries.
from sdl.
Related Issues (20)
- SDL2 threading config in ./cmake/sdlchecks.cmake not correct for non-GNU compiler (e.g. SunPro cc) HOT 2
- UNIX version of SDL_GetBasePath in SDL_sysfilesystem.c not correct for Solaris, probably other UNIXes HOT 2
- Compiling SDL on SPARC platform with GNU toolset should target correct CPU by default HOT 3
- SDL incorrectly detects X11_XRANDR with CMake, does not compile on Solaris 10
- SDL build with configure (autoconf) incorrectly tries to build with Vulkan support on Solaris 10 (probably other UNIXes) HOT 11
- SDL loads wrong controller definition from gamecontrolllerdb HOT 10
- VC : Add /MT /MTd and /MD /MDd in artifacts github HOT 2
- Feature: Open SDL_StepUTF8() for public use HOT 3
- Switch SDLK_PERCENT and SDLK_DOLLAR to match ascii values? HOT 1
- doctest + SDL2main : error LNK2019 (despite using DOCTEST_CONFIG_IMPLEMENT) HOT 13
- Multiple Windows and SDL_EVENT_QUIT failure HOT 3
- SDL_RenderReadPixels doesn't give the same data depending on if the app is fullscreen or not HOT 11
- Encoding of paths in file dialogs HOT 3
- SDL_x11shape.c syntax error if SDL_X11_XSHAPE is disabled HOT 1
- segfault in testaudio HOT 2
- Issue with sdl output with AMD graphic
- Cannot create renderer even after `SDL_DestroyWindowSurface` has been called on a window HOT 3
- Implement SDL_EVENT_TEXT_EDITING_CANDIDATES for fcitx and ibus IMEs
- SDL3 key questions HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.