[Fix] (MG_State, MG_Impl, MG_Test): enforce strict GL 3.3 core rules only on contexts that explicitly request a core profile - texture deleted-name reservation keep and VAO-0 draws relax otherwise or under MOBILEGL_RELAXED_SEMANTICS, and GL_CONTEXT_PROFILE_MASK reports the requested profile

This commit is contained in:
2026-07-17 21:32:16 -04:00
parent 1929a7c546
commit 92cced9bcc
14 changed files with 208 additions and 12 deletions
@@ -96,7 +96,7 @@ namespace MobileGL::MG_State::GLState {
return textureObject;
}
void TextureState::MarkTextureObjectForDeletion(Uint index) {
void TextureState::MarkTextureObjectForDeletion(Uint index, Bool keepUnboundReservation) {
if (m_indexGenerator.IsValid(index)) {
auto it = m_textureObjects.find(index);
if (it != m_textureObjects.end()) {
@@ -123,10 +123,15 @@ namespace MobileGL::MG_State::GLState {
BumpTextureBindGeneration();
m_textureObjects.erase(index);
m_indexGenerator.Delete(index);
} else if (!keepUnboundReservation) {
// GL 3.3 core 3.8.1 makes a deleted name unused again even when GenTextures only
// reserved it and no bind ever instantiated an object (so a later bind of it must
// fail), and the reservation has to return to the free list.
m_indexGenerator.Delete(index);
}
// Compatibility: legacy Minecraft may delete a generated name before its first bind,
// then bind and populate that same name. Keep such a reservation alive; only a real
// texture object reaching deletion releases its index above.
// Relaxed semantics: legacy apps may delete a generated name before its first
// bind, then bind and populate that same name. Keep such a reservation alive there;
// a real texture object reaching deletion still releases its index above.
}
}
@@ -60,7 +60,7 @@ namespace MobileGL::MG_State::GLState {
const ImageTextureBinding& GetImageTextureBinding(Int unit) const;
Int GetActiveTextureUnit() const;
void SetActiveTextureUnit(Int unit);
void MarkTextureObjectForDeletion(Uint index);
void MarkTextureObjectForDeletion(Uint index, Bool keepUnboundReservation);
Bool ValidateName(Uint index) const;
Bool ValidateTextureObject(Uint index) const;