diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-08-26 15:59:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-27 12:28:05 +0200 |
commit | 84c4b66721c893775938e40808486e1ce506732e (patch) | |
tree | e0269e8c65b33f8a1a7e05cc443a7e98c58fb8dd /Userland/Libraries/LibGL/Texture.cpp | |
parent | 6c80d121110e4fcc1c309bd50aabc9825dc75a93 (diff) | |
download | serenity-84c4b66721c893775938e40808486e1ce506732e.zip |
LibGL+LibGPU+LibSoftGPU: Implement texture pixel format support
In OpenGL this is called the (base) internal format which is an
expectation expressed by the client for the minimum supported texel
storage format in the GPU for textures.
Since we store everything as RGBA in a `FloatVector4`, the only thing
we do in this patch is remember the expected internal format, and when
we write new texels we fixate the value for the alpha channel to 1 for
two formats that require it.
`PixelConverter` has learned how to transform pixels during transfer to
support this.
Diffstat (limited to 'Userland/Libraries/LibGL/Texture.cpp')
-rw-r--r-- | Userland/Libraries/LibGL/Texture.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGL/Texture.cpp b/Userland/Libraries/LibGL/Texture.cpp index 4e80a7bff6..f6afb81bd1 100644 --- a/Userland/Libraries/LibGL/Texture.cpp +++ b/Userland/Libraries/LibGL/Texture.cpp @@ -308,13 +308,6 @@ void GLContext::gl_tex_gen_floatv(GLenum coord, GLenum pname, GLfloat const* par m_texcoord_generation_dirty = true; } -// FIXME: talk to GPU::Device to determine supported GPU::PixelTypes -constexpr GPU::PixelType texture_fixed_pixel_type = { - .format = GPU::PixelFormat::RGBA, - .bits = GPU::PixelComponentBits::AllBits, - .data_type = GPU::PixelDataType::Float, -}; - void GLContext::gl_tex_image_2d(GLenum target, GLint level, GLint internal_format, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data) { RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); @@ -341,7 +334,8 @@ void GLContext::gl_tex_image_2d(GLenum target, GLint level, GLint internal_forma // that constructing GL textures in any but the default mipmap order, going from level 0 upwards will cause mip levels to stay uninitialized. // To be spec compliant we should create the device image once the texture has become complete and is used for rendering the first time. // All images that were attached before the device image was created need to be stored somewhere to be used to initialize the device image once complete. - texture_2d->set_device_image(m_rasterizer->create_image(texture_fixed_pixel_type, width, height, 1, 999, 1)); + auto internal_pixel_format = pixel_format_for_internal_format(internal_format); + texture_2d->set_device_image(m_rasterizer->create_image(internal_pixel_format, width, height, 1, 999, 1)); m_sampler_config_is_dirty = true; } |