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
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-04-18 15:04:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-04-18 15:04:00 +0300
commita229ca8f4826c6aa1867c0abf283fa9e46e32368 (patch)
tree0daa18c7f2fb35e1101ea330d3ed08ef76a504be /intern
parentedcf128ce279e1fa721a1ba16fc3a3dfeac4833b (diff)
Garwain: fix ShaderInterface buffer shrinking
Diffstat (limited to 'intern')
-rw-r--r--intern/gawain/src/shader_interface.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/intern/gawain/src/shader_interface.c b/intern/gawain/src/shader_interface.c
index 2d0eb353aaf..4a07f954c36 100644
--- a/intern/gawain/src/shader_interface.c
+++ b/intern/gawain/src/shader_interface.c
@@ -202,19 +202,21 @@ ShaderInterface* ShaderInterface_create(GLint program)
if (name_buffer_used < name_buffer_len)
{
// realloc shaderface to shrink name buffer
- ShaderInterface* orig_pointer = shaderface;
- shaderface = realloc(shaderface, offsetof(ShaderInterface, inputs) + input_ct * sizeof(ShaderInput) + name_buffer_used);
- const ptrdiff_t delta = (char*)shaderface - (char*)orig_pointer;
+ const size_t shaderface_alloc =
+ offsetof(ShaderInterface, inputs) + (input_ct * sizeof(ShaderInput)) + name_buffer_used;
+ const char* shaderface_orig_start = (const char*)shaderface;
+ const char* shaderface_orig_end = &shaderface_orig_start[shaderface_alloc];
+ shaderface = realloc(shaderface, shaderface_alloc);
+ const ptrdiff_t delta = (char*)shaderface - shaderface_orig_start;
if (delta)
{
// each input->name will need adjustment (except static built-in names)
- const uint32_t input_ct_new = shaderface->uniform_ct + shaderface->attrib_ct;
- for (uint32_t i = 0; i < input_ct_new; ++i)
+ for (uint32_t i = 0; i < input_ct; ++i)
{
ShaderInput* input = shaderface->inputs + i;
- if (input->builtin_type == UNIFORM_CUSTOM || input->builtin_type == UNIFORM_NONE)
+ if (input->name >= shaderface_orig_start && input->name < shaderface_orig_end)
input->name += delta;
}
}