GPU: double uniform names buffer size
authorJacques Lucke <mail@jlucke.com>
Tue, 21 May 2019 15:14:38 +0000 (17:14 +0200)
committerJacques Lucke <mail@jlucke.com>
Tue, 21 May 2019 15:17:56 +0000 (17:17 +0200)
Adding a constant yields quadratic time complexity which can
have quite a big impact on some scenes.

I used the file from T64901 for testing.
In the test file, the time it took to execute `wm_draw_update`
changed from `0.60s` to `0.51s`.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D4916

source/blender/draw/intern/draw_manager.h
source/blender/draw/intern/draw_manager_data.c

index b5dc882..8927d2e 100644 (file)
@@ -45,7 +45,6 @@
 
 #define DRW_DEBUG_USE_UNIFORM_NAME 0
 #define DRW_UNIFORM_BUFFER_NAME 64
-#define DRW_UNIFORM_BUFFER_NAME_INC 1024
 
 /* ------------ Profiling --------------- */
 
index f8ef1bc..837b68c 100644 (file)
@@ -142,7 +142,7 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup,
     size_t len = strlen(name) + 1;
 
     if (len >= max_len) {
-      DST.uniform_names.buffer_len += DRW_UNIFORM_BUFFER_NAME_INC;
+      DST.uniform_names.buffer_len += MAX2(DST.uniform_names.buffer_len, len);
       DST.uniform_names.buffer = MEM_reallocN(DST.uniform_names.buffer,
                                               DST.uniform_names.buffer_len);
     }