Change the internal constant color from a (per-draw) vertex attribute to a uniform. Pack most built-in uniforms into a single vec4 array and update them all with a single glUniform call.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2019-11-18 21:13:54 -04:00
parent 37c579929b
commit 3435a6bcbf
10 changed files with 98 additions and 172 deletions
+11 -5
View File
@@ -68,12 +68,8 @@ public:
BUILTIN_TEXTURE_VIDEO_Y,
BUILTIN_TEXTURE_VIDEO_CB,
BUILTIN_TEXTURE_VIDEO_CR,
BUILTIN_MATRIX_VIEW_FROM_LOCAL,
BUILTIN_MATRIX_CLIP_FROM_VIEW,
BUILTIN_MATRIX_CLIP_FROM_LOCAL,
BUILTIN_MATRIX_VIEW_NORMAL_FROM_LOCAL,
BUILTIN_UNIFORMS_PER_DRAW,
BUILTIN_POINT_SIZE,
BUILTIN_SCREEN_SIZE,
BUILTIN_MAX_ENUM
};
@@ -133,6 +129,16 @@ public:
Texture **textures;
};
// The members in here must respect uniform buffer alignment/padding rules.
struct BuiltinUniformData
{
Matrix4 transformMatrix;
Matrix4 projectionMatrix;
Vector4 normalMatrix[3]; // 3x3 matrix padded to an array of 3 vector4s.
Vector4 screenSizeParams;
Colorf constantColor;
};
// Pointer to currently active Shader.
static Shader *current;