diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-06-01 08:02:32 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-06-01 08:02:32 +0300 |
commit | ca346d2176737b6aa296617452a8a6cacb7a970a (patch) | |
tree | 43d004433aa46e04ac142a64382dbb7e2e587886 /source/blender/draw | |
parent | 46cb24e7c253f898f1574516514506a34976e9fa (diff) | |
parent | 54d076b20d39dfd043cbbe7dd8375adfb8755937 (diff) |
Merge remote-tracking branch 'origin/blender-v3.2-release'
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_subdivision.cc | 16 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_subdivision.h | 4 |
2 files changed, 17 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 52170fbd518..f94a3f0b9d8 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -575,6 +575,7 @@ static void draw_subdiv_free_edit_mode_cache(DRWSubdivCache *cache) void draw_subdiv_cache_free(DRWSubdivCache *cache) { GPU_VERTBUF_DISCARD_SAFE(cache->patch_coords); + GPU_VERTBUF_DISCARD_SAFE(cache->corner_patch_coords); GPU_VERTBUF_DISCARD_SAFE(cache->face_ptex_offset_buffer); GPU_VERTBUF_DISCARD_SAFE(cache->subdiv_polygon_offset_buffer); GPU_VERTBUF_DISCARD_SAFE(cache->extra_coarse_face_data); @@ -834,6 +835,11 @@ static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_con cache->patch_coords, get_blender_patch_coords_format(), GPU_USAGE_DYNAMIC); GPU_vertbuf_data_alloc(cache->patch_coords, cache->num_subdiv_loops); + cache->corner_patch_coords = GPU_vertbuf_calloc(); + GPU_vertbuf_init_with_format_ex( + cache->corner_patch_coords, get_blender_patch_coords_format(), GPU_USAGE_DYNAMIC); + GPU_vertbuf_data_alloc(cache->corner_patch_coords, cache->num_subdiv_loops); + cache->verts_orig_index = GPU_vertbuf_calloc(); GPU_vertbuf_init_with_format_ex( cache->verts_orig_index, get_origindex_format(), GPU_USAGE_DYNAMIC); @@ -1129,6 +1135,12 @@ static bool draw_subdiv_build_cache(DRWSubdivCache *cache, * the mesh to not be watertight, leading to shadowing artifacts (see T97877). */ blender::Vector<int> first_loop_index(cache->num_subdiv_verts, -1); + /* Save coordinates for corners, as attributes may vary for each loop connected to the same + * vertex. */ + memcpy(GPU_vertbuf_get_data(cache->corner_patch_coords), + cache_building_context.patch_coords, + sizeof(CompressedPatchCoord) * cache->num_subdiv_loops); + for (int i = 0; i < cache->num_subdiv_loops; i++) { const int vertex = cache_building_context.subdiv_loop_subdiv_vert_index[i]; if (first_loop_index[vertex] != -1) { @@ -1424,7 +1436,7 @@ void draw_subdiv_extract_uvs(const DRWSubdivCache *cache, GPU_vertbuf_bind_as_ssbo(src_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->gpu_patch_map.patch_map_handles, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->gpu_patch_map.patch_map_quadtree, binding_point++); - GPU_vertbuf_bind_as_ssbo(cache->patch_coords, binding_point++); + GPU_vertbuf_bind_as_ssbo(cache->corner_patch_coords, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->verts_orig_index, binding_point++); GPU_vertbuf_bind_as_ssbo(patch_arrays_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(patch_index_buffer, binding_point++); @@ -1499,7 +1511,7 @@ void draw_subdiv_interp_custom_data(const DRWSubdivCache *cache, GPU_vertbuf_bind_as_ssbo(cache->subdiv_polygon_offset_buffer, binding_point++); GPU_vertbuf_bind_as_ssbo(src_data, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->face_ptex_offset_buffer, binding_point++); - GPU_vertbuf_bind_as_ssbo(cache->patch_coords, binding_point++); + GPU_vertbuf_bind_as_ssbo(cache->corner_patch_coords, binding_point++); GPU_vertbuf_bind_as_ssbo(cache->extra_coarse_face_data, binding_point++); GPU_vertbuf_bind_as_ssbo(dst_data, binding_point++); BLI_assert(binding_point <= MAX_GPU_SUBDIV_SSBOS); diff --git a/source/blender/draw/intern/draw_subdivision.h b/source/blender/draw/intern/draw_subdivision.h index 15c770a51c4..8920a2dcd51 100644 --- a/source/blender/draw/intern/draw_subdivision.h +++ b/source/blender/draw/intern/draw_subdivision.h @@ -104,8 +104,10 @@ typedef struct DRWSubdivCache { bool optimal_display; bool use_custom_loop_normals; - /* Coordinates used to evaluate patches for UVs, positions, and normals. */ + /* Coordinates used to evaluate patches for positions and normals. */ struct GPUVertBuf *patch_coords; + /* Coordinates used to evaluate patches for attributes. */ + struct GPUVertBuf *corner_patch_coords; /* Coordinates used to evaluate patches for the face centers (or face dots) in edit-mode. */ struct GPUVertBuf *fdots_patch_coords; |