Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-10-05 15:16:37 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-10-05 15:16:37 +0300
commite1e452c0629ee74b527439b64681396c71afe4e1 (patch)
treed2814344242de3d48e1f728064015f8ae7b8ef0e /source/blender/draw/intern
parent0b5bdc426588e1fed41c4d71ec06bdf9f2180b69 (diff)
Draw manager: Avoid unneeded memory malloc/free when attempting to create missing uniform
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/draw_manager.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 7f600718dd1..05b8f1657c4 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -685,31 +685,32 @@ static DRWInterface *DRW_interface_duplicate(DRWInterface *interface_src)
static void DRW_interface_uniform(DRWShadingGroup *shgroup, const char *name,
DRWUniformType type, const void *value, int length, int arraysize)
{
- DRWUniform *uni = MEM_mallocN(sizeof(DRWUniform), "DRWUniform");
-
+ int location;
if (type == DRW_UNIFORM_BLOCK) {
- uni->location = GPU_shader_get_uniform_block(shgroup->shader, name);
+ location = GPU_shader_get_uniform_block(shgroup->shader, name);
}
else {
- uni->location = GPU_shader_get_uniform(shgroup->shader, name);
+ location = GPU_shader_get_uniform(shgroup->shader, name);
}
- BLI_assert(arraysize > 0);
-
- uni->type = type;
- uni->value = value;
- uni->length = length;
- uni->arraysize = arraysize;
-
- if (uni->location == -1) {
+ if (location == -1) {
if (G.debug & G_DEBUG)
fprintf(stderr, "Uniform '%s' not found!\n", name);
/* Nice to enable eventually, for now eevee uses uniforms that might not exist. */
// BLI_assert(0);
- MEM_freeN(uni);
return;
}
+ DRWUniform *uni = MEM_mallocN(sizeof(DRWUniform), "DRWUniform");
+
+ BLI_assert(arraysize > 0);
+
+ uni->location = location;
+ uni->type = type;
+ uni->value = value;
+ uni->length = length;
+ uni->arraysize = arraysize;
+
BLI_addtail(&shgroup->interface->uniforms, uni);
}