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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-16 10:40:38 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2022-01-16 10:40:38 +0300
commitbc66cd9868746ce92dd6de004a8b8e6a0188defe (patch)
tree709174bdf08407a7c06d9fd4c10b3523ab3487b0 /source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
parent3574f2730d2a42cda2881d26209b8dc53b1d2047 (diff)
Fix T94865: GPU subdiv crash switching to texpaint area
The crash is due to the fact that GPU subdivision extraction routines for edit data (including UVs) only worked for BMesh. However, a Mesh based version is still needed for texture painting. This adds the missing components. This also ensures all data are properly initialized (at least the ones revealed by the bug).
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc')
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
index b1866708d14..b25e40690c9 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
@@ -139,38 +139,46 @@ static void extract_edituv_data_init_subdiv(const DRWSubdivCache *subdiv_cache,
extract_edituv_data_init_common(mr, vbo, data, subdiv_cache->num_subdiv_loops);
}
-static void extract_edituv_data_iter_subdiv(const DRWSubdivCache *subdiv_cache,
- const MeshRenderData *mr,
- void *_data,
- uint subdiv_quad_index)
+static void extract_edituv_data_iter_subdiv_bm(const DRWSubdivCache *subdiv_cache,
+ const MeshRenderData *mr,
+ void *_data,
+ uint subdiv_quad_index,
+ const BMFace *coarse_quad)
{
MeshExtract_EditUVData_Data *data = static_cast<MeshExtract_EditUVData_Data *>(_data);
int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index);
int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index);
- int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index;
uint start_loop_idx = subdiv_quad_index * 4;
uint end_loop_idx = (subdiv_quad_index + 1) * 4;
for (uint i = start_loop_idx; i < end_loop_idx; i++) {
const int vert_origindex = subdiv_loop_vert_index[i];
const int edge_origindex = subdiv_loop_edge_index[i];
- const int poly_origindex = subdiv_loop_poly_index[i];
EditLoopData *edit_loop_data = &data->vbo_data[i];
memset(edit_loop_data, 0, sizeof(EditLoopData));
- BMFace *efa = bm_original_face_get(mr, poly_origindex);
-
if (vert_origindex != -1 && edge_origindex != -1) {
BMEdge *eed = bm_original_edge_get(mr, edge_origindex);
/* Loop on an edge endpoint. */
- BMLoop *l = BM_face_edge_share_loop(efa, eed);
+ BMLoop *l = BM_face_edge_share_loop(const_cast<BMFace *>(coarse_quad), eed);
mesh_render_data_loop_flag(mr, l, data->cd_ofs, edit_loop_data);
mesh_render_data_loop_edge_flag(mr, l, data->cd_ofs, edit_loop_data);
}
}
}
+static void extract_edituv_data_iter_subdiv_mesh(const DRWSubdivCache *subdiv_cache,
+ const MeshRenderData *mr,
+ void *_data,
+ uint subdiv_quad_index,
+ const MPoly *coarse_quad)
+{
+ const int coarse_quad_index = static_cast<int>(coarse_quad - mr->mpoly);
+ BMFace *coarse_quad_bm = bm_original_face_get(mr, coarse_quad_index);
+ extract_edituv_data_iter_subdiv_bm(subdiv_cache, mr, _data, subdiv_quad_index, coarse_quad_bm);
+}
+
constexpr MeshExtract create_extractor_edituv_data()
{
MeshExtract extractor = {nullptr};
@@ -178,7 +186,8 @@ constexpr MeshExtract create_extractor_edituv_data()
extractor.iter_poly_bm = extract_edituv_data_iter_poly_bm;
extractor.iter_poly_mesh = extract_edituv_data_iter_poly_mesh;
extractor.init_subdiv = extract_edituv_data_init_subdiv;
- extractor.iter_subdiv = extract_edituv_data_iter_subdiv;
+ extractor.iter_subdiv_bm = extract_edituv_data_iter_subdiv_bm;
+ extractor.iter_subdiv_mesh = extract_edituv_data_iter_subdiv_mesh;
extractor.data_type = MR_DATA_NONE;
extractor.data_size = sizeof(MeshExtract_EditUVData_Data);
extractor.use_threading = true;