mickelson / sfml-pi

SFML on Linux without X11 using DRM/KMS (or dispmanx on RPi0-3)
Other
62 stars 26 forks source link

Add KMS / DRM support for using library outside x on raspberry pi 4 ? #13

Closed joyrider3774 closed 4 years ago

joyrider3774 commented 4 years ago

Hey,

I've seen some code being posted and referenced that uses KMS / DRM to run code outside X for rapsberry pi 4 for example KMS Cube from mesa or some examples dealing with opengles2 / 3 book or this simple example . They run fine outside X on my raspberry pi4.

I think an update to SFML-PI to use KMS / DRM to use the library outside x is all thats needed to make attractmode work on the PI4, it would make a lot of people happy. I have tried mashing up some code but failed miserably as i'm no C/C++ nor a Linux dev and the code if i would get it working eventually would not be release worthy maybe someone else is up for the task ?

mickelson commented 4 years ago

Hi there Jools, yes I agree that a suid binary isn’t ideal. I’m kinda thrashing around a bit but the problem seems to be the combo of the linux drm requirement that one process has to close the drm file descriptor before another process can start using the display, combined with sfml’s keeping of a hidden “shared context” after you first initialize open gl. once this context is created I don’t think there is any way for the library user to have it cleared/reinitialized, short of restarting the whole program. I was hoping to not have to mess around with the inner workings of sfml too much here, but I will take a look and see if there is a straight forward way to get sfml to release its hidden context appropriately so that everything can be cleanly closed for the launch and then reinitialized, eliminating the need for the setting and dropping of drm master. Andrew On Jun 1, 2020, at 10:39 PM, Jools Wills @.***> wrote:  I've only just started looking at this, but I'm not sure I'm seeing the full picture so apologies if I've misunderstood. Having a SUID binary isn't ideal but I'm unsure why there is a need for drmSetMaster/drmDropMaster ? Is there an issue closing the egl context / reiniting after launching something? I was wondering if this was a workaround without modification of the sgml library API or something else? Wouldn't it be enough to rejig the code, so that FeWindow can be closed/cleaned up in run_program and then re-initialised after or so? Sorry if I'm missing something. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Ok, with the latest commits to sfml-pi and attract-mode there is no longer any need for the 'attract-drm-helper' suid binary. Attract-mode should be able to launch emulators now when running in drm without any additional assistance

joolswills commented 4 years ago

Great news. Thanks.

joyrider3774 commented 4 years ago

@mickelson readme mentions SFML_DRM_RATE but code currently still uses SFML_DRM_REFRESH see here https://github.com/mickelson/sfml-pi/blob/master/src/SFML/Window/Unix/DRM/DRMContext.cpp#L119 not sure if you are goana or wanted to change the env var in the code or not or you made a little typo in readme

mickelson commented 4 years ago

I’m losing my mind I swear, I was looking right at it when I updated the doc. Thanks for pointing that out, I’ll fix it now

On Jun 16, 2020, at 1:35 PM, Willems Davy notifications@github.com wrote:

 @mickelson readme mentions SFML_DRM_RATE but code currently still uses SFML_DRM_REFRESH see here https://github.com/mickelson/sfml-pi/blob/master/src/SFML/Window/Unix/DRM/DRMContext.cpp#L119 not sure if you are goana or wanted to change the env var in the code or not

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.