[Fix] (MG_Impl/GL_Program): fix GetUniform_State for mat3 alignment issues

This commit is contained in:
2025-11-21 22:24:47 +08:00
parent 854d293404
commit e3f73291e9
+13 -1
View File
@@ -423,7 +423,19 @@ namespace MobileGL {
auto offset = programObject->GetUniformOffset(location);
auto size = programObject->GetUniformSizesInBytes(location);
char* pUBO = (char*)programObject->MapUBO();
memcpy(params, pUBO + offset, size);
auto* ttype = programObject->GetUniformTType(location);
if (!ttype->isMatrix() || ttype->getMatrixCols() != 3)
memcpy(params, pUBO + offset, size);
else {
// TODO: we only deal with mat3 yet, deal with other types later
// assuming float here, which may not be the case
auto* pBase = pUBO + offset;
for (int i = 0; i < ttype->getMatrixRows(); i++) {
memcpy((char*)params + ttype->getMatrixCols() * sizeof(float) * i, pBase + 4 * sizeof(float) * i,
ttype->getMatrixCols() * sizeof(float));
}
}
}
// TODO: handle 1i variant as texture unit
}