diff options
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 68 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_anim_viz.c | 2 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_hair.c | 4 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 34 |
6 files changed, 49 insertions, 65 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index cf7e9521053..6d290f9a2d3 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -313,43 +313,47 @@ void DRW_shader_free(struct GPUShader *shader); /* Batches */ typedef enum { + /** Wrtie mask */ DRW_STATE_WRITE_DEPTH = (1 << 0), DRW_STATE_WRITE_COLOR = (1 << 1), - DRW_STATE_DEPTH_ALWAYS = (1 << 2), - DRW_STATE_DEPTH_LESS = (1 << 3), - DRW_STATE_DEPTH_LESS_EQUAL = (1 << 4), - DRW_STATE_DEPTH_EQUAL = (1 << 5), - DRW_STATE_DEPTH_GREATER = (1 << 6), - DRW_STATE_DEPTH_GREATER_EQUAL = (1 << 7), - DRW_STATE_CULL_BACK = (1 << 8), - DRW_STATE_CULL_FRONT = (1 << 9), - DRW_STATE_WIRE = (1 << 10), /* TODO remove */ - DRW_STATE_POINT = (1 << 11), /* TODO remove */ + DRW_STATE_WRITE_STENCIL = (1 << 2), + DRW_STATE_WRITE_STENCIL_SHADOW_PASS = (1 << 3), + DRW_STATE_WRITE_STENCIL_SHADOW_FAIL = (1 << 4), + + /** Depth test */ + DRW_STATE_DEPTH_ALWAYS = (1 << 5), + DRW_STATE_DEPTH_LESS = (1 << 6), + DRW_STATE_DEPTH_LESS_EQUAL = (1 << 7), + DRW_STATE_DEPTH_EQUAL = (1 << 8), + DRW_STATE_DEPTH_GREATER = (1 << 9), + DRW_STATE_DEPTH_GREATER_EQUAL = (1 << 10), + /** Culling test */ + DRW_STATE_CULL_BACK = (1 << 11), + DRW_STATE_CULL_FRONT = (1 << 12), + /** Stencil test */ + DRW_STATE_STENCIL_EQUAL = (1 << 13), + DRW_STATE_STENCIL_NEQUAL = (1 << 14), + + /** Blend state */ + DRW_STATE_ADDITIVE = (1 << 15), + /** Same as additive but let alpha accumulate without premult. */ + DRW_STATE_ADDITIVE_FULL = (1 << 16), + DRW_STATE_BLEND = (1 << 17), + /** Use that if color is already premult by alpha. */ + DRW_STATE_BLEND_PREMUL = (1 << 18), + DRW_STATE_BLEND_PREMUL_UNDER = (1 << 19), + DRW_STATE_BLEND_OIT = (1 << 20), + DRW_STATE_MULTIPLY = (1 << 21), + + DRW_STATE_CLIP_PLANES = (1 << 22), + DRW_STATE_WIRE_SMOOTH = (1 << 23), + DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 24), /** Polygon offset. Does not work with lines and points. */ - DRW_STATE_OFFSET_POSITIVE = (1 << 12), + DRW_STATE_OFFSET_POSITIVE = (1 << 25), /** Polygon offset. Does not work with lines and points. */ - DRW_STATE_OFFSET_NEGATIVE = (1 << 13), - DRW_STATE_WIRE_WIDE = (1 << 14), - DRW_STATE_BLEND = (1 << 15), - DRW_STATE_ADDITIVE = (1 << 16), - DRW_STATE_MULTIPLY = (1 << 17), - DRW_STATE_BLEND_PREMUL_UNDER = (1 << 18), - DRW_STATE_CLIP_PLANES = (1 << 19), - /** Same as DRW_STATE_ADDITIVE but let alpha accumulate without premult. */ - DRW_STATE_ADDITIVE_FULL = (1 << 20), - /** Use that if color is already premult by alpha. */ - DRW_STATE_BLEND_PREMUL = (1 << 21), - DRW_STATE_WIRE_SMOOTH = (1 << 22), - DRW_STATE_TRANS_FEEDBACK = (1 << 23), - DRW_STATE_BLEND_OIT = (1 << 24), - DRW_STATE_FIRST_VERTEX_CONVENTION = (1 << 25), - - DRW_STATE_WRITE_STENCIL = (1 << 27), - DRW_STATE_WRITE_STENCIL_SHADOW_PASS = (1 << 28), - DRW_STATE_WRITE_STENCIL_SHADOW_FAIL = (1 << 29), - DRW_STATE_STENCIL_EQUAL = (1 << 30), - DRW_STATE_STENCIL_NEQUAL = (1 << 31), + DRW_STATE_OFFSET_NEGATIVE = (1 << 26), } DRWState; + #define DRW_STATE_DEFAULT \ (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL) #define DRW_STATE_RASTERIZER_ENABLED \ diff --git a/source/blender/draw/intern/draw_anim_viz.c b/source/blender/draw/intern/draw_anim_viz.c index 31d7a45ede9..72459309133 100644 --- a/source/blender/draw/intern/draw_anim_viz.c +++ b/source/blender/draw/intern/draw_anim_viz.c @@ -139,7 +139,7 @@ static void MPATH_cache_init(void *vedata) } { - DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_POINT; + DRWState state = DRW_STATE_WRITE_COLOR; psl->points = DRW_pass_create("Motionpath Point Pass", state); } } diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 51f097e79d8..e1c86790cdc 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -385,7 +385,6 @@ struct DRWCallBuffer *buffer_groundpoints_uniform_color(DRWPass *pass, DRWShadingGroup *grp = DRW_shgroup_create(sh, pass); DRW_shgroup_uniform_vec4(grp, "color", color, 1); - DRW_shgroup_state_enable(grp, DRW_STATE_POINT); if (sh_cfg == GPU_SHADER_CFG_CLIPPED) { DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d); } diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 6dee25fabae..50819f6a522 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -98,9 +98,9 @@ static GPUShader *hair_refine_shader_get(ParticleRefineShader sh) void DRW_hair_init(void) { #ifdef USE_TRANSFORM_FEEDBACK - g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_TRANS_FEEDBACK); + g_tf_pass = DRW_pass_create("Update Hair Pass", 0); #else - g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_POINT); + g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_WRITE_COLOR); #endif } diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index e68f3e4b9e1..5c9f49e4ee5 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1729,16 +1729,15 @@ void DRW_draw_render_loop_ex(struct Depsgraph *depsgraph, } DRW_draw_callbacks_post_scene(); + DRW_state_reset(); + if (DST.draw_ctx.evil_C) { - DRW_state_reset(); ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.ar, REGION_DRAW_POST_VIEW); /* Callback can be nasty and do whatever they want with the state. * Don't trust them! */ DRW_state_reset(); } - DRW_state_reset(); - drw_debug_draw(); GPU_depth_test(false); diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index bb4e807bb2d..2c29ce343dd 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -168,18 +168,11 @@ void drw_state_set(DRWState state) /* Wire Width */ { int test; - if (CHANGED_ANY_STORE_VAR(DRW_STATE_WIRE | DRW_STATE_WIRE_WIDE | DRW_STATE_WIRE_SMOOTH, - test)) { - if (test & DRW_STATE_WIRE_WIDE) { - GPU_line_width(3.0f); - } - else if (test & DRW_STATE_WIRE_SMOOTH) { + if ((test = CHANGED_TO(DRW_STATE_WIRE_SMOOTH))) { + if (test == 1) { GPU_line_width(2.0f); GPU_line_smooth(true); } - else if (test & DRW_STATE_WIRE) { - GPU_line_width(1.0f); - } else { GPU_line_width(1.0f); GPU_line_smooth(false); @@ -187,20 +180,6 @@ void drw_state_set(DRWState state) } } - /* Points Size */ - { - int test; - if ((test = CHANGED_TO(DRW_STATE_POINT))) { - if (test == 1) { - GPU_enable_program_point_size(); - glPointSize(5.0f); - } - else { - GPU_disable_program_point_size(); - } - } - } - /* Blending (all buffer) */ { int test; @@ -401,6 +380,9 @@ void DRW_state_reset(void) { DRW_state_reset_ex(DRW_STATE_DEFAULT); + GPU_point_size(5); + GPU_enable_program_point_size(); + /* Reset blending function */ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } @@ -689,8 +671,8 @@ bool DRW_culling_sphere_test(BoundSphere *bsphere) /* TODO we could test against the inscribed sphere of the frustum to early out positively. */ /* Test against the 6 frustum planes. */ - /* TODO order planes with sides first then far then near clip. Should be better culling heuristic - * when sculpting. */ + /* TODO order planes with sides first then far then near clip. Should be better culling + * heuristic when sculpting. */ for (int p = 0; p < 6; p++) { float dist = plane_point_side_v3(DST.clipping.frustum_planes[p], bsphere->center); if (dist < -bsphere->radius) { @@ -1101,7 +1083,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) DST.shader = shgroup->shader; } - if ((pass_state & DRW_STATE_TRANS_FEEDBACK) != 0 && (shgroup->tfeedback_target != NULL)) { + if (shgroup->tfeedback_target != NULL) { use_tfeedback = GPU_shader_transform_feedback_enable(shgroup->shader, shgroup->tfeedback_target->vbo_id); } |