diff options
author | Germano Cavalcante <mano-wii> | 2021-08-23 15:52:13 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-08-23 19:37:32 +0300 |
commit | ebdae7573618637c60e836bbc00618f65a7a7c4f (patch) | |
tree | 1514432827aa9f55d2e385ba9247c4f067101029 /source/blender/draw/intern/mesh_extractors | |
parent | 7d17f2addf80f7ee315b49e0c281562050ee0667 (diff) |
Cleanup: Move 'tris_per_mat' member out of 'MeshBufferCache'
`MeshBufferCache` is a struct representing a list of buffers.
As such, `GPUIndexBuf **tris_per_mat` is out of place as it does not
represent one of the buffers in the list.
In fact this member should be close to `GPUBatch **surface_per_mat` as
they are related.
The code for dependencies between buffer and batch had to be reworked
as it relies on the member's position.
Differential Revision: https://developer.blender.org/D12227
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc index e346177af52..264cef16223 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_tris.cc @@ -105,20 +105,19 @@ static void extract_tris_finish(const MeshRenderData *mr, /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch * is created before the surfaces-per-material. */ - if (mr->use_final_mesh && cache->final.tris_per_mat) { - MeshBufferCache *mbc_final = &cache->final; + if (mr->use_final_mesh && cache->tris_per_mat) { int mat_start = 0; for (int i = 0; i < mr->mat_len; i++) { /* These IBOs have not been queried yet but we create them just in case they are needed * later since they are not tracked by mesh_buffer_cache_create_requested(). */ - if (mbc_final->tris_per_mat[i] == nullptr) { - mbc_final->tris_per_mat[i] = GPU_indexbuf_calloc(); + if (cache->tris_per_mat[i] == nullptr) { + cache->tris_per_mat[i] = GPU_indexbuf_calloc(); } const int mat_tri_len = mr->poly_sorted.mat_tri_len[i]; /* Multiply by 3 because these are triangle indices. */ const int start = mat_start * 3; const int len = mat_tri_len * 3; - GPU_indexbuf_create_subrange_in_place(mbc_final->tris_per_mat[i], ibo, start, len); + GPU_indexbuf_create_subrange_in_place(cache->tris_per_mat[i], ibo, start, len); mat_start += mat_tri_len; } } @@ -197,17 +196,16 @@ static void extract_tris_single_mat_finish(const MeshRenderData *mr, /* Create ibo sub-ranges. Always do this to avoid error when the standard surface batch * is created before the surfaces-per-material. */ - if (mr->use_final_mesh && cache->final.tris_per_mat) { - MeshBufferCache *mbc = &cache->final; + if (mr->use_final_mesh && cache->tris_per_mat) { for (int i = 0; i < mr->mat_len; i++) { /* These IBOs have not been queried yet but we create them just in case they are needed * later since they are not tracked by mesh_buffer_cache_create_requested(). */ - if (mbc->tris_per_mat[i] == nullptr) { - mbc->tris_per_mat[i] = GPU_indexbuf_calloc(); + if (cache->tris_per_mat[i] == nullptr) { + cache->tris_per_mat[i] = GPU_indexbuf_calloc(); } /* Multiply by 3 because these are triangle indices. */ const int len = mr->tri_len * 3; - GPU_indexbuf_create_subrange_in_place(mbc->tris_per_mat[i], ibo, 0, len); + GPU_indexbuf_create_subrange_in_place(cache->tris_per_mat[i], ibo, 0, len); } } } |