diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-02 13:23:11 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-02 17:46:38 +0300 |
commit | 38cfcdd51bd26dfb0e181a8023f32d784144490e (patch) | |
tree | a1f28eb6fd484d2e0624f717e761601977a295ee /source | |
parent | cb59ef10320e9db95548d9f1586ed7ee7ebafc78 (diff) |
DRW: Remove defered uniform creation
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 13 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 7 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 25 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 7 |
4 files changed, 2 insertions, 50 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 74bb596454b..7432766a172 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -112,17 +112,6 @@ static ListBase DRW_engines = {NULL, NULL}; static void drw_state_prepare_clean_for_draw(DRWManager *dst) { memset(dst, 0x0, offsetof(DRWManager, gl_context)); - - /* Maybe not the best place for this. */ - if (!DST.uniform_names.buffer) { - DST.uniform_names.buffer = MEM_callocN(DRW_UNIFORM_BUFFER_NAME, "Name Buffer"); - DST.uniform_names.buffer_len = DRW_UNIFORM_BUFFER_NAME; - } - else if (DST.uniform_names.buffer_len > DRW_UNIFORM_BUFFER_NAME) { - DST.uniform_names.buffer = MEM_reallocN(DST.uniform_names.buffer, DRW_UNIFORM_BUFFER_NAME); - DST.uniform_names.buffer_len = DRW_UNIFORM_BUFFER_NAME; - } - DST.uniform_names.buffer_ofs = 0; } /* This function is used to reset draw manager to a state @@ -2737,8 +2726,6 @@ void DRW_engines_free(void) DRW_TEXTURE_FREE_SAFE(G_draw.ramp); DRW_TEXTURE_FREE_SAFE(G_draw.weight_ramp); - MEM_SAFE_FREE(DST.uniform_names.buffer); - if (DST.draw_list) { GPU_draw_list_discard(DST.draw_list); } diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index a27af84fa02..796abde140d 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -308,7 +308,6 @@ struct DRWUniform { uint32_t type : 5; /* DRWUniformType */ uint32_t length : 5; /* cannot be more than 16 */ uint32_t arraysize : 5; /* cannot be more than 16 too */ - uint32_t name_ofs : 17; /* name offset in name buffer. */ }; struct DRWShadingGroup { @@ -559,12 +558,6 @@ typedef struct DRWManager { DRWDebugLine *lines; DRWDebugSphere *spheres; } debug; - - struct { - char *buffer; - uint buffer_len; - uint buffer_ofs; - } uniform_names; } DRWManager; extern DRWManager DST; /* TODO: get rid of this and allow multi-threaded rendering. */ diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index aa401bcffa5..e7a74734f19 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -232,7 +232,7 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup, location = GPU_shader_get_uniform_block(shgroup->shader, name); } else { - location = GPU_shader_get_uniform(shgroup->shader, name); + location = GPU_shader_get_uniform_ensure(shgroup->shader, name); } if (location == -1) { @@ -244,28 +244,7 @@ static void drw_shgroup_uniform(DRWShadingGroup *shgroup, BLI_assert(arraysize > 0 && arraysize <= 16); BLI_assert(length >= 0 && length <= 16); - DRWUniform *uni = drw_shgroup_uniform_create_ex( - shgroup, location, type, value, length, arraysize); - - /* If location is -2, the uniform has not yet been queried. - * We save the name for query just before drawing. */ - if (location == -2 || DRW_DEBUG_USE_UNIFORM_NAME) { - int ofs = DST.uniform_names.buffer_ofs; - int max_len = DST.uniform_names.buffer_len - ofs; - size_t len = strlen(name) + 1; - - if (len >= max_len) { - 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); - } - - char *dst = DST.uniform_names.buffer + ofs; - memcpy(dst, name, len); /* Copies NULL terminator. */ - - DST.uniform_names.buffer_ofs += len; - uni->name_ofs = ofs; - } + drw_shgroup_uniform_create_ex(shgroup, location, type, value, length, arraysize); } void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex) diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index 6c62d4d2405..cff4df89219 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -931,13 +931,6 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup, for (int i = 0; i < unichunk->uniform_used; i++, uni++) { GPUTexture *tex; GPUUniformBuffer *ubo; - if (uni->location == -2) { - uni->location = GPU_shader_get_uniform_ensure(shgroup->shader, - DST.uniform_names.buffer + uni->name_ofs); - if (uni->location == -1) { - continue; - } - } const void *data = uni->pvalue; if (ELEM(uni->type, DRW_UNIFORM_INT_COPY, DRW_UNIFORM_FLOAT_COPY)) { data = uni->fvalue; |