Blender
V3.3
|
#include "draw_subdivision.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_scene.h"
#include "BKE_subdiv.h"
#include "BKE_subdiv_eval.h"
#include "BKE_subdiv_foreach.h"
#include "BKE_subdiv_mesh.h"
#include "BKE_subdiv_modifier.h"
#include "BLI_linklist.h"
#include "BLI_string.h"
#include "PIL_time.h"
#include "DRW_engine.h"
#include "DRW_render.h"
#include "GPU_capabilities.h"
#include "GPU_compute.h"
#include "GPU_index_buffer.h"
#include "GPU_state.h"
#include "GPU_vertex_buffer.h"
#include "opensubdiv_capi.h"
#include "opensubdiv_capi_type.h"
#include "opensubdiv_converter_capi.h"
#include "opensubdiv_evaluator_capi.h"
#include "opensubdiv_topology_refiner_capi.h"
#include "draw_cache_extract.hh"
#include "draw_cache_impl.h"
#include "draw_cache_inline.h"
#include "mesh_extractors/extract_mesh.hh"
Go to the source code of this file.
Classes | |
struct | CompressedPatchCoord |
struct | DRWCacheBuildingContext |
struct | DRWSubdivUboStorage |
Macros | |
#define | SUBDIV_LOCAL_WORK_GROUP_SIZE 64 |
Functions | |
static const char * | get_shader_code (int shader_type) |
static const char * | get_shader_name (int shader_type) |
static GPUShader * | get_patch_evaluation_shader (int shader_type) |
static GPUShader * | get_subdiv_shader (int shader_type, const char *defines) |
static uint | tris_count_from_number_of_loops (const uint number_of_loops) |
static uint | get_dispatch_size (uint elements) |
static void | drw_subdiv_compute_dispatch (const DRWSubdivCache *cache, GPUShader *shader, const int src_offset, const int dst_offset, uint total_dispatch_size, const bool has_sculpt_mask=false) |
void | draw_subdiv_extract_pos_nor (const DRWSubdivCache *cache, GPUVertBuf *pos_nor, GPUVertBuf *orco) |
void | draw_subdiv_extract_uvs (const DRWSubdivCache *cache, GPUVertBuf *uvs, const int face_varying_channel, const int dst_offset) |
void | draw_subdiv_interp_custom_data (const DRWSubdivCache *cache, GPUVertBuf *src_data, GPUVertBuf *dst_data, int dimensions, int dst_offset, bool compress_to_u16) |
void | draw_subdiv_build_sculpt_data_buffer (const DRWSubdivCache *cache, GPUVertBuf *mask_vbo, GPUVertBuf *face_set_vbo, GPUVertBuf *sculpt_data) |
void | draw_subdiv_accumulate_normals (const DRWSubdivCache *cache, GPUVertBuf *pos_nor, GPUVertBuf *face_adjacency_offsets, GPUVertBuf *face_adjacency_lists, GPUVertBuf *vertex_loop_map, GPUVertBuf *vertex_normals) |
void | draw_subdiv_finalize_normals (const DRWSubdivCache *cache, GPUVertBuf *vertex_normals, GPUVertBuf *subdiv_loop_subdiv_vert_index, GPUVertBuf *pos_nor) |
void | draw_subdiv_finalize_custom_normals (const DRWSubdivCache *cache, GPUVertBuf *src_custom_normals, GPUVertBuf *pos_nor) |
void | draw_subdiv_build_tris_buffer (const DRWSubdivCache *cache, GPUIndexBuf *subdiv_tris, const int material_count) |
void | draw_subdiv_build_fdots_buffers (const DRWSubdivCache *cache, GPUVertBuf *fdots_pos, GPUVertBuf *fdots_nor, GPUIndexBuf *fdots_indices) |
void | draw_subdiv_build_lines_buffer (const DRWSubdivCache *cache, GPUIndexBuf *lines_indices) |
void | draw_subdiv_build_lines_loose_buffer (const DRWSubdivCache *cache, GPUIndexBuf *lines_indices, GPUVertBuf *lines_flags, uint num_loose_edges) |
void | draw_subdiv_build_edge_fac_buffer (const DRWSubdivCache *cache, GPUVertBuf *pos_nor, GPUVertBuf *edge_idx, GPUVertBuf *edge_fac) |
void | draw_subdiv_build_lnor_buffer (const DRWSubdivCache *cache, GPUVertBuf *pos_nor, GPUVertBuf *lnor) |
void | draw_subdiv_build_edituv_stretch_area_buffer (const DRWSubdivCache *cache, GPUVertBuf *coarse_data, GPUVertBuf *subdiv_data) |
void | draw_subdiv_build_edituv_stretch_angle_buffer (const DRWSubdivCache *cache, GPUVertBuf *pos_nor, GPUVertBuf *uvs, int uvs_offset, GPUVertBuf *stretch_angles) |
static void | draw_subdiv_cache_ensure_mat_offsets (DRWSubdivCache *cache, Mesh *mesh_eval, uint mat_len) |
static bool | draw_subdiv_create_requested_buffers (Object *ob, Mesh *mesh, MeshBatchCache *batch_cache, MeshBufferCache *mbc, const bool is_editmode, const bool is_paint_mode, const bool is_mode_active, const float obmat[4][4], const bool do_final, const bool do_uvedit, const bool do_cage, const ToolSettings *ts, const bool use_hide, OpenSubdiv_EvaluatorCache *evaluator_cache) |
void | DRW_subdivide_loose_geom (DRWSubdivCache *subdiv_cache, MeshBufferCache *cache) |
blender::Span< DRWSubdivLooseEdge > | draw_subdiv_cache_get_loose_edges (const DRWSubdivCache *cache) |
blender::Span< DRWSubdivLooseVertex > | draw_subdiv_cache_get_loose_verts (const DRWSubdivCache *cache) |
void | DRW_create_subdivision (Object *ob, Mesh *mesh, MeshBatchCache *batch_cache, MeshBufferCache *mbc, const bool is_editmode, const bool is_paint_mode, const bool is_mode_active, const float obmat[4][4], const bool do_final, const bool do_uvedit, const bool do_cage, const ToolSettings *ts, const bool use_hide) |
void | DRW_subdiv_free () |
void | DRW_subdiv_cache_free (Subdiv *subdiv) |
void | DRW_cache_free_old_subdiv () |
static GPUVertFormat * | get_uvs_format () |
static GPUVertFormat * | get_patch_array_format () |
static GPUVertFormat * | get_patch_handle_format () |
static GPUVertFormat * | get_quadtree_format () |
static GPUVertFormat * | get_patch_param_format () |
static GPUVertFormat * | get_patch_index_format () |
static GPUVertFormat * | get_subdiv_vertex_format () |
MINLINE CompressedPatchCoord | make_patch_coord (int ptex_face_index, float u, float v) |
static GPUVertFormat * | get_blender_patch_coords_format () |
static GPUVertFormat * | get_origindex_format () |
GPUVertFormat * | draw_subdiv_get_pos_nor_format () |
Utilities to initialize a OpenSubdiv_Buffer for a GPUVertBuf. | |
static void | vertbuf_bind_gpu (const OpenSubdiv_Buffer *buffer) |
static void * | vertbuf_alloc (const OpenSubdiv_Buffer *interface, const uint len) |
static void | vertbuf_device_alloc (const OpenSubdiv_Buffer *interface, const uint len) |
static void | vertbuf_wrap_device_handle (const OpenSubdiv_Buffer *interface, uint64_t handle) |
static void | vertbuf_update_data (const OpenSubdiv_Buffer *interface, uint start, uint len, const void *data) |
static void | opensubdiv_gpu_buffer_init (OpenSubdiv_Buffer *buffer_interface, GPUVertBuf *vertbuf) |
static GPUVertBuf * | create_buffer_and_interface (OpenSubdiv_Buffer *interface, GPUVertFormat *format) |
Utilities to build a GPUVertBuf from an origindex buffer. | |
void | draw_subdiv_init_origindex_buffer (GPUVertBuf *buffer, int32_t *vert_origindex, uint num_loops, uint loose_len) |
GPUVertBuf * | draw_subdiv_build_origindex_buffer (int *vert_origindex, uint num_loops) |
Utilities for DRWPatchMap. | |
static void | draw_patch_map_build (DRWPatchMap *gpu_patch_map, Subdiv *subdiv) |
static void | draw_patch_map_free (DRWPatchMap *gpu_patch_map) |
Subdivision grid traversal. | |
Traverse the uniform subdivision grid over coarse faces and gather useful information for building the draw buffers on the GPU. We primarily gather the patch coordinates for all subdivision faces, as well as the original coarse indices for each subdivision element (vertex, face, or edge) which directly maps to its coarse counterpart (note that all subdivision faces map to a coarse face). This information will then be cached in DRWSubdivCache for subsequent reevaluations, as long as the topology does not change. | |
static bool | draw_subdiv_topology_info_cb (const SubdivForeachContext *foreach_context, const int num_vertices, const int num_edges, const int num_loops, const int num_polygons, const int *subdiv_polygon_offset) |
static void | draw_subdiv_vertex_corner_cb (const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int UNUSED(ptex_face_index), const float UNUSED(u), const float UNUSED(v), const int coarse_vertex_index, const int UNUSED(coarse_poly_index), const int UNUSED(coarse_corner), const int subdiv_vertex_index) |
static void | draw_subdiv_vertex_edge_cb (const SubdivForeachContext *UNUSED(foreach_context), void *UNUSED(tls_v), const int UNUSED(ptex_face_index), const float UNUSED(u), const float UNUSED(v), const int UNUSED(coarse_edge_index), const int UNUSED(coarse_poly_index), const int UNUSED(coarse_corner), const int UNUSED(subdiv_vertex_index)) |
static void | draw_subdiv_edge_cb (const SubdivForeachContext *foreach_context, void *UNUSED(tls), const int coarse_edge_index, const int subdiv_edge_index, const bool UNUSED(is_loose), const int UNUSED(subdiv_v1), const int UNUSED(subdiv_v2)) |
static void | draw_subdiv_loop_cb (const SubdivForeachContext *foreach_context, void *UNUSED(tls_v), const int ptex_face_index, const float u, const float v, const int UNUSED(coarse_loop_index), const int coarse_poly_index, const int UNUSED(coarse_corner), const int subdiv_loop_index, const int subdiv_vertex_index, const int subdiv_edge_index) |
static void | draw_subdiv_foreach_callbacks (SubdivForeachContext *foreach_context) |
static void | do_subdiv_traversal (DRWCacheBuildingContext *cache_building_context, Subdiv *subdiv) |
static GPUVertBuf * | gpu_vertbuf_create_from_format (GPUVertFormat *format, uint len) |
static void | build_vertex_face_adjacency_maps (DRWSubdivCache *cache) |
static bool | draw_subdiv_build_cache (DRWSubdivCache *cache, Subdiv *subdiv, Mesh *mesh_eval, const SubsurfRuntimeData *runtime_data) |
DRWSubdivUboStorage. | |
Common uniforms for the various shaders. | |
static void | draw_subdiv_init_ubo_storage (const DRWSubdivCache *cache, DRWSubdivUboStorage *ubo, const int src_offset, const int dst_offset, const uint total_dispatch_size, const bool has_sculpt_mask) |
static void | draw_subdiv_ubo_update_and_bind (const DRWSubdivCache *cache, GPUShader *shader, const int src_offset, const int dst_offset, const uint total_dispatch_size, const bool has_sculpt_mask=false) |
Variables | |
char | datatoc_common_subdiv_custom_data_interp_comp_glsl [] |
char | datatoc_common_subdiv_ibo_lines_comp_glsl [] |
char | datatoc_common_subdiv_ibo_tris_comp_glsl [] |
char | datatoc_common_subdiv_lib_glsl [] |
char | datatoc_common_subdiv_normals_accumulate_comp_glsl [] |
char | datatoc_common_subdiv_normals_finalize_comp_glsl [] |
char | datatoc_common_subdiv_patch_evaluation_comp_glsl [] |
char | datatoc_common_subdiv_vbo_edge_fac_comp_glsl [] |
char | datatoc_common_subdiv_vbo_lnor_comp_glsl [] |
char | datatoc_common_subdiv_vbo_sculpt_data_comp_glsl [] |
char | datatoc_common_subdiv_vbo_edituv_strech_angle_comp_glsl [] |
char | datatoc_common_subdiv_vbo_edituv_strech_area_comp_glsl [] |
static GPUShader * | g_subdiv_shaders [NUM_SHADERS] |
static OpenSubdiv_EvaluatorCache * | g_evaluator_cache = nullptr |
static LinkNode * | gpu_subdiv_free_queue = nullptr |
static ThreadMutex | gpu_subdiv_queue_mutex = BLI_MUTEX_INITIALIZER |
#define SUBDIV_COARSE_FACE_FLAG_ACTIVE 4u |
Definition at line 615 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_ACTIVE_MASK (SUBDIV_COARSE_FACE_FLAG_ACTIVE << SUBDIV_COARSE_FACE_FLAG_OFFSET) |
Definition at line 624 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_HIDDEN 8u |
Definition at line 616 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_HIDDEN_MASK (SUBDIV_COARSE_FACE_FLAG_HIDDEN << SUBDIV_COARSE_FACE_FLAG_OFFSET) |
Definition at line 626 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_OFFSET 28u |
Definition at line 618 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_SELECT 2u |
Definition at line 614 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_SELECT_MASK (SUBDIV_COARSE_FACE_FLAG_SELECT << SUBDIV_COARSE_FACE_FLAG_OFFSET) |
Definition at line 622 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_SMOOTH 1u |
Definition at line 613 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_FLAG_SMOOTH_MASK (SUBDIV_COARSE_FACE_FLAG_SMOOTH << SUBDIV_COARSE_FACE_FLAG_OFFSET) |
Definition at line 620 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_COARSE_FACE_LOOP_START_MASK |
Definition at line 629 of file draw_cache_impl_subdivision.cc.
#define SUBDIV_LOCAL_WORK_GROUP_SIZE 64 |
Definition at line 1269 of file draw_cache_impl_subdivision.cc.
anonymous enum |
Definition at line 60 of file draw_cache_impl_subdivision.cc.
|
static |
Definition at line 1012 of file draw_cache_impl_subdivision.cc.
References get_origindex_format(), gpu_vertbuf_create_from_format(), GPU_vertbuf_get_data(), MEM_callocN, MEM_freeN, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::num_subdiv_verts, DRWSubdivCache::subdiv_loop_subdiv_vert_index, DRWSubdivCache::subdiv_vertex_face_adjacency, and DRWSubdivCache::subdiv_vertex_face_adjacency_offsets.
Referenced by draw_subdiv_build_cache().
Definition at line 634 of file draw_cache_impl_subdivision.cc.
References BM_elem_flag_test, BM_ELEM_HIDDEN, BM_elem_index_get, BM_ELEM_SELECT, BM_ELEM_SMOOTH, BMFace::l_first, SUBDIV_COARSE_FACE_FLAG_ACTIVE, SUBDIV_COARSE_FACE_FLAG_HIDDEN, SUBDIV_COARSE_FACE_FLAG_OFFSET, SUBDIV_COARSE_FACE_FLAG_SELECT, and SUBDIV_COARSE_FACE_FLAG_SMOOTH.
Referenced by draw_subdiv_cache_extra_coarse_face_data_bm(), and draw_subdiv_cache_extra_coarse_face_data_mapped().
|
static |
Definition at line 457 of file draw_cache_impl_subdivision.cc.
References buffer, GPU_USAGE_DEVICE_ONLY, GPU_vertbuf_calloc(), GPU_vertbuf_init_with_format_ex(), and opensubdiv_gpu_buffer_init().
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_extract_pos_nor(), and draw_subdiv_extract_uvs().
|
static |
Definition at line 981 of file draw_cache_impl_subdivision.cc.
References BKE_subdiv_foreach_subdiv_geometry(), DRWCacheBuildingContext::cache, DRWCacheBuildingContext::coarse_mesh, draw_subdiv_foreach_callbacks(), DRWCacheBuildingContext::edge_origindex_map, DRWSubdivCache::num_subdiv_loops, DRWCacheBuildingContext::settings, DRWCacheBuildingContext::subdiv_loop_edge_index, DRWCacheBuildingContext::subdiv_loop_subdiv_edge_index, and SubdivForeachContext::user_data.
Referenced by draw_subdiv_build_cache().
|
static |
Definition at line 504 of file draw_cache_impl_subdivision.cc.
References Subdiv::evaluator, get_patch_handle_format(), get_quadtree_format(), OpenSubdiv_Evaluator::getPatchMap, GPU_USAGE_STATIC, GPU_vertbuf_calloc(), GPU_vertbuf_init_with_format_ex(), DRWPatchMap::max_depth, DRWPatchMap::max_patch_face, DRWPatchMap::min_patch_face, opensubdiv_gpu_buffer_init(), DRWPatchMap::patch_map_handles, DRWPatchMap::patch_map_quadtree, and DRWPatchMap::patches_are_triangular.
Referenced by draw_subdiv_build_cache().
|
static |
Definition at line 540 of file draw_cache_impl_subdivision.cc.
References GPU_VERTBUF_DISCARD_SAFE, DRWPatchMap::max_depth, DRWPatchMap::max_patch_face, DRWPatchMap::min_patch_face, DRWPatchMap::patch_map_handles, DRWPatchMap::patch_map_quadtree, and DRWPatchMap::patches_are_triangular.
Referenced by draw_subdiv_cache_free().
void draw_subdiv_accumulate_normals | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | pos_nor, | ||
GPUVertBuf * | face_adjacency_offsets, | ||
GPUVertBuf * | face_adjacency_lists, | ||
GPUVertBuf * | vertex_loop_map, | ||
GPUVertBuf * | vertex_normals | ||
) |
Definition at line 1559 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_verts, and SHADER_BUFFER_NORMALS_ACCUMULATE.
Referenced by blender::draw::extract_pos_nor_init_subdiv().
|
static |
Definition at line 1052 of file draw_cache_impl_subdivision.cc.
References BKE_subdiv_face_ptex_offset_get(), build_vertex_face_adjacency_maps(), DRWCacheBuildingContext::cache, DRWCacheBuildingContext::coarse_mesh, DRWSubdivCache::corner_patch_coords, do_subdiv_traversal(), draw_patch_map_build(), draw_subdiv_build_origindex_buffer(), draw_subdiv_cache_free(), DRWCacheBuildingContext::edge_origindex_map, DRWSubdivCache::face_ptex_offset, DRWSubdivCache::face_ptex_offset_buffer, DRWSubdivCache::fdots_patch_coords, get_blender_patch_coords_format(), DRWSubdivCache::gpu_patch_map, gpu_vertbuf_create_from_format(), GPU_vertbuf_get_data(), make_patch_coord(), DRWSubdivCache::may_have_loose_geom, MEM_SAFE_FREE, Mesh::mpoly, DRWSubdivCache::num_coarse_poly, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::num_subdiv_verts, DRWCacheBuildingContext::patch_coords, DRWSubdivCache::patch_coords, SubdivToMeshSettings::resolution, SubsurfRuntimeData::resolution, DRWSubdivCache::resolution, DRWCacheBuildingContext::settings, DRWCacheBuildingContext::subdiv_loop_subdiv_vert_index, DRWSubdivCache::subdiv_polygon_offset, DRWSubdivCache::subdiv_polygon_offset_buffer, MPoly::totloop, Mesh::totpoly, SubdivToMeshSettings::use_optimal_display, and DRWCacheBuildingContext::vert_origindex_map.
Referenced by draw_subdiv_create_requested_buffers().
void draw_subdiv_build_edge_fac_buffer | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | pos_nor, | ||
GPUVertBuf * | edge_idx, | ||
GPUVertBuf * | edge_fac | ||
) |
Definition at line 1799 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_crappy_amd_driver(), GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, and SHADER_BUFFER_EDGE_FAC.
Referenced by blender::draw::extract_edge_fac_init_subdiv().
void draw_subdiv_build_edituv_stretch_angle_buffer | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | pos_nor, | ||
GPUVertBuf * | uvs, | ||
int | uvs_offset, | ||
GPUVertBuf * | stretch_angles | ||
) |
Definition at line 1885 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, and SHADER_BUFFER_UV_STRETCH_ANGLE.
Referenced by blender::draw::extract_edituv_stretch_angle_init_subdiv().
void draw_subdiv_build_edituv_stretch_area_buffer | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | coarse_data, | ||
GPUVertBuf * | subdiv_data | ||
) |
Definition at line 1858 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, SHADER_BUFFER_UV_STRETCH_AREA, and DRWSubdivCache::subdiv_polygon_offset_buffer.
Referenced by blender::draw::extract_edituv_stretch_area_init_subdiv().
void draw_subdiv_build_fdots_buffers | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | fdots_pos, | ||
GPUVertBuf * | fdots_nor, | ||
GPUIndexBuf * | fdots_indices | ||
) |
Definition at line 1685 of file draw_cache_impl_subdivision.cc.
References BLI_assert, create_buffer_and_interface(), draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), Subdiv::evaluator, DRWSubdivCache::extra_coarse_face_data, DRWSubdivCache::fdots_patch_coords, OpenSubdiv_Evaluator::fillPatchArraysBuffer, get_patch_array_format(), get_patch_evaluation_shader(), get_patch_index_format(), get_patch_param_format(), get_subdiv_vertex_format(), GPU_BARRIER_ELEMENT_ARRAY, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_indexbuf_bind_as_ssbo(), GPU_memory_barrier(), DRWSubdivCache::gpu_patch_map, GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), GPU_vertbuf_discard(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_coarse_poly, opensubdiv_gpu_buffer_init(), DRWPatchMap::patch_map_handles, DRWPatchMap::patch_map_quadtree, SHADER_PATCH_EVALUATION_FACE_DOTS, SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS, DRWSubdivCache::subdiv, DRWSubdivCache::verts_orig_index, OpenSubdiv_Evaluator::wrapPatchIndexBuffer, OpenSubdiv_Evaluator::wrapPatchParamBuffer, and OpenSubdiv_Evaluator::wrapSrcBuffer.
Referenced by blender::draw::extract_fdots_init_subdiv().
void draw_subdiv_build_lines_buffer | ( | const DRWSubdivCache * | cache, |
GPUIndexBuf * | lines_indices | ||
) |
Definition at line 1758 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), DRWSubdivCache::edges_orig_index, DRWSubdivCache::extra_coarse_face_data, get_subdiv_shader(), GPU_BARRIER_ELEMENT_ARRAY, GPU_indexbuf_bind_as_ssbo(), GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, SHADER_BUFFER_LINES, and DRWSubdivCache::subdiv_polygon_offset_buffer.
Referenced by blender::draw::extract_lines_init_subdiv().
void draw_subdiv_build_lines_loose_buffer | ( | const DRWSubdivCache * | cache, |
GPUIndexBuf * | lines_indices, | ||
GPUVertBuf * | lines_flags, | ||
uint | num_loose_edges | ||
) |
Definition at line 1779 of file draw_cache_impl_subdivision.cc.
References drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_ELEMENT_ARRAY, GPU_indexbuf_bind_as_ssbo(), GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), and SHADER_BUFFER_LINES_LOOSE.
Referenced by blender::draw::extract_lines_loose_geom_subdiv().
void draw_subdiv_build_lnor_buffer | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | pos_nor, | ||
GPUVertBuf * | lnor | ||
) |
Definition at line 1825 of file draw_cache_impl_subdivision.cc.
References BLI_assert, draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), DRWSubdivCache::extra_coarse_face_data, get_subdiv_shader(), GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, SHADER_BUFFER_LNOR, DRWSubdivCache::subdiv_polygon_offset_buffer, and DRWSubdivCache::verts_orig_index.
Referenced by blender::draw::extract_lnor_init_subdiv().
GPUVertBuf* draw_subdiv_build_origindex_buffer | ( | int * | vert_origindex, |
uint | num_loops | ||
) |
Definition at line 491 of file draw_cache_impl_subdivision.cc.
References buffer, draw_subdiv_init_origindex_buffer(), and GPU_vertbuf_calloc().
Referenced by draw_subdiv_build_cache(), draw_subdiv_cache_ensure_mat_offsets(), and blender::draw::extract_pos_nor_init_subdiv().
void draw_subdiv_build_sculpt_data_buffer | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | mask_vbo, | ||
GPUVertBuf * | face_set_vbo, | ||
GPUVertBuf * | sculpt_data | ||
) |
Definition at line 1532 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, and SHADER_BUFFER_SCULPT_DATA.
Referenced by blender::draw::extract_sculpt_data_init_subdiv().
void draw_subdiv_build_tris_buffer | ( | const DRWSubdivCache * | cache, |
GPUIndexBuf * | subdiv_tris, | ||
const int | material_count | ||
) |
Definition at line 1639 of file draw_cache_impl_subdivision.cc.
References BLI_assert, draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), DRWSubdivCache::extra_coarse_face_data, get_subdiv_shader(), GPU_BARRIER_ELEMENT_ARRAY, GPU_indexbuf_bind_as_ssbo(), GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, DRWSubdivCache::polygon_mat_offset, SHADER_BUFFER_TRIS, SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, and DRWSubdivCache::subdiv_polygon_offset_buffer.
Referenced by blender::draw::extract_tris_init_subdiv().
|
static |
For material assignments we want indices for triangles that share a common material to be laid out contiguously in memory. To achieve this, we sort the indices based on which material the coarse polygon was assigned. The sort is performed by offsetting the loops indices so that they are directly assigned to the right sorted indices.
The offsets are computed not based on the loops indices, but on the number of subdivided polygons for each coarse polygon. We then only store a single offset for each coarse polygon, since all sub-faces are contiguous, they all share the same offset.
Definition at line 1947 of file draw_cache_impl_subdivision.cc.
References draw_subdiv_build_origindex_buffer(), draw_subdiv_cache_free_material_data(), DRWSubdivCache::mat_end, MPoly::mat_nr, DRWSubdivCache::mat_start, MEM_callocN, MEM_dupallocN, MEM_freeN, MEM_mallocN, Mesh::mpoly, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::polygon_mat_offset, DRWSubdivCache::subdiv_polygon_offset, and Mesh::totpoly.
Referenced by draw_subdiv_create_requested_buffers().
|
static |
Definition at line 658 of file draw_cache_impl_subdivision.cc.
References bm, BM_elem_index_get, BM_FACES_OF_MESH, BM_ITER_MESH, and compute_coarse_face_flag().
Referenced by draw_subdiv_cache_update_extra_coarse_face_data().
|
static |
Definition at line 688 of file draw_cache_impl_subdivision.cc.
References bm, bm_original_face_get(), compute_coarse_face_flag(), draw_subdiv_cache_extra_coarse_face_data_mesh(), MeshRenderData::efa_act, mesh, and Mesh::totpoly.
Referenced by draw_subdiv_cache_update_extra_coarse_face_data().
|
static |
Definition at line 671 of file draw_cache_impl_subdivision.cc.
References MPoly::flag, MPoly::loopstart, ME_FACE_SEL, ME_HIDE, ME_SMOOTH, mesh, Mesh::mpoly, SUBDIV_COARSE_FACE_FLAG_HIDDEN, SUBDIV_COARSE_FACE_FLAG_OFFSET, SUBDIV_COARSE_FACE_FLAG_SELECT, SUBDIV_COARSE_FACE_FLAG_SMOOTH, and Mesh::totpoly.
Referenced by draw_subdiv_cache_extra_coarse_face_data_mapped(), and draw_subdiv_cache_update_extra_coarse_face_data().
void draw_subdiv_cache_free | ( | DRWSubdivCache * | cache | ) |
Definition at line 575 of file draw_cache_impl_subdivision.cc.
References DRWSubdivCache::corner_patch_coords, draw_patch_map_free(), draw_subdiv_cache_free_material_data(), draw_subdiv_free_edit_mode_cache(), DRWSubdivLooseGeom::edge_len, DRWSubdivLooseGeom::edges, DRWSubdivCache::extra_coarse_face_data, DRWSubdivCache::face_ptex_offset_buffer, DRWSubdivCache::gpu_patch_map, GPU_uniformbuf_free(), GPU_VERTBUF_DISCARD_SAFE, DRWSubdivLooseGeom::loop_len, DRWSubdivCache::loose_geom, DRWSubdivCache::may_have_loose_geom, MEM_SAFE_FREE, DRWSubdivCache::num_coarse_poly, DRWSubdivCache::num_subdiv_edges, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::num_subdiv_quads, DRWSubdivCache::num_subdiv_triangles, DRWSubdivCache::num_subdiv_verts, DRWSubdivCache::patch_coords, DRWSubdivCache::resolution, DRWSubdivCache::subdiv_loop_poly_index, DRWSubdivCache::subdiv_loop_subdiv_edge_index, DRWSubdivCache::subdiv_loop_subdiv_vert_index, DRWSubdivCache::subdiv_polygon_offset, DRWSubdivCache::subdiv_polygon_offset_buffer, DRWSubdivCache::subdiv_vertex_face_adjacency, DRWSubdivCache::subdiv_vertex_face_adjacency_offsets, DRWSubdivCache::ubo, DRWSubdivLooseGeom::vert_len, and DRWSubdivLooseGeom::verts.
Referenced by draw_subdiv_build_cache(), and mesh_batch_cache_free_subdiv_cache().
|
static |
Definition at line 561 of file draw_cache_impl_subdivision.cc.
References GPU_VERTBUF_DISCARD_SAFE, DRWSubdivCache::mat_end, DRWSubdivCache::mat_start, MEM_SAFE_FREE, and DRWSubdivCache::polygon_mat_offset.
Referenced by draw_subdiv_cache_ensure_mat_offsets(), and draw_subdiv_cache_free().
blender::Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges | ( | const DRWSubdivCache * | cache | ) |
Definition at line 2196 of file draw_cache_impl_subdivision.cc.
References DRWSubdivLooseGeom::edge_len, DRWSubdivLooseGeom::edges, and DRWSubdivCache::loose_geom.
Referenced by blender::draw::extract_edge_idx_loose_geom_subdiv(), blender::draw::extract_edit_data_loose_geom_subdiv(), blender::draw::extract_lines_loose_geom_subdiv(), blender::draw::extract_points_loose_geom_subdiv(), blender::draw::extract_pos_nor_loose_geom_subdiv(), and blender::draw::extract_vert_idx_loose_geom_subdiv().
blender::Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts | ( | const DRWSubdivCache * | cache | ) |
Definition at line 2201 of file draw_cache_impl_subdivision.cc.
References DRWSubdivLooseGeom::edge_len, DRWSubdivCache::loose_geom, DRWSubdivLooseGeom::vert_len, and DRWSubdivLooseGeom::verts.
Referenced by blender::draw::extract_points_loose_geom_subdiv(), blender::draw::extract_pos_nor_loose_geom_subdiv(), and blender::draw::extract_vert_idx_loose_geom_subdiv().
|
static |
Definition at line 556 of file draw_cache_impl_subdivision.cc.
References Subdiv::evaluator, DRWSubdivCache::num_subdiv_loops, and DRWSubdivCache::subdiv.
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_build_lnor_buffer(), draw_subdiv_build_tris_buffer(), draw_subdiv_extract_pos_nor(), draw_subdiv_extract_uvs(), and draw_subdiv_interp_custom_data().
|
static |
Definition at line 704 of file draw_cache_impl_subdivision.cc.
References DRWSubdivCache::bm, draw_subdiv_cache_extra_coarse_face_data_bm(), draw_subdiv_cache_extra_coarse_face_data_mapped(), draw_subdiv_cache_extra_coarse_face_data_mesh(), MeshRenderData::efa_act, DRWSubdivCache::extra_coarse_face_data, MeshRenderData::extract_type, GPU_COMP_U32, GPU_FETCH_INT, GPU_USAGE_DYNAMIC, GPU_vertbuf_calloc(), GPU_vertbuf_data_alloc(), GPU_vertbuf_get_data(), GPU_vertbuf_init_with_format_ex(), GPU_vertbuf_tag_dirty(), GPU_vertformat_attr_add(), mesh, MR_EXTRACT_BMESH, MR_EXTRACT_MAPPED, BMesh::totface, and Mesh::totpoly.
Referenced by draw_subdiv_create_requested_buffers().
|
static |
Definition at line 2012 of file draw_cache_impl_subdivision.cc.
References BKE_object_get_editmesh_eval_final(), BKE_subdiv_eval_begin_from_mesh(), BKE_subsurf_modifier_subdiv_descriptor_ensure(), BLI_assert, BMEditMesh::bm, bm, DRWSubdivCache::bm, MeshBufferCache::buff, CD_CUSTOMLOOPNORMAL, CustomData_has_layer(), draw_subdiv_build_cache(), draw_subdiv_cache_ensure_mat_offsets(), draw_subdiv_cache_update_extra_coarse_face_data(), draw_subdiv_invalidate_evaluator_for_orco(), DRW_ibo_requested(), MeshRenderData::edit_bmesh, Mesh::edit_mesh, Mesh::flag, SubsurfRuntimeData::has_gpu_subdiv, MeshBufferList::ibo, DRWSubdivCache::is_edit_mode, Mesh::ldata, SubdivSettings::level, MeshBatchCache::mat_len, ME_AUTOSMOOTH, mesh, DRWSubdivCache::mesh, mesh_batch_cache_ensure_subdiv_cache(), blender::draw::mesh_buffer_cache_create_requested_subdiv(), mesh_render_data_create(), mesh_render_data_free(), DRWSubdivCache::num_subdiv_edges, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::num_subdiv_quads, DRWSubdivCache::num_subdiv_triangles, DRWSubdivCache::num_subdiv_verts, DRWSubdivCache::optimal_display, Mesh::runtime, SubsurfRuntimeData::settings, SubsurfRuntimeData::stats_totedge, SubsurfRuntimeData::stats_totloop, SubsurfRuntimeData::stats_totpoly, SubsurfRuntimeData::stats_totvert, DRWSubdivCache::subdiv, SUBDIV_EVALUATOR_TYPE_GPU, Mesh_Runtime::subsurf_runtime_data, Mesh::totpoly, MeshBufferList::tris, tris_count_from_number_of_loops(), DRWSubdivCache::use_custom_loop_normals, DRWSubdivCache::use_hide, MeshRenderData::use_hide, SubsurfRuntimeData::use_loop_normals, and SubsurfRuntimeData::use_optimal_display.
Referenced by DRW_create_subdivision().
|
static |
Definition at line 923 of file draw_cache_impl_subdivision.cc.
References DRWCacheBuildingContext::e_origindex, DRWCacheBuildingContext::edge_origindex_map, and SubdivForeachContext::user_data.
Referenced by draw_subdiv_foreach_callbacks().
void draw_subdiv_extract_pos_nor | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | pos_nor, | ||
GPUVertBuf * | orco | ||
) |
Definition at line 1318 of file draw_cache_impl_subdivision.cc.
References BLI_assert, create_buffer_and_interface(), draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), Subdiv::evaluator, OpenSubdiv_Evaluator::fillPatchArraysBuffer, get_patch_array_format(), get_patch_evaluation_shader(), get_patch_index_format(), get_patch_param_format(), get_subdiv_vertex_format(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), DRWSubdivCache::gpu_patch_map, GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), GPU_vertbuf_discard(), GPU_VERTBUF_DISCARD_SAFE, MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, DRWSubdivCache::patch_coords, DRWPatchMap::patch_map_handles, DRWPatchMap::patch_map_quadtree, SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_ORCO, DRWSubdivCache::subdiv, DRWSubdivCache::verts_orig_index, OpenSubdiv_Evaluator::wrapPatchIndexBuffer, OpenSubdiv_Evaluator::wrapPatchParamBuffer, OpenSubdiv_Evaluator::wrapSrcBuffer, and OpenSubdiv_Evaluator::wrapSrcVertexDataBuffer.
Referenced by blender::draw::extract_edituv_stretch_angle_init_subdiv(), and blender::draw::extract_pos_nor_init_subdiv().
void draw_subdiv_extract_uvs | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | uvs, | ||
const int | face_varying_channel, | ||
const int | dst_offset | ||
) |
Definition at line 1395 of file draw_cache_impl_subdivision.cc.
References BLI_assert, OpenSubdiv_Buffer::buffer_offset, DRWSubdivCache::corner_patch_coords, create_buffer_and_interface(), draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), Subdiv::evaluator, OpenSubdiv_Evaluator::fillFVarPatchArraysBuffer, get_patch_array_format(), get_patch_evaluation_shader(), get_patch_index_format(), get_patch_param_format(), get_uvs_format(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), DRWSubdivCache::gpu_patch_map, GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), GPU_vertbuf_discard(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, DRWPatchMap::patch_map_handles, DRWPatchMap::patch_map_quadtree, SHADER_PATCH_EVALUATION_FVAR, DRWSubdivCache::subdiv, DRWSubdivCache::verts_orig_index, OpenSubdiv_Evaluator::wrapFVarPatchIndexBuffer, OpenSubdiv_Evaluator::wrapFVarPatchParamBuffer, and OpenSubdiv_Evaluator::wrapFVarSrcBuffer.
Referenced by blender::draw::extract_uv_init_subdiv().
void draw_subdiv_finalize_custom_normals | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | src_custom_normals, | ||
GPUVertBuf * | pos_nor | ||
) |
Definition at line 1614 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, and SHADER_BUFFER_NORMALS_FINALIZE.
Referenced by blender::draw::extract_pos_nor_init_subdiv().
void draw_subdiv_finalize_normals | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | vertex_normals, | ||
GPUVertBuf * | subdiv_loop_subdiv_vert_index, | ||
GPUVertBuf * | pos_nor | ||
) |
Definition at line 1589 of file draw_cache_impl_subdivision.cc.
References BLI_assert, drw_subdiv_compute_dispatch(), get_subdiv_shader(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, and SHADER_BUFFER_NORMALS_FINALIZE.
Referenced by blender::draw::extract_pos_nor_init_subdiv().
|
static |
Definition at line 971 of file draw_cache_impl_subdivision.cc.
References draw_subdiv_edge_cb(), draw_subdiv_loop_cb(), draw_subdiv_topology_info_cb(), draw_subdiv_vertex_corner_cb(), draw_subdiv_vertex_edge_cb(), SubdivForeachContext::edge, SubdivForeachContext::loop, SubdivForeachContext::topology_info, SubdivForeachContext::vertex_corner, and SubdivForeachContext::vertex_edge.
Referenced by do_subdiv_traversal().
|
static |
Definition at line 568 of file draw_cache_impl_subdivision.cc.
References DRWSubdivCache::edges_orig_index, DRWSubdivCache::fdots_patch_coords, GPU_VERTBUF_DISCARD_SAFE, and DRWSubdivCache::verts_orig_index.
Referenced by draw_subdiv_cache_free().
GPUVertFormat* draw_subdiv_get_pos_nor_format | ( | void | ) |
Return the format used for the positions and normals VBO.
Definition at line 393 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_F32, GPU_FETCH_FLOAT, GPU_vertformat_alias_add(), and GPU_vertformat_attr_add().
Referenced by blender::draw::extract_edituv_stretch_angle_init_subdiv(), and blender::draw::extract_pos_nor_init_subdiv().
void draw_subdiv_init_origindex_buffer | ( | GPUVertBuf * | buffer, |
int32_t * | vert_origindex, | ||
uint | num_loops, | ||
uint | loose_len | ||
) |
Definition at line 479 of file draw_cache_impl_subdivision.cc.
References buffer, get_origindex_format(), GPU_USAGE_STATIC, GPU_vertbuf_data_alloc(), GPU_vertbuf_get_data(), and GPU_vertbuf_init_with_format_ex().
Referenced by draw_subdiv_build_origindex_buffer(), blender::draw::extract_edge_fac_init_subdiv(), blender::draw::extract_edge_idx_init_subdiv(), blender::draw::extract_poly_idx_init_subdiv(), and blender::draw::extract_vert_idx_init_subdiv().
|
static |
Definition at line 1215 of file draw_cache_impl_subdivision.cc.
References DRWSubdivUboStorage::coarse_face_active_mask, DRWSubdivUboStorage::coarse_face_hidden_mask, DRWSubdivUboStorage::coarse_face_loopstart_mask, DRWSubdivUboStorage::coarse_face_select_mask, DRWSubdivUboStorage::coarse_face_smooth_mask, DRWSubdivUboStorage::coarse_poly_count, DRWSubdivUboStorage::dst_offset, DRWSubdivUboStorage::edge_loose_offset, DRWSubdivCache::gpu_patch_map, DRWSubdivUboStorage::has_sculpt_mask, DRWSubdivUboStorage::is_edit_mode, DRWSubdivCache::is_edit_mode, DRWSubdivUboStorage::max_depth, DRWPatchMap::max_depth, DRWSubdivUboStorage::max_patch_face, DRWPatchMap::max_patch_face, DRWSubdivUboStorage::min_patch_face, DRWPatchMap::min_patch_face, DRWSubdivCache::num_coarse_poly, DRWSubdivUboStorage::num_subdiv_loops, DRWSubdivCache::num_subdiv_loops, DRWSubdivUboStorage::optimal_display, DRWSubdivCache::optimal_display, DRWSubdivUboStorage::patches_are_triangular, DRWPatchMap::patches_are_triangular, DRWSubdivUboStorage::src_offset, SUBDIV_COARSE_FACE_FLAG_ACTIVE_MASK, SUBDIV_COARSE_FACE_FLAG_HIDDEN_MASK, SUBDIV_COARSE_FACE_FLAG_SELECT_MASK, SUBDIV_COARSE_FACE_FLAG_SMOOTH_MASK, SUBDIV_COARSE_FACE_LOOP_START_MASK, DRWSubdivUboStorage::total_dispatch_size, DRWSubdivUboStorage::use_hide, and DRWSubdivCache::use_hide.
Referenced by draw_subdiv_ubo_update_and_bind().
void draw_subdiv_interp_custom_data | ( | const DRWSubdivCache * | cache, |
GPUVertBuf * | src_data, | ||
GPUVertBuf * | dst_data, | ||
int | dimensions, | ||
int | dst_offset, | ||
bool | compress_to_u16 | ||
) |
Definition at line 1464 of file draw_cache_impl_subdivision.cc.
References BLI_assert, DRWSubdivCache::corner_patch_coords, draw_subdiv_cache_need_polygon_data(), drw_subdiv_compute_dispatch(), DRWSubdivCache::extra_coarse_face_data, DRWSubdivCache::face_ptex_offset_buffer, get_subdiv_shader(), GPU_BARRIER_SHADER_STORAGE, GPU_BARRIER_VERTEX_ATTRIB_ARRAY, GPU_memory_barrier(), GPU_shader_bind(), GPU_shader_unbind(), GPU_vertbuf_bind_as_ssbo(), MAX_GPU_SUBDIV_SSBOS, DRWSubdivCache::num_subdiv_quads, SHADER_COMP_CUSTOM_DATA_INTERP_1D, SHADER_COMP_CUSTOM_DATA_INTERP_2D, SHADER_COMP_CUSTOM_DATA_INTERP_3D, SHADER_COMP_CUSTOM_DATA_INTERP_4D, and DRWSubdivCache::subdiv_polygon_offset_buffer.
Referenced by blender::draw::extract_attr_init_subdiv(), blender::draw::extract_pos_nor_init_subdiv(), blender::draw::extract_sculpt_data_init_subdiv(), blender::draw::extract_tan_init_subdiv(), and blender::draw::extract_weights_init_subdiv().
Definition at line 747 of file draw_cache_impl_subdivision.cc.
References CD_ORCO, CustomData_has_layer(), Subdiv::evaluator, OpenSubdiv_Evaluator::hasVertexData, mesh, openSubdiv_deleteEvaluator(), openSubdiv_deleteTopologyRefiner(), Subdiv::topology_refiner, and Mesh::vdata.
Referenced by draw_subdiv_create_requested_buffers().
|
static |
Definition at line 948 of file draw_cache_impl_subdivision.cc.
References make_patch_coord(), DRWCacheBuildingContext::patch_coords, DRWCacheBuildingContext::subdiv_loop_poly_index, DRWCacheBuildingContext::subdiv_loop_subdiv_edge_index, DRWCacheBuildingContext::subdiv_loop_subdiv_vert_index, DRWCacheBuildingContext::subdiv_loop_vert_index, SubdivForeachContext::user_data, v, and DRWCacheBuildingContext::vert_origindex_map.
Referenced by draw_subdiv_foreach_callbacks().
|
static |
Definition at line 803 of file draw_cache_impl_subdivision.cc.
References DRWCacheBuildingContext::cache, CD_ORIGINDEX, DRWCacheBuildingContext::coarse_mesh, DRWSubdivCache::corner_patch_coords, CustomData_get_layer(), DRWCacheBuildingContext::e_origindex, Mesh::edata, DRWCacheBuildingContext::edge_origindex_map, DRWSubdivCache::edges_orig_index, get_blender_patch_coords_format(), get_origindex_format(), GPU_USAGE_DYNAMIC, GPU_vertbuf_calloc(), GPU_vertbuf_data_alloc(), GPU_vertbuf_get_data(), GPU_vertbuf_init_with_format_ex(), DRWSubdivCache::may_have_loose_geom, MEM_dupallocN, MEM_mallocN, DRWSubdivCache::num_subdiv_edges, DRWSubdivCache::num_subdiv_loops, DRWSubdivCache::num_subdiv_quads, DRWSubdivCache::num_subdiv_verts, DRWCacheBuildingContext::patch_coords, DRWSubdivCache::patch_coords, DRWCacheBuildingContext::subdiv_loop_edge_index, DRWCacheBuildingContext::subdiv_loop_poly_index, DRWSubdivCache::subdiv_loop_poly_index, DRWCacheBuildingContext::subdiv_loop_subdiv_edge_index, DRWSubdivCache::subdiv_loop_subdiv_edge_index, DRWCacheBuildingContext::subdiv_loop_subdiv_vert_index, DRWSubdivCache::subdiv_loop_subdiv_vert_index, DRWCacheBuildingContext::subdiv_loop_vert_index, DRWSubdivCache::subdiv_polygon_offset, SubdivForeachContext::user_data, DRWCacheBuildingContext::v_origindex, Mesh::vdata, DRWCacheBuildingContext::vert_origindex_map, and DRWSubdivCache::verts_orig_index.
Referenced by draw_subdiv_foreach_callbacks().
|
static |
Definition at line 1243 of file draw_cache_impl_subdivision.cc.
References draw_subdiv_init_ubo_storage(), GPU_shader_get_uniform_block_binding(), GPU_uniformbuf_bind(), GPU_uniformbuf_create_ex(), GPU_uniformbuf_update(), and DRWSubdivCache::ubo.
Referenced by drw_subdiv_compute_dispatch().
|
static |
Definition at line 895 of file draw_cache_impl_subdivision.cc.
References BLI_assert, ORIGINDEX_NONE, SubdivForeachContext::user_data, and DRWCacheBuildingContext::vert_origindex_map.
Referenced by draw_subdiv_foreach_callbacks().
|
static |
Definition at line 910 of file draw_cache_impl_subdivision.cc.
Referenced by draw_subdiv_foreach_callbacks().
Definition at line 2281 of file draw_cache_impl_subdivision.cc.
References BKE_subdiv_free(), BLI_linklist_pop(), BLI_mutex_lock(), BLI_mutex_unlock(), Subdiv::evaluator, gpu_subdiv_free_queue, gpu_subdiv_queue_mutex, OPENSUBDIV_EVALUATOR_CPU, and OpenSubdiv_Evaluator::type.
Referenced by DRW_render_to_image(), DRW_subdiv_free(), ED_view3d_draw_offscreen(), and view3d_main_region_draw().
void DRW_create_subdivision | ( | Object * | ob, |
Mesh * | mesh, | ||
MeshBatchCache * | batch_cache, | ||
MeshBufferCache * | mbc, | ||
const bool | is_editmode, | ||
const bool | is_paint_mode, | ||
const bool | is_mode_active, | ||
const float | obmat[4][4], | ||
const bool | do_final, | ||
const bool | do_uvedit, | ||
const bool | do_cage, | ||
const ToolSettings * | ts, | ||
const bool | use_hide | ||
) |
Definition at line 2209 of file draw_cache_impl_subdivision.cc.
References draw_subdiv_create_requested_buffers(), g_evaluator_cache, mesh, openSubdiv_createEvaluatorCache(), OPENSUBDIV_EVALUATOR_GPU, and PIL_check_seconds_timer().
Referenced by DRW_mesh_batch_cache_create_requested().
Definition at line 2274 of file draw_cache_impl_subdivision.cc.
References BLI_linklist_prepend(), BLI_mutex_lock(), BLI_mutex_unlock(), gpu_subdiv_free_queue, and gpu_subdiv_queue_mutex.
Referenced by DRW_engines_register().
|
static |
Helper to ensure that the UBO is always initialized before dispatching computes and that the same number of elements that need to be processed is used for the UBO and the dispatch size. Use this instead of a raw call to GPU_compute_dispatch.
Definition at line 1280 of file draw_cache_impl_subdivision.cc.
References BLI_assert, ceilf, draw_subdiv_ubo_update_and_bind(), get_dispatch_size(), GPU_compute_dispatch(), GPU_max_work_group_count(), and sqrtf.
Referenced by draw_subdiv_accumulate_normals(), draw_subdiv_build_edge_fac_buffer(), draw_subdiv_build_edituv_stretch_angle_buffer(), draw_subdiv_build_edituv_stretch_area_buffer(), draw_subdiv_build_fdots_buffers(), draw_subdiv_build_lines_buffer(), draw_subdiv_build_lines_loose_buffer(), draw_subdiv_build_lnor_buffer(), draw_subdiv_build_sculpt_data_buffer(), draw_subdiv_build_tris_buffer(), draw_subdiv_extract_pos_nor(), draw_subdiv_extract_uvs(), draw_subdiv_finalize_custom_normals(), draw_subdiv_finalize_normals(), and draw_subdiv_interp_custom_data().
Definition at line 2257 of file draw_cache_impl_subdivision.cc.
References DRW_cache_free_old_subdiv(), g_evaluator_cache, g_subdiv_shaders, GPU_shader_free(), NUM_SHADERS, and openSubdiv_deleteEvaluatorCache().
Referenced by WM_exit_ex().
void DRW_subdivide_loose_geom | ( | DRWSubdivCache * | subdiv_cache, |
MeshBufferCache * | cache | ||
) |
Definition at line 2109 of file draw_cache_impl_subdivision.cc.
References BKE_subdiv_mesh_interpolate_position_on_edge(), DRWSubdivLooseVertex::co, MVert::co, DRWSubdivLooseEdge::coarse_edge_index, DRWSubdivLooseVertex::coarse_vertex_index, copy_v3_v3(), MeshExtractLooseGeom::edge_len, DRWSubdivLooseGeom::edge_len, MeshExtractLooseGeom::edges, DRWSubdivLooseGeom::edges, float(), SubdivSettings::is_simple, DRWSubdivLooseGeom::loop_len, MeshBufferCache::loose_geom, DRWSubdivCache::loose_geom, DRWSubdivLooseEdge::loose_subdiv_v1_index, DRWSubdivLooseEdge::loose_subdiv_v2_index, Mesh::medge, MEM_callocN, DRWSubdivCache::mesh, Mesh::mvert, DRWSubdivCache::resolution, Subdiv::settings, DRWSubdivCache::subdiv, u1, u2, MEdge::v1, MEdge::v2, MeshExtractLooseGeom::vert_len, DRWSubdivLooseGeom::vert_len, MeshExtractLooseGeom::verts, and DRWSubdivLooseGeom::verts.
Referenced by blender::draw::mesh_buffer_cache_create_requested_subdiv().
|
static |
Definition at line 373 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_U32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_build_cache(), and draw_subdiv_topology_info_cb().
Definition at line 1270 of file draw_cache_impl_subdivision.cc.
References divide_ceil_u(), and SUBDIV_LOCAL_WORK_GROUP_SIZE.
Referenced by drw_subdiv_compute_dispatch().
|
static |
Definition at line 384 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_I32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by build_vertex_face_adjacency_maps(), draw_subdiv_init_origindex_buffer(), and draw_subdiv_topology_info_cb().
|
static |
Definition at line 288 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_I32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_extract_pos_nor(), and draw_subdiv_extract_uvs().
|
static |
Definition at line 201 of file draw_cache_impl_subdivision.cc.
References datatoc_common_subdiv_lib_glsl, g_subdiv_shaders, get_shader_code(), get_shader_name(), GPU_shader_create_compute(), MEM_freeN, MEM_mallocN, openSubdiv_getGLSLPatchBasisSource(), SHADER_PATCH_EVALUATION_FACE_DOTS, SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS, SHADER_PATCH_EVALUATION_FVAR, and SHADER_PATCH_EVALUATION_ORCO.
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_extract_pos_nor(), draw_subdiv_extract_uvs(), and get_subdiv_shader().
|
static |
Definition at line 303 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_I32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by draw_patch_map_build().
|
static |
Definition at line 336 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_I32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_extract_pos_nor(), and draw_subdiv_extract_uvs().
|
static |
Definition at line 326 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_F32, GPU_FETCH_FLOAT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_build_fdots_buffers(), draw_subdiv_extract_pos_nor(), and draw_subdiv_extract_uvs().
|
static |
Definition at line 315 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_U32, GPU_FETCH_INT, and GPU_vertformat_attr_add().
Referenced by draw_patch_map_build().
|
static |
Definition at line 87 of file draw_cache_impl_subdivision.cc.
References datatoc_common_subdiv_custom_data_interp_comp_glsl, datatoc_common_subdiv_ibo_lines_comp_glsl, datatoc_common_subdiv_ibo_tris_comp_glsl, datatoc_common_subdiv_normals_accumulate_comp_glsl, datatoc_common_subdiv_normals_finalize_comp_glsl, datatoc_common_subdiv_patch_evaluation_comp_glsl, datatoc_common_subdiv_vbo_edge_fac_comp_glsl, datatoc_common_subdiv_vbo_edituv_strech_angle_comp_glsl, datatoc_common_subdiv_vbo_edituv_strech_area_comp_glsl, datatoc_common_subdiv_vbo_lnor_comp_glsl, datatoc_common_subdiv_vbo_sculpt_data_comp_glsl, SHADER_BUFFER_EDGE_FAC, SHADER_BUFFER_LINES, SHADER_BUFFER_LINES_LOOSE, SHADER_BUFFER_LNOR, SHADER_BUFFER_NORMALS_ACCUMULATE, SHADER_BUFFER_NORMALS_FINALIZE, SHADER_BUFFER_SCULPT_DATA, SHADER_BUFFER_TRIS, SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, SHADER_BUFFER_UV_STRETCH_ANGLE, SHADER_BUFFER_UV_STRETCH_AREA, SHADER_COMP_CUSTOM_DATA_INTERP_1D, SHADER_COMP_CUSTOM_DATA_INTERP_2D, SHADER_COMP_CUSTOM_DATA_INTERP_3D, SHADER_COMP_CUSTOM_DATA_INTERP_4D, SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FACE_DOTS, SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS, SHADER_PATCH_EVALUATION_FVAR, and SHADER_PATCH_EVALUATION_ORCO.
Referenced by get_patch_evaluation_shader(), and get_subdiv_shader().
|
static |
Definition at line 136 of file draw_cache_impl_subdivision.cc.
References SHADER_BUFFER_EDGE_FAC, SHADER_BUFFER_LINES, SHADER_BUFFER_LINES_LOOSE, SHADER_BUFFER_LNOR, SHADER_BUFFER_NORMALS_ACCUMULATE, SHADER_BUFFER_NORMALS_FINALIZE, SHADER_BUFFER_SCULPT_DATA, SHADER_BUFFER_TRIS, SHADER_BUFFER_TRIS_MULTIPLE_MATERIALS, SHADER_BUFFER_UV_STRETCH_ANGLE, SHADER_BUFFER_UV_STRETCH_AREA, SHADER_COMP_CUSTOM_DATA_INTERP_1D, SHADER_COMP_CUSTOM_DATA_INTERP_2D, SHADER_COMP_CUSTOM_DATA_INTERP_3D, SHADER_COMP_CUSTOM_DATA_INTERP_4D, SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FACE_DOTS, SHADER_PATCH_EVALUATION_FACE_DOTS_WITH_NORMALS, SHADER_PATCH_EVALUATION_FVAR, and SHADER_PATCH_EVALUATION_ORCO.
Referenced by get_patch_evaluation_shader(), and get_subdiv_shader().
|
static |
Definition at line 257 of file draw_cache_impl_subdivision.cc.
References datatoc_common_subdiv_lib_glsl, ELEM, g_subdiv_shaders, get_patch_evaluation_shader(), get_shader_code(), get_shader_name(), GPU_shader_create_compute(), SHADER_PATCH_EVALUATION, SHADER_PATCH_EVALUATION_FACE_DOTS, SHADER_PATCH_EVALUATION_FVAR, and SHADER_PATCH_EVALUATION_ORCO.
Referenced by draw_subdiv_accumulate_normals(), draw_subdiv_build_edge_fac_buffer(), draw_subdiv_build_edituv_stretch_angle_buffer(), draw_subdiv_build_edituv_stretch_area_buffer(), draw_subdiv_build_lines_buffer(), draw_subdiv_build_lines_loose_buffer(), draw_subdiv_build_lnor_buffer(), draw_subdiv_build_sculpt_data_buffer(), draw_subdiv_build_tris_buffer(), draw_subdiv_finalize_custom_normals(), draw_subdiv_finalize_normals(), and draw_subdiv_interp_custom_data().
|
static |
Definition at line 346 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_F32, GPU_FETCH_FLOAT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_build_fdots_buffers(), and draw_subdiv_extract_pos_nor().
|
static |
Vertex formats used for data transfer from OpenSubdiv, and for data processing on our side.
Definition at line 278 of file draw_cache_impl_subdivision.cc.
References GPU_COMP_F32, GPU_FETCH_FLOAT, and GPU_vertformat_attr_add().
Referenced by draw_subdiv_extract_uvs().
|
static |
Definition at line 1002 of file draw_cache_impl_subdivision.cc.
References GPU_vertbuf_calloc(), GPU_vertbuf_data_alloc(), GPU_vertbuf_init_with_format, len, and verts.
Referenced by build_vertex_face_adjacency_maps(), and draw_subdiv_build_cache().
MINLINE CompressedPatchCoord make_patch_coord | ( | int | ptex_face_index, |
float | u, | ||
float | v | ||
) |
Definition at line 363 of file draw_cache_impl_subdivision.cc.
References v.
Referenced by draw_subdiv_build_cache(), and draw_subdiv_loop_cb().
|
static |
Definition at line 736 of file draw_cache_impl_subdivision.cc.
References MEM_callocN, and MeshBatchCache::subdiv_cache.
Referenced by draw_subdiv_create_requested_buffers().
|
static |
Definition at line 446 of file draw_cache_impl_subdivision.cc.
References OpenSubdiv_Buffer::alloc, OpenSubdiv_Buffer::bind_gpu, OpenSubdiv_Buffer::buffer_offset, OpenSubdiv_Buffer::data, OpenSubdiv_Buffer::device_alloc, OpenSubdiv_Buffer::device_update, vertbuf_alloc(), vertbuf_bind_gpu(), vertbuf_device_alloc(), vertbuf_update_data(), vertbuf_wrap_device_handle(), and OpenSubdiv_Buffer::wrap_device_handle.
Referenced by create_buffer_and_interface(), draw_patch_map_build(), and draw_subdiv_build_fdots_buffers().
Definition at line 469 of file draw_cache_impl_subdivision.cc.
Referenced by draw_subdiv_create_requested_buffers().
|
static |
Definition at line 416 of file draw_cache_impl_subdivision.cc.
References OpenSubdiv_Buffer::data, GPU_vertbuf_data_alloc(), GPU_vertbuf_get_data(), len, and verts.
Referenced by GPU_vertbuf_calloc(), and opensubdiv_gpu_buffer_init().
|
static |
Definition at line 410 of file draw_cache_impl_subdivision.cc.
References buffer, GPU_vertbuf_use(), and verts.
Referenced by opensubdiv_gpu_buffer_init().
|
static |
Definition at line 423 of file draw_cache_impl_subdivision.cc.
References OpenSubdiv_Buffer::data, GPU_vertbuf_data_alloc(), len, and verts.
Referenced by opensubdiv_gpu_buffer_init().
|
static |
Definition at line 437 of file draw_cache_impl_subdivision.cc.
References OpenSubdiv_Buffer::data, data, GPU_vertbuf_update_sub(), len, and verts.
Referenced by opensubdiv_gpu_buffer_init().
|
static |
Definition at line 431 of file draw_cache_impl_subdivision.cc.
References OpenSubdiv_Buffer::data, GPU_vertbuf_wrap_handle(), and verts.
Referenced by opensubdiv_gpu_buffer_init().
char datatoc_common_subdiv_custom_data_interp_comp_glsl[] |
Definition at line 47 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_ibo_lines_comp_glsl[] |
Definition at line 48 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_ibo_tris_comp_glsl[] |
Definition at line 49 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_lib_glsl[] |
Definition at line 50 of file draw_cache_impl_subdivision.cc.
Referenced by get_patch_evaluation_shader(), and get_subdiv_shader().
char datatoc_common_subdiv_normals_accumulate_comp_glsl[] |
Definition at line 51 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_normals_finalize_comp_glsl[] |
Definition at line 52 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_patch_evaluation_comp_glsl[] |
Definition at line 53 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_vbo_edge_fac_comp_glsl[] |
Definition at line 54 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_vbo_edituv_strech_angle_comp_glsl[] |
Definition at line 57 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_vbo_edituv_strech_area_comp_glsl[] |
Definition at line 58 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_vbo_lnor_comp_glsl[] |
Definition at line 55 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
char datatoc_common_subdiv_vbo_sculpt_data_comp_glsl[] |
Definition at line 56 of file draw_cache_impl_subdivision.cc.
Referenced by get_shader_code().
|
static |
Definition at line 2207 of file draw_cache_impl_subdivision.cc.
Referenced by DRW_create_subdivision(), and DRW_subdiv_free().
|
static |
Definition at line 85 of file draw_cache_impl_subdivision.cc.
Referenced by DRW_subdiv_free(), get_patch_evaluation_shader(), and get_subdiv_shader().
|
static |
Definition at line 2271 of file draw_cache_impl_subdivision.cc.
Referenced by DRW_cache_free_old_subdiv(), and DRW_subdiv_cache_free().
|
static |
Definition at line 2272 of file draw_cache_impl_subdivision.cc.
Referenced by DRW_cache_free_old_subdiv(), and DRW_subdiv_cache_free().