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/GPU_shader_interface.h | |
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/GPU_shader_interface.h')
-rw-r--r-- | source/blender/gpu/GPU_shader_interface.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 7875ac35fae..28ee162bdbd 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -92,9 +92,8 @@ typedef struct GPUShaderInterface { uint16_t enabled_ubo_mask; uint64_t enabled_tex_mask; /** Opengl Location of builtin uniforms. Fast access, no lookup needed. */ - /* TODO replace by location only array. */ - GPUShaderInput builtins[GPU_NUM_UNIFORMS]; - GPUShaderInput builtin_blocks[GPU_NUM_UNIFORM_BLOCKS]; + int32_t builtins[GPU_NUM_UNIFORMS]; + int32_t builtin_blocks[GPU_NUM_UNIFORM_BLOCKS]; /** Flat array. In this order: Attributes, Ubos, Uniforms. */ GPUShaderInput inputs[0]; } GPUShaderInterface; @@ -103,10 +102,10 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); void GPU_shaderinterface_discard(GPUShaderInterface *); const GPUShaderInput *GPU_shaderinterface_uniform(const GPUShaderInterface *, const char *name); -const GPUShaderInput *GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *shaderface, - GPUUniformBuiltin builtin); -const GPUShaderInput *GPU_shaderinterface_block_builtin(const GPUShaderInterface *shaderface, - GPUUniformBlockBuiltin builtin); +int32_t GPU_shaderinterface_uniform_builtin(const GPUShaderInterface *shaderface, + GPUUniformBuiltin builtin); +int32_t GPU_shaderinterface_block_builtin(const GPUShaderInterface *shaderface, + GPUUniformBlockBuiltin builtin); const GPUShaderInput *GPU_shaderinterface_ubo(const GPUShaderInterface *, const char *name); const GPUShaderInput *GPU_shaderinterface_attr(const GPUShaderInterface *, const char *name); |