DRW: Remove unecessary GL calls
This commit is contained in:
parent
6ee5e6a333
commit
f8c857ad72
Notes:
blender-bot
2023-02-14 07:25:51 +01:00
Referenced by commit 4b89bf88c7
, Revert "DRW: Remove unecessary GL calls"
|
@ -47,6 +47,30 @@ GlobalsUboStorage ts;
|
|||
struct GPUUniformBuffer *globals_ubo = NULL;
|
||||
struct GPUTexture *globals_ramp = NULL;
|
||||
|
||||
static struct GPUTexture *create_weight_ramp_texture(void)
|
||||
{
|
||||
ColorBand ramp = {0};
|
||||
float *colors;
|
||||
int col_size;
|
||||
|
||||
ramp.tot = 3;
|
||||
ramp.data[0].b = 1.0f;
|
||||
ramp.data[1].g = 1.0f;
|
||||
ramp.data[2].r = 1.0f;
|
||||
ramp.data[0].a = ramp.data[1].a = ramp.data[2].a = 1.0f;
|
||||
ramp.data[0].pos = 0.0f;
|
||||
ramp.data[1].pos = 0.5f;
|
||||
ramp.data[2].pos = 1.0f;
|
||||
|
||||
BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
|
||||
|
||||
struct GPUTexture *tex = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
|
||||
|
||||
MEM_freeN(colors);
|
||||
|
||||
return tex;
|
||||
}
|
||||
|
||||
void DRW_globals_update(void)
|
||||
{
|
||||
UI_GetThemeColor4fv(TH_WIRE, ts.colorWire);
|
||||
|
@ -131,29 +155,9 @@ void DRW_globals_update(void)
|
|||
|
||||
DRW_uniformbuffer_update(globals_ubo, &ts);
|
||||
|
||||
ColorBand ramp = {0};
|
||||
float *colors;
|
||||
int col_size;
|
||||
|
||||
ramp.tot = 3;
|
||||
ramp.data[0].a = 1.0f;
|
||||
ramp.data[0].b = 1.0f;
|
||||
ramp.data[0].pos = 0.0f;
|
||||
ramp.data[1].a = 1.0f;
|
||||
ramp.data[1].g = 1.0f;
|
||||
ramp.data[1].pos = 0.5f;
|
||||
ramp.data[2].a = 1.0f;
|
||||
ramp.data[2].r = 1.0f;
|
||||
ramp.data[2].pos = 1.0f;
|
||||
|
||||
BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
|
||||
|
||||
if (globals_ramp) {
|
||||
GPU_texture_free(globals_ramp);
|
||||
if (globals_ramp == NULL) {
|
||||
globals_ramp = create_weight_ramp_texture();
|
||||
}
|
||||
globals_ramp = GPU_texture_create_1D(col_size, GPU_RGBA8, colors, NULL);
|
||||
|
||||
MEM_freeN(colors);
|
||||
}
|
||||
|
||||
/* ********************************* SHGROUP ************************************* */
|
||||
|
|
|
@ -263,7 +263,7 @@ void drw_state_set(DRWState state)
|
|||
}
|
||||
else {
|
||||
glDisable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE); /* Don't multiply incoming color by alpha. */
|
||||
// glBlendFunc(GL_ONE, GL_ONE); /* Don't multiply incoming color by alpha. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1023,8 +1023,11 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
release_ubo_slots(shader_changed);
|
||||
release_texture_slots(shader_changed);
|
||||
|
||||
drw_state_set((pass_state & shgroup->state_extra_disable) | shgroup->state_extra);
|
||||
drw_stencil_set(shgroup->stencil_mask);
|
||||
/* Only set the state if there is something to draw. */
|
||||
if (!DRW_shgroup_is_empty(shgroup)) {
|
||||
drw_state_set((pass_state & shgroup->state_extra_disable) | shgroup->state_extra);
|
||||
drw_stencil_set(shgroup->stencil_mask);
|
||||
}
|
||||
|
||||
/* Binding Uniform */
|
||||
for (DRWUniform *uni = shgroup->uniforms; uni; uni = uni->next) {
|
||||
|
@ -1234,9 +1237,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
if (use_tfeedback) {
|
||||
GPU_shader_transform_feedback_disable(shgroup->shader);
|
||||
}
|
||||
|
||||
/* TODO: remove, (currently causes alpha issue with sculpt, need to investigate) */
|
||||
DRW_state_reset();
|
||||
}
|
||||
|
||||
static void drw_update_view(void)
|
||||
|
@ -1275,6 +1275,10 @@ static void drw_draw_pass_ex(DRWPass *pass, DRWShadingGroup *start_group, DRWSha
|
|||
|
||||
BLI_assert(DST.buffer_finish_called && "DRW_render_instance_buffer_finish had not been called before drawing");
|
||||
|
||||
if (DRW_pass_is_empty(pass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
drw_update_view();
|
||||
|
||||
drw_state_set(pass->state);
|
||||
|
|
Loading…
Reference in New Issue