mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGL: Allow glTexImage2D to create uninitialized textures
When passing a nullptr as the pixel array LibGL now allocates texture memory but does not initialize the texture contents.
This commit is contained in:
parent
22905daacb
commit
b38edf994b
Notes:
sideshowbarker
2024-07-18 05:30:45 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/b38edf994b4 Pull-request: https://github.com/SerenityOS/serenity/pull/9451 Reviewed-by: https://github.com/Quaker762 ✅ Reviewed-by: https://github.com/alimpfard
1 changed files with 7 additions and 9 deletions
|
@ -18,17 +18,18 @@ void Texture2D::upload_texture_data(GLenum, GLint lod, GLint internal_format, GL
|
||||||
// Considering we control this library, and `gl.h` itself, we don't need to add any
|
// Considering we control this library, and `gl.h` itself, we don't need to add any
|
||||||
// checks here to see if we support them; the program will simply fail to compile..
|
// checks here to see if we support them; the program will simply fail to compile..
|
||||||
|
|
||||||
// Somebody passed us in nullptr...
|
auto& mip = m_mipmaps[lod];
|
||||||
// Apparently this allocates memory on the GPU (according to Khronos docs..)?
|
mip.set_width(width);
|
||||||
|
mip.set_height(height);
|
||||||
|
|
||||||
|
// No pixel data was supplied. Just allocate texture memory and leave it uninitialized.
|
||||||
if (pixels == nullptr) {
|
if (pixels == nullptr) {
|
||||||
dbgln("LibGL: pixels == nullptr when uploading texture data.");
|
mip.pixel_data().resize(width * height);
|
||||||
VERIFY_NOT_REACHED();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_internal_format = internal_format;
|
m_internal_format = internal_format;
|
||||||
|
|
||||||
// Get reference to the mip
|
|
||||||
auto& mip = m_mipmaps[lod];
|
|
||||||
const u8* pixel_byte_array = reinterpret_cast<const u8*>(pixels);
|
const u8* pixel_byte_array = reinterpret_cast<const u8*>(pixels);
|
||||||
|
|
||||||
mip.pixel_data().clear();
|
mip.pixel_data().clear();
|
||||||
|
@ -75,9 +76,6 @@ void Texture2D::upload_texture_data(GLenum, GLint lod, GLint internal_format, GL
|
||||||
} else {
|
} else {
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
mip.set_width(width);
|
|
||||||
mip.set_height(height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MipMap const& Texture2D::mipmap(unsigned lod) const
|
MipMap const& Texture2D::mipmap(unsigned lod) const
|
||||||
|
|
Loading…
Reference in a new issue