From 46be4f11459fa85586acce2b01fba65f6220c2dd Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Fri, 20 Aug 2021 13:48:36 +0200 Subject: [PATCH] mesa_demo: adjust to Mesa 21.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * support argc/argv + double buffering (Alexander Boettcher) * Route intel/gpu driver to platform driver * Use Gui session instead of framebuffer session (Josef Söntgen) issue #4254 --- repos/libports/run/mesa-gears.inc | 4 +- repos/libports/run/mesa.inc | 76 ++++----------- .../src/test/mesa_demo/eglut/eglut_genode.cc | 95 ++++++++++--------- .../raw/drivers_interactive-pc/drivers.config | 12 ++- 4 files changed, 81 insertions(+), 106 deletions(-) diff --git a/repos/libports/run/mesa-gears.inc b/repos/libports/run/mesa-gears.inc index b4f8cda9b1..a872b72368 100644 --- a/repos/libports/run/mesa-gears.inc +++ b/repos/libports/run/mesa-gears.inc @@ -1,7 +1,7 @@ set demo_component test/mesa_demo/gears set demo_binary gears -set demo_ram_quota 256M -set demo_caps 1500 +set demo_ram_quota 32M +set demo_caps 300 set demo_config { diff --git a/repos/libports/run/mesa.inc b/repos/libports/run/mesa.inc index 2728df05ff..002d7bc6a6 100644 --- a/repos/libports/run/mesa.inc +++ b/repos/libports/run/mesa.inc @@ -20,15 +20,12 @@ lappend imports [depot_user]/pkg/drivers_interactive-[board] } lappend imports [depot_user]/src/nitpicker -lappend imports [depot_user]/src/gui_fb -lappend imports [depot_user]/src/demo lappend imports [depot_user]/src/report_rom import_from_depot $imports set build_components { drivers/gpu/intel - drivers/framebuffer/intel lib/mesa/softpipe core init timer } @@ -107,58 +104,23 @@ set backend_library egl_swrast.lib.so if {$use_iris} { set backend_library egl_iris.lib.so } if {$use_etnaviv} { set backend_library egl_etnaviv.lib.so } -set launchpad_config { - - - - - - - - - - - - - - - - +append config " + + " - - - - - - - - } - -append launchpad_config " - - " - -append launchpad_config $demo_config - -append launchpad_config " - - - - " -append launchpad_config { - - - - - -} +append config $demo_config +append config " + + + + " append config { - - } -append config $launchpad_config -append config { - } + + + + +} append_if $use_iris config { @@ -172,13 +134,7 @@ append_if $use_iris config { - - - - - - - } +} append_if $use_etnaviv config { @@ -206,7 +162,7 @@ set boot_modules { append_if $use_iris boot_modules { egl_iris.lib.so libdrm.lib.so - intel_gpu_drv intel_fb_drv + intel_gpu_drv } append_if $use_etnaviv boot_modules { diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc index a2af966525..fb71b5ded8 100644 --- a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc +++ b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc @@ -26,10 +26,12 @@ * DEALINGS IN THE SOFTWARE. */ +#include #include #include -#include +#include #include +#include extern "C" { #include "eglutint.h" @@ -49,66 +51,59 @@ Genode::Entrypoint &genode_entrypoint() struct Window : Genode_egl_window { - Genode::Env &env; - Genode::Constructible framebuffer; - Genode::Io_signal_handler mode_dispatcher; - bool mode_change_pending = false; + using View_handle = Gui::Session::View_handle; + using Command = Gui::Session::Command; + + Genode::Env &env; + Framebuffer::Mode mode; + Gui::Connection gui { env }; + Genode::Constructible ds { }; + View_handle view { }; + + Genode::addr_t fb_addr { 0 }; + Genode::addr_t fb_size { 0 }; + Genode::Ram_dataspace_capability buffer_cap { }; Window(Genode::Env &env, int w, int h) : - env(env), - mode_dispatcher(*signal_ep, *this, &Window::mode_handler) + env(env), mode { .area = Gui::Area(w, h) } { width = w; height = h; + type = WINDOW; - Framebuffer::Mode const mode { .area = { (unsigned)width, (unsigned)height } }; - - framebuffer.construct(env, mode); - addr = env.rm().attach(framebuffer->dataspace()); - - framebuffer->mode_sigh(mode_dispatcher); + gui.buffer(mode, false); + view = gui.create_view(); mode_change(); - } - void mode_handler() - { - mode_change_pending = true; - } - - void update() - { - env.rm().detach(addr); - addr = env.rm().attach(framebuffer->dataspace()); + gui.enqueue(view, "eglut"); + gui.enqueue(view, View_handle()); + gui.execute(); } void mode_change() { - Framebuffer::Mode mode = framebuffer->mode(); + if (ds.constructed()) + ds.destruct(); - eglut_window *win = _eglut->current; - if (win) { - win->native.width = mode.area.w(); - win->native.height = mode.area.h(); - width = mode.area.w(); - height = mode.area.h(); + ds.construct(env.rm(), gui.framebuffer()->dataspace()); - if (win->reshape_cb) - win->reshape_cb(win->native.width, win->native.height); - } - - update(); - mode_change_pending = false; + addr = ds->local_addr(); + + Gui::Rect rect { Gui::Point { 0, 0 }, mode.area }; + gui.enqueue(view, rect); + gui.execute(); } void refresh() { - framebuffer->refresh(0, 0, width, height); + gui.framebuffer()->refresh(0, 0, mode.area.w(), mode.area.h()); } }; -Genode::Constructible eglut_win; + +static Genode::Constructible eglut_win; void _eglutNativeInitDisplay() @@ -145,10 +140,6 @@ void _eglutNativeEventLoop() while (true) { struct eglut_window *win =_eglut->current; - if (eglut_win->mode_change_pending) { - eglut_win->mode_change(); - } - if (_eglut->idle_cb) _eglut->idle_cb(); @@ -171,10 +162,28 @@ void _eglutNativeEventLoop() extern "C" int eglut_main(int argc, char *argv[]); +/* initial environment for the FreeBSD libc implementation */ +extern char **environ; + + +static void construct_component(Libc::Env &env) +{ + int argc = 0; + char **argv = nullptr; + char **envp = nullptr; + + populate_args_and_env(env, argc, argv, envp); + + environ = envp; + + exit(eglut_main(argc, argv)); +} + + void Libc::Component::construct(Libc::Env &env) { genode_env = &env; signal_ep.construct(env, 1024*sizeof(long), "eglut_signal_ep", Genode::Affinity::Location()); - Libc::with_libc([] () { eglut_main(1, nullptr); }); + Libc::with_libc([&] () { construct_component(env); }); } diff --git a/repos/os/recipes/raw/drivers_interactive-pc/drivers.config b/repos/os/recipes/raw/drivers_interactive-pc/drivers.config index e8fde7ce60..c9afd4b57c 100644 --- a/repos/os/recipes/raw/drivers_interactive-pc/drivers.config +++ b/repos/os/recipes/raw/drivers_interactive-pc/drivers.config @@ -16,6 +16,9 @@ + + + @@ -69,12 +72,19 @@ + + + + + + + - +