From 84c4b66721c893775938e40808486e1ce506732e Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Fri, 26 Aug 2022 15:59:51 +0200 Subject: 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. --- Userland/Libraries/LibGL/Texture.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'Userland/Libraries/LibGL/Texture.cpp') 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; } -- cgit v1.2.3