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
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-05-19 17:54:01 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-22 14:29:04 +0300
commit2b1da51b2fc2482411c10ce5c387d3b1c6ee87b0 (patch)
treee18c697a7c28dcb31396c64a9c27314837f1b5ad /source/blender/draw/intern/draw_manager_exec.c
parentb82afb4b016c5924a5cc99523f0157b9af5cc384 (diff)
Cleanup: DRW: Refactor code for better readability and simplification
- Remove DST.frontface and DST.backface. - Separate uniform update into its own function draw_update_uniforms.
Diffstat (limited to 'source/blender/draw/intern/draw_manager_exec.c')
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c128
1 files changed, 65 insertions, 63 deletions
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 2c29ce343dd..49927b74e72 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -1023,6 +1023,67 @@ static void release_ubo_slots(bool with_persist)
}
}
+static void draw_update_uniforms(DRWShadingGroup *shgroup)
+{
+ for (DRWUniform *uni = shgroup->uniforms; uni; uni = uni->next) {
+ 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;
+ }
+ switch (uni->type) {
+ case DRW_UNIFORM_INT_COPY:
+ case DRW_UNIFORM_INT:
+ GPU_shader_uniform_vector_int(
+ shgroup->shader, uni->location, uni->length, uni->arraysize, data);
+ break;
+ case DRW_UNIFORM_FLOAT_COPY:
+ case DRW_UNIFORM_FLOAT:
+ GPU_shader_uniform_vector(
+ shgroup->shader, uni->location, uni->length, uni->arraysize, data);
+ break;
+ case DRW_UNIFORM_TEXTURE:
+ tex = (GPUTexture *)uni->pvalue;
+ BLI_assert(tex);
+ bind_texture(tex, BIND_TEMP);
+ GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
+ break;
+ case DRW_UNIFORM_TEXTURE_PERSIST:
+ tex = (GPUTexture *)uni->pvalue;
+ BLI_assert(tex);
+ bind_texture(tex, BIND_PERSIST);
+ GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
+ break;
+ case DRW_UNIFORM_TEXTURE_REF:
+ tex = *((GPUTexture **)uni->pvalue);
+ BLI_assert(tex);
+ bind_texture(tex, BIND_TEMP);
+ GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
+ break;
+ case DRW_UNIFORM_BLOCK:
+ ubo = (GPUUniformBuffer *)uni->pvalue;
+ bind_ubo(ubo, BIND_TEMP);
+ GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
+ break;
+ case DRW_UNIFORM_BLOCK_PERSIST:
+ ubo = (GPUUniformBuffer *)uni->pvalue;
+ bind_ubo(ubo, BIND_PERSIST);
+ GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
+ break;
+ }
+ }
+
+ BLI_assert(ubo_bindings_validate(shgroup));
+}
+
BLI_INLINE bool draw_select_do_call(DRWShadingGroup *shgroup, DRWCall *call)
{
#ifdef USE_GPU_SELECT
@@ -1070,8 +1131,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
{
BLI_assert(shgroup->shader);
- GPUTexture *tex;
- GPUUniformBuffer *ubo;
const bool shader_changed = (DST.shader != shgroup->shader);
bool use_tfeedback = false;
@@ -1094,62 +1153,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
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) {
- 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;
- }
- switch (uni->type) {
- case DRW_UNIFORM_INT_COPY:
- case DRW_UNIFORM_INT:
- GPU_shader_uniform_vector_int(
- shgroup->shader, uni->location, uni->length, uni->arraysize, data);
- break;
- case DRW_UNIFORM_FLOAT_COPY:
- case DRW_UNIFORM_FLOAT:
- GPU_shader_uniform_vector(
- shgroup->shader, uni->location, uni->length, uni->arraysize, data);
- break;
- case DRW_UNIFORM_TEXTURE:
- tex = (GPUTexture *)uni->pvalue;
- BLI_assert(tex);
- bind_texture(tex, BIND_TEMP);
- GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
- break;
- case DRW_UNIFORM_TEXTURE_PERSIST:
- tex = (GPUTexture *)uni->pvalue;
- BLI_assert(tex);
- bind_texture(tex, BIND_PERSIST);
- GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
- break;
- case DRW_UNIFORM_TEXTURE_REF:
- tex = *((GPUTexture **)uni->pvalue);
- BLI_assert(tex);
- bind_texture(tex, BIND_TEMP);
- GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
- break;
- case DRW_UNIFORM_BLOCK:
- ubo = (GPUUniformBuffer *)uni->pvalue;
- bind_ubo(ubo, BIND_TEMP);
- GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
- break;
- case DRW_UNIFORM_BLOCK_PERSIST:
- ubo = (GPUUniformBuffer *)uni->pvalue;
- bind_ubo(ubo, BIND_PERSIST);
- GPU_shader_uniform_buffer(shgroup->shader, uni->location, ubo);
- break;
- }
- }
-
- BLI_assert(ubo_bindings_validate(shgroup));
+ draw_update_uniforms(shgroup);
/* Rendering Calls */
{
@@ -1159,10 +1163,8 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
/* OPTI/IDEA(clem): Do this preparation in another thread. */
draw_visibility_eval(call->state);
- draw_matrices_model_prepare(call->state);
- if ((call->state->flag & DRW_CALL_CULLED) != 0 &&
- (call->state->flag & DRW_CALL_BYPASS_CULLING) == 0) {
+ if ((call->state->flag & DRW_CALL_CULLED) != 0) {
continue;
}
@@ -1175,7 +1177,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
/* Negative scale objects */
bool neg_scale = call->state->flag & DRW_CALL_NEGSCALE;
if (neg_scale != prev_neg_scale) {
- glFrontFace((neg_scale) ? DST.backface : DST.frontface);
+ glFrontFace((neg_scale) ? GL_CW : GL_CCW);
prev_neg_scale = neg_scale;
}
@@ -1194,7 +1196,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
}
}
/* Reset state */
- glFrontFace(DST.frontface);
+ glFrontFace(GL_CCW);
}
if (use_tfeedback) {