Blender V5.3
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
10
11#include "vk_batch.hh"
12#include "vk_context.hh"
13
14namespace blender::gpu {
15
17 VKContext &context,
18 VKBatch &batch,
19 VKShaderInterface::Key shader_key,
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);
35 return vao;
36}
37
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
constexpr IndexRange()=default
const VKVertexAttributeObject & get_or_create(VKContext &context, VKBatch &batch, VKShaderInterface::Key shader_key, VKVertexInputDescriptionPool &pool)
void update_bindings(const VKContext &context, VKBatch &batch)
void update_vertex_input_key(VKVertexInputDescriptionPool &pool)
Pool with all used vertex input descriptions.