summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGL
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2021-12-23 02:38:20 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-24 05:10:28 -0800
commit39995548e4bd6f95994c2a728ee00ccc5bff9adb (patch)
tree5c7fe93bdce5dd83e4fbb15a71ec93c4791d9044 /Userland/Libraries/LibGL
parent1a758d7bf23b32da2ab3e442e2dd58a5b7731f55 (diff)
downloadserenity-39995548e4bd6f95994c2a728ee00ccc5bff9adb.zip
LibGL+LibSoftGPU: Add method to query device info
This adds a method `info()` to SoftGPU that returns the name of the hardware vendor and device name, as well as the number of texture untis. LibGL uses the returned texture unit count to initialize its internal texture unit array.
Diffstat (limited to 'Userland/Libraries/LibGL')
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.cpp7
-rw-r--r--Userland/Libraries/LibGL/SoftwareGLContext.h5
2 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
index a894283819..72da04c7cb 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp
@@ -58,7 +58,10 @@ static constexpr size_t TEXTURE_MATRIX_STACK_LIMIT = 8;
SoftwareGLContext::SoftwareGLContext(Gfx::Bitmap& frontbuffer)
: m_frontbuffer(frontbuffer)
, m_rasterizer(frontbuffer.size())
+ , m_device_info(m_rasterizer.info())
{
+ m_texture_units.resize(m_device_info.num_texture_units);
+ m_active_texture_unit = &m_texture_units[0];
}
Optional<ContextParameter> SoftwareGLContext::get_context_parameter(GLenum name)
@@ -333,9 +336,9 @@ GLubyte* SoftwareGLContext::gl_get_string(GLenum name)
switch (name) {
case GL_VENDOR:
- return reinterpret_cast<GLubyte*>(const_cast<char*>("The SerenityOS Developers"));
+ return reinterpret_cast<GLubyte*>(const_cast<char*>(m_device_info.vendor_name.characters()));
case GL_RENDERER:
- return reinterpret_cast<GLubyte*>(const_cast<char*>("SerenityOS OpenGL"));
+ return reinterpret_cast<GLubyte*>(const_cast<char*>(m_device_info.device_name.characters()));
case GL_VERSION:
return reinterpret_cast<GLubyte*>(const_cast<char*>("1.5"));
case GL_EXTENSIONS:
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h
index cde187e80d..042a491652 100644
--- a/Userland/Libraries/LibGL/SoftwareGLContext.h
+++ b/Userland/Libraries/LibGL/SoftwareGLContext.h
@@ -233,10 +233,11 @@ private:
// Texture objects
TextureNameAllocator m_name_allocator;
HashMap<GLuint, RefPtr<Texture>> m_allocated_textures;
- Array<TextureUnit, 32> m_texture_units;
- TextureUnit* m_active_texture_unit { &m_texture_units[0] };
+ Vector<TextureUnit, 32> m_texture_units;
+ TextureUnit* m_active_texture_unit;
SoftGPU::Device m_rasterizer;
+ SoftGPU::DeviceInfo const m_device_info;
bool m_sampler_config_is_dirty { true };
struct Listing {