[Bf-blender-cvs] [6482e092d06] temp-pbvh-vbos: temp-pbvh-vbos: Fix dyntopo wireframe bug
Joseph Eagar
noreply at git.blender.org
Fri Sep 16 05:06:19 CEST 2022
Commit: 6482e092d06ee1ab862f9e98ddccbe8c23fb2bb0
Author: Joseph Eagar
Date: Thu Sep 15 20:06:04 2022 -0700
Branches: temp-pbvh-vbos
https://developer.blender.org/rB6482e092d06ee1ab862f9e98ddccbe8c23fb2bb0
temp-pbvh-vbos: Fix dyntopo wireframe bug
===================================================================
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/pbvh.c
M source/blender/draw/intern/draw_manager_data.c
M source/blender/draw/intern/draw_pbvh.cc
===================================================================
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index e1168dea126..d4badbf2dc1 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -737,14 +737,3 @@ int BKE_pbvh_debug_draw_gen_get(PBVHNode *node);
#ifdef __cplusplus
}
#endif
-
-/* Disable optimization for a function (for debugging use only!)*/
-#ifdef __clang__
-# define ATTR_NO_OPT __attribute__((optnone))
-#elif defined(_MSC_VER)
-# define ATTR_NO_OPT __pragma(optimize("", off))
-#elif defined(__GNUC__)
-# define ATTR_NO_OPT __attribute__((optimize("O0")))
-#else
-# define ATTR_NO_OPT
-#endif
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 3ff6a63d5fb..991a0863235 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2787,17 +2787,15 @@ static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v)
return true;
}
-ATTR_NO_OPT void BKE_pbvh_draw_cb(PBVH *pbvh,
- bool update_only_visible,
- PBVHFrustumPlanes *update_frustum,
- PBVHFrustumPlanes *draw_frustum,
- void (*draw_fn)(void *user_data,
- PBVHBatches *batches,
- PBVH_GPU_Args *args),
- void *user_data,
- bool UNUSED(full_render),
- PBVHAttrReq *attrs,
- int attrs_num)
+void BKE_pbvh_draw_cb(PBVH *pbvh,
+ bool update_only_visible,
+ PBVHFrustumPlanes *update_frustum,
+ PBVHFrustumPlanes *draw_frustum,
+ void (*draw_fn)(void *user_data, PBVHBatches *batches, PBVH_GPU_Args *args),
+ void *user_data,
+ bool UNUSED(full_render),
+ PBVHAttrReq *attrs,
+ int attrs_num)
{
PBVHNode **nodes;
int totnode;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 13e09dbb6b2..3d841cd8e14 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1162,9 +1162,9 @@ static float sculpt_debug_colors[9][4] = {
{0.7f, 0.2f, 1.0f, 1.0f},
};
-ATTR_NO_OPT static void sculpt_draw_cb(DRWSculptCallbackData *scd,
- PBVHBatches *batches,
- PBVH_GPU_Args *pbvh_draw_args)
+static void sculpt_draw_cb(DRWSculptCallbackData *scd,
+ PBVHBatches *batches,
+ PBVH_GPU_Args *pbvh_draw_args)
{
if (!batches) {
return;
@@ -1244,7 +1244,7 @@ static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4])
}
}
-ATTR_NO_OPT static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
+static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
{
/* PBVH should always exist for non-empty meshes, created by depsgraph eval. */
PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL;
@@ -1325,13 +1325,13 @@ ATTR_NO_OPT static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
}
}
-ATTR_NO_OPT void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
- Object *ob,
- bool use_wire,
- bool use_mask,
- bool use_fset,
- bool use_color,
- bool use_uv)
+void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
+ Object *ob,
+ bool use_wire,
+ bool use_mask,
+ bool use_fset,
+ bool use_color,
+ bool use_uv)
{
DRWSculptCallbackData scd = {
.ob = ob,
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc
index 309a5d442a0..9c90ef1676a 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -79,6 +79,11 @@ struct PBVHVbo {
{
}
+ void clear_data()
+ {
+ GPU_vertbuf_clear(vert_buf);
+ }
+
string build_key()
{
char buf[512];
@@ -114,7 +119,7 @@ struct PBVHBatch {
std::sort(vbos.begin(), vbos.end(), cmp(master_vbos));
}
- ATTR_NO_OPT string build_key(Vector<PBVHVbo> &master_vbos)
+ string build_key(Vector<PBVHVbo> &master_vbos)
{
key = "";
@@ -153,8 +158,10 @@ struct PBVHBatches {
int material_index = 0;
- PBVHBatches(PBVH_GPU_Args *args)
+ int count_faces(PBVH_GPU_Args *args)
{
+ int count = 0;
+
switch (args->pbvh_type) {
case PBVH_FACES: {
for (int i = 0; i < args->totprim; i++) {
@@ -164,32 +171,41 @@ struct PBVHBatches {
continue;
}
- faces_count++;
+ count++;
}
break;
}
case PBVH_GRIDS: {
- faces_count = BKE_pbvh_count_grid_quads((BLI_bitmap **)args->grid_hidden,
- args->grid_indices,
- args->totprim,
- args->ccg_key.grid_size);
+ count = BKE_pbvh_count_grid_quads((BLI_bitmap **)args->grid_hidden,
+ args->grid_indices,
+ args->totprim,
+ args->ccg_key.grid_size);
break;
}
case PBVH_BMESH: {
GSET_FOREACH_BEGIN (BMFace *, f, args->bm_faces) {
if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) {
- faces_count++;
+ count++;
}
}
GSET_FOREACH_END();
-
- tris_count = faces_count;
}
}
+
+ return count;
+ }
+
+ PBVHBatches(PBVH_GPU_Args *args)
+ {
+ faces_count = count_faces(args);
+
+ if (args->pbvh_type == PBVH_BMESH) {
+ tris_count = faces_count;
+ }
}
- ATTR_NO_OPT ~PBVHBatches()
+ ~PBVHBatches()
{
for (PBVHBatch &batch : batches.values()) {
GPU_BATCH_DISCARD_SAFE(batch.tris);
@@ -201,9 +217,10 @@ struct PBVHBatches {
}
GPU_INDEXBUF_DISCARD_SAFE(tri_index);
+ GPU_INDEXBUF_DISCARD_SAFE(lines_index);
}
- ATTR_NO_OPT string build_key(PBVHAttrReq *attrs, int attrs_num)
+ string build_key(PBVHAttrReq *attrs, int attrs_num)
{
string key;
PBVHBatch batch;
@@ -223,7 +240,7 @@ struct PBVHBatches {
return batch.key;
}
- ATTR_NO_OPT bool has_vbo(eAttrDomain domain, int type, string name)
+ bool has_vbo(eAttrDomain domain, int type, string name)
{
for (PBVHVbo &vbo : vbos) {
if (vbo.domain == domain && vbo.type == type && vbo.name == name) {
@@ -245,7 +262,7 @@ struct PBVHBatches {
return -1;
}
- ATTR_NO_OPT PBVHVbo *get_vbo(eAttrDomain domain, int type, string name)
+ PBVHVbo *get_vbo(eAttrDomain domain, int type, string name)
{
for (PBVHVbo &vbo : vbos) {
if (vbo.domain == domain && vbo.type == type && vbo.name == name) {
@@ -261,7 +278,7 @@ struct PBVHBatches {
return batches.contains(build_key(attrs, attrs_num));
}
- ATTR_NO_OPT PBVHBatch &ensure_batch(PBVHAttrReq *attrs, int attrs_num, PBVH_GPU_Args *args)
+ PBVHBatch &ensure_batch(PBVHAttrReq *attrs, int attrs_num, PBVH_GPU_Args *args)
{
if (!has_batch(attrs, attrs_num)) {
create_batch(attrs, attrs_num, args);
@@ -311,7 +328,7 @@ struct PBVHBatches {
;
}
- ATTR_NO_OPT void fill_vbo_grids_intern(
+ void fill_vbo_grids_intern(
PBVHVbo &vbo,
PBVH_GPU_Args *args,
std::function<
@@ -409,7 +426,6 @@ struct PBVHBatches {
}
}
- ATTR_NO_OPT
void fill_vbo_grids(PBVHVbo &vbo, PBVH_GPU_Args *args)
{
int gridsize = args->ccg_key.grid_size;
@@ -471,7 +487,7 @@ struct PBVHBatches {
}
}
- ATTR_NO_OPT void fill_vbo_faces(PBVHVbo &vbo, PBVH_GPU_Args *args)
+ void fill_vbo_faces(PBVHVbo &vbo, PBVH_GPU_Args *args)
{
int totvert = args->totprim * 3;
@@ -580,7 +596,7 @@ struct PBVHBatches {
}
}
- ATTR_NO_OPT void gpu_flush()
+ void gpu_flush()
{
for (PBVHVbo &vbo : vbos) {
if (vbo.vert_buf && GPU_vertbuf_get_data(vbo.vert_buf)) {
@@ -589,7 +605,7 @@ struct PBVHBatches {
}
}
- ATTR_NO_OPT void update(PBVH_GPU_Args *args)
+ void update(PBVH_GPU_Args *args)
{
check_index_buffers(args);
@@ -700,10 +716,7 @@ struct PBVHBatches {
}
}
- ATTR_NO_OPT void create_vbo(eAttrDomain domain,
- const uint32_t type,
- string name,
- PBVH_GPU_Args *args)
+ void create_vbo(eAttrDomain domain, const uint32_t type, string name, PBVH_GPU_Args *args)
{
PBVHVbo vbo(domain, type, name);
GPUVertFormat format;
@@ -803,11 +816,26 @@ struct PBVHBatches {
vbos.append(vbo);
}
- ATTR_NO_OPT void update_pre(PBVHAttrReq *attrs, int attrs_num, PBVH_GPU_Args *args)
+ void update_pre(PBVH_GPU_Args *args)
{
+ if (args->pbvh_type == PBVH_BMESH) {
+ int count = count_faces(args);
+
+ if (faces_count != count) {
+ for (PBVHVbo &vbo : vbos) {
+ vbo.clear_data();
+ }
+
+ GPU_INDEXBUF_DISCARD_SAFE(tri_index);
+ GPU_INDEXBUF_DISCARD_SAFE(lines_index);
+
+ tri_index = lines_index = nullptr;
+ faces_count = tris_count = count;
+ }
+ }
}
- ATTR_NO_OPT void create_index_faces(PBVH_GPU_Args *args)
+ void create_index_faces(PBVH_GPU_Args *args)
{
/* Calculate number of edges*/
int edge_count = 0;
@@ -861,7 +889,7 @@ struct PBVHBatches {
lines_index = GPU_indexbuf_build(&elb_lines);
}
- ATTR_NO_OPT void create_index_bmesh(PBVH_GPU_Args *args)
+ void create_index_bme
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list