[Feat] (MG_State/Program): glUniformMatrix* with transpose,

This commit is contained in:
2025-08-22 17:29:31 +08:00
parent 7a7f6a0533
commit c33056fd8e
4 changed files with 322 additions and 32 deletions
@@ -70,8 +70,8 @@ namespace MobileGL {
return;
}
auto uniformCount = m_program->getNumUniformVariables();
for (int i = 0; i < uniformCount; i++) {
m_activeUniformCount = m_program->getNumUniformVariables();
for (int i = 0; i < m_activeUniformCount; i++) {
auto& uniform = m_program->getUniform(i);
auto location = uniform.layoutLocation();
m_maxUniformLocation = std::max(m_maxUniformLocation, location);
@@ -85,7 +85,7 @@ namespace MobileGL {
m_uniformOffsets.resize(m_maxUniformLocation + 1);
m_uniformArraySizes.resize(m_maxUniformLocation + 1);
for (int i = 0; i < uniformCount; i++) {
for (int i = 0; i < m_activeUniformCount; i++) {
auto& uniform = m_program->getUniform(i);
auto location = uniform.layoutLocation();
m_uniformNames[location] = uniform.name;
@@ -168,16 +168,17 @@ namespace MobileGL {
auto srcResult = ShaderCompiler::DecompileShader(session);
assert(srcResult);
auto src = srcResult.value();
printf("decompiled src: \n%s\n", src.c_str());
auto& meta = session.GetMetadata();
auto size = meta.uboSize;
m_uboScratch.resize(size);
m_uniformOffsets.resize(meta.plainUniformOffsetsInUBO.size());
m_uniformOffsets.resize(m_maxUniformLocation + 1);
for (const auto& [name, offset] : meta.plainUniformOffsetsInUBO) {
if (m_uniformLocations.find(name) != m_uniformLocations.end())
m_uniformOffsets[m_uniformLocations[name]] = offset;
}
m_uniformSizesInBytes.resize(meta.plainUniformMemberSizesInBytes.size());
m_uniformSizesInBytes.resize(m_maxUniformLocation + 1);
for (const auto& [name, size] : meta.plainUniformMemberSizesInBytes) {
if (m_uniformLocations.find(name) != m_uniformLocations.end())
m_uniformSizesInBytes[m_uniformLocations[name]] = size;
@@ -1,6 +1,7 @@
#pragma once
#include <Includes.h>
#include "ShaderObject.h"
#include "MG_Util/Metrics/BufferMetrics.h"
#include "MG_Util/ShaderTranspiler/SpvcSession.h"
namespace MobileGL {
@@ -20,7 +21,8 @@ namespace MobileGL {
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
const String& GetInfoLog() const { return m_infoLog; }
Int GetUniformMaxLength() const { return m_uniformNameMaxLength; }
Uint GetUniformCount() { return m_uniformNames.size(); }
Uint GetUniformCount() { return m_activeUniformCount; }
Uint GetMaxUniformLocation() const { return m_maxUniformLocation; }
Int GetUniformLocation(const String& name) {
const auto it = m_uniformLocations.find(name);
return (it == m_uniformLocations.end()) ? -1 : (Int)it->second;
@@ -40,7 +42,7 @@ namespace MobileGL {
return m_uniformOffsets[location];
}
Uint GetUniformSizesInBytes(Uint location) const {
return m_uniformSizesInBytes[location];
return MG_Util::GetGLTypeSize(m_uniformTypes[location]);
}
Int GetAttributeLocation(const String& name) {
@@ -101,6 +103,7 @@ namespace MobileGL {
Vector<Uint> m_uniformSizesInBytes;
Vector<Uint8> m_uboScratch;
Uint m_activeUniformCount = 0;
Uint m_maxUniformLocation = 0;
Int m_uniformNameMaxLength = 0;
Int m_attribInNameMaxLength = 0;