Blender
V4.3
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
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:50
is_initialized
bool is_initialized
Definition
COM_compositor.cc:22
GPU_SAMPLER_CUSTOM_ICON
@ GPU_SAMPLER_CUSTOM_ICON
Definition
GPU_texture.hh:129
GPU_SAMPLER_CUSTOM_COMPARE
@ GPU_SAMPLER_CUSTOM_COMPARE
Definition
GPU_texture.hh:121
GPU_SAMPLER_STATE_TYPE_CUSTOM
@ GPU_SAMPLER_STATE_TYPE_CUSTOM
Definition
GPU_texture.hh:151
GPU_SAMPLER_STATE_TYPE_INTERNAL
@ GPU_SAMPLER_STATE_TYPE_INTERNAL
Definition
GPU_texture.hh:157
GPU_SAMPLER_FILTERING_TYPES_COUNT
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT
Definition
GPU_texture.hh:69
GPUSamplerExtendMode
GPUSamplerExtendMode
Definition
GPU_texture.hh:78
GPUSamplerFiltering
GPUSamplerFiltering
Definition
GPU_texture.hh:34
GPU_SAMPLER_EXTEND_MODES_COUNT
#define GPU_SAMPLER_EXTEND_MODES_COUNT
Definition
GPU_texture.hh:95
blender::gpu::VKSampler
Definition
vk_sampler.hh:20
blender::gpu::VKSampler::free
void free()
Definition
vk_sampler.cc:76
blender::gpu::VKSampler::create
void create(const GPUSamplerState &sampler_state)
Definition
vk_sampler.cc:22
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:23
GPUSamplerState
Definition
GPU_texture.hh:174
GPUSamplerState::custom_type
GPUSamplerCustomType custom_type
Definition
GPU_texture.hh:189
GPUSamplerState::extend_yz
GPUSamplerExtendMode extend_yz
Definition
GPU_texture.hh:187
GPUSamplerState::icon_sampler
static constexpr GPUSamplerState icon_sampler()
Definition
GPU_texture.hh:234
GPUSamplerState::filtering
GPUSamplerFiltering filtering
Definition
GPU_texture.hh:176
GPUSamplerState::extend_x
GPUSamplerExtendMode extend_x
Definition
GPU_texture.hh:181
GPUSamplerState::compare_sampler
static constexpr GPUSamplerState compare_sampler()
Definition
GPU_texture.hh:252
GPUSamplerState::type
GPUSamplerStateType type
Definition
GPU_texture.hh:191
vk_samplers.hh
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0