1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:17:35 +00:00

LibGL+LibGPU+LibSoftGPU: Implement GL_GENERATE_MIPMAP

We can now generate texture mipmaps on the fly if the client requests
it. This fixes the missing textures in our PrBoom+ port.
This commit is contained in:
Jelle Raaijmakers 2022-09-04 22:18:16 +02:00 committed by Linus Groh
parent dda5987684
commit 1540c56e6c
10 changed files with 148 additions and 82 deletions

View file

@ -22,15 +22,16 @@ class Image final : public GPU::Image {
public:
Image(void const* ownership_token, GPU::PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels);
u32 level_width(u32 level) const { return m_mipmap_buffers[level]->width(); }
u32 level_height(u32 level) const { return m_mipmap_buffers[level]->height(); }
u32 level_depth(u32 level) const { return m_mipmap_buffers[level]->depth(); }
u32 num_levels() const { return m_num_levels; }
virtual u32 width_at_level(u32 level) const override { return m_mipmap_buffers[level]->width(); }
virtual u32 height_at_level(u32 level) const override { return m_mipmap_buffers[level]->height(); }
virtual u32 depth_at_level(u32 level) const override { return m_mipmap_buffers[level]->depth(); }
virtual u32 number_of_levels() const override { return m_number_of_levels; }
bool width_is_power_of_two() const { return m_width_is_power_of_two; }
bool height_is_power_of_two() const { return m_height_is_power_of_two; }
bool depth_is_power_of_two() const { return m_depth_is_power_of_two; }
GPU::ImageDataLayout image_data_layout(u32 level, Vector3<i32> offset) const;
virtual void regenerate_mipmaps() override;
FloatVector4 texel(u32 level, int x, int y, int z) const
{
@ -57,7 +58,7 @@ public:
}
private:
u32 m_num_levels { 0 };
u32 m_number_of_levels { 0 };
GPU::PixelFormat m_pixel_format;
FixedArray<RefPtr<Typed3DBuffer<FloatVector4>>> m_mipmap_buffers;