We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5476 - [KMSDRM] Help needed investigating a game's low performance on this backend only.
Summary: [KMSDRM] Help needed investigating a game's low performance on this backend o...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.15
Hardware: All Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-17 22:39 UTC by Manuel Alfayate Corchete
Modified: 2021-02-05 00:24 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Alfayate Corchete 2021-01-17 22:39:05 UTC
Hi there,

While doing broad tests on ths KMSDRM backend, I found out that vanilla-conquer (https://github.com/TheAssemblyArmada/Vanilla-Conquer) shows abysmal performance on KMSDRM, resulting in very bad framerates compared to the exact same binary running on the SDL2 X11 backend.

-There are no errors returned by any of the the KMSDRM functions (meaning that drmModePageFlip() is always returning OK, so we are not missing any frames that the games sends, or so it looks).

-In both backends (X11 and KMSDRM) CPU usage is the same, ~25% on my X86_64 laptop.

-In both backends, the SDL internal rendering path seems to be the same, as SDL reports the SAME content in the SDL_RendererInfo for the SDL_Renderer it creates using X11 or KMSDRM:

(gdb) p info
$1 = {name = 0x7ffff7f56b21 "opengl", flags = 14, 
  num_texture_formats = 8, texture_formats = {372645892, 
    376840196, 370546692, 374740996, 842094169, 1448433993, 
    842094158, 825382478, 0, 0, 0, 0, 0, 0, 0, 0}, 
  max_texture_width = 16384, max_texture_height = 16384}


-The engine creates it's renderer here:

https://github.com/TheAssemblyArmada/Vanilla-Conquer/blob/34072fea51a9ba7c5fb78d82f14ab94f180055c0/common/video_sdl2.cpp#L175

It blits from an 8bpp surface
https://github.com/TheAssemblyArmada/Vanilla-Conquer/blob/34072fea51a9ba7c5fb78d82f14ab94f180055c0/common/video_sdl2.cpp#L490

to a 32bpp surface:
https://github.com/TheAssemblyArmada/Vanilla-Conquer/blob/34072fea51a9ba7c5fb78d82f14ab94f180055c0/common/video_sdl2.cpp#L494

It does this blitting here:
https://github.com/TheAssemblyArmada/Vanilla-Conquer/blob/34072fea51a9ba7c5fb78d82f14ab94f180055c0/common/video_sdl2.cpp#L565


...but it gets done ultimately, so I don't see how that would be affected by the backend.



Any ideas on what could going on here are welcome. Thanks!
Comment 1 Sam Lantinga 2021-01-18 18:38:45 UTC
What are the actual framerates? I believe that KMSDRM may be doing vsync by default and X11 does not.
Comment 2 wahil1976 2021-01-19 17:49:21 UTC
Does profiling the executable and the SDL library work? That would show us what functions take the most time to complete.
Comment 3 Manuel Alfayate Corchete 2021-02-05 00:24:40 UTC
This has been fixed by the engine's people, so closing this. Thanks!