mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:47: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:
parent
dda5987684
commit
1540c56e6c
10 changed files with 148 additions and 82 deletions
|
@ -10,10 +10,8 @@
|
|||
|
||||
#include "Texture.h"
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/IntegralMath.h>
|
||||
#include <LibGL/GL/gl.h>
|
||||
#include <LibGL/Tex/MipMap.h>
|
||||
#include <LibGL/Tex/Sampler2D.h>
|
||||
#include <LibGPU/ImageDataLayout.h>
|
||||
|
||||
|
@ -31,24 +29,17 @@ public:
|
|||
void upload_texture_data(GLuint lod, GLenum internal_format, GPU::ImageDataLayout input_layout, GLvoid const* pixels);
|
||||
void replace_sub_texture_data(GLuint lod, GPU::ImageDataLayout input_layout, Vector3<i32> const& output_offset, GLvoid const* pixels);
|
||||
|
||||
MipMap const& mipmap(unsigned lod) const
|
||||
{
|
||||
if (lod >= m_mipmaps.size())
|
||||
return m_mipmaps.last();
|
||||
|
||||
return m_mipmaps.at(lod);
|
||||
}
|
||||
|
||||
void set_generate_mipmaps(bool generate_mipmaps);
|
||||
GLenum internal_format() const { return m_internal_format; }
|
||||
Sampler2D const& sampler() const { return m_sampler; }
|
||||
Sampler2D& sampler() { return m_sampler; }
|
||||
|
||||
int width_at_lod(unsigned level) const { return (level >= m_mipmaps.size()) ? 0 : m_mipmaps.at(level).width(); }
|
||||
int height_at_lod(unsigned level) const { return (level >= m_mipmaps.size()) ? 0 : m_mipmaps.at(level).height(); }
|
||||
int width_at_lod(unsigned level) const { return static_cast<int>(device_image()->width_at_level(level)); }
|
||||
int height_at_lod(unsigned level) const { return static_cast<int>(device_image()->height_at_level(level)); }
|
||||
int depth_at_lod(unsigned level) const { return static_cast<int>(device_image()->depth_at_level(level)); }
|
||||
|
||||
private:
|
||||
// FIXME: Mipmaps are currently unused, but we have the plumbing for it at least
|
||||
Array<MipMap, LOG2_MAX_TEXTURE_SIZE> m_mipmaps;
|
||||
bool m_generate_mipmaps { false };
|
||||
GLenum m_internal_format;
|
||||
Sampler2D m_sampler;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue