mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
[Feat] (ProgramState): Implement automatic GLSL uniform management.
- Add SPIRV-Cross/glslang integration for uniform reflection. - Auto-detect and assign locations for uniforms/samplers. - Support most types of uniform. - Implement glUniform* functions with type safety. - Add MG_Util::Program: - GLSL-SPIRV conversion - SPIRV uniform reflection - Program uniform dumping
This commit is contained in:
@@ -130,4 +130,169 @@ namespace MG_GL::GL {
|
||||
MG_State::SetError(result);
|
||||
MG_Util::Debug::LogE("Error getting shader param: %s", MG_Util::Debug::GLEnumToString(result));
|
||||
}
|
||||
|
||||
void Uniform1f(GLint location, GLfloat v0) {
|
||||
MG_Util::Debug::LogD("glUniform1f, location: %d, v0: %f", location, v0);
|
||||
MG_State::UpdateProgramUniformFloat1(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2f(GLint location, GLfloat v0, GLfloat v1) {
|
||||
MG_Util::Debug::LogD("glUniform2f, location: %d, v0: %f, v1: %f", location, v0, v1);
|
||||
MG_State::UpdateProgramUniformFloat2(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) {
|
||||
MG_Util::Debug::LogD("glUniform3f, location: %d, v0: %f, v1: %f, v2: %f", location, v0, v1, v2);
|
||||
MG_State::UpdateProgramUniformFloat3(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) {
|
||||
MG_Util::Debug::LogD("glUniform4f, location: %d, v0: %f, v1: %f, v2: %f, v3: %f", location, v0, v1, v2, v3);
|
||||
MG_State::UpdateProgramUniformFloat4(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniform1fv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformFloatVector1(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniform2fv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformFloatVector2(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniform3fv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformFloatVector3(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4fv(GLint location, GLsizei count, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniform4fv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformFloatVector4(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform1i(GLint location, GLint v0) {
|
||||
MG_Util::Debug::LogD("glUniform1i, location: %d, v0: %d", location, v0);
|
||||
MG_State::UpdateProgramUniformInt1(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2i(GLint location, GLint v0, GLint v1) {
|
||||
MG_Util::Debug::LogD("glUniform2i, location: %d, v0: %d, v1: %d", location, v0, v1);
|
||||
MG_State::UpdateProgramUniformInt2(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3i(GLint location, GLint v0, GLint v1, GLint v2) {
|
||||
MG_Util::Debug::LogD("glUniform3i, location: %d, v0: %d, v1: %d, v2: %d", location, v0, v1, v2);
|
||||
MG_State::UpdateProgramUniformInt3(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) {
|
||||
MG_Util::Debug::LogD("glUniform4i, location: %d, v0: %d, v1: %d, v2: %d, v3: %d", location, v0, v1, v2, v3);
|
||||
MG_State::UpdateProgramUniformInt4(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1iv(GLint location, GLsizei count, const GLint* value) {
|
||||
MG_Util::Debug::LogD("glUniform1iv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformIntVector1(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2iv(GLint location, GLsizei count, const GLint* value) {
|
||||
MG_Util::Debug::LogD("glUniform2iv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformIntVector2(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3iv(GLint location, GLsizei count, const GLint* value) {
|
||||
MG_Util::Debug::LogD("glUniform3iv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformIntVector3(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4iv(GLint location, GLsizei count, const GLint* value) {
|
||||
MG_Util::Debug::LogD("glUniform4iv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformIntVector4(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform1ui(GLint location, GLuint v0) {
|
||||
MG_Util::Debug::LogD("glUniform1ui, location: %d, v0: %u", location, v0);
|
||||
MG_State::UpdateProgramUniformUInt1(location, v0);
|
||||
}
|
||||
|
||||
void Uniform2ui(GLint location, GLuint v0, GLuint v1) {
|
||||
MG_Util::Debug::LogD("glUniform2ui, location: %d, v0: %u, v1: %u", location, v0, v1);
|
||||
MG_State::UpdateProgramUniformUInt2(location, v0, v1);
|
||||
}
|
||||
|
||||
void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) {
|
||||
MG_Util::Debug::LogD("glUniform3ui, location: %d, v0: %u, v1: %u, v2: %u", location, v0, v1, v2);
|
||||
MG_State::UpdateProgramUniformUInt3(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) {
|
||||
MG_Util::Debug::LogD("glUniform4ui, location: %d, v0: %u, v1: %u, v2: %u, v3: %u", location, v0, v1, v2, v3);
|
||||
MG_State::UpdateProgramUniformUInt4(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) {
|
||||
MG_Util::Debug::LogD("glUniform1uiv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformUIntVector1(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) {
|
||||
MG_Util::Debug::LogD("glUniform2uiv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformUIntVector2(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) {
|
||||
MG_Util::Debug::LogD("glUniform3uiv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformUIntVector3(location, count, value);
|
||||
}
|
||||
|
||||
void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) {
|
||||
MG_Util::Debug::LogD("glUniform4uiv, location: %d, count: %d", location, count);
|
||||
MG_State::UpdateProgramUniformUIntVector4(location, count, value);
|
||||
}
|
||||
|
||||
void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix2fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix2x2Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix3fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix3x3Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix4fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix4x4Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix2x3fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix2x3Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix2x4fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix2x4Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix3x2fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix3x2Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix3x4fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix3x4Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix4x2fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix4x2Vector(location, count, transpose, value);
|
||||
}
|
||||
|
||||
void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
|
||||
MG_Util::Debug::LogD("glUniformMatrix4x3fv, location: %d, count: %d, transpose: %d", location, count, transpose);
|
||||
MG_State::UpdateProgramUniformMatrix4x3Vector(location, count, transpose, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user