alyssa changed the topic of #panfrost to: Panfrost - FLOSS Mali Midgard & Bifrost - Logs https://freenode.irclog.whitequark.org/panfrost - <daniels> avoiding X is a huge feature
raster has joined #panfrost
<alyssa> Just getting a black screen..
mias_ has quit [Ping timeout: 256 seconds]
unoccupied has quit [Quit: WeeChat 2.5]
icecream95 has quit [Ping timeout: 250 seconds]
<mrfixit2001> alyssa what are you trying to boot?
<alyssa> mrfixit2001: ODROID N-2
<mrfixit2001> alyssa as far as I know manjaro has it booting. Here's what they use for a config: https://gitlab.manjaro.org/manjaro-arm/packages/core/linux-odroid-n2/-/blob/master/config but I think they are still using 4.9: https://github.com/hardkernel/linux/commits/odroidn2-4.9.y
<alyssa> ainline is a must..
<alyssa> er, current 5.x mainline anyway
<mrfixit2001> I wish I had one to help you. Any uart output to look at?
<alyssa> Don't have a cable atm
<mrfixit2001> Well, you could always waste a bunch of time diffing the device trees :D https://github.com/hardkernel/linux/blob/odroidn2-4.9.y/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
<mrfixit2001> alyssa can I please pick your brain about something stupid
<alyssa> mm?
<mrfixit2001> So in order to improve the performance for some demanding emulators on some rockchip boards, I have added very simple code to change the resolution when the emulator starts. Unfortunately, fbset and tvservice are not applicable to rockchip for some reason... So the kernel param has kms set to 1080p over hdmi - but when an emulator starts I might
<mrfixit2001> change it to 720p so it runs faster.
<mrfixit2001> In order to do this - I actually have had to patch the emulator itself to initialize a simple graphics stack prior to the emulator booting. It's init's drm, gbm, and egl.
<mrfixit2001> then sets the crtc mode that I want
<mrfixit2001> With the BSP 4.4 kernel and the mali blob - this works without an issue. The resolution changes, the emulator renders fine, and I cleanup everything when it closes and revert back to the old crtc.
<mrfixit2001> Make sense so far?
<alyssa> ....not entirely :|
<mrfixit2001> The problem - it isn't working on mainline. On panfrost or on lima. There is no error. The resolution changes on the screen. But it's left at a blank black screen. The emulator runs and I can hear it's sound but there's no video.
<mrfixit2001> Let me try and explain better.
<anarsoul> use wayland and/or x11? :)
<anarsoul> so you don't have to initialize display yourself
<mrfixit2001> Before the emulator does any initialization of it's graphics stack at all, I patch it to run a new set of functions. It opens /dev/dri/card0, finds the drmMode that I want in the connector's modes, creates a gbm device and surface, sets up an egl display, context, and surface, swaps the buffers, locks the gbm surface, gets the fb from the bo, and
<mrfixit2001> then changes the crtc mode. Once that all is done, the emulator continues as usual and renders to the screen with the new resolution.
<mrfixit2001> Everything I've done is fully GBM / GLES - no windowing system at all...
<mrfixit2001> so no x or wayland to help me, unfortunately anarsoul
<mrfixit2001> The thing is - it works perfectly with the old mali drivers. I've literally been tinkering with it for 3 days and trying a variation of different things with no luck.
<mrfixit2001> So obviously something is different about mesa and mainline.
<mrfixit2001> And here is something very strange...
<mrfixit2001> when I printf strerror(errno) at every step along the way - I actually end up seeing "permission denied" showing up after the creation of the gbm device - but the object exists and there's no error.
<mrfixit2001> I've gone as far as chmod 777 /dev/dri*, no change
<mrfixit2001> ^-- missed a slash but you get the idea
<mrfixit2001> I'm hoping SOMEONE has some idea. Cause I'm running out of them haha I did find that I can hijack the buffer_id of the current drm mode and change the resolution on the screen without initializing any gbm or egl, and the resolution does change and the fb graphic on the screen gets all distorted - but then the emulator doesn't render at all and I'm
<mrfixit2001> just stuck at the distoretd fb image instead of a black screen haha
<mrfixit2001> I'm going to copy/paste all this into the lima channel as well and hope someone has any ideas. Please don't be shy if someone has any thoughts.
<anarsoul> no need, thanks
stikonas has quit [Ping timeout: 246 seconds]
<anarsoul> I'm already here
<mrfixit2001> anarsoul I saw that just seconds too late lol sorry, was in the middle of copy and pasting
<mrfixit2001> your feedback is really appreciated. If you have any ideas at all.
<mrfixit2001> I'm not shy about patching the kernel or mesa - happy to test and try anything you like.
<anarsoul> your emulator is likely using SDL, so just use wayland (any compositor of your choice) or X11 and appropriate SDL backend
<anarsoul> it's not really panfrost or lima specific
<mrfixit2001> I would really like to get this working with GBM. I'm of the mentality that if it worked on the old driver then we should be able to make it work on the new driver. Full backwards compatibility is the goal, right? :) The entire buildroot defconfig and emulator packages have been setup for GBM/GLES.
<anarsoul> mrfixit2001: not really, buffer management is totally different in blob, so it's hard to tell where exactly it fails for you. As alternative you can change resolution at boot time
<mrfixit2001> I guess I don't understand then. Because everything else, all patches and libraries in the entire buildroot toolchain, are identical. I've done a full rebuild using mainline kernel and headers, along with using mesa instead of libmali. Otherwise there's no difference, so what am I missing? How isn't it one of the only two things I've changed? Not
<mrfixit2001> doubting you - just trying to understand.
<mrfixit2001> thank you again for taking the time to reply. I do understand that I can just change the entire system's resolution, but the goal is to be able to change the resolution at runtime.
<mrfixit2001> Other applications are able to accomplish this on their own - namingly retroarch and kodi - they change the resolution to whatever they want as they initialize. But the stand-alone emulators don't have the code for that inherently.
<anarsoul> then add support for changing resolution to SDL backend?
<mrfixit2001> the SDL libraries in my build have not changed - they don't interfere at all with it using libmali
<anarsoul> *sigh*
<mrfixit2001> :(
<anarsoul> IIRC libmali doesn't allocate scanout
<anarsoul> mesa drivers do
<anarsoul> so likely your emulator is rendering into old scanout
<anarsoul> that's just a guess though
<mrfixit2001> One thought I had... is lima/panfrost/mainline perhaps limiting the number of concurrent connections to /dev/dri/card0?
<mrfixit2001> hmm scanout? is libmali ignored that - I could try removing GBM_BO_USE_SCANOUT from my gbm code
<anarsoul> mrfixit2001: I'm not sure how exactly blob works
<anarsoul> but
<anarsoul> if you get blackscreen and emulator thinks that it's working it means it renders somewhere
raster has quit [Quit: Gettin' stinky!]
<anarsoul> anyway, to fix it do that same what kodi or retroarch do
<anarsoul> don't do guess work, research how you're supposed to use API and use it proper way
<anarsoul> hope it helps
<mrfixit2001> That's the problem - kodi and retroarch already have the code inherently. They fully init the full graphics stack already and change the resolution. My patch initializes the entire stack first, and then lets the emulator initialize it's own again over it.
<mrfixit2001> sadly - without GBM_BO_USE_SCANOUT it just segfaults :( worth a shot
<anarsoul> mrfixit2001: so fix emulators to initialize whole stack
<anarsoul> BO you allocate with GBM is your scanout
<anarsoul> aka framebuffer
<anarsoul> likely your emulator allocates its own
<mrfixit2001> I did spend a few hours trying to patch the missing pieces into the emulator. I ended up abandoning the idea and hoping that the way it used to work was "close" and just needed some tweaks.
<mrfixit2001> haha why doesn't it "just work"?? lol I'd prefer to figure out why it's not compatible - but if I need to try adding the missing pieces to the emulator again I can.
<anarsoul> mrfixit2001: it doesn't "just work" because you're using API incorrectly
<mrfixit2001> One sneaky suspicion I have is with the eglCreateWindowSurface function. It used to accept the gbm surface as a parameter - but for some reason now it demands that parameter is a EGLNativeWindowType
<mrfixit2001> I've direct casted the gbm surface - as I've seen done in many examples online - but it "feels" wrong
<HdkR> That's the correct thing to do
<HdkR> EGLNativeWindowType is a bit overloaded
<HdkR> This is why there was a new extension that landed recently
<mrfixit2001> If the API is incorrect - it shouldn't have worked on libmali tho?
<mrfixit2001> HdkR that's a relief to know, and one less thing for me to tinker with. Thank you!
<HdkR> Changes the native window to a void* (like it should have originally been) and forces you to declare a platform
<HdkR> Khronos hecked up and didn't expect multiple window types on a single platform
<anarsoul> mrfixit2001: my guess is that you're doing something that has undefined behavior
<mrfixit2001> Here is the exact code I'm trying to make work
<mrfixit2001> I call drm_setres() within the emulator before it initializes any of it's own graphics at all.
<mrfixit2001> and then drm_clearres() to clean up as it exits.
<mrfixit2001> You can ignore the "popen" call - it just reaches into the recalbox config so that users can control what resolution they want the emulator to change to.
<anarsoul> and what emulator does next?
<anarsoul> does initialize egl again?
<mrfixit2001> depends on the emulator. In the one I am currently testing on it actually initializes the SDL video subsystem and creates an SDL window and context.
<mrfixit2001> ^-- an SDL_WINDOW_OPENGL
<anarsoul> so likely it reinitilizes egl
<mrfixit2001> it doesn't run any egl init functions, as those are inside an ifdef statement that disables them when SDL is used
<anarsoul> likely sdl does it for you
<mrfixit2001> that is possible, and likely, yes.
<mrfixit2001> It worries me that when I run "gbm_create_device" the object exists - but if I printf the strerror(errno) then I actually see "permission denied"
<mrfixit2001> I check the value of strerror(errno) immediately before calling gbm_create_device and it's not that, so I'm 100% confident that is the command creating the errno, but then how is the object being created successfully? very strange.
<mrfixit2001> I saw one example creating the gbm device and surface against renderD128, but that doesn't seem to be right. I tried it anyways, and it actually resolved the permission denied error - but then there was absolutely no resolution change of course lol
<mrfixit2001> Another thing I tested is setting the desired resolution to 1080p - the same as it already is. The code still all runs the same, and the screen still goes black. Just to rule out the new resolution itself not being an issue.
vstehle has quit [Ping timeout: 264 seconds]
<mrfixit2001> anarsoul I can confirm that if I simplify the code to do nothing more than simply open /dev/dri/card0 and then run drmModeSetCrtc with a different mode against the current crtc's buffer_id that the resolution changes, the screen isn't blank, but the emulator doesn't render to the screen (I hear the sounds still). If I don't do ANYTHING else except
<mrfixit2001> open card0 then the exact same thing happens. But, if I close card0 then it renders fine - but of course there's no resolution change.
<mrfixit2001> I really feel like this is an issue with limiting concurrent connections to card0
<mrfixit2001> but I need to go, to avoid further angering the wife any more haha I'll check back tomorrow for updates, hopefully I don't time out.
<mrfixit2001> and hope someone has some further ideas.
<mrfixit2001> ^-- to clarify further and simplify what I'm saying... just running this will cause the emulator to not render to the screen and get audio only: open("/dev/dri/card0", O_RDONLY)
<mrfixit2001> literally not running anything else except that. Of course, if I close this connection then it renders fine.
<mrfixit2001> Ok - goodnight - looking forward to feedback
icecream95 has joined #panfrost
buzzmarshall has quit [Remote host closed the connection]
davidlt has joined #panfrost
vstehle has joined #panfrost
camus1 has joined #panfrost
kaspter has quit [Ping timeout: 250 seconds]
camus1 is now known as kaspter
doublej41 has joined #panfrost
MistahDarcy has quit [Ping timeout: 250 seconds]
doublej472 has quit [Ping timeout: 260 seconds]
Elpaulo has quit [Write error: Connection reset by peer]
Elpaulo has joined #panfrost
unoccupied has joined #panfrost
warpme_ has quit [Quit: Connection closed for inactivity]
mias_ has joined #panfrost
<icecream95> mrfixit2001: gbm_create_device sets errno for me as well, so I don't think it's related to your problem.
raster has joined #panfrost
<icecream95> There can only be one "DRM-Master" at a time, so opening /dev/dri/card0 in two different processes isn't going to work without using drmAuthMagic.
icecream95 has quit [Ping timeout: 264 seconds]
mixfix41 has quit [Ping timeout: 250 seconds]
_whitelogger has joined #panfrost
stikonas has joined #panfrost
stikonas has quit [Ping timeout: 246 seconds]
afaerber has quit [Ping timeout: 256 seconds]
afaerber has joined #panfrost
warpme_ has joined #panfrost
buzzmarshall has joined #panfrost
cwabbott has joined #panfrost
kaspter has quit [Remote host closed the connection]
kaspter has joined #panfrost
cwabbott has quit [Ping timeout: 240 seconds]
stikonas has joined #panfrost
raster has quit [Quit: Gettin' stinky!]
cwabbott has joined #panfrost
tomboy64 has quit [Remote host closed the connection]
tomboy64 has joined #panfrost
cwabbott has quit [Quit: cwabbott]
cwabbott has joined #panfrost
cwabbott has quit [Quit: cwabbott]
cwabbott has joined #panfrost
<mrfixit2001> @icecream95 anarsoul wanted to thank you both for your time and feedback! Icecream's response gave me an idea... something so simple, and something I hadn't tried... I changed my code to do nothing except open card0, find the desired mode, and set it on the local buffer. I didn't init any gbm or egl at all, and I added drmDropMaster after I changed
<mrfixit2001> the mode... and BOOM it works :D
<alyssa> :-)
davidlt has quit [Ping timeout: 250 seconds]
<mrfixit2001> strange that the mali blob didn't honor what the drm master was
<alyssa> BREAKING NEWS: The blob has a bug, blob revealed to be "not designed for upstream linux"
* alyssa faints
icecream95 has joined #panfrost
icecream95 has quit [Quit: leaving]
tomboy64 has quit [Remote host closed the connection]
tomboy64 has joined #panfrost
Stary has joined #panfrost
icecream95 has joined #panfrost
cwabbott has quit [Quit: cwabbott]
<mrfixit2001> alyssa lol "blob" sounds like a symptom of a "bug" in itself, so no surprise there! haha in this case, the bug was a helpful one lmao