Blender
V5.3
source
blender
gpu
vulkan
vk_vertex_attribute_object_cache.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2026 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
vk_vertex_attribute_object_cache.hh
"
10
11
#include "
vk_batch.hh
"
12
#include "
vk_context.hh
"
13
14
namespace
blender::gpu
{
15
16
const
VKVertexAttributeObject
&
VKVertexAttributeObjectCache::get_or_create
(
17
VKContext
&context,
18
VKBatch
&batch,
19
VKShaderInterface::Key
shader_key,
20
VKVertexInputDescriptionPool
&pool)
21
{
22
for
(
int
index
:
IndexRange
(
CACHE_LEN
)) {
23
if
(keys_[
index
] == shader_key) {
24
return
values_[
index
];
25
}
26
}
27
28
int
slot = write_index_;
29
write_index_ = (write_index_ + 1) %
CACHE_LEN
;
30
31
VKVertexAttributeObject
&vao = values_[slot];
32
keys_[slot] = shader_key;
33
vao.
update_bindings
(context, batch);
34
vao.
update_vertex_input_key
(pool);
35
return
vao;
36
}
37
38
void
VKVertexAttributeObjectCache::clear
()
39
{
40
for
(
int
index
:
IndexRange
(
CACHE_LEN
)) {
41
keys_[
index
] = 0;
42
values_[
index
].clear();
43
}
44
write_index_ = 0;
45
}
46
47
}
// namespace blender::gpu
blender::IndexRange::IndexRange
constexpr IndexRange()=default
blender::gpu::ShaderInterface::Key
uint64_t Key
Definition
gpu_shader_interface.hh:53
blender::gpu::VKBatch
Definition
vk_batch.hh:19
blender::gpu::VKContext
Definition
vk_context.hh:42
blender::gpu::VKVertexAttributeObjectCache::clear
void clear()
Definition
vk_vertex_attribute_object_cache.cc:38
blender::gpu::VKVertexAttributeObjectCache::CACHE_LEN
static constexpr int CACHE_LEN
Definition
vk_vertex_attribute_object_cache.hh:31
blender::gpu::VKVertexAttributeObjectCache::get_or_create
const VKVertexAttributeObject & get_or_create(VKContext &context, VKBatch &batch, VKShaderInterface::Key shader_key, VKVertexInputDescriptionPool &pool)
Definition
vk_vertex_attribute_object_cache.cc:16
blender::gpu::VKVertexAttributeObject
Definition
vk_vertex_attribute_object.hh:29
blender::gpu::VKVertexAttributeObject::update_bindings
void update_bindings(const VKContext &context, VKBatch &batch)
Definition
vk_vertex_attribute_object.cc:106
blender::gpu::VKVertexAttributeObject::update_vertex_input_key
void update_vertex_input_key(VKVertexInputDescriptionPool &pool)
Definition
vk_vertex_attribute_object.cc:42
blender::gpu::VKVertexInputDescriptionPool
Pool with all used vertex input descriptions.
Definition
vk_vertex_input_description.hh:63
blender::ed::asset::index
Definition
ED_asset_indexer.hh:26
blender::gpu
Definition
blf_internal_types.hh:35
vk_batch.hh
vk_context.hh
vk_vertex_attribute_object_cache.hh
Generated on
for Blender by
doxygen
1.18.0