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-06-22 19:40:43 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-08-17 15:48:49 +0300
commit673742001a91fd04d239987cfa982830e6b7d9d1 (patch)
tree8ff85aa4e344810c40df933b2f1b7e37bd4c7af9
parent8d0713e8d21ed3cbe093fadf9f42b833c68a41f8 (diff)
DRW: Add DRWCommandSetStencil
Now multiple stencils can be set inside a shgroup. Should not change the previous behavior as all usage of DRW_shgroup_stencil_mask was done at shgroup creation.
-rw-r--r--source/blender/draw/intern/draw_manager.h13
-rw-r--r--source/blender/draw/intern/draw_manager_data.c14
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c4
3 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index c0fd361dbc2..646eb27a76e 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -156,6 +156,7 @@ typedef enum {
DRW_CMD_DRAW_INSTANCE = 2,
DRW_CMD_DRAW_PROCEDURAL = 3,
/* Other Commands */
+ DRW_CMD_STENCIL = 14,
DRW_CMD_SELECTID = 15,
/* Needs to fit in 4bits */
} eDRWCommandType;
@@ -189,12 +190,18 @@ typedef struct DRWCommandSetSelectID {
uint select_id;
} DRWCommandSetSelectID;
+typedef struct DRWCommandSetStencil {
+ uint mask;
+} DRWCommandSetStencil;
+
typedef union DRWCommand {
/* Only sortable type */
DRWCommandDraw draw;
DRWCommandDrawRange range;
DRWCommandDrawInstance instance;
DRWCommandDrawProcedural procedural;
+ /* Stencil */
+ DRWCommandSetStencil stencil;
/* Select */
DRWCommandSetSelectID select_id;
} DRWCommand;
@@ -253,6 +260,8 @@ struct DRWShadingGroup {
struct DRWUniformChunk *uniforms; /* Uniforms pointers */
uint32_t uniform_count; /* Index of next uniform inside DRWUniformChunk. */
+ int objectinfo;
+
struct {
/* Chunks of draw calls. */
struct DRWCommandChunk *first, *last;
@@ -262,10 +271,6 @@ struct DRWShadingGroup {
DRWState state_extra;
/** State changes for this batch only (and'd with the pass's state) */
DRWState state_extra_disable;
- /** Stencil mask to use for stencil test / write operations */
- uint stencil_mask;
-
- int objectinfo;
DRWPass *pass_parent; /* backlink to pass we're in */
};
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 70a88a7c01c..f6751ff8d88 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -665,6 +665,13 @@ static void drw_command_set_select_id(DRWShadingGroup *shgroup, GPUVertBuf *buf,
cmd->select_id = select_id;
}
+static void drw_command_set_stencil_mask(DRWShadingGroup *shgroup, uint mask)
+{
+ BLI_assert(mask <= 0xFF);
+ DRWCommandSetStencil *cmd = drw_command_create(shgroup, DRW_CMD_STENCIL);
+ cmd->mask = mask;
+}
+
void DRW_shgroup_call_ex(DRWShadingGroup *shgroup,
Object *ob,
float (*obmat)[4],
@@ -1084,7 +1091,6 @@ static DRWShadingGroup *drw_shgroup_create_ex(struct GPUShader *shader, DRWPass
shgroup->shader = shader;
shgroup->state_extra = 0;
shgroup->state_extra_disable = ~0x0;
- shgroup->stencil_mask = 0;
shgroup->cmd.first = NULL;
shgroup->cmd.last = NULL;
shgroup->pass_parent = pass;
@@ -1208,8 +1214,7 @@ void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_stencil_mask(DRWShadingGroup *shgroup, uint mask)
{
- BLI_assert(mask <= 255);
- shgroup->stencil_mask = mask;
+ drw_command_set_stencil_mask(shgroup, mask);
}
bool DRW_shgroup_is_empty(DRWShadingGroup *shgroup)
@@ -1228,7 +1233,8 @@ DRWShadingGroup *DRW_shgroup_get_next(DRWShadingGroup *shgroup)
* shgroups. */
uint DRW_shgroup_stencil_mask_get(DRWShadingGroup *shgroup)
{
- return shgroup->stencil_mask;
+ /* TODO remove. This is broken. */
+ return 0;
}
DRWShadingGroup *DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index ca312c9765a..e4b482764fe 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -1198,7 +1198,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
release_texture_slots(shader_changed);
drw_state_set((pass_state & shgroup->state_extra_disable) | shgroup->state_extra);
- drw_stencil_set(shgroup->stencil_mask);
draw_update_uniforms(shgroup, &state, &use_tfeedback);
@@ -1225,6 +1224,9 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
}
switch (cmd_type) {
+ case DRW_CMD_STENCIL:
+ drw_stencil_set(cmd->stencil.mask);
+ break;
case DRW_CMD_SELECTID:
state.select_id = cmd->select_id.select_id;
state.select_buf = cmd->select_id.select_buf;