mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +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:
@@ -81,6 +81,38 @@ namespace MG_State {
|
||||
GLint QueryProgramUniformLocation(GLuint program, const GLchar* name);
|
||||
GLenum QueryProgramStateIntVector(GLuint program, GLenum pname, GLint* params);
|
||||
GLenum QueryShaderStateIntVector(GLuint shader, GLenum pname, GLint* params);
|
||||
template<typename T>
|
||||
GLenum SetUniform(GLuint program, GLint location, GLsizei count, const T* value, GLenum type);
|
||||
|
||||
template<typename T>
|
||||
GLenum SetUniformMatrix(GLuint program, GLint location, GLsizei count, GLboolean transpose, const T* value, GLenum matrixType);
|
||||
|
||||
#define DECLARE_UNIFORM_FUNCTIONS(type, suffix, vecType) \
|
||||
void UpdateProgramUniform##suffix##1(GLint location, type v0); \
|
||||
void UpdateProgramUniform##suffix##2(GLint location, type v0, type v1); \
|
||||
void UpdateProgramUniform##suffix##3(GLint location, type v0, type v1, type v2); \
|
||||
void UpdateProgramUniform##suffix##4(GLint location, type v0, type v1, type v2, type v3); \
|
||||
void UpdateProgramUniform##suffix##Vector1(GLint location, GLsizei count, const type* value); \
|
||||
void UpdateProgramUniform##suffix##Vector2(GLint location, GLsizei count, const type* value); \
|
||||
void UpdateProgramUniform##suffix##Vector3(GLint location, GLsizei count, const type* value); \
|
||||
void UpdateProgramUniform##suffix##Vector4(GLint location, GLsizei count, const type* value);
|
||||
DECLARE_UNIFORM_FUNCTIONS(GLfloat, Float, GL_FLOAT)
|
||||
DECLARE_UNIFORM_FUNCTIONS(GLint, Int, GL_INT)
|
||||
DECLARE_UNIFORM_FUNCTIONS(GLuint, UInt, GL_UNSIGNED_INT)
|
||||
DECLARE_UNIFORM_FUNCTIONS(GLboolean, Bool, GL_BOOL)
|
||||
#undef DECLARE_UNIFORM_FUNCTIONS
|
||||
#define DECLARE_MATRIX_FUNCTIONS(suffix, matrixType) \
|
||||
void UpdateProgramUniformMatrix##suffix##Vector(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
|
||||
DECLARE_MATRIX_FUNCTIONS(2x2, GL_FLOAT_MAT2)
|
||||
DECLARE_MATRIX_FUNCTIONS(3x3, GL_FLOAT_MAT3)
|
||||
DECLARE_MATRIX_FUNCTIONS(4x4, GL_FLOAT_MAT4)
|
||||
DECLARE_MATRIX_FUNCTIONS(2x3, GL_FLOAT_MAT2x3)
|
||||
DECLARE_MATRIX_FUNCTIONS(2x4, GL_FLOAT_MAT2x4)
|
||||
DECLARE_MATRIX_FUNCTIONS(3x2, GL_FLOAT_MAT3x2)
|
||||
DECLARE_MATRIX_FUNCTIONS(3x4, GL_FLOAT_MAT3x4)
|
||||
DECLARE_MATRIX_FUNCTIONS(4x2, GL_FLOAT_MAT4x2)
|
||||
DECLARE_MATRIX_FUNCTIONS(4x3, GL_FLOAT_MAT4x3)
|
||||
#undef DECLARE_MATRIX_FUNCTIONS
|
||||
|
||||
GLuint GetCurrentProgram();
|
||||
bool SetProgramStatus(GLuint program, GLboolean status);
|
||||
|
||||
Reference in New Issue
Block a user