22 case TextureFormat::SFLOAT_16_16_16_16:
23 case TextureFormat::SFLOAT_16_16_16:
24 case TextureFormat::SFLOAT_16_16:
25 case TextureFormat::SFLOAT_16:
84# define DEBUG_NAME_LEN 64
86# define DEBUG_NAME_LEN 8
90#define GPU_MAX_IMAGE 8
93#define GPU_TEX_MAX_FBO_ATTACHED 32
107#ifndef GPU_NO_USE_PY_REFERENCES
179 GPUPixelBuffer *pixbuf) = 0;
283 case TextureFormat::SFLOAT_32_DEPTH:
284 case TextureFormat::UNORM_16_DEPTH:
287 case TextureFormat::SFLOAT_32_DEPTH_UINT_8:
294 case TextureFormat::SFLOAT_16_16_16:
295 case TextureFormat::SNORM_16_16_16_16:
296 case TextureFormat::SNORM_8_8_8_8:
297 case TextureFormat::SFLOAT_32_32_32:
298 case TextureFormat::SINT_32_32_32:
299 case TextureFormat::UINT_32_32_32:
300 case TextureFormat::SNORM_16_16_16:
301 case TextureFormat::SINT_16_16_16:
302 case TextureFormat::UINT_16_16_16:
303 case TextureFormat::UNORM_16_16_16:
304 case TextureFormat::SNORM_8_8_8:
305 case TextureFormat::UNORM_8_8_8:
306 case TextureFormat::SINT_8_8_8:
307 case TextureFormat::UINT_8_8_8:
308 case TextureFormat::SNORM_16_16:
309 case TextureFormat::SNORM_8_8:
310 case TextureFormat::SNORM_16:
311 case TextureFormat::SNORM_8:
312 case TextureFormat::SRGB_DXT1:
313 case TextureFormat::SRGB_DXT3:
314 case TextureFormat::SRGB_DXT5:
315 case TextureFormat::SNORM_DXT1:
316 case TextureFormat::SNORM_DXT3:
317 case TextureFormat::SNORM_DXT5:
318 case TextureFormat::SRGBA_8_8_8:
319 case TextureFormat::UFLOAT_9_9_9_EXP_5:
320 BLI_assert_msg(0,
"Texture cannot be attached to a framebuffer because of its type");
331 bool use_stencil) = 0;
352 return reinterpret_cast<GPUPixelBuffer *
>(pixbuf);
360 return reinterpret_cast<const PixelBuffer *
>(pixbuf);
373 case TextureFormat::SRGB_DXT1:
374 case TextureFormat::SNORM_DXT1:
376 case TextureFormat::SRGB_DXT3:
377 case TextureFormat::SRGB_DXT5:
378 case TextureFormat::SNORM_DXT3:
379 case TextureFormat::SNORM_DXT5:
391 case TextureFormat::UINT_8_8_8_8:
393 case TextureFormat::SINT_8_8_8_8:
395 case TextureFormat::UNORM_8_8_8_8:
397 case TextureFormat::UINT_32_32_32_32:
399 case TextureFormat::SINT_32_32_32_32:
401 case TextureFormat::SFLOAT_32_32_32_32:
403 case TextureFormat::UINT_16_16_16_16:
405 case TextureFormat::SINT_16_16_16_16:
407 case TextureFormat::SFLOAT_16_16_16_16:
409 case TextureFormat::UNORM_16_16_16_16:
411 case TextureFormat::UINT_8_8:
413 case TextureFormat::SINT_8_8:
415 case TextureFormat::UNORM_8_8:
417 case TextureFormat::UINT_32_32:
419 case TextureFormat::SINT_32_32:
421 case TextureFormat::SFLOAT_32_32:
423 case TextureFormat::UINT_16_16:
425 case TextureFormat::SINT_16_16:
427 case TextureFormat::SFLOAT_16_16:
429 case TextureFormat::UNORM_16_16:
431 case TextureFormat::UINT_8:
433 case TextureFormat::SINT_8:
435 case TextureFormat::UNORM_8:
437 case TextureFormat::UINT_32:
439 case TextureFormat::SINT_32:
441 case TextureFormat::SFLOAT_32:
443 case TextureFormat::UINT_16:
445 case TextureFormat::SINT_16:
447 case TextureFormat::SFLOAT_16:
449 case TextureFormat::UNORM_16:
453 case TextureFormat::UNORM_10_10_10_2:
455 case TextureFormat::UINT_10_10_10_2:
457 case TextureFormat::UFLOAT_11_11_10:
459 case TextureFormat::SFLOAT_32_DEPTH_UINT_8:
461 case TextureFormat::SRGBA_8_8_8_8:
465 case TextureFormat::SFLOAT_16_16_16:
467 case TextureFormat::SNORM_16_16_16:
469 case TextureFormat::SINT_16_16_16:
471 case TextureFormat::UINT_16_16_16:
473 case TextureFormat::UNORM_16_16_16:
475 case TextureFormat::SNORM_16_16_16_16:
476 case TextureFormat::SNORM_8_8_8_8:
478 case TextureFormat::SFLOAT_32_32_32:
480 case TextureFormat::SINT_32_32_32:
482 case TextureFormat::UINT_32_32_32:
484 case TextureFormat::SNORM_8_8_8:
486 case TextureFormat::UNORM_8_8_8:
488 case TextureFormat::SINT_8_8_8:
490 case TextureFormat::UINT_8_8_8:
492 case TextureFormat::SNORM_16_16:
493 case TextureFormat::SNORM_8_8:
494 case TextureFormat::SNORM_16:
495 case TextureFormat::SNORM_8:
499 case TextureFormat::SRGB_DXT1:
500 case TextureFormat::SRGB_DXT3:
501 case TextureFormat::SRGB_DXT5:
503 case TextureFormat::SNORM_DXT1:
504 case TextureFormat::SNORM_DXT3:
505 case TextureFormat::SNORM_DXT5:
507 case TextureFormat::SRGBA_8_8_8:
509 case TextureFormat::UFLOAT_9_9_9_EXP_5:
513 case TextureFormat::SFLOAT_32_DEPTH:
514 case TextureFormat::UNORM_16_DEPTH:
531 switch (data_format) {
555 ((tex_format == TextureFormat::UNORM_10_10_10_2 ||
556 tex_format == TextureFormat::UINT_10_10_10_2) &&
568 switch (tex_format) {
570 case TextureFormat::UINT_32_32_32_32:
571 case TextureFormat::UINT_32_32:
572 case TextureFormat::UINT_32:
574 case TextureFormat::UINT_16_16_16_16:
575 case TextureFormat::UINT_16_16:
576 case TextureFormat::UINT_16:
578 case TextureFormat::UINT_8_8_8_8:
579 case TextureFormat::UINT_8_8:
580 case TextureFormat::UINT_8:
583 case TextureFormat::SINT_32_32_32_32:
584 case TextureFormat::SINT_32_32:
585 case TextureFormat::SINT_32:
587 case TextureFormat::SINT_16_16_16_16:
588 case TextureFormat::SINT_16_16:
589 case TextureFormat::SINT_16:
591 case TextureFormat::SINT_8_8_8_8:
592 case TextureFormat::SINT_8_8:
593 case TextureFormat::SINT_8:
596 case TextureFormat::SFLOAT_32_32_32_32:
597 case TextureFormat::SFLOAT_32_32:
598 case TextureFormat::SFLOAT_32:
600 case TextureFormat::SFLOAT_16_16_16_16:
601 case TextureFormat::SFLOAT_16_16:
602 case TextureFormat::SFLOAT_16:
604 case TextureFormat::UNORM_16_16_16_16:
605 case TextureFormat::UNORM_16_16:
606 case TextureFormat::UNORM_16:
608 case TextureFormat::UNORM_8_8_8_8:
609 case TextureFormat::UNORM_8_8:
610 case TextureFormat::UNORM_8:
614 case TextureFormat::UNORM_10_10_10_2:
615 case TextureFormat::UINT_10_10_10_2:
617 case TextureFormat::UFLOAT_11_11_10:
619 case TextureFormat::SFLOAT_32_DEPTH_UINT_8:
622 case TextureFormat::SRGBA_8_8_8_8:
626 case TextureFormat::UINT_32_32_32:
628 case TextureFormat::UINT_16_16_16:
630 case TextureFormat::UINT_8_8_8:
632 case TextureFormat::SINT_32_32_32:
634 case TextureFormat::SINT_16_16_16:
636 case TextureFormat::SINT_8_8_8:
638 case TextureFormat::UNORM_16_16_16:
640 case TextureFormat::UNORM_8_8_8:
642 case TextureFormat::SNORM_16_16_16_16:
643 case TextureFormat::SNORM_16_16_16:
644 case TextureFormat::SNORM_16_16:
645 case TextureFormat::SNORM_16:
647 case TextureFormat::SNORM_8_8_8_8:
648 case TextureFormat::SNORM_8_8_8:
649 case TextureFormat::SNORM_8_8:
650 case TextureFormat::SNORM_8:
652 case TextureFormat::SFLOAT_32_32_32:
654 case TextureFormat::SFLOAT_16_16_16:
658 case TextureFormat::SRGB_DXT1:
659 case TextureFormat::SRGB_DXT3:
660 case TextureFormat::SRGB_DXT5:
661 case TextureFormat::SNORM_DXT1:
662 case TextureFormat::SNORM_DXT3:
663 case TextureFormat::SNORM_DXT5:
667 case TextureFormat::SRGBA_8_8_8:
669 case TextureFormat::UFLOAT_9_9_9_EXP_5:
673 case TextureFormat::SFLOAT_32_DEPTH:
674 case TextureFormat::UNORM_16_DEPTH:
687 switch (tex_format) {
689 case TextureFormat::UINT_32_32_32_32:
690 case TextureFormat::UINT_32_32:
691 case TextureFormat::UINT_32:
692 case TextureFormat::UINT_16_16_16_16:
693 case TextureFormat::UINT_16_16:
694 case TextureFormat::UINT_16:
695 case TextureFormat::UINT_8_8_8_8:
696 case TextureFormat::UINT_8_8:
697 case TextureFormat::UINT_8:
700 case TextureFormat::SINT_32_32_32_32:
701 case TextureFormat::SINT_32_32:
702 case TextureFormat::SINT_32:
703 case TextureFormat::SINT_16_16_16_16:
704 case TextureFormat::SINT_16_16:
705 case TextureFormat::SINT_16:
706 case TextureFormat::SINT_8_8_8_8:
707 case TextureFormat::SINT_8_8:
708 case TextureFormat::SINT_8:
711 case TextureFormat::SFLOAT_32_32_32_32:
712 case TextureFormat::SFLOAT_32_32:
713 case TextureFormat::SFLOAT_32:
714 case TextureFormat::SFLOAT_16_16_16_16:
715 case TextureFormat::SFLOAT_16_16:
716 case TextureFormat::SFLOAT_16:
717 case TextureFormat::UNORM_16_16_16_16:
718 case TextureFormat::UNORM_16_16:
719 case TextureFormat::UNORM_16:
720 case TextureFormat::UNORM_8_8_8_8:
721 case TextureFormat::UNORM_8_8:
722 case TextureFormat::UNORM_8:
726 case TextureFormat::UNORM_10_10_10_2:
727 case TextureFormat::UINT_10_10_10_2:
729 case TextureFormat::UFLOAT_11_11_10:
731 case TextureFormat::SFLOAT_32_DEPTH_UINT_8:
734 case TextureFormat::SRGBA_8_8_8_8:
738 case TextureFormat::UINT_32_32_32:
739 case TextureFormat::UINT_16_16_16:
740 case TextureFormat::UINT_8_8_8:
742 case TextureFormat::SINT_32_32_32:
743 case TextureFormat::SINT_16_16_16:
744 case TextureFormat::SINT_8_8_8:
746 case TextureFormat::UNORM_16_16_16:
747 case TextureFormat::UNORM_8_8_8:
749 case TextureFormat::SNORM_16_16_16_16:
750 case TextureFormat::SNORM_16_16_16:
751 case TextureFormat::SNORM_16_16:
752 case TextureFormat::SNORM_16:
754 case TextureFormat::SNORM_8_8_8_8:
755 case TextureFormat::SNORM_8_8_8:
756 case TextureFormat::SNORM_8_8:
757 case TextureFormat::SNORM_8:
759 case TextureFormat::SFLOAT_32_32_32:
760 case TextureFormat::SFLOAT_16_16_16:
764 case TextureFormat::SRGB_DXT1:
765 case TextureFormat::SRGB_DXT3:
766 case TextureFormat::SRGB_DXT5:
767 case TextureFormat::SNORM_DXT1:
768 case TextureFormat::SNORM_DXT3:
769 case TextureFormat::SNORM_DXT5:
773 case TextureFormat::SRGBA_8_8_8:
775 case TextureFormat::UFLOAT_9_9_9_EXP_5:
779 case TextureFormat::SFLOAT_32_DEPTH:
780 case TextureFormat::UNORM_16_DEPTH:
791 switch (tex_format) {
793 case TextureFormat::UINT_32_32_32_32:
794 case TextureFormat::UINT_32_32:
795 case TextureFormat::UINT_32:
796 case TextureFormat::UINT_16_16_16_16:
797 case TextureFormat::UINT_16_16:
798 case TextureFormat::UINT_16:
799 case TextureFormat::UINT_8_8_8_8:
800 case TextureFormat::UINT_8_8:
801 case TextureFormat::UINT_8:
802 case TextureFormat::SINT_32_32_32_32:
803 case TextureFormat::SINT_32_32:
804 case TextureFormat::SINT_32:
805 case TextureFormat::SINT_16_16_16_16:
806 case TextureFormat::SINT_16_16:
807 case TextureFormat::SINT_16:
808 case TextureFormat::SINT_8_8_8_8:
809 case TextureFormat::SINT_8_8:
810 case TextureFormat::SINT_8:
811 case TextureFormat::SFLOAT_32_32_32_32:
812 case TextureFormat::SFLOAT_32_32:
813 case TextureFormat::SFLOAT_32:
814 case TextureFormat::SFLOAT_16_16_16_16:
815 case TextureFormat::SFLOAT_16_16:
816 case TextureFormat::SFLOAT_16:
817 case TextureFormat::UNORM_16_16_16_16:
818 case TextureFormat::UNORM_16_16:
819 case TextureFormat::UNORM_16:
820 case TextureFormat::UNORM_8_8_8_8:
821 case TextureFormat::UNORM_8_8:
822 case TextureFormat::UNORM_8:
826 case TextureFormat::UNORM_10_10_10_2:
827 case TextureFormat::UINT_10_10_10_2:
828 case TextureFormat::UFLOAT_11_11_10:
829 case TextureFormat::SRGBA_8_8_8_8:
831 case TextureFormat::SFLOAT_32_DEPTH_UINT_8:
835 case TextureFormat::SFLOAT_32_DEPTH:
836 case TextureFormat::UNORM_16_DEPTH:
840 case TextureFormat::UINT_32_32_32:
841 case TextureFormat::UINT_16_16_16:
842 case TextureFormat::UINT_8_8_8:
843 case TextureFormat::SINT_32_32_32:
844 case TextureFormat::SINT_16_16_16:
845 case TextureFormat::SINT_8_8_8:
846 case TextureFormat::UNORM_16_16_16:
847 case TextureFormat::UNORM_8_8_8:
848 case TextureFormat::SNORM_16_16_16_16:
849 case TextureFormat::SNORM_16_16_16:
850 case TextureFormat::SNORM_16_16:
851 case TextureFormat::SNORM_16:
852 case TextureFormat::SNORM_8_8_8_8:
853 case TextureFormat::SNORM_8_8_8:
854 case TextureFormat::SNORM_8_8:
855 case TextureFormat::SNORM_8:
856 case TextureFormat::SFLOAT_32_32_32:
857 case TextureFormat::SFLOAT_16_16_16:
858 BLI_assert_msg(0,
"This texture format is not compatible with framebuffer attachment.");
862 case TextureFormat::SRGB_DXT1:
863 case TextureFormat::SRGB_DXT3:
864 case TextureFormat::SRGB_DXT5:
865 case TextureFormat::SNORM_DXT1:
866 case TextureFormat::SNORM_DXT3:
867 case TextureFormat::SNORM_DXT5:
868 case TextureFormat::SRGBA_8_8_8:
869 case TextureFormat::UFLOAT_9_9_9_EXP_5:
870 BLI_assert_msg(0,
"This texture format is not compatible with framebuffer attachment.");
882 if (
format->attr_len == 0) {
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
MINLINE int max_ii(int a, int b)
#define ENUM_OPERATORS(_type, _max)
@ GPU_DATA_UINT_24_8_DEPRECATED
@ GPU_DATA_2_10_10_10_REV
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
virtual ~PixelBuffer()=default
virtual GPUPixelBufferNativeHandle get_native_handle()=0
virtual size_t get_size()=0
virtual void mip_range_set(int min, int max)=0
GPUSamplerState sampler_state
void attach_to(FrameBuffer *fb, GPUAttachmentType type)
virtual bool init_internal(VertBuf *vbo)=0
int mip_width_get(int mip) const
int mip_depth_get(int mip) const
virtual void * read(int mip, eGPUDataFormat format)=0
bool init_1D(int w, int layers, int mip_len, TextureFormat format)
virtual void generate_mipmap()=0
GPUTextureType type_get() const
GPUTextureFormatFlag format_flag_get() const
void update(eGPUDataFormat format, const void *data)
eGPUTextureUsage gpu_image_usage_flags_
eGPUTextureUsage usage_get() const
bool init_cubemap(int w, int layers, int mip_len, TextureFormat format)
char name_[DEBUG_NAME_LEN]
bool init_view(Texture *src, TextureFormat format, GPUTextureType type, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array, bool use_stencil)
FrameBuffer * fb_[GPU_TEX_MAX_FBO_ATTACHED]
bool init_2D(int w, int h, int layers, int mip_len, TextureFormat format)
int dimensions_count() const
virtual bool init_internal(blender::gpu::Texture *src, int mip_offset, int layer_offset, bool use_stencil)=0
virtual void swizzle_set(const char swizzle_mask[4])=0
virtual void update_sub(int offset[3], int extent[3], eGPUDataFormat format, GPUPixelBuffer *pixbuf)=0
bool init_3D(int w, int h, int d, int mip_len, TextureFormat format)
GPUAttachmentType fb_attachment_[GPU_TEX_MAX_FBO_ATTACHED]
GPUAttachmentType attachment_type(int slot) const
int mip_height_get(int mip) const
bool init_buffer(VertBuf *vbo, TextureFormat format)
virtual void clear(eGPUDataFormat format, const void *data)=0
virtual bool init_internal()=0
virtual void update_sub(int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data)=0
void mip_size_get(int mip, int r_size[3]) const
TextureFormat format_get() const
virtual void copy_to(Texture *tex)=0
void usage_set(eGPUTextureUsage usage_flags)
Texture(const char *name)
void detach_from(FrameBuffer *fb)
GPUTextureFormatFlag format_flag_
@ GPU_FB_DEPTH_STENCIL_ATTACHMENT
@ GPU_FB_COLOR_ATTACHMENT0
@ GPU_FB_DEPTH_ATTACHMENT
#define GPU_TEX_MAX_FBO_ATTACHED
BLI_INLINE float fb(float length, float L)
int format_component_len(const DataFormat format)
static Context * unwrap(GPUContext *ctx)
bool is_half_float(TextureFormat format)
eGPUDataFormat to_texture_data_format(TextureFormat tex_format)
static GPUContext * wrap(Context *ctx)
@ GPU_FORMAT_NORMALIZED_INTEGER
@ GPU_FORMAT_DEPTH_STENCIL
size_t to_block_size(TextureFormat data_type)
int to_bytesize(const DataFormat format)
int to_component_len(TextureFormat format)
constexpr bool validate_data_format(TextureFormat tex_format, eGPUDataFormat data_format)
GPUTextureFormatFlag to_format_flag(TextureFormat format)
constexpr TextureFormat to_texture_format(TextureTargetFormat format)
GPUFrameBufferBits to_framebuffer_bits(TextureFormat tex_format)
static constexpr GPUSamplerState default_sampler()