From 5bb76e9b6326c5b36e2e9e3d1d41d90012fafa11 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sun, 27 Mar 2022 18:54:31 +0200 Subject: LibGL+LibGPU+LibSoftGPU: Load SoftGPU driver dynamically This loads libsoftgpu.so during GLContext creation and instantiates the device class which is then passed into the GLContext constructor. --- Userland/Libraries/LibGL/GLContext.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Userland/Libraries/LibGL/GLContext.cpp') diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index 9ba9d06791..70b6c93b04 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #include #include -#include __attribute__((visibility("hidden"))) GL::GLContext* g_gl_context; @@ -61,10 +61,11 @@ static constexpr size_t TEXTURE_MATRIX_STACK_LIMIT = 8; return return_value; \ } -GLContext::GLContext(Gfx::Bitmap& frontbuffer) +GLContext::GLContext(RefPtr driver, NonnullOwnPtr device, Gfx::Bitmap& frontbuffer) : m_viewport { frontbuffer.rect() } , m_frontbuffer { frontbuffer } - , m_rasterizer { make(frontbuffer.size()) } + , m_driver { driver } + , m_rasterizer { move(device) } , m_device_info { m_rasterizer->info() } { m_texture_units.resize(m_device_info.num_texture_units); @@ -3064,7 +3065,7 @@ void GLContext::sync_light_state() } m_rasterizer->set_options(options); - for (auto light_id = 0u; light_id < SoftGPU::NUM_LIGHTS; light_id++) { + for (auto light_id = 0u; light_id < m_device_info.num_lights; light_id++) { auto const& current_light_state = m_light_states.at(light_id); m_rasterizer->set_light_state(light_id, current_light_state); } @@ -3645,7 +3646,10 @@ void GLContext::get_material_param(Face face, GLenum pname, T* params) NonnullOwnPtr create_context(Gfx::Bitmap& bitmap) { - auto context = make(bitmap); + // FIXME: Make driver selectable. This is currently hardcoded to LibSoftGPU + auto driver = MUST(GPU::Driver::try_create("softgpu")); + auto device = MUST(driver->try_create_device(bitmap.size())); + auto context = make(driver, move(device), bitmap); dbgln_if(GL_DEBUG, "GL::create_context({}) -> {:p}", bitmap.size(), context.ptr()); if (!g_gl_context) -- cgit v1.2.3