|
Blender V4.3
|
#include "draw_instance_data.hh"#include "draw_manager_c.hh"#include "DRW_engine.hh"#include "DRW_render.hh"#include "GPU_material.hh"#include "DNA_particle_types.h"#include "BKE_duplilist.hh"#include "RNA_access.hh"#include "RNA_path.hh"#include "BLI_bitmap.h"#include "BLI_memblock.h"#include "BLI_mempool.h"#include "BLI_utildefines.h"#include "MEM_guardedalloc.h"Go to the source code of this file.
Classes | |
| struct | DRWInstanceData |
| struct | DRWInstanceDataList |
| struct | DRWTempBufferHandle |
| struct | DRWTempInstancingHandle |
| struct | DRWSparseUniformBuf |
| struct | DRWUniformAttrBuf |
Variables | |
| static ListBase | g_idatalists = {nullptr, nullptr} |
Sparse Uniform Buffer | |
| #define | CHUNK_LIST_STEP (1 << 4) |
| static void | drw_sparse_uniform_buffer_init (DRWSparseUniformBuf *buffer, uint item_size, uint chunk_size) |
| DRWSparseUniformBuf * | DRW_sparse_uniform_buffer_new (uint item_size, uint chunk_size) |
| void | DRW_sparse_uniform_buffer_flush (DRWSparseUniformBuf *buffer) |
| void | DRW_sparse_uniform_buffer_clear (DRWSparseUniformBuf *buffer, bool free_all) |
| void | DRW_sparse_uniform_buffer_free (DRWSparseUniformBuf *buffer) |
| bool | DRW_sparse_uniform_buffer_is_empty (DRWSparseUniformBuf *buffer) |
| static GPUUniformBuf * | drw_sparse_uniform_buffer_get_ubo (DRWSparseUniformBuf *buffer, int chunk) |
| void | DRW_sparse_uniform_buffer_bind (DRWSparseUniformBuf *buffer, int chunk, int location) |
| void | DRW_sparse_uniform_buffer_unbind (DRWSparseUniformBuf *buffer, int chunk) |
| void * | DRW_sparse_uniform_buffer_ensure_item (DRWSparseUniformBuf *buffer, int chunk, int item) |
| #define CHUNK_LIST_STEP (1 << 4) |
Definition at line 410 of file draw_instance_data.cc.
Referenced by DRW_sparse_uniform_buffer_clear(), and DRW_sparse_uniform_buffer_ensure_item().
| GPUUniformBuf * drw_ensure_layer_attribute_buffer | ( | ) |
Definition at line 640 of file draw_instance_data.cc.
References BKE_view_layer_find_rgba_attribute(), LayerAttribute::buffer_length, count, LayerAttribute::data, DRWManager::draw_ctx, DRW_RESOURCE_CHUNK_LEN, DST, GPU_uniformbuf_create_ex(), GPU_uniformbuf_update(), LayerAttribute::hash_code, LISTBASE_FOREACH, MEM_calloc_arrayN, ViewLayer::name, DRWContextState::scene, DRWContextState::view_layer, DRWData::vlattrs_ubo, and DRWManager::vmempool.
Referenced by draw_update_uniforms().
| void DRW_instance_buffer_finish | ( | DRWInstanceDataList * | idatalist | ) |
Upload all instance data to the GPU as soon as possible.
Definition at line 204 of file draw_instance_data.cc.
References batch, DRWTempInstancingHandle::batch, BLI_memblock_clear(), BLI_memblock_iternew(), BLI_memblock_iterstep(), DRWTempInstancingHandle::buf, DRW_BUFFER_VERTS_CHUNK, DRWTempInstancingHandle::geom, GPU_BATCH_BUILDING, GPU_batch_copy(), GPU_BATCH_INST_VBO_MAX_LEN, GPU_batch_instbuf_add(), GPU_vertbuf_data_len_set(), GPU_vertbuf_data_resize(), GPU_vertbuf_get_vertex_alloc(), GPU_vertbuf_use(), DRWTempInstancingHandle::instancer, instancing_batch_references_add(), DRWInstanceDataList::pool_batching, DRWInstanceDataList::pool_buffers, DRWInstanceDataList::pool_instancing, temp_batch_free(), temp_buffer_handle_free(), and temp_instancing_handle_free().
Referenced by DRW_render_instance_buffer_finish().
|
static |
Definition at line 259 of file draw_instance_data.cc.
References attr_size(), BLI_assert, BLI_mempool_create(), DRWInstanceData::data_size, DRWInstanceDataList::idata_head, DRWInstanceDataList::idata_tail, MEM_callocN, DRWInstanceData::mempool, DRWInstanceData::next, and DRWInstanceData::used.
Referenced by DRW_instance_data_request().
|
static |
Definition at line 282 of file draw_instance_data.cc.
References BLI_mempool_destroy(), and DRWInstanceData::mempool.
Referenced by DRW_instance_data_list_free(), and DRW_instance_data_list_free_unused().
| DRWInstanceDataList * DRW_instance_data_list_create | ( | ) |
This is here because GPUViewport needs it.
Definition at line 315 of file draw_instance_data.cc.
References BLI_addtail(), BLI_memblock_create, g_idatalists, MEM_callocN, DRWInstanceDataList::pool_batching, DRWInstanceDataList::pool_buffers, and DRWInstanceDataList::pool_instancing.
Referenced by DRW_viewport_data_create().
| void DRW_instance_data_list_free | ( | DRWInstanceDataList * | idatalist | ) |
Definition at line 329 of file draw_instance_data.cc.
References BLI_memblock_destroy(), BLI_remlink(), DRW_instance_data_free(), g_idatalists, DRWInstanceDataList::idata_head, DRWInstanceDataList::idata_tail, MAX_INSTANCE_DATA_SIZE, MEM_freeN(), DRWInstanceData::next, DRWInstanceDataList::pool_batching, DRWInstanceDataList::pool_buffers, DRWInstanceDataList::pool_instancing, temp_batch_free(), temp_buffer_handle_free(), and temp_instancing_handle_free().
Referenced by DRW_viewport_data_free().
| void DRW_instance_data_list_free_unused | ( | DRWInstanceDataList * | idatalist | ) |
Definition at line 363 of file draw_instance_data.cc.
References DRW_instance_data_free(), DRWInstanceDataList::idata_head, DRWInstanceDataList::idata_tail, MAX_INSTANCE_DATA_SIZE, MEM_freeN(), DRWInstanceData::next, and DRWInstanceData::used.
Referenced by drw_viewport_data_reset().
| void DRW_instance_data_list_reset | ( | DRWInstanceDataList * | idatalist | ) |
Definition at line 352 of file draw_instance_data.cc.
References DRWInstanceDataList::idata_head, MAX_INSTANCE_DATA_SIZE, DRWInstanceData::next, and DRWInstanceData::used.
Referenced by drw_viewport_data_reset().
| void DRW_instance_data_list_resize | ( | DRWInstanceDataList * | idatalist | ) |
Definition at line 393 of file draw_instance_data.cc.
References BLI_mempool_clear_ex(), BLI_mempool_len(), DRWInstanceDataList::idata_head, MAX_INSTANCE_DATA_SIZE, DRWInstanceData::mempool, and DRWInstanceData::next.
Referenced by drw_viewport_data_reset().
| void * DRW_instance_data_next | ( | DRWInstanceData * | idata | ) |
Return a pointer to the next instance data space.
Definition at line 287 of file draw_instance_data.cc.
References BLI_mempool_alloc(), and DRWInstanceData::mempool.
Referenced by DRW_drawdata_ensure().
| DRWInstanceData * DRW_instance_data_request | ( | DRWInstanceDataList * | idatalist, |
| uint | attr_size ) |
Definition at line 292 of file draw_instance_data.cc.
References attr_size(), BLI_assert, drw_instance_data_create(), DRWInstanceDataList::idata_head, MAX_INSTANCE_DATA_SIZE, DRWInstanceData::next, and DRWInstanceData::used.
Referenced by DRW_drawdata_ensure().
| void DRW_sparse_uniform_buffer_bind | ( | DRWSparseUniformBuf * | buffer, |
| int | chunk, | ||
| int | location ) |
Bind the UBO for the given chunk, if present. A nullptr buffer pointer is handled as empty.
Definition at line 520 of file draw_instance_data.cc.
References drw_sparse_uniform_buffer_get_ubo(), and GPU_uniformbuf_bind().
Referenced by draw_call_resource_bind(), and draw_update_uniforms().
| void DRW_sparse_uniform_buffer_clear | ( | DRWSparseUniformBuf * | buffer, |
| bool | free_all ) |
Clean all buffers and free unused ones.
Definition at line 458 of file draw_instance_data.cc.
References BLI_BITMAP_RESIZE, BLI_bitmap_set_all(), BLI_BITMAP_TEST, DRWSparseUniformBuf::chunk_buffers, CHUNK_LIST_STEP, DRWSparseUniformBuf::chunk_ubos, DRWSparseUniformBuf::chunk_used, GPU_uniformbuf_free(), MEM_recallocN, MEM_SAFE_FREE, and DRWSparseUniformBuf::num_chunks.
Referenced by DRW_sparse_uniform_buffer_free(), DRW_uniform_attrs_pool_clear_all(), and drw_uniform_attrs_pool_free_cb().
| void * DRW_sparse_uniform_buffer_ensure_item | ( | DRWSparseUniformBuf * | buffer, |
| int | chunk, | ||
| int | item ) |
Returns a pointer to the given item of the given chunk, allocating memory if necessary.
Definition at line 536 of file draw_instance_data.cc.
References BLI_BITMAP_ENABLE, BLI_BITMAP_RESIZE, BLI_BITMAP_TEST, DRWSparseUniformBuf::chunk_buffers, DRWSparseUniformBuf::chunk_bytes, CHUNK_LIST_STEP, DRWSparseUniformBuf::chunk_ubos, DRWSparseUniformBuf::chunk_used, DRWSparseUniformBuf::item_size, MEM_callocN, MEM_recallocN, and DRWSparseUniformBuf::num_chunks.
Referenced by drw_uniform_attrs_pool_update().
| void DRW_sparse_uniform_buffer_flush | ( | DRWSparseUniformBuf * | buffer | ) |
Flush data from ordinary memory to UBOs.
Definition at line 446 of file draw_instance_data.cc.
References BLI_BITMAP_TEST, DRWSparseUniformBuf::chunk_buffers, DRWSparseUniformBuf::chunk_bytes, DRWSparseUniformBuf::chunk_ubos, DRWSparseUniformBuf::chunk_used, GPU_uniformbuf_create, GPU_uniformbuf_update(), and DRWSparseUniformBuf::num_chunks.
Referenced by DRW_uniform_attrs_pool_flush_all().
| void DRW_sparse_uniform_buffer_free | ( | DRWSparseUniformBuf * | buffer | ) |
Frees the buffer.
Definition at line 501 of file draw_instance_data.cc.
References DRW_sparse_uniform_buffer_clear(), and MEM_freeN().
|
static |
Definition at line 512 of file draw_instance_data.cc.
References BLI_BITMAP_TEST, DRWSparseUniformBuf::chunk_ubos, and DRWSparseUniformBuf::chunk_used.
Referenced by DRW_sparse_uniform_buffer_bind(), and DRW_sparse_uniform_buffer_unbind().
|
static |
Definition at line 425 of file draw_instance_data.cc.
References DRWSparseUniformBuf::chunk_buffers, DRWSparseUniformBuf::chunk_bytes, DRWSparseUniformBuf::chunk_size, DRWSparseUniformBuf::chunk_ubos, DRWSparseUniformBuf::chunk_used, DRWSparseUniformBuf::item_size, and DRWSparseUniformBuf::num_chunks.
Referenced by DRW_sparse_uniform_buffer_new(), and drw_uniform_attrs_pool_ensure().
| bool DRW_sparse_uniform_buffer_is_empty | ( | DRWSparseUniformBuf * | buffer | ) |
Checks if the buffer contains any allocated chunks.
Definition at line 507 of file draw_instance_data.cc.
References DRWSparseUniformBuf::num_chunks.
Referenced by DRW_uniform_attrs_pool_clear_all().
| DRWSparseUniformBuf * DRW_sparse_uniform_buffer_new | ( | unsigned int | item_size, |
| unsigned int | chunk_size ) |
Allocate a chunked UBO with the specified item and chunk size.
Definition at line 438 of file draw_instance_data.cc.
References drw_sparse_uniform_buffer_init(), and MEM_mallocN.
| void DRW_sparse_uniform_buffer_unbind | ( | DRWSparseUniformBuf * | buffer, |
| int | chunk ) |
Unbind the UBO for the given chunk, if present. A nullptr buffer pointer is handled as empty.
Definition at line 528 of file draw_instance_data.cc.
References drw_sparse_uniform_buffer_get_ubo(), and GPU_uniformbuf_unbind().
Referenced by draw_call_batching_finish(), and draw_call_resource_bind().
| blender::gpu::Batch * DRW_temp_batch_instance_request | ( | DRWInstanceDataList * | idatalist, |
| blender::gpu::VertBuf * | buf, | ||
| blender::gpu::Batch * | instancer, | ||
| blender::gpu::Batch * | geom ) |
Definition at line 126 of file draw_instance_data.cc.
References batch, DRWTempInstancingHandle::batch, BLI_assert, BLI_memblock_alloc(), GPU_BATCH_BUILDING, GPU_batch_calloc(), GPU_batch_clear(), GPU_BATCH_VBO_MAX_LEN, GPU_VERTBUF_DATA_UPLOADED, GPU_vertbuf_get_status(), instancing_batch_references_remove(), and DRWInstanceDataList::pool_instancing.
Referenced by DRW_shgroup_call_buffer_instance(), and DRW_shgroup_call_instances_with_attrs().
| blender::gpu::Batch * DRW_temp_batch_request | ( | DRWInstanceDataList * | idatalist, |
| blender::gpu::VertBuf * | buf, | ||
| GPUPrimType | type ) |
Definition at line 167 of file draw_instance_data.cc.
References batch, BLI_memblock_alloc(), GPU_batch_calloc(), GPU_batch_clear(), GPU_batch_init, GPU_VERTBUF_DATA_UPLOADED, GPU_vertbuf_get_status(), and DRWInstanceDataList::pool_batching.
Referenced by DRW_shgroup_call_buffer().
| blender::gpu::VertBuf * DRW_temp_buffer_request | ( | DRWInstanceDataList * | idatalist, |
| GPUVertFormat * | format, | ||
| int * | vert_len ) |
This manager allows to distribute existing batches for instancing attributes. This reduce the number of batches creation. Querying a batch is done with a vertex format. This format should be static so that its pointer never changes (because we are using this pointer as identifier [we don't want to check the full format that would be too slow]).
Definition at line 102 of file draw_instance_data.cc.
References BLI_assert, BLI_memblock_alloc(), DRW_BUFFER_VERTS_CHUNK, DRWTempBufferHandle::format, GPU_USAGE_DYNAMIC, GPU_vertbuf_calloc(), GPU_vertbuf_data_alloc(), GPU_VERTBUF_DISCARD_SAFE, GPU_vertbuf_init_with_format_ex(), and DRWInstanceDataList::pool_buffers.
Referenced by DRW_shgroup_call_buffer(), and DRW_shgroup_call_buffer_instance().
|
static |
Definition at line 602 of file draw_instance_data.cc.
References BKE_object_dupli_find_rgba_attribute(), GPUUniformAttr::name, and GPUUniformAttr::use_dupli.
Referenced by drw_uniform_attrs_pool_update().
| void DRW_uniform_attrs_pool_clear_all | ( | GHash * | table | ) |
Definition at line 725 of file draw_instance_data.cc.
References BLI_ghash_remove(), DRW_sparse_uniform_buffer_clear(), DRW_sparse_uniform_buffer_is_empty(), drw_uniform_attrs_pool_free_cb(), GHASH_FOREACH_BEGIN, GHASH_FOREACH_END, DRWUniformAttrBuf::key, DRWUniformAttrBuf::last_handle, and DRWUniformAttrBuf::next_empty.
Referenced by drw_viewport_data_reset().
|
static |
Definition at line 580 of file draw_instance_data.cc.
References BLI_ghash_ensure_p_ex(), GPUUniformAttrList::count, DRW_RESOURCE_CHUNK_LEN, drw_sparse_uniform_buffer_init(), GPU_uniform_attr_list_copy(), DRWUniformAttrBuf::key, DRWUniformAttrBuf::last_handle, MEM_callocN, and DRWUniformAttrBuf::ubos.
Referenced by drw_uniform_attrs_pool_update().
| DRWSparseUniformBuf * DRW_uniform_attrs_pool_find_ubo | ( | GHash * | table, |
| const GPUUniformAttrList * | key ) |
Definition at line 697 of file draw_instance_data.cc.
References BLI_ghash_lookup(), and DRWUniformAttrBuf::ubos.
Referenced by draw_update_uniforms().
| void DRW_uniform_attrs_pool_flush_all | ( | GHash * | table | ) |
Definition at line 708 of file draw_instance_data.cc.
References DRW_sparse_uniform_buffer_flush(), GHASH_FOREACH_BEGIN, and GHASH_FOREACH_END.
Referenced by drw_resource_buffer_finish().
| void DRW_uniform_attrs_pool_free | ( | GHash * | table | ) |
Definition at line 747 of file draw_instance_data.cc.
References BLI_ghash_free(), and drw_uniform_attrs_pool_free_cb().
Referenced by DRW_viewport_data_free().
|
static |
Definition at line 716 of file draw_instance_data.cc.
References DRW_sparse_uniform_buffer_clear(), GPU_uniform_attr_list_free(), DRWUniformAttrBuf::key, MEM_freeN(), ptr, and DRWUniformAttrBuf::ubos.
Referenced by DRW_uniform_attrs_pool_clear_all(), and DRW_uniform_attrs_pool_free().
| GHash * DRW_uniform_attrs_pool_new | ( | ) |
Definition at line 703 of file draw_instance_data.cc.
References GPU_uniform_attr_list_hash_new().
Referenced by DRW_viewport_data_create().
| void drw_uniform_attrs_pool_update | ( | GHash * | table, |
| const GPUUniformAttrList * | key, | ||
| DRWResourceHandle * | handle, | ||
| const Object * | ob, | ||
| const Object * | dupli_parent, | ||
| const DupliObject * | dupli_source ) |
Definition at line 617 of file draw_instance_data.cc.
References DRW_handle_chunk_get(), DRW_handle_id_get(), DRW_sparse_uniform_buffer_ensure_item(), drw_uniform_attribute_lookup(), drw_uniform_attrs_pool_ensure(), float, DRWUniformAttrBuf::key, DRWUniformAttrBuf::last_handle, GPUUniformAttrList::list, LISTBASE_FOREACH, and DRWUniformAttrBuf::ubos.
Referenced by drw_resource_handle().
|
static |
Definition at line 78 of file draw_instance_data.cc.
References batch, GPU_BATCH_INST_VBO_MAX_LEN, GPU_BATCH_VBO_MAX_LEN, and GPU_vertbuf_handle_ref_add().
Referenced by DRW_instance_buffer_finish().
|
static |
Definition at line 88 of file draw_instance_data.cc.
References batch, GPU_BATCH_INST_VBO_MAX_LEN, GPU_BATCH_VBO_MAX_LEN, and GPU_vertbuf_handle_ref_remove().
Referenced by DRW_temp_batch_instance_request(), and temp_instancing_handle_free().
|
static |
Definition at line 199 of file draw_instance_data.cc.
References batch, and GPU_BATCH_DISCARD_SAFE.
Referenced by DRW_instance_buffer_finish(), and DRW_instance_data_list_free().
|
static |
Definition at line 187 of file draw_instance_data.cc.
References GPU_VERTBUF_DISCARD_SAFE.
Referenced by DRW_instance_buffer_finish(), and DRW_instance_data_list_free().
|
static |
Definition at line 193 of file draw_instance_data.cc.
References GPU_BATCH_DISCARD_SAFE, and instancing_batch_references_remove().
Referenced by DRW_instance_buffer_finish(), and DRW_instance_data_list_free().
|
static |
Definition at line 76 of file draw_instance_data.cc.
Referenced by DRW_instance_data_list_create(), and DRW_instance_data_list_free().