Blender V4.5
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.h"
18#include "BLI_utildefines.h"
19
20#include "GPU_format.hh"
21
22namespace blender::gpu {
23class VertBuf;
24}
25
26namespace blender::gpu {
27
28/* -------------------------------------------------------------------- */
31
35enum class TextureFormat : uint8_t {
37
38#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) blender_enum = int(DataFormat::blender_enum),
39
40#define GPU_TEXTURE_FORMAT_EXPAND(impl) \
41 SNORM_8_(impl) \
42 SNORM_8_8_(impl) \
43 SNORM_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
44 SNORM_8_8_8_8_(impl) \
45\
46 SNORM_16_(impl) \
47 SNORM_16_16_(impl) \
48 SNORM_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
49 SNORM_16_16_16_16_(impl) \
50\
51 UNORM_8_(impl) \
52 UNORM_8_8_(impl) \
53 UNORM_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
54 UNORM_8_8_8_8_(impl) \
55\
56 UNORM_16_(impl) \
57 UNORM_16_16_(impl) \
58 UNORM_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
59 UNORM_16_16_16_16_(impl) \
60\
61 SINT_8_(impl) \
62 SINT_8_8_(impl) \
63 SINT_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
64 SINT_8_8_8_8_(impl) \
65\
66 SINT_16_(impl) \
67 SINT_16_16_(impl) \
68 SINT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
69 SINT_16_16_16_16_(impl) \
70\
71 SINT_32_(impl) \
72 SINT_32_32_(impl) \
73 SINT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
74 SINT_32_32_32_32_(impl) \
75\
76 UINT_8_(impl) \
77 UINT_8_8_(impl) \
78 UINT_8_8_8_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
79 UINT_8_8_8_8_(impl) \
80\
81 UINT_16_(impl) \
82 UINT_16_16_(impl) \
83 UINT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
84 UINT_16_16_16_16_(impl) \
85\
86 UINT_32_(impl) \
87 UINT_32_32_(impl) \
88 UINT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
89 UINT_32_32_32_32_(impl) \
90\
91 SFLOAT_16_(impl) \
92 SFLOAT_16_16_(impl) \
93 SFLOAT_16_16_16_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
94 SFLOAT_16_16_16_16_(impl) \
95\
96 SFLOAT_32_(impl) \
97 SFLOAT_32_32_(impl) \
98 SFLOAT_32_32_32_(impl) /* TODO(fclem): Incompatible with metal, to remove. */ \
99 SFLOAT_32_32_32_32_(impl) \
100\
101 UNORM_10_10_10_2_(impl) \
102 UINT_10_10_10_2_(impl) \
103\
104 UFLOAT_11_11_10_(impl) \
105 UFLOAT_9_9_9_EXP_5_(impl) \
106\
107 UNORM_16_DEPTH_(impl) \
108 UNORM_24_DEPTH_(impl) /* TODO(fclem): Incompatible with metal, is emulated. To remove. */ \
109 UNORM_24_DEPTH_UINT_8_(impl) \
110 SFLOAT_32_DEPTH_(impl) \
111 SFLOAT_32_DEPTH_UINT_8_(impl) \
112\
113 SRGBA_8_8_8_(impl) \
114 SRGBA_8_8_8_8_(impl) \
115\
116 SNORM_DXT1_(impl) \
117 SNORM_DXT3_(impl) \
118 SNORM_DXT5_(impl) \
119 SRGB_DXT1_(impl) \
120 SRGB_DXT3_(impl) \
121 SRGB_DXT5_(impl)
122
124
125#undef DECLARE
126};
127
129{
130 return DataFormat(int(format));
131}
132
136enum class TextureTargetFormat : uint8_t {
138
139#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) \
140 blender_enum = int(TextureFormat::blender_enum),
141
142#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl) \
143 UNORM_8_(impl) \
144 UNORM_8_8_(impl) \
145 UNORM_8_8_8_8_(impl) \
146\
147 UNORM_16_(impl) \
148 UNORM_16_16_(impl) \
149 UNORM_16_16_16_16_(impl) \
150\
151 SINT_8_(impl) \
152 SINT_8_8_(impl) \
153 SINT_8_8_8_8_(impl) \
154\
155 SINT_16_(impl) \
156 SINT_16_16_(impl) \
157 SINT_16_16_16_16_(impl) \
158\
159 SINT_32_(impl) \
160 SINT_32_32_(impl) \
161 SINT_32_32_32_32_(impl) \
162\
163 UINT_8_(impl) \
164 UINT_8_8_(impl) \
165 UINT_8_8_8_8_(impl) \
166\
167 UINT_16_(impl) \
168 UINT_16_16_(impl) \
169 UINT_16_16_16_16_(impl) \
170\
171 UINT_32_(impl) \
172 UINT_32_32_(impl) \
173 UINT_32_32_32_32_(impl) \
174\
175 SFLOAT_16_(impl) \
176 SFLOAT_16_16_(impl) \
177 SFLOAT_16_16_16_16_(impl) \
178\
179 SFLOAT_32_(impl) \
180 SFLOAT_32_32_(impl) \
181 SFLOAT_32_32_32_32_(impl) \
182\
183 UNORM_10_10_10_2_(impl) \
184 UINT_10_10_10_2_(impl) \
185\
186 UFLOAT_11_11_10_(impl) \
187\
188 UNORM_16_DEPTH_(impl) \
189 UNORM_24_DEPTH_(impl) /* TODO(fclem): Incompatible with metal, is emulated. To remove. */ \
190 UNORM_24_DEPTH_UINT_8_(impl) \
191 SFLOAT_32_DEPTH_(impl) \
192 SFLOAT_32_DEPTH_UINT_8_(impl) \
193\
194 SRGBA_8_8_8_8_(impl)
195
197
198#undef DECLARE
199};
200
202{
203 return TextureFormat(int(format));
204}
205
209enum class TextureWriteFormat : uint8_t {
211
212#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) \
213 blender_enum = int(TextureFormat::blender_enum),
214
215#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl) \
216 UNORM_8_(impl) \
217 UNORM_8_8_(impl) \
218 UNORM_8_8_8_8_(impl) \
219\
220 UNORM_16_(impl) \
221 UNORM_16_16_(impl) \
222 UNORM_16_16_16_16_(impl) \
223\
224 SINT_8_(impl) \
225 SINT_8_8_(impl) \
226 SINT_8_8_8_8_(impl) \
227\
228 SINT_16_(impl) \
229 SINT_16_16_(impl) \
230 SINT_16_16_16_16_(impl) \
231\
232 SINT_32_(impl) \
233 SINT_32_32_(impl) \
234 SINT_32_32_32_32_(impl) \
235\
236 UINT_8_(impl) \
237 UINT_8_8_(impl) \
238 UINT_8_8_8_8_(impl) \
239\
240 UINT_16_(impl) \
241 UINT_16_16_(impl) \
242 UINT_16_16_16_16_(impl) \
243\
244 UINT_32_(impl) \
245 UINT_32_32_(impl) \
246 UINT_32_32_32_32_(impl) \
247\
248 SFLOAT_16_(impl) \
249 SFLOAT_16_16_(impl) \
250 SFLOAT_16_16_16_16_(impl) \
251\
252 SFLOAT_32_(impl) \
253 SFLOAT_32_32_(impl) \
254 SFLOAT_32_32_32_32_(impl) \
255\
256 UNORM_10_10_10_2_(impl) \
257 UINT_10_10_10_2_(impl) \
258\
259 UFLOAT_11_11_10_(impl)
260
262
263#undef DECLARE
264};
265
267{
268 return TextureFormat(int(format));
269}
270
272
273} // namespace blender::gpu
274
275/* -------------------------------------------------------------------- */
278
314
316
317
321 1;
322
343
344#define GPU_SAMPLER_EXTEND_MODES_COUNT (GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER + 1)
345
380
381#define GPU_SAMPLER_CUSTOM_TYPES_COUNT (GPU_SAMPLER_CUSTOM_ICON + 1)
382
408
441
458
475
491
509
514 {
515 this->filtering = this->filtering | filtering_flags;
516 }
517
522 {
523 this->filtering = this->filtering & ~filtering_flags;
524 }
525
530 void set_filtering_flag_from_test(GPUSamplerFiltering filtering_flags, bool test)
531 {
532 if (test) {
533 this->enable_filtering_flag(filtering_flags);
534 }
535 else {
536 this->disable_filtering_flag(filtering_flags);
537 }
538 }
539
540 std::string to_string() const
541 {
543 return "internal";
544 }
545
546 if (this->type == GPU_SAMPLER_STATE_TYPE_CUSTOM) {
547 switch (this->custom_type) {
549 return "compare";
550 break;
552 return "icon";
553 break;
554 default:
556 return "";
557 }
558 }
559
560 /* The sampler state is of type PARAMETERS, so serialize the parameters. */
562 std::string serialized_parameters;
563
565 serialized_parameters += "linear-filter_";
566 }
567
569 serialized_parameters += "mipmap_";
570 }
571
573 serialized_parameters += "anisotropic_";
574 }
575
576 switch (this->extend_x) {
578 serialized_parameters += "extend-x_";
579 break;
581 serialized_parameters += "repeat-x_";
582 break;
584 serialized_parameters += "mirrored-repeat-x_";
585 break;
587 serialized_parameters += "clamp-to-border-x_";
588 break;
589 default:
591 }
592
593 switch (this->extend_yz) {
595 serialized_parameters += "extend-y_";
596 break;
598 serialized_parameters += "repeat-y_";
599 break;
601 serialized_parameters += "mirrored-repeat-y_";
602 break;
604 serialized_parameters += "clamp-to-border-y_";
605 break;
606 default:
608 }
609
610 switch (this->extend_yz) {
612 serialized_parameters += "extend-z";
613 break;
615 serialized_parameters += "repeat-z";
616 break;
618 serialized_parameters += "mirrored-repeat-z";
619 break;
621 serialized_parameters += "clamp-to-border-z";
622 break;
623 default:
625 }
626
627 return serialized_parameters;
628 }
629
630 bool operator==(GPUSamplerState const &rhs) const
631 {
632 return this->filtering == rhs.filtering && this->extend_x == rhs.extend_x &&
633 this->extend_yz == rhs.extend_yz && this->custom_type == rhs.custom_type &&
634 this->type == rhs.type;
635 }
636};
637
639
640/* -------------------------------------------------------------------- */
643
649 /* Formats texture & render-buffer. */
650
651 GPU_RGBA8UI = uint8_t(blender::gpu::TextureFormat::UINT_8_8_8_8),
652 GPU_RGBA8I = uint8_t(blender::gpu::TextureFormat::SINT_8_8_8_8),
653 GPU_RGBA8 = uint8_t(blender::gpu::TextureFormat::UNORM_8_8_8_8),
654 GPU_RGBA16UI = uint8_t(blender::gpu::TextureFormat::UINT_16_16_16_16),
655 GPU_RGBA16I = uint8_t(blender::gpu::TextureFormat::SINT_16_16_16_16),
656 GPU_RGBA16F = uint8_t(blender::gpu::TextureFormat::SFLOAT_16_16_16_16),
657 GPU_RGBA16 = uint8_t(blender::gpu::TextureFormat::UNORM_16_16_16_16),
658 GPU_RGBA32UI = uint8_t(blender::gpu::TextureFormat::UINT_32_32_32_32),
659 GPU_RGBA32I = uint8_t(blender::gpu::TextureFormat::SINT_32_32_32_32),
660 GPU_RGBA32F = uint8_t(blender::gpu::TextureFormat::SFLOAT_32_32_32_32),
661
662 GPU_RG8UI = uint8_t(blender::gpu::TextureFormat::UINT_8_8),
663 GPU_RG8I = uint8_t(blender::gpu::TextureFormat::SINT_8_8),
664 GPU_RG8 = uint8_t(blender::gpu::TextureFormat::UNORM_8_8),
665 GPU_RG16UI = uint8_t(blender::gpu::TextureFormat::UINT_16_16),
666 GPU_RG16I = uint8_t(blender::gpu::TextureFormat::SINT_16_16),
667 GPU_RG16F = uint8_t(blender::gpu::TextureFormat::SFLOAT_16_16),
668 GPU_RG16 = uint8_t(blender::gpu::TextureFormat::UNORM_16_16),
669 GPU_RG32UI = uint8_t(blender::gpu::TextureFormat::UINT_32_32),
670 GPU_RG32I = uint8_t(blender::gpu::TextureFormat::SINT_32_32),
671 GPU_RG32F = uint8_t(blender::gpu::TextureFormat::SFLOAT_32_32),
672
673 GPU_R8UI = uint8_t(blender::gpu::TextureFormat::UINT_8),
674 GPU_R8I = uint8_t(blender::gpu::TextureFormat::SINT_8),
675 GPU_R8 = uint8_t(blender::gpu::TextureFormat::UNORM_8),
676 GPU_R16UI = uint8_t(blender::gpu::TextureFormat::UINT_16),
677 GPU_R16I = uint8_t(blender::gpu::TextureFormat::SINT_16),
678 GPU_R16F = uint8_t(blender::gpu::TextureFormat::SFLOAT_16),
679 GPU_R16 = uint8_t(blender::gpu::TextureFormat::UNORM_16),
680 GPU_R32UI = uint8_t(blender::gpu::TextureFormat::UINT_32),
681 GPU_R32I = uint8_t(blender::gpu::TextureFormat::SINT_32),
682 GPU_R32F = uint8_t(blender::gpu::TextureFormat::SFLOAT_32),
683
684 /* Special formats texture & render-buffer. */
685
686 GPU_RGB10_A2 = uint8_t(blender::gpu::TextureFormat::UNORM_10_10_10_2),
687 GPU_RGB10_A2UI = uint8_t(blender::gpu::TextureFormat::UINT_10_10_10_2),
688 GPU_R11F_G11F_B10F = uint8_t(blender::gpu::TextureFormat::UFLOAT_11_11_10),
689 GPU_DEPTH32F_STENCIL8 = uint8_t(blender::gpu::TextureFormat::SFLOAT_32_DEPTH_UINT_8),
690 GPU_DEPTH24_STENCIL8 = uint8_t(blender::gpu::TextureFormat::UNORM_24_DEPTH_UINT_8),
691 GPU_SRGB8_A8 = uint8_t(blender::gpu::TextureFormat::SRGBA_8_8_8_8),
692
693 /* Texture only formats. */
694
695 GPU_RGBA8_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_8_8_8_8),
696 GPU_RGB8_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_8_8_8),
697 GPU_RG8_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_8_8),
698 GPU_R8_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_8),
699 GPU_RGBA16_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_16_16_16_16),
700 GPU_RGB16_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_16_16_16),
701 GPU_RG16_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_16_16),
702 GPU_R16_SNORM = uint8_t(blender::gpu::TextureFormat::SNORM_16),
703
704 GPU_RGB8UI = uint8_t(blender::gpu::TextureFormat::UINT_8_8_8),
705 GPU_RGB8I = uint8_t(blender::gpu::TextureFormat::SINT_8_8_8),
706 GPU_RGB8 = uint8_t(blender::gpu::TextureFormat::UNORM_8_8_8),
707 GPU_RGB16UI = uint8_t(blender::gpu::TextureFormat::UINT_16_16_16),
708 GPU_RGB16I = uint8_t(blender::gpu::TextureFormat::SINT_16_16_16),
709 GPU_RGB16F = uint8_t(blender::gpu::TextureFormat::SFLOAT_16_16_16),
710 GPU_RGB16 = uint8_t(blender::gpu::TextureFormat::UNORM_16_16_16),
711 GPU_RGB32UI = uint8_t(blender::gpu::TextureFormat::UINT_32_32_32),
712 GPU_RGB32I = uint8_t(blender::gpu::TextureFormat::SINT_32_32_32),
713 GPU_RGB32F = uint8_t(blender::gpu::TextureFormat::SFLOAT_32_32_32),
714
715 /* Special formats, texture only. */
716 GPU_SRGB8_A8_DXT1 = uint8_t(blender::gpu::TextureFormat::SRGB_DXT1),
717 GPU_SRGB8_A8_DXT3 = uint8_t(blender::gpu::TextureFormat::SRGB_DXT3),
718 GPU_SRGB8_A8_DXT5 = uint8_t(blender::gpu::TextureFormat::SRGB_DXT5),
719 GPU_RGBA8_DXT1 = uint8_t(blender::gpu::TextureFormat::SNORM_DXT1),
720 GPU_RGBA8_DXT3 = uint8_t(blender::gpu::TextureFormat::SNORM_DXT3),
721 GPU_RGBA8_DXT5 = uint8_t(blender::gpu::TextureFormat::SNORM_DXT5),
722 GPU_SRGB8 = uint8_t(blender::gpu::TextureFormat::SRGBA_8_8_8),
723 GPU_RGB9_E5 = uint8_t(blender::gpu::TextureFormat::UFLOAT_9_9_9_EXP_5),
724#if 0 /* TODO: Add support for them. */
725 GPU_COMPRESSED_RG_RGTC2,
726 GPU_COMPRESSED_SIGNED_RG_RGTC2,
727 GPU_COMPRESSED_RED_RGTC1,
728 GPU_COMPRESSED_SIGNED_RED_RGTC1,
729#endif
730
731 /* Depth Formats. */
732 GPU_DEPTH_COMPONENT32F = uint8_t(blender::gpu::TextureFormat::SFLOAT_32_DEPTH),
733 GPU_DEPTH_COMPONENT24 = uint8_t(blender::gpu::TextureFormat::UNORM_24_DEPTH),
734 GPU_DEPTH_COMPONENT16 = uint8_t(blender::gpu::TextureFormat::UNORM_16_DEPTH),
735};
736
755
768 /* Whether texture is sampled or read during a shader. */
770 /* Whether the texture is written to by a shader using imageStore. */
772 /* Whether a texture is used as an attachment in a frame-buffer. */
774 /* Whether a texture is used to create a texture view utilizing a different texture format to the
775 * source textures format. This includes the use of stencil views. */
777 /* Whether the texture needs to be read from by the CPU. */
779 /* When used, the texture will not have any backing storage and can solely exist as a virtual
780 * frame-buffer attachment. */
782 /* Whether a texture can support atomic operations. */
784 /* Whether a texture can be exported to other instances/processes. */
786 /* Create a texture whose usage cannot be defined prematurely.
787 * This is unoptimized and should not be used. */
790};
791
793
795
796/* -------------------------------------------------------------------- */
799
801struct GPUTexture;
802
813GPUTexture *GPU_texture_create_1d(const char *name,
814 int width,
815 int mip_len,
817 eGPUTextureUsage usage,
818 const float *data);
819GPUTexture *GPU_texture_create_1d_array(const char *name,
820 int width,
821 int layer_len,
822 int mip_len,
824 eGPUTextureUsage usage,
825 const float *data);
826GPUTexture *GPU_texture_create_2d(const char *name,
827 int width,
828 int height,
829 int mip_len,
831 eGPUTextureUsage usage,
832 const float *data);
833GPUTexture *GPU_texture_create_2d_array(const char *name,
834 int width,
835 int height,
836 int layer_len,
837 int mip_len,
839 eGPUTextureUsage usage,
840 const float *data);
841GPUTexture *GPU_texture_create_3d(const char *name,
842 int width,
843 int height,
844 int depth,
845 int mip_len,
847 eGPUTextureUsage usage,
848 const void *data);
849GPUTexture *GPU_texture_create_cube(const char *name,
850 int width,
851 int mip_len,
853 eGPUTextureUsage usage,
854 const float *data);
855GPUTexture *GPU_texture_create_cube_array(const char *name,
856 int width,
857 int layer_len,
858 int mip_len,
860 eGPUTextureUsage usage,
861 const float *data);
867GPUTexture *GPU_texture_create_compressed_2d(const char *name,
868 int width,
869 int height,
870 int mip_len,
872 eGPUTextureUsage usage,
873 const void *data);
874
879GPUTexture *GPU_texture_create_from_vertbuf(const char *name, blender::gpu::VertBuf *vertex_buf);
880
886GPUTexture *GPU_texture_create_error(int dimension, bool array);
887
889
890/* -------------------------------------------------------------------- */
893
900void GPU_texture_ref(GPUTexture *texture);
901
906void GPU_texture_free(GPUTexture *texture);
907
908#define GPU_TEXTURE_FREE_SAFE(texture) \
909 do { \
910 if (texture != nullptr) { \
911 GPU_texture_free(texture); \
912 texture = nullptr; \
913 } \
914 } while (0)
915
917
918/* -------------------------------------------------------------------- */
921
946GPUTexture *GPU_texture_create_view(const char *name,
947 GPUTexture *source_texture,
948 eGPUTextureFormat view_format,
949 int mip_start,
950 int mip_len,
951 int layer_start,
952 int layer_len,
953 bool cube_as_array,
954 bool use_stencil);
955
957
958/* -------------------------------------------------------------------- */
961
970
979void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data);
980
992void GPU_texture_update_sub(GPUTexture *texture,
993 eGPUDataFormat data_format,
994 const void *pixels,
995 int offset_x,
996 int offset_y,
997 int offset_z,
998 int width,
999 int height,
1000 int depth);
1001
1008void GPU_texture_update_mipmap(GPUTexture *texture,
1009 int mip_level,
1010 eGPUDataFormat data_format,
1011 const void *pixels);
1012
1021void GPU_texture_clear(GPUTexture *texture, eGPUDataFormat data_format, const void *data);
1022
1027void GPU_texture_copy(GPUTexture *dst, GPUTexture *src);
1028
1034
1041void *GPU_texture_read(GPUTexture *texture, eGPUDataFormat data_format, int mip_level);
1042
1044
1045/* -------------------------------------------------------------------- */
1048
1052void GPU_texture_bind(GPUTexture *texture, int unit);
1056void GPU_texture_bind_ex(GPUTexture *texture, GPUSamplerState state, int unit);
1061void GPU_texture_unbind(GPUTexture *texture);
1066
1072void GPU_texture_image_bind(GPUTexture *texture, int unit);
1077void GPU_texture_image_unbind(GPUTexture *texture);
1082
1084
1085/* -------------------------------------------------------------------- */
1088
1092void GPU_texture_compare_mode(GPUTexture *texture, bool use_compare);
1093
1100void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter);
1101
1109void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter);
1110
1115void GPU_texture_anisotropic_filter(GPUTexture *texture, bool use_aniso);
1116
1121void GPU_texture_extend_mode_x(GPUTexture *texture, GPUSamplerExtendMode extend_mode);
1122
1127void GPU_texture_extend_mode_y(GPUTexture *texture, GPUSamplerExtendMode extend_mode);
1128
1133void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode);
1134
1151void GPU_texture_swizzle_set(GPUTexture *texture, const char swizzle[4]);
1152
1154
1155/* -------------------------------------------------------------------- */
1158
1163int GPU_texture_dimensions(const GPUTexture *texture);
1164
1168int GPU_texture_width(const GPUTexture *texture);
1169
1173int GPU_texture_height(const GPUTexture *texture);
1174
1179int GPU_texture_depth(const GPUTexture *texture);
1180
1184int GPU_texture_layer_count(const GPUTexture *texture);
1185
1189int GPU_texture_mip_count(const GPUTexture *texture);
1190
1195
1199eGPUTextureUsage GPU_texture_usage(const GPUTexture *texture);
1200
1204bool GPU_texture_is_array(const GPUTexture *texture);
1205
1209bool GPU_texture_is_cube(const GPUTexture *texture);
1210
1214bool GPU_texture_has_depth_format(const GPUTexture *texture);
1215
1219bool GPU_texture_has_stencil_format(const GPUTexture *texture);
1220
1224bool GPU_texture_has_integer_format(const GPUTexture *texture);
1225
1229bool GPU_texture_has_float_format(const GPUTexture *texture);
1230
1234bool GPU_texture_has_normalized_format(const GPUTexture *texture);
1235
1239bool GPU_texture_has_signed_format(const GPUTexture *texture);
1240
1246void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *r_size);
1247
1249
1250/* -------------------------------------------------------------------- */
1256
1262int GPU_texture_original_width(const GPUTexture *texture);
1263int GPU_texture_original_height(const GPUTexture *texture);
1264void GPU_texture_original_size_set(GPUTexture *texture, int width, int height);
1265
1270#ifndef GPU_NO_USE_PY_REFERENCES
1271void **GPU_texture_py_reference_get(GPUTexture *texture);
1272void GPU_texture_py_reference_set(GPUTexture *texture, void **py_ref);
1273#endif
1274
1280int GPU_texture_opengl_bindcode(const GPUTexture *texture);
1281
1283
1284/* -------------------------------------------------------------------- */
1287
1292
1297
1303
1309unsigned int GPU_texture_memory_usage_get();
1310
1314void GPU_samplers_update();
1315
1317
1318/* -------------------------------------------------------------------- */
1324
1326struct GPUPixelBuffer;
1327
1331GPUPixelBuffer *GPU_pixel_buffer_create(size_t byte_size);
1332
1337void GPU_pixel_buffer_free(GPUPixelBuffer *pixel_buf);
1338
1345void *GPU_pixel_buffer_map(GPUPixelBuffer *pixel_buf);
1346
1351void GPU_pixel_buffer_unmap(GPUPixelBuffer *pixel_buf);
1352
1356size_t GPU_pixel_buffer_size(GPUPixelBuffer *pixel_buf);
1357
1372
1374
1381 eGPUDataFormat data_format,
1382 GPUPixelBuffer *pixel_buf,
1383 int offset_x,
1384 int offset_y,
1385 int offset_z,
1386 int width,
1387 int height,
1388 int depth);
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
#define BLI_assert(a)
Definition BLI_assert.h:46
unsigned int uint
#define ENUM_OPERATORS(_type, _max)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
GPUSamplerCustomType
@ GPU_SAMPLER_CUSTOM_ICON
@ GPU_SAMPLER_CUSTOM_COMPARE
int GPU_texture_height(const GPUTexture *texture)
GPUTexture * GPU_texture_create_compressed_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const void *data)
void GPU_texture_bind(GPUTexture *texture, int unit)
int GPU_texture_original_height(const GPUTexture *texture)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_extend_mode_y(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl)
GPUTexture * GPU_texture_create_1d(const char *name, int width, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
const char * GPU_texture_format_name(eGPUTextureFormat format)
void GPU_texture_free(GPUTexture *texture)
void GPU_pixel_buffer_unmap(GPUPixelBuffer *pixel_buf)
int GPU_texture_width(const GPUTexture *texture)
void GPU_texture_clear(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_ref(GPUTexture *texture)
void ** GPU_texture_py_reference_get(GPUTexture *texture)
void GPU_texture_bind_ex(GPUTexture *texture, GPUSamplerState state, int unit)
int GPU_texture_dimensions(const GPUTexture *texture)
void GPU_texture_copy(GPUTexture *dst, GPUTexture *src)
#define GPU_TEXTURE_FORMAT_EXPAND(impl)
size_t GPU_texture_dataformat_size(eGPUDataFormat data_format)
void * GPU_texture_read(GPUTexture *texture, eGPUDataFormat data_format, int mip_level)
bool GPU_texture_has_float_format(const GPUTexture *texture)
bool GPU_texture_is_cube(const GPUTexture *texture)
void GPU_texture_image_unbind_all()
int GPU_texture_depth(const GPUTexture *texture)
GPUPixelBufferNativeHandle GPU_pixel_buffer_get_native_handle(GPUPixelBuffer *pixel_buf)
void GPU_texture_unbind(GPUTexture *texture)
size_t GPU_pixel_buffer_size(GPUPixelBuffer *pixel_buf)
int GPU_texture_mip_count(const GPUTexture *texture)
int GPU_texture_original_width(const GPUTexture *texture)
GPUSamplerStateType
@ GPU_SAMPLER_STATE_TYPE_CUSTOM
@ GPU_SAMPLER_STATE_TYPE_PARAMETERS
@ GPU_SAMPLER_STATE_TYPE_INTERNAL
void GPU_texture_py_reference_set(GPUTexture *texture, void **py_ref)
void * GPU_pixel_buffer_map(GPUPixelBuffer *pixel_buf)
void GPU_pixel_buffer_free(GPUPixelBuffer *pixel_buf)
void GPU_texture_update_sub_from_pixel_buffer(GPUTexture *texture, eGPUDataFormat data_format, GPUPixelBuffer *pixel_buf, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_anisotropic_filter(GPUTexture *texture, bool use_aniso)
GPUTexture * GPU_texture_create_error(int dimension, bool array)
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT
GPUTexture * GPU_texture_create_cube_array(const char *name, int width, int layer_len, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
eGPUDataFormat
@ GPU_DATA_HALF_FLOAT
@ GPU_DATA_UINT_24_8
@ GPU_DATA_INT
@ GPU_DATA_10_11_11_REV
@ GPU_DATA_UBYTE
@ GPU_DATA_UINT
@ GPU_DATA_2_10_10_10_REV
@ GPU_DATA_FLOAT
void GPU_texture_compare_mode(GPUTexture *texture, bool use_compare)
bool GPU_texture_has_normalized_format(const GPUTexture *texture)
void GPU_texture_extend_mode_x(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode(GPUTexture *texture, GPUSamplerExtendMode extend_mode)
bool GPU_texture_has_integer_format(const GPUTexture *texture)
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, blender::gpu::VertBuf *vertex_buf)
GPUTexture * GPU_texture_create_view(const char *name, GPUTexture *source_texture, eGPUTextureFormat view_format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array, bool use_stencil)
bool GPU_texture_is_array(const GPUTexture *texture)
int GPU_texture_opengl_bindcode(const GPUTexture *texture)
eGPUTextureUsage
@ GPU_TEXTURE_USAGE_MEMORY_EXPORT
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
@ GPU_TEXTURE_USAGE_MEMORYLESS
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_GENERAL
@ GPU_TEXTURE_USAGE_ATOMIC
@ GPU_TEXTURE_USAGE_FORMAT_VIEW
bool GPU_texture_has_stencil_format(const GPUTexture *texture)
GPUSamplerExtendMode
@ GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_REPEAT
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
void GPU_texture_update_sub(GPUTexture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
void GPU_texture_update_mipmap(GPUTexture *texture, int mip_level, eGPUDataFormat data_format, const void *pixels)
GPUTexture * GPU_texture_create_2d_array(const char *name, int width, int height, int layer_len, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_mipmap_mode(GPUTexture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_image_unbind(GPUTexture *texture)
GPUTexture * GPU_texture_create_3d(const char *name, int width, int height, int depth, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const void *data)
void GPU_texture_image_bind(GPUTexture *texture, int unit)
void GPU_texture_filter_mode(GPUTexture *texture, bool use_filter)
eGPUTextureFormat
@ GPU_RGB16
@ GPU_R16UI
@ GPU_RGB8
@ GPU_RG16F
@ GPU_DEPTH32F_STENCIL8
@ GPU_R32F
@ GPU_SRGB8
@ GPU_R16I
@ GPU_SRGB8_A8
@ GPU_RG8_SNORM
@ GPU_DEPTH24_STENCIL8
@ GPU_RGB10_A2
@ GPU_RGB8I
@ GPU_R32I
@ GPU_RGBA8_SNORM
@ GPU_RGB10_A2UI
@ GPU_RG8UI
@ GPU_R16F
@ GPU_RGB16I
@ GPU_RGBA16_SNORM
@ GPU_RGB9_E5
@ GPU_SRGB8_A8_DXT5
@ GPU_RG8I
@ GPU_RG16I
@ GPU_RG32UI
@ GPU_RGB32I
@ GPU_RGBA32F
@ GPU_RGBA16F
@ GPU_RG8
@ GPU_RG32I
@ GPU_SRGB8_A8_DXT1
@ GPU_RG16
@ GPU_RGBA32UI
@ GPU_R8I
@ GPU_R16
@ GPU_RG16UI
@ GPU_RGBA8I
@ GPU_RGBA8_DXT1
@ GPU_RGBA8UI
@ GPU_RGB32F
@ GPU_RGBA16UI
@ GPU_RGBA16I
@ GPU_R8UI
@ GPU_RGBA16
@ GPU_SRGB8_A8_DXT3
@ GPU_RGB8_SNORM
@ GPU_RGBA8_DXT3
@ GPU_RGB32UI
@ GPU_R8_SNORM
@ GPU_RG32F
@ GPU_R8
@ GPU_RGB16_SNORM
@ GPU_DEPTH_COMPONENT24
@ GPU_RG16_SNORM
@ GPU_RGB8UI
@ GPU_RGB16F
@ GPU_RGB16UI
@ GPU_R32UI
@ GPU_RGBA32I
@ GPU_RGBA8_DXT5
@ GPU_DEPTH_COMPONENT32F
@ GPU_R16_SNORM
@ GPU_DEPTH_COMPONENT16
@ GPU_R11F_G11F_B10F
@ GPU_RGBA8
void GPU_texture_unbind_all()
GPUTexture * GPU_texture_create_cube(const char *name, int width, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_update_mipmap_chain(GPUTexture *texture)
eGPUTextureUsage GPU_texture_usage(const GPUTexture *texture)
bool GPU_texture_has_signed_format(const GPUTexture *texture)
#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl)
GPUPixelBuffer * GPU_pixel_buffer_create(size_t byte_size)
GPUTexture * GPU_texture_create_1d_array(const char *name, int width, int layer_len, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_unpack_row_length_set(uint len)
GPUSamplerFiltering
@ GPU_SAMPLER_FILTERING_MIPMAP
@ GPU_SAMPLER_FILTERING_ANISOTROPIC
@ GPU_SAMPLER_FILTERING_LINEAR
@ GPU_SAMPLER_FILTERING_DEFAULT
void GPU_texture_original_size_set(GPUTexture *texture, int width, int height)
int GPU_texture_layer_count(const GPUTexture *texture)
bool GPU_texture_has_depth_format(const GPUTexture *texture)
void GPU_samplers_update()
size_t GPU_texture_component_len(eGPUTextureFormat format)
void GPU_texture_update(GPUTexture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_get_mipmap_size(GPUTexture *texture, int mip_level, int *r_size)
unsigned int GPU_texture_memory_usage_get()
eGPUTextureFormat GPU_texture_format(const GPUTexture *texture)
void GPU_texture_swizzle_set(GPUTexture *texture, const char swizzle[4])
BMesh const char void * data
long long int int64_t
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
format
static ulong state[N]
constexpr DataFormat to_data_format(TextureFormat format)
constexpr TextureFormat to_texture_format(TextureTargetFormat format)
GPUSamplerCustomType custom_type
GPUSamplerExtendMode extend_yz
static constexpr GPUSamplerState internal_sampler()
static constexpr GPUSamplerState icon_sampler()
static constexpr GPUSamplerState default_sampler()
GPUSamplerFiltering filtering
void enable_filtering_flag(GPUSamplerFiltering filtering_flags)
std::string to_string() const
void disable_filtering_flag(GPUSamplerFiltering filtering_flags)
GPUSamplerExtendMode extend_x
static constexpr GPUSamplerState compare_sampler()
bool operator==(GPUSamplerState const &rhs) const
GPUSamplerStateType type
void set_filtering_flag_from_test(GPUSamplerFiltering filtering_flags, bool test)
uint len