Blender
V5.0
source
blender
gpu
vulkan
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
8
9
#include "
vk_samplers.hh
"
10
11
namespace
blender::gpu
{
12
13
void
VKSamplers::init
()
14
{
15
if
(custom_sampler_cache_[0].is_initialized()) {
16
return
;
17
}
18
custom_sampler_cache_[
GPU_SAMPLER_CUSTOM_COMPARE
].create(
GPUSamplerState::compare_sampler
());
19
custom_sampler_cache_[
GPU_SAMPLER_CUSTOM_ICON
].create(
GPUSamplerState::icon_sampler
());
20
21
GPUSamplerState
state
= {};
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
34
void
VKSamplers::free
()
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
48
const
VKSampler
&
VKSamplers::get
(
const
GPUSamplerState
&sampler_state)
const
49
{
50
BLI_assert
(sampler_state.
type
!=
GPU_SAMPLER_STATE_TYPE_INTERNAL
);
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
BLI_assert
#define BLI_assert(a)
Definition
BLI_assert.h:46
GPU_SAMPLER_CUSTOM_ICON
@ GPU_SAMPLER_CUSTOM_ICON
Definition
GPU_texture.hh:374
GPU_SAMPLER_CUSTOM_COMPARE
@ GPU_SAMPLER_CUSTOM_COMPARE
Definition
GPU_texture.hh:366
GPU_SAMPLER_STATE_TYPE_CUSTOM
@ GPU_SAMPLER_STATE_TYPE_CUSTOM
Definition
GPU_texture.hh:396
GPU_SAMPLER_STATE_TYPE_INTERNAL
@ GPU_SAMPLER_STATE_TYPE_INTERNAL
Definition
GPU_texture.hh:402
GPU_SAMPLER_FILTERING_TYPES_COUNT
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT
Definition
GPU_texture.hh:314
GPUSamplerExtendMode
GPUSamplerExtendMode
Definition
GPU_texture.hh:323
GPUSamplerFiltering
GPUSamplerFiltering
Definition
GPU_texture.hh:279
GPU_SAMPLER_EXTEND_MODES_COUNT
#define GPU_SAMPLER_EXTEND_MODES_COUNT
Definition
GPU_texture.hh:340
blender::gpu::VKSampler
Definition
vk_sampler.hh:20
blender::gpu::VKSamplers::get
const VKSampler & get(const GPUSamplerState &sampler_state) const
Definition
vk_samplers.cc:48
blender::gpu::VKSamplers::init
void init()
Definition
vk_samplers.cc:13
blender::gpu::VKSamplers::free
void free()
Definition
vk_samplers.cc:34
state
static ulong state[N]
Definition
mathutils_noise.cc:56
blender::gpu
Definition
blf_internal_types.hh:32
GPUSamplerState
Definition
GPU_texture.hh:419
GPUSamplerState::custom_type
GPUSamplerCustomType custom_type
Definition
GPU_texture.hh:434
GPUSamplerState::extend_yz
GPUSamplerExtendMode extend_yz
Definition
GPU_texture.hh:432
GPUSamplerState::icon_sampler
static constexpr GPUSamplerState icon_sampler()
Definition
GPU_texture.hh:479
GPUSamplerState::filtering
GPUSamplerFiltering filtering
Definition
GPU_texture.hh:421
GPUSamplerState::extend_x
GPUSamplerExtendMode extend_x
Definition
GPU_texture.hh:426
GPUSamplerState::compare_sampler
static constexpr GPUSamplerState compare_sampler()
Definition
GPU_texture.hh:497
GPUSamplerState::type
GPUSamplerStateType type
Definition
GPU_texture.hh:436
vk_samplers.hh
Generated on
for Blender by
doxygen
1.16.1