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:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-06-05 15:46:00 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-06-05 15:49:48 +0300
commit2cd1bc3aa7e66a295313c9ab82fbd7ba4b4905e1 (patch)
treebd1b56bcb1b94b96941f97f80609533c91d2066f
parent1a912462f4e51d069bda5084f3d702006e0a5b7e (diff)
Fix T88859: Assert when changing view modes
The `loose_lines`' ibo was not being initialized.
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.cc21
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_extractors.c38
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh_private.h4
3 files changed, 43 insertions, 20 deletions
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index b48ee1ddc3f..fca40206659 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -777,7 +777,6 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
* +-----> | extract_task2_loop_3 |
* +----------------------+
*/
- const bool do_lines_loose_subbuffer = mbc->ibo.lines_loose != nullptr;
const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
GPU_use_hq_normals_workaround();
@@ -787,8 +786,7 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
#define EXTRACT_ADD_REQUESTED(type, type_lowercase, name) \
do { \
if (DRW_##type_lowercase##_requested(mbc->type_lowercase.name)) { \
- const MeshExtract *extractor = mesh_extract_override_get( \
- &extract_##name, do_hq_normals, do_lines_loose_subbuffer); \
+ const MeshExtract *extractor = mesh_extract_override_get(&extract_##name, do_hq_normals); \
extractors.append(extractor); \
} \
} while (0)
@@ -818,7 +816,22 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
EXTRACT_ADD_REQUESTED(VBO, vbo, skin_roots);
EXTRACT_ADD_REQUESTED(IBO, ibo, tris);
- EXTRACT_ADD_REQUESTED(IBO, ibo, lines);
+ if (DRW_ibo_requested(mbc->ibo.lines)) {
+ const MeshExtract *extractor;
+ if (mbc->ibo.lines_loose != nullptr) {
+ /* Update #lines_loose ibo. */
+ extractor = &extract_lines_with_lines_loose;
+ }
+ else {
+ extractor = &extract_lines;
+ }
+ extractors.append(extractor);
+ }
+ else if (DRW_ibo_requested(mbc->ibo.lines_loose)) {
+ /* Note: #ibo.lines must have been created first. */
+ const MeshExtract *extractor = &extract_lines_loose_only;
+ extractors.append(extractor);
+ }
EXTRACT_ADD_REQUESTED(IBO, ibo, points);
EXTRACT_ADD_REQUESTED(IBO, ibo, fdots);
EXTRACT_ADD_REQUESTED(IBO, ibo, lines_paint_mask);
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
index a806632c18d..0a3945291bb 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c
@@ -94,24 +94,12 @@ static const MeshExtract *mesh_extract_override_hq_normals(const MeshExtract *ex
return extractor;
}
-static const MeshExtract *mesh_extract_override_loose_lines(const MeshExtract *extractor)
-{
- if (extractor == &extract_lines) {
- return &extract_lines_with_lines_loose;
- }
- return extractor;
-}
-
const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
- const bool do_hq_normals,
- const bool do_lines_loose_subbuffer)
+ const bool do_hq_normals)
{
if (do_hq_normals) {
extractor = mesh_extract_override_hq_normals(extractor);
}
- if (do_lines_loose_subbuffer) {
- extractor = mesh_extract_override_loose_lines(extractor);
- }
return extractor;
}
@@ -386,7 +374,7 @@ const MeshExtract extract_lines = {
/** \} */
/* ---------------------------------------------------------------------- */
-/** \name Extract Loose Edges Sub Buffer
+/** \name Extract Lines and Loose Edges Sub Buffer
* \{ */
static void extract_lines_loose_subbuffer(const MeshRenderData *mr, struct MeshBatchCache *cache)
@@ -425,6 +413,28 @@ const MeshExtract extract_lines_with_lines_loose = {
/** \} */
/* ---------------------------------------------------------------------- */
+/** \name Extract Loose Edges Sub Buffer
+ * \{ */
+
+static void *extract_lines_loose_only_init(const MeshRenderData *mr,
+ struct MeshBatchCache *cache,
+ void *buf)
+{
+ BLI_assert(buf == cache->final.ibo.lines_loose);
+ UNUSED_VARS_NDEBUG(buf);
+ extract_lines_loose_subbuffer(mr, cache);
+ return NULL;
+}
+
+const MeshExtract extract_lines_loose_only = {
+ .init = extract_lines_loose_only_init,
+ .data_type = 0,
+ .use_threading = false,
+ .mesh_buffer_offset = offsetof(MeshBufferCache, ibo.lines_loose)};
+
+/** \} */
+
+/* ---------------------------------------------------------------------- */
/** \name Extract Point Indices
* \{ */
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_private.h b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
index 644354989d8..6761282fe79 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh_private.h
+++ b/source/blender/draw/intern/draw_cache_extract_mesh_private.h
@@ -463,8 +463,7 @@ void mesh_render_data_update_looptris(MeshRenderData *mr,
void *mesh_extract_buffer_get(const MeshExtract *extractor, MeshBufferCache *mbc);
eMRIterType mesh_extract_iter_type(const MeshExtract *ext);
const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
- const bool do_hq_normals,
- const bool do_lines_loose_subbuffer);
+ const bool do_hq_normals);
/*
* Total number of extractions types.
*/
@@ -473,6 +472,7 @@ const MeshExtract *mesh_extract_override_get(const MeshExtract *extractor,
extern const MeshExtract extract_tris;
extern const MeshExtract extract_lines;
extern const MeshExtract extract_lines_with_lines_loose;
+extern const MeshExtract extract_lines_loose_only;
extern const MeshExtract extract_points;
extern const MeshExtract extract_fdots;
extern const MeshExtract extract_lines_paint_mask;