1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:27:43 +00:00

LibGL: Make glDeleteTextures skip over 0 names

As stated in the manual:
     glDeleteTextures silently ignores 0's and names that do not
     correspond to existing textures.

If we do not skip these 0 names, they end up as invalid free texture
names in our name allocator.
This commit is contained in:
Jelle Raaijmakers 2021-11-28 02:45:08 +01:00 committed by Andreas Kling
parent 4abd6aa198
commit 7ad70f623e
3 changed files with 7 additions and 8 deletions

View file

@ -673,10 +673,12 @@ void SoftwareGLContext::gl_delete_textures(GLsizei n, const GLuint* textures)
RETURN_WITH_ERROR_IF(n < 0, GL_INVALID_VALUE); RETURN_WITH_ERROR_IF(n < 0, GL_INVALID_VALUE);
RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION); RETURN_WITH_ERROR_IF(m_in_draw_state, GL_INVALID_OPERATION);
m_name_allocator.free(n, textures);
for (auto i = 0; i < n; i++) { for (auto i = 0; i < n; i++) {
GLuint name = textures[i]; GLuint name = textures[i];
if (name == 0)
continue;
m_name_allocator.free(name);
auto texture_object = m_allocated_textures.find(name); auto texture_object = m_allocated_textures.find(name);
if (texture_object == m_allocated_textures.end() || texture_object->value.is_null()) if (texture_object == m_allocated_textures.end() || texture_object->value.is_null())

View file

@ -22,12 +22,9 @@ void TextureNameAllocator::allocate(GLsizei count, GLuint* textures)
} }
} }
void TextureNameAllocator::free(GLsizei count, const GLuint* textures) void TextureNameAllocator::free(GLuint texture)
{ {
size_t tex_array_index = 0; m_free_texture_names.push(texture);
while (count-- > 0)
m_free_texture_names.push(textures[tex_array_index++]);
} }
} }

View file

@ -16,7 +16,7 @@ public:
TextureNameAllocator() = default; TextureNameAllocator() = default;
void allocate(GLsizei count, GLuint* textures); void allocate(GLsizei count, GLuint* textures);
void free(GLsizei count, const GLuint* textures); void free(GLuint texture);
private: private:
Stack<GLuint, 512> m_free_texture_names; Stack<GLuint, 512> m_free_texture_names;