From 10b34ad69724a0b69c30239abb6cb309bb9c8e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 4 Jun 2020 14:15:25 +0200 Subject: 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. --- source/blender/gpu/intern/gpu_shader.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'source/blender/gpu/intern/gpu_shader.c') diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 651410cf333..8c03567b95f 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -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); } } -- cgit v1.2.3