Only send all vcol layers to gpu (for pbvh drawing) in a material
draw mode.
This commit is contained in:
parent
7c9235d0e0
commit
215c346017
|
@ -308,7 +308,8 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|||
PBVHFrustumPlanes *update_frustum,
|
||||
PBVHFrustumPlanes *draw_frustum,
|
||||
void (*draw_fn)(void *user_data, struct GPU_PBVH_Buffers *buffers),
|
||||
void *user_data);
|
||||
void *user_data,
|
||||
bool active_vcol_only);
|
||||
|
||||
void BKE_pbvh_draw_debug_cb(
|
||||
PBVH *pbvh,
|
||||
|
|
|
@ -1021,6 +1021,7 @@ typedef struct PBVHUpdateData {
|
|||
int flag;
|
||||
bool show_sculpt_face_sets;
|
||||
bool flat_vcol_shading;
|
||||
bool active_vcol_only;
|
||||
} PBVHUpdateData;
|
||||
|
||||
static void pbvh_update_normals_accum_task_cb(void *__restrict userdata,
|
||||
|
@ -1337,7 +1338,8 @@ static void pbvh_update_draw_buffer_cb(void *__restrict userdata,
|
|||
pbvh->cd_vert_node_offset,
|
||||
pbvh->face_sets_color_seed,
|
||||
pbvh->face_sets_color_default,
|
||||
data->flat_vcol_shading);
|
||||
data->flat_vcol_shading,
|
||||
data->active_vcol_only);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1360,7 +1362,8 @@ void BKE_pbvh_set_flat_vcol_shading(PBVH *pbvh, bool value)
|
|||
pbvh->flat_vcol_shading = value;
|
||||
}
|
||||
|
||||
static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag)
|
||||
static void pbvh_update_draw_buffers(
|
||||
PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag, bool active_vcol_only)
|
||||
{
|
||||
if ((update_flag & PBVH_RebuildDrawBuffers) || ELEM(pbvh->type, PBVH_GRIDS, PBVH_BMESH)) {
|
||||
/* Free buffers uses OpenGL, so not in parallel. */
|
||||
|
@ -1402,8 +1405,10 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode,
|
|||
GPU_pbvh_update_attribute_names(vdata, ldata);
|
||||
|
||||
/* Parallel creation and update of draw buffers. */
|
||||
PBVHUpdateData data = {
|
||||
.pbvh = pbvh, .nodes = nodes, .flat_vcol_shading = pbvh->flat_vcol_shading};
|
||||
PBVHUpdateData data = {.pbvh = pbvh,
|
||||
.nodes = nodes,
|
||||
.flat_vcol_shading = pbvh->flat_vcol_shading,
|
||||
.active_vcol_only = active_vcol_only};
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
|
||||
|
@ -1467,8 +1472,7 @@ void BKE_pbvh_update_origcolor_bmesh(PBVH *pbvh, PBVHNode *node)
|
|||
return;
|
||||
}
|
||||
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_ALL)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_ALL) {
|
||||
MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, vd.bm_vert);
|
||||
float *c2 = BM_ELEM_CD_GET_VOID_P(vd.bm_vert, pbvh->cd_vcol_offset);
|
||||
|
||||
|
@ -1485,8 +1489,7 @@ void BKE_pbvh_update_origco_bmesh(PBVH *pbvh, PBVHNode *node)
|
|||
return;
|
||||
}
|
||||
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_ALL)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_ALL) {
|
||||
MDynTopoVert *mv = BKE_PBVH_DYNVERT(pbvh->cd_dyn_vert, vd.bm_vert);
|
||||
|
||||
copy_v3_v3(mv->origco, vd.bm_vert->co);
|
||||
|
@ -2811,7 +2814,8 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|||
PBVHFrustumPlanes *update_frustum,
|
||||
PBVHFrustumPlanes *draw_frustum,
|
||||
void (*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers),
|
||||
void *user_data)
|
||||
void *user_data,
|
||||
bool active_vcol_only)
|
||||
{
|
||||
PBVHNode **nodes;
|
||||
int totnode;
|
||||
|
@ -2834,7 +2838,7 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|||
|
||||
/* Update draw buffers. */
|
||||
if (totnode != 0 && (update_flag & (PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers))) {
|
||||
pbvh_update_draw_buffers(pbvh, nodes, totnode, update_flag);
|
||||
pbvh_update_draw_buffers(pbvh, nodes, totnode, update_flag, active_vcol_only);
|
||||
}
|
||||
MEM_SAFE_FREE(nodes);
|
||||
|
||||
|
@ -3265,8 +3269,7 @@ void BKE_pbvh_ensure_proxyarray_indexmap(PBVH *pbvh, PBVHNode *node, GHash *vert
|
|||
PBVHVertexIter vd;
|
||||
|
||||
int i = 0;
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
BLI_ghash_insert(gs, (void *)vd.vertex.i, (void *)i);
|
||||
i++;
|
||||
}
|
||||
|
@ -3305,8 +3308,7 @@ GHash *pbvh_build_vert_node_map(PBVH *pbvh, PBVHNode **nodes, int totnode, int m
|
|||
continue;
|
||||
}
|
||||
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
BLI_ghash_insert(vert_node_map, (void *)vd.vertex.i, (void *)(node - pbvh->nodes));
|
||||
}
|
||||
BKE_pbvh_vertex_iter_end;
|
||||
|
@ -3414,8 +3416,7 @@ void BKE_pbvh_ensure_proxyarray(SculptSession *ss,
|
|||
int i = 0;
|
||||
|
||||
# if 1
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
void **val;
|
||||
|
||||
if (!BLI_ghash_ensure_p(gs, (void *)vd.vertex.i, &val)) {
|
||||
|
@ -3431,8 +3432,7 @@ void BKE_pbvh_ensure_proxyarray(SculptSession *ss,
|
|||
}
|
||||
|
||||
i = 0;
|
||||
BKE_pbvh_vertex_iter_begin(pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
if (i >= p->size) {
|
||||
printf("error!! %s\n", __func__);
|
||||
break;
|
||||
|
@ -3595,8 +3595,7 @@ static void pbvh_gather_proxyarray_exec(void *__restrict userdata,
|
|||
|
||||
int mask = p->datamask;
|
||||
|
||||
BKE_pbvh_vertex_iter_begin(data->pbvh, node, vd, PBVH_ITER_UNIQUE)
|
||||
{
|
||||
BKE_pbvh_vertex_iter_begin (data->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
if (mask & PV_CO) {
|
||||
copy_v3_v3(vd.co, p->co[i]);
|
||||
}
|
||||
|
|
|
@ -888,6 +888,7 @@ typedef struct DRWSculptCallbackData {
|
|||
bool fast_mode; /* Set by draw manager. Do not init. */
|
||||
|
||||
int debug_node_nr;
|
||||
bool active_vcol_only;
|
||||
} DRWSculptCallbackData;
|
||||
|
||||
#define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
|
||||
|
@ -1041,7 +1042,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
|
|||
&update_frustum,
|
||||
&draw_frustum,
|
||||
(void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb,
|
||||
scd);
|
||||
scd, scd->active_vcol_only);
|
||||
|
||||
if (SCULPT_DEBUG_BUFFERS) {
|
||||
int debug_node_nr = 0;
|
||||
|
@ -1063,6 +1064,7 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire
|
|||
.use_wire = use_wire,
|
||||
.use_mats = false,
|
||||
.use_mask = use_mask,
|
||||
.active_vcol_only = true
|
||||
};
|
||||
drw_sculpt_generate_calls(&scd);
|
||||
}
|
||||
|
@ -1078,6 +1080,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
|
|||
.use_wire = false,
|
||||
.use_mats = true,
|
||||
.use_mask = false,
|
||||
.active_vcol_only = false
|
||||
};
|
||||
drw_sculpt_generate_calls(&scd);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
const int cd_vert_node_offset,
|
||||
int face_sets_color_seed,
|
||||
int face_sets_color_default,
|
||||
bool flat_vcol);
|
||||
bool flat_vcol,
|
||||
bool active_vcol_only);
|
||||
|
||||
void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers,
|
||||
struct SubdivCCG *subdiv_ccg,
|
||||
|
|
|
@ -979,14 +979,24 @@ void GPU_pbvh_update_attribute_names(CustomData *vdata, CustomData *ldata)
|
|||
}
|
||||
}
|
||||
|
||||
static int gpu_pbvh_bmesh_make_vcol_offs(BMesh *bm, int r_cd_vcols[MAX_MCOL])
|
||||
static int gpu_pbvh_bmesh_make_vcol_offs(BMesh *bm, int r_cd_vcols[MAX_MCOL], bool active_only)
|
||||
{
|
||||
if (active_only) {
|
||||
int idx = CustomData_get_offset(&bm->vdata, CD_PROP_COLOR);
|
||||
if (idx >= 0) {
|
||||
r_cd_vcols[0] = idx;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
int tot = CustomData_number_of_layers(&bm->vdata, CD_PROP_COLOR);
|
||||
|
||||
for (int i = 0; i < tot; i++) {
|
||||
int idx = CustomData_get_layer_index_n(&bm->vdata, CD_PROP_COLOR, i);
|
||||
//idx = CustomData_get_active_layer_index(&bm->vdata, CD_PROP_COLOR);
|
||||
// idx = CustomData_get_active_layer_index(&bm->vdata, CD_PROP_COLOR);
|
||||
|
||||
if (idx < 0) {
|
||||
printf("eek, corruption in customdata!\n");
|
||||
|
@ -996,7 +1006,7 @@ static int gpu_pbvh_bmesh_make_vcol_offs(BMesh *bm, int r_cd_vcols[MAX_MCOL])
|
|||
CustomDataLayer *cl = bm->vdata.layers + idx;
|
||||
|
||||
if (cl->flag & CD_FLAG_TEMPORARY) {
|
||||
continue; //ignore original color layer
|
||||
continue; // ignore original color layer
|
||||
}
|
||||
|
||||
r_cd_vcols[count++] = CustomData_get_n_offset(&bm->vdata, CD_PROP_COLOR, i);
|
||||
|
@ -1047,7 +1057,8 @@ static void GPU_pbvh_bmesh_buffers_update_flat_vcol(GPU_PBVH_Buffers *buffers,
|
|||
const int update_flags,
|
||||
const int cd_vert_node_offset,
|
||||
int face_sets_color_seed,
|
||||
int face_sets_color_default)
|
||||
int face_sets_color_default,
|
||||
bool active_vcol_only)
|
||||
{
|
||||
const bool have_uv = CustomData_has_layer(&bm->ldata, CD_MLOOPUV);
|
||||
const bool show_mask = (update_flags & GPU_PBVH_BUFFERS_SHOW_MASK) != 0;
|
||||
|
@ -1062,7 +1073,7 @@ static void GPU_pbvh_bmesh_buffers_update_flat_vcol(GPU_PBVH_Buffers *buffers,
|
|||
int cd_fset_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
|
||||
|
||||
int cd_vcols[MAX_MCOL];
|
||||
const int cd_vcol_count = gpu_pbvh_bmesh_make_vcol_offs(bm, cd_vcols);
|
||||
const int cd_vcol_count = gpu_pbvh_bmesh_make_vcol_offs(bm, cd_vcols, active_vcol_only);
|
||||
|
||||
/* Count visible triangles */
|
||||
tottri = gpu_bmesh_face_visible_count(bm_faces) * 6;
|
||||
|
@ -1222,7 +1233,8 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
const int cd_vert_node_offset,
|
||||
int face_sets_color_seed,
|
||||
int face_sets_color_default,
|
||||
bool flat_vcol)
|
||||
bool flat_vcol,
|
||||
bool active_vcol_only)
|
||||
{
|
||||
|
||||
if (flat_vcol && CustomData_has_layer(&bm->vdata, CD_PROP_COLOR)) {
|
||||
|
@ -1234,7 +1246,8 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
update_flags,
|
||||
cd_vert_node_offset,
|
||||
face_sets_color_seed,
|
||||
face_sets_color_default);
|
||||
face_sets_color_default,
|
||||
active_vcol_only);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1251,7 +1264,7 @@ void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers,
|
|||
int cd_fset_offset = CustomData_get_offset(&bm->pdata, CD_SCULPT_FACE_SETS);
|
||||
|
||||
int cd_vcols[MAX_MCOL];
|
||||
int cd_vcol_count = gpu_pbvh_bmesh_make_vcol_offs(bm, cd_vcols);
|
||||
int cd_vcol_count = gpu_pbvh_bmesh_make_vcol_offs(bm, cd_vcols, active_vcol_only);
|
||||
|
||||
/* Count visible triangles */
|
||||
tottri = gpu_bmesh_face_visible_count(bm_faces);
|
||||
|
|
Loading…
Reference in New Issue