tonarino / just-gl

Run an OpenGL application on Linux, and nothing more.
1 stars 0 forks source link

Add support for GPU rendering #3

Closed mbernat closed 10 months ago

mbernat commented 11 months ago

Based on my investigation so far it should be easiest to support GPU rendering via glium + glutin.

  1. We need to create a simple Window struct holding GBM context and implement HasRawWindowHandle & HasRawDisplayHandle for it.
  2. Next, it should be possible to initialized glutin with our Window. It should support GBM handles out of box.
  3. Finally, glium should work with the glutin context.

Other alternatives require (minor) forking to support GBM RawWindowHandle & RawDisplayHandle.

mbernat commented 11 months ago

I'm slowly working through custom glutin initialization. So far I haven't encountered any major obstacles but it's going slowly and I guess we won't know if it's working until I hook up everything correctly all the way to some glium example.

bschwind commented 11 months ago

@mbernat let me know if you want me to test anything on real hardware.

Probably one of the easiest ways to see if things are working is to use the gl crate and just clear the screen to a known color or something simple like that.

Though once we have glutin contexts working, drawing a triangle with glium is very straightforward too.

mbernat commented 11 months ago

Thanks @bschwind , I'll let you know when I have anything testable.

I've spent a lot of time just following glium/glutin types and didn't really get anywhere because I just don't know anything about GBM & EGL and I also started getting some IO errors from GBM operations (likely my fault, not HW). But I found a nice example in C [1] that seems to involve all the pieces in the right order. I'll try to get it working and then I'll port it to our codebase.

[1] https://github.com/eyelash/tutorials/blob/master/drm-gbm.c

mbernat commented 11 months ago

I now have some awful code that can render one broken frame and immediately crash. Also, it only works with nouveau.

I will refactor it into a semi-reasonable PR and we can continue testing and building on that afterwards.

strohel commented 11 months ago

@mbernat I just want to say thanks for the serious progress here (on #12 and on #11) - that's some very perseverant "bashing it until it works"!