DRW: Remove defered uniform creation
This commit is contained in:
parent
cb59ef1032
commit
38cfcdd51b
@ -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);
|
||||
}
|
||||
|
@ -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. */
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user