mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:07:44 +00:00
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.
This commit is contained in:
parent
211d24a218
commit
5bb76e9b63
11 changed files with 165 additions and 9 deletions
|
@ -18,4 +18,4 @@ set(SOURCES
|
|||
)
|
||||
|
||||
serenity_lib(LibGL gl)
|
||||
target_link_libraries(LibGL LibM LibCore LibGfx LibSoftGPU)
|
||||
target_link_libraries(LibGL LibM LibCore LibGfx LibGPU)
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGL/GLContext.h>
|
||||
#include <LibGPU/Device.h>
|
||||
#include <LibGPU/Enums.h>
|
||||
#include <LibGPU/ImageFormat.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Painter.h>
|
||||
#include <LibGfx/Vector4.h>
|
||||
#include <LibSoftGPU/Device.h>
|
||||
|
||||
__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<GPU::Driver> driver, NonnullOwnPtr<GPU::Device> device, Gfx::Bitmap& frontbuffer)
|
||||
: m_viewport { frontbuffer.rect() }
|
||||
, m_frontbuffer { frontbuffer }
|
||||
, m_rasterizer { make<SoftGPU::Device>(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<GLContext> create_context(Gfx::Bitmap& bitmap)
|
||||
{
|
||||
auto context = make<GLContext>(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<GLContext>(driver, move(device), bitmap);
|
||||
dbgln_if(GL_DEBUG, "GL::create_context({}) -> {:p}", bitmap.size(), context.ptr());
|
||||
|
||||
if (!g_gl_context)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <LibGL/Tex/TextureUnit.h>
|
||||
#include <LibGPU/Device.h>
|
||||
#include <LibGPU/DeviceInfo.h>
|
||||
#include <LibGPU/Driver.h>
|
||||
#include <LibGPU/Light.h>
|
||||
#include <LibGPU/Vertex.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
@ -48,7 +49,7 @@ enum Face {
|
|||
|
||||
class GLContext final {
|
||||
public:
|
||||
GLContext(Gfx::Bitmap&);
|
||||
GLContext(RefPtr<GPU::Driver> driver, NonnullOwnPtr<GPU::Device>, Gfx::Bitmap&);
|
||||
~GLContext();
|
||||
|
||||
void gl_begin(GLenum mode);
|
||||
|
@ -303,6 +304,7 @@ private:
|
|||
return m_texture_coordinate_generation[texture_unit][capability - GL_TEXTURE_GEN_S];
|
||||
}
|
||||
|
||||
RefPtr<GPU::Driver> m_driver;
|
||||
NonnullOwnPtr<GPU::Device> m_rasterizer;
|
||||
GPU::DeviceInfo const m_device_info;
|
||||
bool m_sampler_config_is_dirty { true };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue