[Bf-blender-cvs] [93c9347e9c4] greasepencil-refactor: GPencil: Refactor: Use drawcall matrices instead of custom one
Clément Foucault
noreply at git.blender.org
Tue Jan 7 15:31:27 CET 2020
Commit: 93c9347e9c4aa23ff8f680307ce999cd2146e0d6
Author: Clément Foucault
Date: Mon Jan 6 14:15:54 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB93c9347e9c4aa23ff8f680307ce999cd2146e0d6
GPencil: Refactor: Use drawcall matrices instead of custom one
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_shader.c
M source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
M source/blender/draw/engines/overlay/overlay_motion_path.c
M source/blender/draw/intern/DRW_render.h
M source/blender/draw/intern/draw_manager.h
M source/blender/draw/intern/draw_manager_data.c
M source/blender/draw/intern/draw_manager_exec.c
M source/blender/draw/intern/shaders/common_view_lib.glsl
M source/blender/gpu/GPU_shader_interface.h
M source/blender/gpu/intern/gpu_shader_interface.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index fe1ef42c120..b71dc1b43a7 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -1789,7 +1789,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
}
if ((do_onion) || (elm->onion == false)) {
- DRW_shgroup_call_range(shgrp, cache->b_stroke.batch, start_stroke, len);
+ DRW_shgroup_call_range(shgrp, NULL, cache->b_stroke.batch, start_stroke, len);
}
stl->storage->shgroup_id++;
start_stroke = elm->vertex_idx;
@@ -1818,7 +1818,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL);
if ((do_onion) || (elm->onion == false)) {
- DRW_shgroup_call_range(shgrp, cache->b_point.batch, start_point, len);
+ DRW_shgroup_call_range(shgrp, NULL, cache->b_point.batch, start_point, len);
}
stl->storage->shgroup_id++;
start_point = elm->vertex_idx;
@@ -1844,7 +1844,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
DRW_shgroup_state_disable(shgrp, DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_NEQUAL);
if ((do_onion) || (elm->onion == false)) {
- DRW_shgroup_call_range(shgrp, cache->b_fill.batch, start_fill, len);
+ DRW_shgroup_call_range(shgrp, NULL, cache->b_fill.batch, start_fill, len);
}
stl->storage->shgroup_id++;
start_fill = elm->vertex_idx;
@@ -1858,7 +1858,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
/* use always the same group */
DRW_shgroup_call_range(
- stl->g_data->shgrps_edit_point, cache->b_edit.batch, start_edit, len);
+ stl->g_data->shgrps_edit_point, NULL, cache->b_edit.batch, start_edit, len);
start_edit = elm->vertex_idx;
}
@@ -1872,7 +1872,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
/* use always the same group */
DRW_shgroup_call_range(
- stl->g_data->shgrps_edit_line, cache->b_edlin.batch, start_edlin, len);
+ stl->g_data->shgrps_edit_line, NULL, cache->b_edlin.batch, start_edlin, len);
start_edlin = elm->vertex_idx;
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 059878d1cd2..699a86111cc 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -1005,10 +1005,6 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
DRW_shgroup_uniform_texture(iter->grp, "gpStrokeTexture", iter->tex_stroke);
DRW_shgroup_uniform_texture(iter->grp, "gpSceneDepthTexture", iter->pd->scene_depth_tx);
DRW_shgroup_uniform_bool_copy(iter->grp, "strokeOrder3d", is_stroke_order_3d);
- DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[0]", iter->ob->obmat[0]);
- DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[1]", iter->ob->obmat[1]);
- DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[2]", iter->ob->obmat[2]);
- DRW_shgroup_uniform_vec4_copy(iter->grp, "gpModelMatrix[3]", iter->ob->obmat[3]);
DRW_shgroup_uniform_vec3_copy(iter->grp, "gpNormal", iter->tgp_ob->plane_normal);
DRW_shgroup_uniform_vec2_copy(iter->grp, "sizeViewportInv", DRW_viewport_invert_size_get());
DRW_shgroup_uniform_vec2_copy(iter->grp, "sizeViewport", DRW_viewport_size_get());
@@ -1089,7 +1085,7 @@ static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
geom = (iter->do_sbuffer_call == DRAW_NOW) ? iter->pd->fill_batch : geom;
int vfirst = gps->runtime.fill_start * 3;
int vcount = gps->tot_triangles * 3;
- DRW_shgroup_call_range(iter->grp, geom, vfirst, vcount);
+ DRW_shgroup_call_range(iter->grp, iter->ob, geom, vfirst, vcount);
}
if (show_stroke) {
@@ -1099,7 +1095,7 @@ static void gp_stroke_cache_populate(bGPDlayer *UNUSED(gpl),
int vfirst = gps->runtime.stroke_start - 1;
/* Include "potential" cyclic vertex and start adj vertex (see shader). */
int vcount = gps->totpoints + 1 + 1;
- DRW_shgroup_call_instance_range(iter->grp, geom, vfirst, vcount);
+ DRW_shgroup_call_instance_range(iter->grp, iter->ob, geom, vfirst, vcount);
}
iter->stroke_index_last = gps->runtime.stroke_start + gps->totpoints + 1;
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader.c b/source/blender/draw/engines/gpencil/gpencil_shader.c
index 7f11de84f5c..96431abe888 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader.c
@@ -104,6 +104,7 @@ struct GPUShader *GPENCIL_shader_geometry_get(GPENCIL_e_data *e_data)
(const char *[]){
"#define GP_MATERIAL_BUFFER_LEN " STRINGIFY(GP_MATERIAL_BUFFER_LEN) "\n",
"#define GPENCIL_LIGHT_BUFFER_LEN " STRINGIFY(GPENCIL_LIGHT_BUFFER_LEN) "\n",
+ "#define UNIFORM_RESOURCE_ID\n",
NULL,
},
});
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
index 98687d6d4a0..eb721583bdb 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl
@@ -68,7 +68,7 @@ vec2 rotate_90deg(vec2 v)
mat4 model_matrix_get()
{
- return mat4(gpModelMatrix[0], gpModelMatrix[1], gpModelMatrix[2], gpModelMatrix[3]);
+ return ModelMatrix;
}
vec3 transform_point(mat4 m, vec3 v)
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index a532618d472..f9c7df75e9a 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -155,7 +155,7 @@ static void motion_path_cache(OVERLAY_Data *vedata,
DRW_shgroup_uniform_bool_copy(grp, "selected", selected);
DRW_shgroup_uniform_vec3_copy(grp, "customColor", color);
/* Only draw the required range. */
- DRW_shgroup_call_range(grp, mpath_batch_line_get(mpath), start_index, len);
+ DRW_shgroup_call_range(grp, NULL, mpath_batch_line_get(mpath), start_index, len);
}
/* Draw points. */
@@ -167,7 +167,7 @@ static void motion_path_cache(OVERLAY_Data *vedata,
DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes);
DRW_shgroup_uniform_vec3_copy(grp, "customColor", color);
/* Only draw the required range. */
- DRW_shgroup_call_range(grp, mpath_batch_points_get(mpath), start_index, len);
+ DRW_shgroup_call_range(grp, NULL, mpath_batch_points_get(mpath), start_index, len);
}
/* Draw frame numbers at each frame-step value. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index df2fc1d7edf..61777c51685 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -388,14 +388,10 @@ void DRW_shgroup_call_ex(DRWShadingGroup *shgroup,
#define DRW_shgroup_call_no_cull(shgrp, geom, ob) \
DRW_shgroup_call_ex(shgrp, ob, NULL, geom, true, NULL)
-void DRW_shgroup_call_range(DRWShadingGroup *shgroup,
- struct GPUBatch *geom,
- uint v_sta,
- uint v_ct);
-void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup,
- struct GPUBatch *geom,
- uint v_sta,
- uint v_ct);
+void DRW_shgroup_call_range(
+ DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint v_sta, uint v_ct);
+void DRW_shgroup_call_instance_range(
+ DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint v_sta, uint v_ct);
void DRW_shgroup_call_procedural_points(DRWShadingGroup *sh, Object *ob, uint point_ct);
void DRW_shgroup_call_procedural_lines(DRWShadingGroup *sh, Object *ob, uint line_ct);
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 1d56690a752..7e919b9e2df 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -201,6 +201,7 @@ typedef struct DRWCommandDraw {
/* Assume DRWResourceHandle to be 0. */
typedef struct DRWCommandDrawRange {
GPUBatch *batch;
+ DRWResourceHandle handle;
uint vert_first;
uint vert_count;
} DRWCommandDrawRange;
@@ -214,6 +215,7 @@ typedef struct DRWCommandDrawInstance {
typedef struct DRWCommandDrawInstanceRange {
GPUBatch *batch;
+ DRWResourceHandle handle;
uint inst_first;
uint inst_count;
} DRWCommandDrawInstanceRange;
@@ -283,6 +285,7 @@ typedef enum {
DRW_UNIFORM_BLOCK_OBMATS,
DRW_UNIFORM_BLOCK_OBINFOS,
DRW_UNIFORM_RESOURCE_CHUNK,
+ DRW_UNIFORM_RESOURCE_ID,
/** Legacy / Fallback */
DRW_UNIFORM_BASE_INSTANCE,
DRW_UNIFORM_MODEL_MATRIX,
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index fe8a548cef8..bd4c0d0fb89 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -636,13 +636,12 @@ static void drw_command_draw(DRWShadingGroup *shgroup, GPUBatch *batch, DRWResou
cmd->handle = handle;
}
-static void drw_command_draw_range(DRWShadingGroup *shgroup,
- GPUBatch *batch,
- uint start,
- uint count)
+static void drw_command_draw_range(
+ DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint start, uint count)
{
DRWCommandDrawRange *cmd = drw_command_create(shgroup, DRW_CMD_DRAW_RANGE);
cmd->batch = batch;
+ cmd->handle = handle;
cmd->vert_first = st
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list