[Bf-blender-cvs] [55022884ba6] blender2.8: DRW: Add shading group state disable.

Clément Foucault noreply at git.blender.org
Tue Jul 11 12:46:05 CEST 2017


Commit: 55022884ba690bc35b906053e933b9d4097356c1
Author: Clément Foucault
Date:   Mon Jul 10 11:26:16 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB55022884ba690bc35b906053e933b9d4097356c1

DRW: Add shading group state disable.

This is a way to remove some state flag per Shading Group.

===================================================================

M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index e6f05542357..eeebfd93f40 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -297,6 +297,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
 void DRW_shgroup_set_instance_count(DRWShadingGroup *shgroup, int count);
 
 void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state);
+void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state);
 void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size);
 
 void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 9ca3d30808b..08ae6bf06d6 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -239,6 +239,7 @@ struct DRWShadingGroup {
 	DRWInterface *interface;         /* Uniforms pointers */
 	ListBase calls;                  /* DRWCall or DRWCallDynamic depending of type */
 	DRWState state_extra;            /* State changes for this batch only (or'd with the pass's state) */
+	DRWState state_extra_disable;    /* State changes for this batch only (and'd with the pass's state) */
 	int type;
 
 	Gwn_Batch *instance_geom;  /* Geometry to instance */
@@ -701,6 +702,7 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
 	shgroup->shader = shader;
 	shgroup->interface = DRW_interface_create(shader);
 	shgroup->state_extra = 0;
+	shgroup->state_extra_disable = ~0x0;
 	shgroup->batch_geom = NULL;
 	shgroup->instance_geom = NULL;
 
@@ -991,14 +993,17 @@ void DRW_shgroup_set_instance_count(DRWShadingGroup *shgroup, int count)
 /**
  * State is added to #Pass.state while drawing.
  * Use to temporarily enable draw options.
- *
- * Currently there is no way to disable (could add if needed).
  */
 void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
 {
 	shgroup->state_extra |= state;
 }
 
+void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
+{
+	shgroup->state_extra_disable &= ~state;
+}
+
 void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int size)
 {
 	DRW_interface_attrib(shgroup, name, DRW_ATTRIB_FLOAT, size, false);
@@ -1699,7 +1704,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
 		shgroup_dynamic_batch_from_calls(shgroup);
 	}
 
-	DRW_state_set(pass_state | shgroup->state_extra);
+	DRW_state_set((pass_state & shgroup->state_extra_disable) | shgroup->state_extra);
 
 	/* Binding Uniform */
 	/* Don't check anything, Interface should already contain the least uniform as possible */




More information about the Bf-blender-cvs mailing list