Blender V5.3
GPU_texture.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#pragma once
14
15#include <string>
16
17#include "BLI_assert.hh"
18#include "BLI_bit_span.hh"
19#include "BLI_enum_flags.hh"
20#include "BLI_index_range.hh"
21
22#include "GPU_format.hh"
23
24namespace blender {
25
26struct GPUPixelBuffer;
27
28namespace gpu {
29class VertBuf;
30}
31
32namespace gpu {
33
34/* -------------------------------------------------------------------- */
37
41enum class TextureFormat : uint8_t {
43
44#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) blender_enum = int(DataFormat::blender_enum),
45
46#define GPU_TEXTURE_FORMAT_EXPAND(impl) \
47 SNORM_8_(impl) \
48 SNORM_8_8_(impl) \
49 SNORM_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
50 SNORM_8_8_8_8_(impl) \
51\
52 SNORM_16_(impl) \
53 SNORM_16_16_(impl) \
54 SNORM_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
55 SNORM_16_16_16_16_(impl) \
56\
57 UNORM_8_(impl) \
58 UNORM_8_8_(impl) \
59 UNORM_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
60 UNORM_8_8_8_8_(impl) \
61\
62 UNORM_16_(impl) \
63 UNORM_16_16_(impl) \
64 UNORM_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
65 UNORM_16_16_16_16_(impl) \
66\
67 SINT_8_(impl) \
68 SINT_8_8_(impl) \
69 SINT_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
70 SINT_8_8_8_8_(impl) \
71\
72 SINT_16_(impl) \
73 SINT_16_16_(impl) \
74 SINT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
75 SINT_16_16_16_16_(impl) \
76\
77 SINT_32_(impl) \
78 SINT_32_32_(impl) \
79 SINT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
80 SINT_32_32_32_32_(impl) \
81\
82 UINT_8_(impl) \
83 UINT_8_8_(impl) \
84 UINT_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
85 UINT_8_8_8_8_(impl) \
86\
87 UINT_16_(impl) \
88 UINT_16_16_(impl) \
89 UINT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
90 UINT_16_16_16_16_(impl) \
91\
92 UINT_32_(impl) \
93 UINT_32_32_(impl) \
94 UINT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
95 UINT_32_32_32_32_(impl) \
96\
97 SFLOAT_16_(impl) \
98 SFLOAT_16_16_(impl) \
99 SFLOAT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
100 SFLOAT_16_16_16_16_(impl) \
101\
102 SFLOAT_32_(impl) \
103 SFLOAT_32_32_(impl) \
104 SFLOAT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
105 SFLOAT_32_32_32_32_(impl) \
106\
107 UNORM_10_10_10_2_(impl) \
108 UINT_10_10_10_2_(impl) \
109\
110 UFLOAT_11_11_10_(impl) \
111 UFLOAT_9_9_9_EXP_5_(impl) \
112\
113 UNORM_16_DEPTH_(impl) \
114 SFLOAT_32_DEPTH_(impl) \
115 SFLOAT_32_DEPTH_UINT_8_(impl) \
116\
117 SRGBA_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
118 SRGBA_8_8_8_8_(impl) \
119\
120 SNORM_DXT1_(impl) \
121 SNORM_DXT3_(impl) \
122 SNORM_DXT5_(impl) \
123 SRGB_DXT1_(impl) \
124 SRGB_DXT3_(impl) \
125 SRGB_DXT5_(impl)
126
128
129#undef DECLARE
130};
131
133{
134 return DataFormat(int(format));
135}
136
142
143#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) \
144 blender_enum = int(TextureFormat::blender_enum),
145
146#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl) \
147 UNORM_8_(impl) \
148 UNORM_8_8_(impl) \
149 UNORM_8_8_8_8_(impl) \
150\
151 UNORM_16_(impl) \
152 UNORM_16_16_(impl) \
153 UNORM_16_16_16_16_(impl) \
154\
155 SINT_8_(impl) \
156 SINT_8_8_(impl) \
157 SINT_8_8_8_8_(impl) \
158\
159 SINT_16_(impl) \
160 SINT_16_16_(impl) \
161 SINT_16_16_16_16_(impl) \
162\
163 SINT_32_(impl) \
164 SINT_32_32_(impl) \
165 SINT_32_32_32_32_(impl) \
166\
167 UINT_8_(impl) \
168 UINT_8_8_(impl) \
169 UINT_8_8_8_8_(impl) \
170\
171 UINT_16_(impl) \
172 UINT_16_16_(impl) \
173 UINT_16_16_16_16_(impl) \
174\
175 UINT_32_(impl) \
176 UINT_32_32_(impl) \
177 UINT_32_32_32_32_(impl) \
178\
179 SFLOAT_16_(impl) \
180 SFLOAT_16_16_(impl) \
181 SFLOAT_16_16_16_16_(impl) \
182\
183 SFLOAT_32_(impl) \
184 SFLOAT_32_32_(impl) \
185 SFLOAT_32_32_32_32_(impl) \
186\
187 UNORM_10_10_10_2_(impl) \
188 UINT_10_10_10_2_(impl) \
189\
190 UFLOAT_11_11_10_(impl) \
191\
192 UNORM_16_DEPTH_(impl) \
193 SFLOAT_32_DEPTH_(impl) \
194 SFLOAT_32_DEPTH_UINT_8_(impl) \
195\
196 SRGBA_8_8_8_8_(impl)
197
199
200#undef DECLARE
201};
202
204{
205 return TextureFormat(int(format));
206}
207
213
214#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) \
215 blender_enum = int(TextureFormat::blender_enum),
216
217#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl) \
218 UNORM_8_(impl) \
219 UNORM_8_8_(impl) \
220 UNORM_8_8_8_8_(impl) \
221\
222 UNORM_16_(impl) \
223 UNORM_16_16_(impl) \
224 UNORM_16_16_16_16_(impl) \
225\
226 SINT_8_(impl) \
227 SINT_8_8_(impl) \
228 SINT_8_8_8_8_(impl) \
229\
230 SINT_16_(impl) \
231 SINT_16_16_(impl) \
232 SINT_16_16_16_16_(impl) \
233\
234 SINT_32_(impl) \
235 SINT_32_32_(impl) \
236 SINT_32_32_32_32_(impl) \
237\
238 UINT_8_(impl) \
239 UINT_8_8_(impl) \
240 UINT_8_8_8_8_(impl) \
241\
242 UINT_16_(impl) \
243 UINT_16_16_(impl) \
244 UINT_16_16_16_16_(impl) \
245\
246 UINT_32_(impl) \
247 UINT_32_32_(impl) \
248 UINT_32_32_32_32_(impl) \
249\
250 SFLOAT_16_(impl) \
251 SFLOAT_16_16_(impl) \
252 SFLOAT_16_16_16_16_(impl) \
253\
254 SFLOAT_32_(impl) \
255 SFLOAT_32_32_(impl) \
256 SFLOAT_32_32_32_32_(impl) \
257\
258 UNORM_10_10_10_2_(impl) \
259 UINT_10_10_10_2_(impl) \
260\
261 UFLOAT_11_11_10_(impl)
262
264
265#undef DECLARE
266};
267
269{
270 return TextureFormat(int(format));
271}
272
274
275} // namespace gpu
276
277/* -------------------------------------------------------------------- */
280
319
321
322
326 1;
335
340static inline GPUSamplerFiltering GPU_anisotropic_filtering_flags(int anisotropic_samples)
341{
342 if (anisotropic_samples <= 1) {
344 }
345
346 if (IndexRange::from_begin_end_inclusive(2, 3).contains(anisotropic_samples)) {
348 }
349 else if (IndexRange::from_begin_end_inclusive(4, 7).contains(anisotropic_samples)) {
351 }
352 else if (IndexRange::from_begin_end_inclusive(8, 15).contains(anisotropic_samples)) {
354 }
355
356 /* 16 or higher. */
358}
359
360static inline int GPU_anisotropic_samples_get(GPUSamplerFiltering filtering_flags)
361{
362 switch (filtering_flags & GPU_SAMPLER_FILTERING_ANISOTROPIC_MASK) {
364 return 2;
366 return 4;
368 return 8;
370 return 16;
371 default:
372 return 1;
373 }
375 return 1;
376}
377
398
399#define GPU_SAMPLER_EXTEND_MODES_COUNT (GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER + 1)
400
435
436#define GPU_SAMPLER_CUSTOM_TYPES_COUNT (GPU_SAMPLER_CUSTOM_ICON + 1)
437
463
496
513
530
546
564
569 {
570 this->filtering = this->filtering | filtering_flags;
571 }
572
577 {
578 this->filtering = this->filtering & ~filtering_flags;
579 }
580
585 void set_filtering_flag_from_test(GPUSamplerFiltering filtering_flags, bool test)
586 {
587 if (test) {
588 this->enable_filtering_flag(filtering_flags);
589 }
590 else {
591 this->disable_filtering_flag(filtering_flags);
592 }
593 }
594
595 std::string to_string() const
596 {
598 return "internal";
599 }
600
601 if (this->type == GPU_SAMPLER_STATE_TYPE_CUSTOM) {
602 switch (this->custom_type) {
604 return "compare";
605 break;
607 return "icon";
608 break;
609 default:
611 return "";
612 }
613 }
614
615 /* The sampler state is of type PARAMETERS, so serialize the parameters. */
617 std::string serialized_parameters;
618
620 serialized_parameters += "linear-filter_";
621 }
622
624 serialized_parameters += "mipmap_";
625 }
626
629 {
630 serialized_parameters += "anisotropic2x_";
631 }
634 {
635 serialized_parameters += "anisotropic4x_";
636 }
639 {
640 serialized_parameters += "anisotropic8x_";
641 }
644 {
645 serialized_parameters += "anisotropic16x_";
646 }
647
648 switch (this->extend_x) {
650 serialized_parameters += "extend-x_";
651 break;
653 serialized_parameters += "repeat-x_";
654 break;
656 serialized_parameters += "mirrored-repeat-x_";
657 break;
659 serialized_parameters += "clamp-to-border-x_";
660 break;
661 default:
663 }
664
665 switch (this->extend_yz) {
667 serialized_parameters += "extend-y_";
668 break;
670 serialized_parameters += "repeat-y_";
671 break;
673 serialized_parameters += "mirrored-repeat-y_";
674 break;
676 serialized_parameters += "clamp-to-border-y_";
677 break;
678 default:
680 }
681
682 switch (this->extend_yz) {
684 serialized_parameters += "extend-z";
685 break;
687 serialized_parameters += "repeat-z";
688 break;
690 serialized_parameters += "mirrored-repeat-z";
691 break;
693 serialized_parameters += "clamp-to-border-z";
694 break;
695 default:
697 }
698
699 return serialized_parameters;
700 }
701
703 {
704 uint32_t value = filtering;
705 value = (value << 4) | extend_x;
706 value = (value << 4) | extend_yz;
707 value = (value << 8) | custom_type;
708 value = (value << 8) | type;
709 return value;
710 }
711
712 bool operator==(GPUSamplerState const &rhs) const
713 {
714 return this->filtering == rhs.filtering && this->extend_x == rhs.extend_x &&
715 this->extend_yz == rhs.extend_yz && this->custom_type == rhs.custom_type &&
716 this->type == rhs.type;
717 }
718};
719
721
722/* -------------------------------------------------------------------- */
725
732/* TODO(fclem): Replace by gpu::DataFormat. */
740 /* GPU_DATA_UINT_24_8_DEPRECATED is deprecated since Blender 5.0. It is still here as python
741 * add-ons can still use it. */
746};
747
760 /* Whether texture is sampled or read during a shader. */
762 /* Whether the texture is written to by a shader using imageStore. */
764 /* Whether a texture is used as an attachment in a frame-buffer. */
766 /* Whether a texture is used to create a texture view utilizing a different texture format to the
767 * source textures format. This includes the use of stencil views. */
769 /* Whether the texture needs to be read from by the CPU. */
771 /* When used, the texture will not have any backing storage and can solely exist as a virtual
772 * frame-buffer attachment. */
774 /* Whether a texture can support atomic operations. */
776 /* Whether a texture can be exported to other instances/processes. */
778 /* Create a texture whose usage cannot be defined prematurely.
779 * This is unoptimized and should not be used. */
782};
783
785
787
788/* -------------------------------------------------------------------- */
791
792namespace gpu {
793class Texture;
794} // namespace gpu
795
806gpu::Texture *GPU_texture_create_1d(const char *name,
807 int width,
808 int mip_len,
809 gpu::TextureFormat format,
810 eGPUTextureUsage usage,
811 const float *data);
812gpu::Texture *GPU_texture_create_1d_array(const char *name,
813 int width,
814 int layer_len,
815 int mip_len,
816 gpu::TextureFormat format,
817 eGPUTextureUsage usage,
818 const float *data);
819gpu::Texture *GPU_texture_create_2d(const char *name,
820 int width,
821 int height,
822 int mip_len,
823 gpu::TextureFormat format,
824 eGPUTextureUsage usage,
825 const float *data);
826gpu::Texture *GPU_texture_create_2d_array(const char *name,
827 int width,
828 int height,
829 int layer_len,
830 int mip_len,
831 gpu::TextureFormat format,
832 eGPUTextureUsage usage,
833 const float *data);
834gpu::Texture *GPU_texture_create_3d(const char *name,
835 int width,
836 int height,
837 int depth,
838 int mip_len,
839 gpu::TextureFormat format,
840 eGPUTextureUsage usage,
841 const void *data);
842gpu::Texture *GPU_texture_create_cube(const char *name,
843 int width,
844 int mip_len,
845 gpu::TextureFormat format,
846 eGPUTextureUsage usage,
847 const float *data);
848gpu::Texture *GPU_texture_create_cube_array(const char *name,
849 int width,
850 int layer_len,
851 int mip_len,
852 gpu::TextureFormat format,
853 eGPUTextureUsage usage,
854 const float *data);
860gpu::Texture *GPU_texture_create_compressed_2d(const char *name,
861 int width,
862 int height,
863 int mip_len,
864 gpu::TextureFormat format,
865 eGPUTextureUsage usage,
866 const void *data);
867
872gpu::Texture *GPU_texture_create_from_vertbuf(const char *name, gpu::VertBuf *vertex_buf);
873
879gpu::Texture *GPU_texture_create_error(int dimension, bool array);
880
882
883/* -------------------------------------------------------------------- */
886
893void GPU_texture_ref(gpu::Texture *texture);
894
900void GPU_texture_free(gpu::Texture *texture);
901
902#define GPU_TEXTURE_FREE_SAFE(texture) \
903 do { \
904 if (texture != nullptr) { \
905 blender::GPU_texture_free(texture); \
906 texture = nullptr; \
907 } \
908 } while (0)
909
911
912/* -------------------------------------------------------------------- */
915
940gpu::Texture *GPU_texture_create_view(const char *name,
941 gpu::Texture *source_texture,
942 gpu::TextureFormat view_format,
943 int mip_start,
944 int mip_len,
945 int layer_start,
946 int layer_len,
947 bool cube_as_array,
948 bool use_stencil);
949
951
952/* -------------------------------------------------------------------- */
955
964void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data);
965
977void GPU_texture_update_sub(gpu::Texture *texture,
978 eGPUDataFormat data_format,
979 const void *pixels,
980 int offset_x,
981 int offset_y,
982 int offset_z,
983 int width,
984 int height,
985 int depth,
986 uint unpack_row_length = 0);
987
994void GPU_texture_update_mipmap(gpu::Texture *texture,
995 int mip_level,
996 eGPUDataFormat data_format,
997 const void *pixels,
998 uint unpack_row_length = 0);
999
1008void GPU_texture_clear(gpu::Texture *texture, eGPUDataFormat data_format, const void *data);
1009
1014void GPU_texture_copy(gpu::Texture *dst, gpu::Texture *src);
1015
1020
1028
1034
1042 int layer,
1043 BitSpan modified_chunks);
1044
1053void *GPU_texture_read(gpu::Texture *texture, eGPUDataFormat data_format, int mip_level);
1054
1058void GPU_texture_read(gpu::Texture *texture, eGPUDataFormat data_format, int mip_level, void *dst);
1059
1064 eGPUDataFormat data_format,
1065 int mip_level);
1066
1068
1069/* -------------------------------------------------------------------- */
1072
1076void GPU_texture_bind(gpu::Texture *texture, int unit);
1090
1106
1108
1109/* -------------------------------------------------------------------- */
1112
1116void GPU_texture_compare_mode(gpu::Texture *texture, bool use_compare);
1117
1124void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter);
1125
1133void GPU_texture_mipmap_mode(gpu::Texture *texture, bool use_mipmap, bool use_filter);
1134
1140
1146
1152
1158
1175void GPU_texture_swizzle_set(gpu::Texture *texture, const char swizzle[4]);
1176
1178
1179/* -------------------------------------------------------------------- */
1182
1188
1193
1198
1204
1209
1214
1219
1224
1229
1234
1239
1244
1249
1254
1259
1264
1269
1274
1280void GPU_texture_get_mipmap_size(gpu::Texture *texture, int mip_level, int *r_size);
1281
1283
1284/* -------------------------------------------------------------------- */
1290
1299void GPU_texture_original_size_set(gpu::Texture *texture, int width, int height);
1300
1305#ifndef GPU_NO_USE_PY_REFERENCES
1308#endif
1309
1311
1312/* -------------------------------------------------------------------- */
1315
1320
1325
1331
1337unsigned int GPU_texture_memory_usage_get();
1338
1340
1341/* -------------------------------------------------------------------- */
1347
1352GPUPixelBuffer *GPU_pixel_buffer_create(size_t byte_size);
1353
1358void GPU_pixel_buffer_free(GPUPixelBuffer *pixel_buf);
1359
1366void *GPU_pixel_buffer_map(GPUPixelBuffer *pixel_buf);
1367
1372void GPU_pixel_buffer_unmap(GPUPixelBuffer *pixel_buf);
1373
1377size_t GPU_pixel_buffer_size(GPUPixelBuffer *pixel_buf);
1378
1393
1395
1402 eGPUDataFormat data_format,
1403 GPUPixelBuffer *pixel_buf,
1404 int offset_x,
1405 int offset_y,
1406 int offset_z,
1407 int width,
1408 int height,
1409 int depth);
1411
1412} // namespace blender
#define ENUM_OPERATORS(_enum_type)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl)
#define GPU_TEXTURE_FORMAT_EXPAND(impl)
#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl)
#define BLI_assert_unreachable()
static constexpr IndexRange from_begin_end_inclusive(const int64_t begin, const int64_t last)
#define layer
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
const int state
ENUM_OPERATORS(Layer::Flags)
constexpr DataFormat to_data_format(TextureFormat format)
constexpr TextureFormat to_texture_format(TextureTargetFormat format)
BMesh Iterators.
void GPU_texture_compare_mode(gpu::Texture *texture, bool use_compare)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
size_t GPU_texture_read_size_get(const gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
gpu::Texture * GPU_texture_create_cube_array(const char *name, int width, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
bool GPU_texture_has_depth_format(const gpu::Texture *texture)
gpu::Texture * GPU_texture_create_1d(const char *name, int width, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
__int64 int64_t
Definition BKE_text.h:90
int GPU_texture_depth(const gpu::Texture *texture)
bool GPU_texture_has_integer_format(const gpu::Texture *texture)
void GPU_texture_update(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
gpu::TextureFormat GPU_texture_format(const gpu::Texture *texture)
gpu::Texture * GPU_texture_create_compressed_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
bool GPU_texture_is_view(const gpu::Texture *texture)
unsigned int uint
Definition BKE_text.h:55
eGPUTextureUsage GPU_texture_usage(const gpu::Texture *texture)
void GPU_texture_update_mipmap_chain(gpu::Texture *texture)
constexpr int GPU_TEXTURE_MIPMAP_UPDATE_CHUNK_SIZE
static constexpr GPUSamplerFiltering GPU_SAMPLER_FILTERING_ANISOTROPIC_MASK
void GPU_texture_image_unbind(gpu::Texture *texture)
@ GPU_DATA_2_10_10_10_REV
@ GPU_DATA_HALF_FLOAT
@ GPU_DATA_10_11_11_REV
@ GPU_DATA_UINT_24_8_DEPRECATED
void GPU_texture_copy(gpu::Texture *dst, gpu::Texture *src)
@ GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
void GPU_texture_unbind_all()
bool GPU_texture_has_signed_format(const gpu::Texture *texture)
static constexpr GPUSamplerFiltering GPU_SAMPLER_FILTERING_ANISOTROPIC_ENABLE
gpu::Texture * GPU_texture_create_2d_array(const char *name, int width, int height, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
@ GPU_SAMPLER_FILTERING_ANISOTROPIC_4
@ GPU_SAMPLER_FILTERING_LINEAR
@ GPU_SAMPLER_FILTERING_DEFAULT
@ GPU_SAMPLER_FILTERING_ANISOTROPIC_8
@ GPU_SAMPLER_FILTERING_MIPMAP
@ GPU_SAMPLER_FILTERING_ANISOTROPIC_2
@ GPU_SAMPLER_FILTERING_ANISOTROPIC_16
void GPU_pixel_buffer_unmap(GPUPixelBuffer *pixel_buf)
void * GPU_pixel_buffer_map(GPUPixelBuffer *pixel_buf)
void GPU_texture_anisotropic_filter(gpu::Texture *texture, bool use_aniso)
void ** GPU_texture_py_reference_get(gpu::Texture *texture)
bool GPU_texture_has_normalized_format(const gpu::Texture *texture)
int GPU_texture_dimensions(const gpu::Texture *texture)
void GPU_texture_update_sub(gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
void GPU_texture_mipmap_mode(gpu::Texture *texture, bool use_mipmap, bool use_filter)
static GPUSamplerFiltering GPU_anisotropic_filtering_flags(int anisotropic_samples)
unsigned int uint32_t
Definition BKE_text.h:81
static int GPU_anisotropic_samples_get(GPUSamplerFiltering filtering_flags)
size_t GPU_texture_dataformat_size(eGPUDataFormat data_format)
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_MEMORY_EXPORT
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_GENERAL
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_ATOMIC
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_MEMORYLESS
int GPU_texture_mip_count(const gpu::Texture *texture)
gpu::Texture * GPU_texture_create_from_vertbuf(const char *name, gpu::VertBuf *vertex_buf)
BMesh const char void * data
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT
void GPU_texture_update_mipmap_chain_partial(gpu::Texture *texture, int layer, BitSpan modified_chunks)
void GPU_texture_swizzle_set(gpu::Texture *texture, const char swizzle[4])
unsigned char uint8_t
Definition BKE_text.h:79
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
bool GPU_texture_has_float_format(const gpu::Texture *texture)
gpu::Texture * GPU_texture_create_3d(const char *name, int width, int height, int depth, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
void GPU_texture_original_size_set(gpu::Texture *texture, int width, int height)
int GPU_texture_width(const gpu::Texture *texture)
bool GPU_texture_is_cube(const gpu::Texture *texture)
void GPU_texture_update_mipmap(gpu::Texture *texture, int mip_level, eGPUDataFormat data_format, const void *pixels, uint unpack_row_length=0)
size_t GPU_texture_component_len(gpu::TextureFormat format)
void GPU_texture_bind_ex(gpu::Texture *texture, GPUSamplerState state, int unit)
bool GPU_texture_is_array(const gpu::Texture *texture)
void GPU_texture_extend_mode_x(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
gpu::Texture * GPU_texture_create_cube(const char *name, int width, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
bool GPU_texture_has_compressed_format(const gpu::Texture *texture)
void GPU_pixel_buffer_free(GPUPixelBuffer *pixel_buf)
@ GPU_SAMPLER_CUSTOM_ICON
@ GPU_SAMPLER_CUSTOM_COMPARE
size_t GPU_pixel_buffer_size(GPUPixelBuffer *pixel_buf)
void GPU_texture_extend_mode_y(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_clear(gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_bind(gpu::Texture *texture, int unit)
int GPU_texture_height(const gpu::Texture *texture)
void GPU_texture_free(gpu::Texture *texture)
@ GPU_SAMPLER_STATE_TYPE_PARAMETERS
@ GPU_SAMPLER_STATE_TYPE_CUSTOM
@ GPU_SAMPLER_STATE_TYPE_INTERNAL
GPUPixelBuffer * GPU_pixel_buffer_create(size_t byte_size)
const char * GPU_texture_format_name(gpu::TextureFormat format)
void GPU_texture_image_unbind_all()
void GPU_texture_image_bind(gpu::Texture *texture, int unit)
gpu::Texture * GPU_texture_create_error(int dimension, bool array)
void GPU_texture_unbind(gpu::Texture *texture)
void * GPU_texture_read(gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
int GPU_texture_layer_count(const gpu::Texture *texture)
int GPU_texture_original_height(const gpu::Texture *texture)
gpu::Texture * GPU_texture_create_view(const char *name, gpu::Texture *source_texture, gpu::TextureFormat view_format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array, bool use_stencil)
void GPU_texture_py_reference_set(gpu::Texture *texture, void **py_ref)
int GPU_texture_original_width(const gpu::Texture *texture)
bool GPU_texture_has_stencil_format(const gpu::Texture *texture)
unsigned int GPU_texture_memory_usage_get()
void GPU_texture_update_sub_from_pixel_buffer(gpu::Texture *texture, eGPUDataFormat data_format, GPUPixelBuffer *pixel_buf, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_get_mipmap_size(gpu::Texture *texture, int mip_level, int *r_size)
gpu::Texture * GPU_texture_create_1d_array(const char *name, int width, int layer_len, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_ref(gpu::Texture *texture)
GPUPixelBufferNativeHandle GPU_pixel_buffer_get_native_handle(GPUPixelBuffer *pixel_buf)
eGPUTextureUsage GPU_texture_mipmap_usage(gpu::TextureFormat format)
@ Invalid
Definition types.hh:42
GPUSamplerStateType type
void disable_filtering_flag(GPUSamplerFiltering filtering_flags)
GPUSamplerExtendMode extend_yz
GPUSamplerFiltering filtering
static constexpr GPUSamplerState internal_sampler()
void enable_filtering_flag(GPUSamplerFiltering filtering_flags)
void set_filtering_flag_from_test(GPUSamplerFiltering filtering_flags, bool test)
uint32_t as_uint() const
GPUSamplerCustomType custom_type
std::string to_string() const
static constexpr GPUSamplerState compare_sampler()
GPUSamplerExtendMode extend_x
static constexpr GPUSamplerState icon_sampler()
bool operator==(GPUSamplerState const &rhs) const
static constexpr GPUSamplerState default_sampler()