diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-04 15:15:25 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-04 15:17:06 +0300 |
commit | 10b34ad69724a0b69c30239abb6cb309bb9c8e66 (patch) | |
tree | 85f377a52901450d7efe5a0baf55138cdb80f1b8 /source/blender/gpu/intern/gpu_shader.c | |
parent | 5837de6879f424a0a26ad787b89f1ec98c91c3c6 (diff) |
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.
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 13 |
1 files changed, 5 insertions, 8 deletions
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); } } |