diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-01-15 20:31:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-19 19:57:49 +0100 |
commit | bc17a87450e3c282f026184ef90c61caec78dfb3 (patch) | |
tree | 3da26eacb07524db28487bdf3a0f26bf4ebcc098 | |
parent | 9627576d9c4136374ad3de340c71d1b51c99309a (diff) | |
download | serenity-bc17a87450e3c282f026184ef90c61caec78dfb3.zip |
LibGL: Also track active texture unit index
In addition to tracking a pointer to the active texture unit we also
track its index in the array.
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGL/SoftwareGLContext.h | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.cpp b/Userland/Libraries/LibGL/SoftwareGLContext.cpp index 88048df705..4b7e515512 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.cpp +++ b/Userland/Libraries/LibGL/SoftwareGLContext.cpp @@ -1868,9 +1868,10 @@ GLboolean SoftwareGLContext::gl_is_texture(GLuint texture) void SoftwareGLContext::gl_active_texture(GLenum texture) { - RETURN_WITH_ERROR_IF(texture < GL_TEXTURE0 || texture > GL_TEXTURE31, GL_INVALID_ENUM); + RETURN_WITH_ERROR_IF(texture < GL_TEXTURE0 || texture >= GL_TEXTURE0 + m_device_info.num_texture_units, GL_INVALID_ENUM); - m_active_texture_unit = &m_texture_units.at(texture - GL_TEXTURE0); + m_active_texture_unit_index = texture - GL_TEXTURE0; + m_active_texture_unit = &m_texture_units.at(m_active_texture_unit_index); } void SoftwareGLContext::gl_get_booleanv(GLenum pname, GLboolean* data) diff --git a/Userland/Libraries/LibGL/SoftwareGLContext.h b/Userland/Libraries/LibGL/SoftwareGLContext.h index 6df9d3f370..ff5c794afa 100644 --- a/Userland/Libraries/LibGL/SoftwareGLContext.h +++ b/Userland/Libraries/LibGL/SoftwareGLContext.h @@ -264,6 +264,7 @@ private: HashMap<GLuint, RefPtr<Texture>> m_allocated_textures; Vector<TextureUnit> m_texture_units; TextureUnit* m_active_texture_unit; + size_t m_active_texture_unit_index { 0 }; // Texture coordinate generation state struct TextureCoordinateGeneration { |