[Feat]: implement glBindVertexAttribLocation in DirectGLES backend (fixing OptiFine?)

This commit is contained in:
2025-11-04 22:16:16 +08:00
parent 2f67620a6e
commit 57dd0fe480
6 changed files with 66 additions and 4 deletions
@@ -195,6 +195,10 @@ namespace MobileGL {
std::swap(m_attribs[location], m_attribs[idx]);
std::swap(m_attribTypes[location], m_attribTypes[idx]);
}
for (SizeT idx = 0; idx < m_attribs.size(); ++idx) {
m_attribLocation[m_attribs[idx]] = idx;
}
}
// ---------- UBO ----------
@@ -207,7 +211,6 @@ namespace MobileGL {
m_uniformBlockIndex[ubo.name] = ubo.getBinding();
m_uniformBlockIndexInTProgram[ubo.getBinding()] = i;
}
}
void ProgramObject::GenerateBinary() {
@@ -244,7 +247,9 @@ namespace MobileGL {
assert(binaryResult);
m_generatedSpirv = Move(binaryResult.value());
for (auto spv : m_generatedSpirv) {
for (SizeT i = 0; i < m_generatedSpirv.size(); i++) {
auto& spv = m_generatedSpirv[i];
auto shaderType = shaderTypes[i];
SpvcSession session(spv);
auto result = session.ParseMetaData();
if (result < 0) {
@@ -108,6 +108,8 @@ namespace MobileGL {
Uint GetExternalIndex() const { return m_externalIndex; }
const UnorderedMap<String, Uint>& GetAttribLocationMap() const { return m_attribLocation; }
private:
void DoReflection();
void GenerateBinary();
@@ -124,6 +126,8 @@ namespace MobileGL {
UnorderedMap<String, Uint> m_explicitAttribLocations;
Vector<String> m_attribs;
Vector<GLenum> m_attribTypes;
// For SpvcSession::SetVertexAttribLocation()
UnorderedMap<String, Uint> m_attribLocation;
// Uniforms
UnorderedMap<String, Uint> m_uniformLocations;