OpenJK icon indicating copy to clipboard operation
OpenJK copied to clipboard

AZDO: Move constants into constant buffers

Open xycaleth opened this issue 9 years ago • 0 comments

There are a lot of cases where uniform data is bound multiple times to multiple shaders using glUniformXXX. Each driver call incur some cost. We can eliminate a large number of these calls by storing arrays of data in uniform buffers. Each object then has some index in a regular uniform to fetch the data it needs. For example:

struct ShaderData {
  vec4 color;
  vec4 foo;
  vec2 data;
};

layout(std140) uniform AllShaderData {
  ShaderData u_ShaderData[1024];
}

uniform int u_ShaderIndex;

void main() {
  gl_FragColor = u_ShaderData[u_ShaderIndex].color;
}

xycaleth avatar May 01 '16 09:05 xycaleth