Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.cc
| Show First 20 Lines • Show All 816 Lines • ▼ Show 20 Lines | #define EXTRACT_ADD_REQUESTED(type, name) \ | ||||
| } | } | ||||
| /* We use only one extractor for face dots, as the work is done in a single compute shader. */ | /* We use only one extractor for face dots, as the work is done in a single compute shader. */ | ||||
| if (DRW_vbo_requested(mbuflist->vbo.fdots_nor) || DRW_vbo_requested(mbuflist->vbo.fdots_pos) || | if (DRW_vbo_requested(mbuflist->vbo.fdots_nor) || DRW_vbo_requested(mbuflist->vbo.fdots_pos) || | ||||
| DRW_ibo_requested(mbuflist->ibo.fdots)) { | DRW_ibo_requested(mbuflist->ibo.fdots)) { | ||||
| extractors.append(&extract_fdots_pos); | extractors.append(&extract_fdots_pos); | ||||
| } | } | ||||
| EXTRACT_ADD_REQUESTED(ibo, lines); | if (DRW_ibo_requested(mbuflist->ibo.lines_loose)) { | ||||
| /* `ibo.lines_loose` require the `ibo.lines` buffer. */ | |||||
| if (mbuflist->ibo.lines == nullptr) { | |||||
| DRW_ibo_request(nullptr, &mbuflist->ibo.lines); | |||||
| } | |||||
| const MeshExtract *extractor = DRW_ibo_requested(mbuflist->ibo.lines) ? | |||||
| &extract_lines_with_lines_loose : | |||||
| &extract_lines_loose_only; | |||||
| extractors.append(extractor); | |||||
| } | |||||
| else if (DRW_ibo_requested(mbuflist->ibo.lines)) { | |||||
| const MeshExtract *extractor; | |||||
| if (mbuflist->ibo.lines_loose != nullptr) { | |||||
| /* Update `ibo.lines_loose` as it depends on `ibo.lines`. */ | |||||
| extractor = &extract_lines_with_lines_loose; | |||||
| } | |||||
| else { | |||||
| extractor = &extract_lines; | |||||
| } | |||||
| extractors.append(extractor); | |||||
| } | |||||
| EXTRACT_ADD_REQUESTED(ibo, edituv_points); | EXTRACT_ADD_REQUESTED(ibo, edituv_points); | ||||
| EXTRACT_ADD_REQUESTED(ibo, edituv_tris); | EXTRACT_ADD_REQUESTED(ibo, edituv_tris); | ||||
| EXTRACT_ADD_REQUESTED(ibo, edituv_lines); | EXTRACT_ADD_REQUESTED(ibo, edituv_lines); | ||||
| EXTRACT_ADD_REQUESTED(vbo, vert_idx); | EXTRACT_ADD_REQUESTED(vbo, vert_idx); | ||||
| EXTRACT_ADD_REQUESTED(vbo, edge_idx); | EXTRACT_ADD_REQUESTED(vbo, edge_idx); | ||||
| EXTRACT_ADD_REQUESTED(vbo, poly_idx); | EXTRACT_ADD_REQUESTED(vbo, poly_idx); | ||||
| EXTRACT_ADD_REQUESTED(vbo, edge_fac); | EXTRACT_ADD_REQUESTED(vbo, edge_fac); | ||||
| EXTRACT_ADD_REQUESTED(ibo, points); | EXTRACT_ADD_REQUESTED(ibo, points); | ||||
| Show All 12 Lines | |||||
| #undef EXTRACT_ADD_REQUESTED | #undef EXTRACT_ADD_REQUESTED | ||||
| if (extractors.is_empty()) { | if (extractors.is_empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| mesh_render_data_update_looptris(mr, MR_ITER_LOOPTRI, MR_DATA_LOOPTRI); | mesh_render_data_update_looptris(mr, MR_ITER_LOOPTRI, MR_DATA_LOOPTRI); | ||||
| mesh_render_data_update_loose_geom(mr, mbc, MR_ITER_LEDGE | MR_ITER_LVERT, MR_DATA_LOOSE_GEOM); | mesh_render_data_update_loose_geom(mr, mbc, MR_ITER_LEDGE | MR_ITER_LVERT, MR_DATA_LOOSE_GEOM); | ||||
| DRW_subdivide_loose_geom(subdiv_cache, mbc); | |||||
| void *data_stack = MEM_mallocN(extractors.data_size_total(), __func__); | void *data_stack = MEM_mallocN(extractors.data_size_total(), __func__); | ||||
| uint32_t data_offset = 0; | uint32_t data_offset = 0; | ||||
| for (const ExtractorRunData &run_data : extractors) { | for (const ExtractorRunData &run_data : extractors) { | ||||
| const MeshExtract *extractor = run_data.extractor; | const MeshExtract *extractor = run_data.extractor; | ||||
| void *buffer = mesh_extract_buffer_get(extractor, mbuflist); | void *buffer = mesh_extract_buffer_get(extractor, mbuflist); | ||||
| void *data = POINTER_OFFSET(data_stack, data_offset); | void *data = POINTER_OFFSET(data_stack, data_offset); | ||||
| Show All 17 Lines | if (extractor->iter_subdiv_mesh || extractor->iter_subdiv_bm) { | ||||
| const int poly_origindex = subdiv_loop_poly_index[i * 4]; | const int poly_origindex = subdiv_loop_poly_index[i * 4]; | ||||
| const MPoly *mp = &mr->mpoly[poly_origindex]; | const MPoly *mp = &mr->mpoly[poly_origindex]; | ||||
| extractor->iter_subdiv_mesh(subdiv_cache, mr, data, i, mp); | extractor->iter_subdiv_mesh(subdiv_cache, mr, data, i, mp); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (extractor->iter_loose_geom_subdiv) { | if (extractor->iter_loose_geom_subdiv) { | ||||
| extractor->iter_loose_geom_subdiv(subdiv_cache, mr, &mbc->loose_geom, buffer, data); | extractor->iter_loose_geom_subdiv(subdiv_cache, mr, buffer, data); | ||||
| } | } | ||||
| if (extractor->finish_subdiv) { | if (extractor->finish_subdiv) { | ||||
| extractor->finish_subdiv(subdiv_cache, mr, cache, buffer, data); | extractor->finish_subdiv(subdiv_cache, mr, cache, buffer, data); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(data_stack); | MEM_freeN(data_stack); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines | |||||