Blender V4.3
vk_samplers.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "vk_samplers.hh"
10
11namespace blender::gpu {
12
14{
15 if (custom_sampler_cache_[0].is_initialized()) {
16 return;
17 }
20
22 for (int extend_yz_i = 0; extend_yz_i < GPU_SAMPLER_EXTEND_MODES_COUNT; extend_yz_i++) {
23 state.extend_yz = static_cast<GPUSamplerExtendMode>(extend_yz_i);
24 for (int extend_x_i = 0; extend_x_i < GPU_SAMPLER_EXTEND_MODES_COUNT; extend_x_i++) {
25 state.extend_x = static_cast<GPUSamplerExtendMode>(extend_x_i);
26 for (int filtering_i = 0; filtering_i < GPU_SAMPLER_FILTERING_TYPES_COUNT; filtering_i++) {
27 state.filtering = GPUSamplerFiltering(filtering_i);
28 sampler_cache_[extend_yz_i][extend_x_i][filtering_i].create(state);
29 }
30 }
31 }
32}
33
35{
36 custom_sampler_cache_[GPU_SAMPLER_CUSTOM_COMPARE].free();
37 custom_sampler_cache_[GPU_SAMPLER_CUSTOM_ICON].free();
38
39 for (int extend_yz_i = 0; extend_yz_i < GPU_SAMPLER_EXTEND_MODES_COUNT; extend_yz_i++) {
40 for (int extend_x_i = 0; extend_x_i < GPU_SAMPLER_EXTEND_MODES_COUNT; extend_x_i++) {
41 for (int filtering_i = 0; filtering_i < GPU_SAMPLER_FILTERING_TYPES_COUNT; filtering_i++) {
42 sampler_cache_[extend_yz_i][extend_x_i][filtering_i].free();
43 }
44 }
45 }
46}
47
48const VKSampler &VKSamplers::get(const GPUSamplerState &sampler_state) const
49{
51
52 if (sampler_state.type == GPU_SAMPLER_STATE_TYPE_CUSTOM) {
53 return custom_sampler_cache_[sampler_state.custom_type];
54 }
55 return sampler_cache_[sampler_state.extend_yz][sampler_state.extend_x][sampler_state.filtering];
56}
57
58} // namespace blender::gpu
#define BLI_assert(a)
Definition BLI_assert.h:50
bool is_initialized
@ GPU_SAMPLER_CUSTOM_ICON
@ GPU_SAMPLER_CUSTOM_COMPARE
@ GPU_SAMPLER_STATE_TYPE_CUSTOM
@ GPU_SAMPLER_STATE_TYPE_INTERNAL
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT
GPUSamplerExtendMode
GPUSamplerFiltering
#define GPU_SAMPLER_EXTEND_MODES_COUNT
void create(const GPUSamplerState &sampler_state)
Definition vk_sampler.cc:22
const VKSampler & get(const GPUSamplerState &sampler_state) const
static ulong state[N]
GPUSamplerCustomType custom_type
GPUSamplerExtendMode extend_yz
static constexpr GPUSamplerState icon_sampler()
GPUSamplerFiltering filtering
GPUSamplerExtendMode extend_x
static constexpr GPUSamplerState compare_sampler()
GPUSamplerStateType type