GPUShaderInterface: Change builtin array to array of location/bind

This reduce the base size of the shaderinterface from 400 to 136 bytes.
Improves memory usage and cache coherency when querying a lot of uniforms
at once.
This commit is contained in:
2020-06-04 14:15:25 +02:00
parent 5837de6879
commit 10b34ad697
5 changed files with 41 additions and 53 deletions

View File

@@ -735,15 +735,13 @@ int GPU_shader_get_uniform(GPUShader *shader, const char *name)
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
{
BLI_assert(shader && shader->program);
const GPUShaderInput *uniform = GPU_shaderinterface_uniform_builtin(shader->interface, builtin);
return uniform->location;
return GPU_shaderinterface_uniform_builtin(shader->interface, builtin);
}
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
{
BLI_assert(shader && shader->program);
const GPUShaderInput *uniform = GPU_shaderinterface_block_builtin(shader->interface, builtin);
return uniform->binding;
return GPU_shaderinterface_block_builtin(shader->interface, builtin);
}
int GPU_shader_get_uniform_block(GPUShader *shader, const char *name)
@@ -856,10 +854,9 @@ void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value)
void GPU_shader_set_srgb_uniform(const GPUShaderInterface *interface)
{
const GPUShaderInput *srgb_uniform = GPU_shaderinterface_uniform_builtin(
interface, GPU_UNIFORM_SRGB_TRANSFORM);
if (srgb_uniform) {
glUniform1i(srgb_uniform->location, g_shader_builtin_srgb_transform);
int32_t loc = GPU_shaderinterface_uniform_builtin(interface, GPU_UNIFORM_SRGB_TRANSFORM);
if (loc != -1) {
glUniform1i(loc, g_shader_builtin_srgb_transform);
}
}