From 8de878e202514efbbaeaff7a0693e4899e150bed Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 28 Jun 2021 10:59:40 -0300 Subject: Draw: make 'ibo.lines_loose' extracting safer No functional changes. --- source/blender/draw/intern/draw_cache_extract_mesh.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'source/blender') diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc index d7d43ffe1a3..344150014ed 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.cc +++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc @@ -649,10 +649,20 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, EXTRACT_ADD_REQUESTED(vbo, skin_roots); EXTRACT_ADD_REQUESTED(ibo, tris); - if (DRW_ibo_requested(mbc->ibo.lines)) { + if (DRW_ibo_requested(mbc->ibo.lines_loose)) { + /* `ibo.lines_loose` require the `ibo.lines` buffer. */ + if (mbc->ibo.lines == nullptr) { + DRW_ibo_request(nullptr, &mbc->ibo.lines); + } + const MeshExtract *extractor = DRW_ibo_requested(mbc->ibo.lines) ? + &extract_lines_with_lines_loose : + &extract_lines_loose_only; + extractors.append(extractor); + } + else if (DRW_ibo_requested(mbc->ibo.lines)) { const MeshExtract *extractor; if (mbc->ibo.lines_loose != nullptr) { - /* Update #lines_loose ibo. */ + /* Update `ibo.lines_loose` as it depends on `ibo.lines`. */ extractor = &extract_lines_with_lines_loose; } else { @@ -660,11 +670,6 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph, } 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, points); EXTRACT_ADD_REQUESTED(ibo, fdots); EXTRACT_ADD_REQUESTED(ibo, lines_paint_mask); -- cgit v1.2.3