Blender V5.0
GPU_texture.hh File Reference
#include <string>
#include "BLI_assert.h"
#include "BLI_utildefines.h"
#include "GPU_format.hh"

Go to the source code of this file.

Classes

struct  GPUSamplerState
struct  GPUPixelBufferNativeHandle

Namespaces

namespace  blender
namespace  blender::gpu

Macros

#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_FORMAT_EXPAND(impl)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_TARGET_FORMAT_EXPAND(impl)
#define DECLARE(a, b, c, blender_enum, d, e, f, g, h)
#define GPU_TEXTURE_WRITE_FORMAT_EXPAND(impl)

Functions

Creation
blender::gpu::TextureGPU_texture_create_1d (const char *name, int width, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_1d_array (const char *name, int width, int layer_len, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_2d (const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_2d_array (const char *name, int width, int height, int layer_len, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_3d (const char *name, int width, int height, int depth, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
blender::gpu::TextureGPU_texture_create_cube (const char *name, int width, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_cube_array (const char *name, int width, int layer_len, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
blender::gpu::TextureGPU_texture_create_compressed_2d (const char *name, int width, int height, int mip_len, blender::gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
blender::gpu::TextureGPU_texture_create_from_vertbuf (const char *name, blender::gpu::VertBuf *vertex_buf)
blender::gpu::TextureGPU_texture_create_error (int dimension, bool array)
Texture Views
blender::gpu::TextureGPU_texture_create_view (const char *name, blender::gpu::Texture *source_texture, blender::gpu::TextureFormat view_format, int mip_start, int mip_len, int layer_start, int layer_len, bool cube_as_array, bool use_stencil)
Modify & Update
void GPU_unpack_row_length_set (uint len)
void GPU_texture_update (blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_update_sub (blender::gpu::Texture *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 (blender::gpu::Texture *texture, int mip_level, eGPUDataFormat data_format, const void *pixels)
void GPU_texture_clear (blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *data)
void GPU_texture_copy (blender::gpu::Texture *dst, blender::gpu::Texture *src)
void GPU_texture_update_mipmap_chain (blender::gpu::Texture *texture)
void * GPU_texture_read (blender::gpu::Texture *texture, eGPUDataFormat data_format, int mip_level)
Binding
void GPU_texture_bind (blender::gpu::Texture *texture, int unit)
void GPU_texture_bind_ex (blender::gpu::Texture *texture, GPUSamplerState state, int unit)
void GPU_texture_unbind (blender::gpu::Texture *texture)
void GPU_texture_unbind_all ()
void GPU_texture_image_bind (blender::gpu::Texture *texture, int unit)
void GPU_texture_image_unbind (blender::gpu::Texture *texture)
void GPU_texture_image_unbind_all ()
State API
void GPU_texture_compare_mode (blender::gpu::Texture *texture, bool use_compare)
void GPU_texture_filter_mode (blender::gpu::Texture *texture, bool use_filter)
void GPU_texture_mipmap_mode (blender::gpu::Texture *texture, bool use_mipmap, bool use_filter)
void GPU_texture_anisotropic_filter (blender::gpu::Texture *texture, bool use_aniso)
void GPU_texture_extend_mode_x (blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode_y (blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_extend_mode (blender::gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void GPU_texture_swizzle_set (blender::gpu::Texture *texture, const char swizzle[4])
Introspection API
int GPU_texture_dimensions (const blender::gpu::Texture *texture)
int GPU_texture_width (const blender::gpu::Texture *texture)
int GPU_texture_height (const blender::gpu::Texture *texture)
int GPU_texture_depth (const blender::gpu::Texture *texture)
int GPU_texture_layer_count (const blender::gpu::Texture *texture)
int GPU_texture_mip_count (const blender::gpu::Texture *texture)
blender::gpu::TextureFormat GPU_texture_format (const blender::gpu::Texture *texture)
eGPUTextureUsage GPU_texture_usage (const blender::gpu::Texture *texture)
bool GPU_texture_is_array (const blender::gpu::Texture *texture)
bool GPU_texture_is_cube (const blender::gpu::Texture *texture)
bool GPU_texture_has_depth_format (const blender::gpu::Texture *texture)
bool GPU_texture_has_stencil_format (const blender::gpu::Texture *texture)
bool GPU_texture_has_integer_format (const blender::gpu::Texture *texture)
bool GPU_texture_has_float_format (const blender::gpu::Texture *texture)
bool GPU_texture_has_normalized_format (const blender::gpu::Texture *texture)
bool GPU_texture_has_signed_format (const blender::gpu::Texture *texture)
void GPU_texture_get_mipmap_size (blender::gpu::Texture *texture, int mip_level, int *r_size)
Python API & meta-data

These are not intrinsic properties of a texture but they are stored inside the gpu::Texture structure for tracking purpose.

int GPU_texture_original_width (const blender::gpu::Texture *texture)
int GPU_texture_original_height (const blender::gpu::Texture *texture)
void GPU_texture_original_size_set (blender::gpu::Texture *texture, int width, int height)
void ** GPU_texture_py_reference_get (blender::gpu::Texture *texture)
void GPU_texture_py_reference_set (blender::gpu::Texture *texture, void **py_ref)
Utilities
size_t GPU_texture_component_len (blender::gpu::TextureFormat format)
size_t GPU_texture_dataformat_size (eGPUDataFormat data_format)
const char * GPU_texture_format_name (blender::gpu::TextureFormat format)
unsigned int GPU_texture_memory_usage_get ()
void GPU_samplers_update ()
Pixel Buffer

Used for interfacing with other graphic APIs using graphic interoperability. It can also be used for more efficient partial update from CPU side.

GPUPixelBuffer * GPU_pixel_buffer_create (size_t byte_size)
void GPU_pixel_buffer_free (GPUPixelBuffer *pixel_buf)
void * GPU_pixel_buffer_map (GPUPixelBuffer *pixel_buf)
void GPU_pixel_buffer_unmap (GPUPixelBuffer *pixel_buf)
size_t GPU_pixel_buffer_size (GPUPixelBuffer *pixel_buf)
GPUPixelBufferNativeHandle GPU_pixel_buffer_get_native_handle (GPUPixelBuffer *pixel_buf)
void GPU_texture_update_sub_from_pixel_buffer (blender::gpu::Texture *texture, eGPUDataFormat data_format, GPUPixelBuffer *pixel_buf, int offset_x, int offset_y, int offset_z, int width, int height, int depth)

Sampler State

#define GPU_SAMPLER_EXTEND_MODES_COUNT   (GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER + 1)
#define GPU_SAMPLER_CUSTOM_TYPES_COUNT   (GPU_SAMPLER_CUSTOM_ICON + 1)
enum  GPUSamplerFiltering { GPU_SAMPLER_FILTERING_DEFAULT = 0 , GPU_SAMPLER_FILTERING_LINEAR = (1 << 0) , GPU_SAMPLER_FILTERING_MIPMAP = (1 << 1) , GPU_SAMPLER_FILTERING_ANISOTROPIC = (1 << 2) }
enum  GPUSamplerExtendMode { GPU_SAMPLER_EXTEND_MODE_EXTEND = 0 , GPU_SAMPLER_EXTEND_MODE_REPEAT , GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT , GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER }
enum  GPUSamplerCustomType { GPU_SAMPLER_CUSTOM_COMPARE = 0 , GPU_SAMPLER_CUSTOM_ICON }
enum  GPUSamplerStateType { GPU_SAMPLER_STATE_TYPE_PARAMETERS = 0 , GPU_SAMPLER_STATE_TYPE_CUSTOM , GPU_SAMPLER_STATE_TYPE_INTERNAL }
static const int GPU_SAMPLER_FILTERING_TYPES_COUNT

Freeing

#define GPU_TEXTURE_FREE_SAFE(texture)
void GPU_texture_ref (blender::gpu::Texture *texture)
void GPU_texture_free (blender::gpu::Texture *texture)

Texture Formats

enum class  blender::gpu::TextureFormat : uint8_t { blender::gpu::Invalid = 0 }
enum class  blender::gpu::TextureTargetFormat : uint8_t { blender::gpu::Invalid = 0 }
enum class  blender::gpu::TextureWriteFormat : uint8_t { blender::gpu::Invalid = 0 }
constexpr DataFormat blender::gpu::to_data_format (TextureFormat format)
constexpr TextureFormat blender::gpu::to_texture_format (TextureTargetFormat format)
constexpr TextureFormat blender::gpu::to_texture_format (TextureWriteFormat format)

Enums

enum  eGPUDataFormat {
  GPU_DATA_FLOAT , GPU_DATA_HALF_FLOAT , GPU_DATA_INT , GPU_DATA_UINT ,
  GPU_DATA_UBYTE , GPU_DATA_UINT_24_8_DEPRECATED , GPU_DATA_10_11_11_REV , GPU_DATA_2_10_10_10_REV
}
enum  eGPUTextureUsage {
  GPU_TEXTURE_USAGE_SHADER_READ = (1 << 0) , GPU_TEXTURE_USAGE_SHADER_WRITE = (1 << 1) , GPU_TEXTURE_USAGE_ATTACHMENT = (1 << 2) , GPU_TEXTURE_USAGE_FORMAT_VIEW = (1 << 3) ,
  GPU_TEXTURE_USAGE_HOST_READ = (1 << 4) , GPU_TEXTURE_USAGE_MEMORYLESS = (1 << 5) , GPU_TEXTURE_USAGE_ATOMIC = (1 << 6) , GPU_TEXTURE_USAGE_MEMORY_EXPORT = (1 << 7) ,
  GPU_TEXTURE_USAGE_GENERAL
}
 ENUM_OPERATORS (eGPUTextureUsage, GPU_TEXTURE_USAGE_GENERAL)

Detailed Description

A blender::gpu::Texture is a wrapper around backend specific texture objects. It allows, creation of diverse texture format and types, update, read, reference counting, internal sampler state tracking and texture binding.

Definition in file GPU_texture.hh.

Macro Definition Documentation

◆ DECLARE [1/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(TextureFormat::blender_enum),

Definition at line 38 of file GPU_texture.hh.

◆ DECLARE [2/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(TextureFormat::blender_enum),

Definition at line 38 of file GPU_texture.hh.

◆ DECLARE [3/3]

#define DECLARE ( a,
b,
c,
blender_enum,
d,
e,
f,
g,
h )
Value:
blender_enum = int(DataFormat::blender_enum),

Definition at line 38 of file GPU_texture.hh.

◆ GPU_SAMPLER_CUSTOM_TYPES_COUNT

◆ GPU_SAMPLER_EXTEND_MODES_COUNT

◆ GPU_TEXTURE_FORMAT_EXPAND

#define GPU_TEXTURE_FORMAT_EXPAND ( impl)

◆ GPU_TEXTURE_FREE_SAFE

◆ GPU_TEXTURE_TARGET_FORMAT_EXPAND

#define GPU_TEXTURE_TARGET_FORMAT_EXPAND ( impl)

Definition at line 140 of file GPU_texture.hh.

◆ GPU_TEXTURE_WRITE_FORMAT_EXPAND

#define GPU_TEXTURE_WRITE_FORMAT_EXPAND ( impl)

Definition at line 211 of file GPU_texture.hh.

Enumeration Type Documentation

◆ eGPUDataFormat

Types of data for data specification. Used for formatting upload and download of data. When used with textures, they need to match or be compatible with the blender::gpu::TextureFormat used. Check validate_data_format for compatibility list.

Enumerator
GPU_DATA_FLOAT 
GPU_DATA_HALF_FLOAT 
GPU_DATA_INT 
GPU_DATA_UINT 
GPU_DATA_UBYTE 
GPU_DATA_UINT_24_8_DEPRECATED 

Special type used for depth-stencil textures.

GPU_DATA_10_11_11_REV 

Special type used for packed 32bit per pixel textures. Data is stored in reverse order.

GPU_DATA_2_10_10_10_REV 

Definition at line 657 of file GPU_texture.hh.

◆ eGPUTextureUsage

Texture usage flags allow backend implementations to contextually optimize texture resources. Any texture with an explicit flag should not perform operations which are not explicitly specified in the usage flags. If usage is unknown upfront, then GPU_TEXTURE_USAGE_GENERAL can be used.

NOTE: These usage flags act as hints for the backend implementations. There may be no benefit in some circumstances, and certain resource types may insert additional usage as required. However, explicit usage can ensure that hardware features such as render target/texture compression can be used. For explicit APIs such as Metal/Vulkan, texture usage needs to be specified up-front.

Enumerator
GPU_TEXTURE_USAGE_SHADER_READ 
GPU_TEXTURE_USAGE_SHADER_WRITE 
GPU_TEXTURE_USAGE_ATTACHMENT 
GPU_TEXTURE_USAGE_FORMAT_VIEW 
GPU_TEXTURE_USAGE_HOST_READ 
GPU_TEXTURE_USAGE_MEMORYLESS 
GPU_TEXTURE_USAGE_ATOMIC 
GPU_TEXTURE_USAGE_MEMORY_EXPORT 
GPU_TEXTURE_USAGE_GENERAL 

Definition at line 683 of file GPU_texture.hh.

◆ GPUSamplerCustomType

The GPUSamplerCustomType specifies pre-defined sampler configurations with parameters that are not controllable using the GPUSamplerFiltering and GPUSamplerExtendMode options. Hence, the use of a custom sampler type is mutually exclusive with the use of the aforementioned enums.

The parameters that needs to be set for those custom samplers are not added as yet another option inside the GPUSamplerState structure because every possible configuration of sampler states are generated, setup, and cached at startup, so adding yet another axis of variation will multiply the number of configurations that needs to be cached, which is not worth it due to the limited use of the parameters needed to setup those custom samplers.

Enumerator
GPU_SAMPLER_CUSTOM_COMPARE 

Enable compare mode for depth texture. The depth texture must then be bound to a shadow sampler. This is equivalent to:

  • GPU_SAMPLER_FILTERING_LINEAR.
  • GPU_SAMPLER_EXTEND_MODE_EXTEND.

And sets:

  • TEXTURE_COMPARE_MODE -> COMPARE_REF_TO_TEXTURE.
  • TEXTURE_COMPARE_FUNC -> LEQUAL.
GPU_SAMPLER_CUSTOM_ICON 

Special icon sampler with custom LOD bias and interpolation mode. This sets:

  • TEXTURE_MAG_FILTER -> LINEAR.
  • TEXTURE_MIN_FILTER -> LINEAR_MIPMAP_NEAREST.
  • TEXTURE_LOD_BIAS -> -0.5.

Definition at line 353 of file GPU_texture.hh.

◆ GPUSamplerExtendMode

The GPUSamplerExtendMode specifies how the texture will be extrapolated for out-of-bound texture sampling.

Enumerator
GPU_SAMPLER_EXTEND_MODE_EXTEND 

Extrapolate by extending the edge pixels of the texture, in other words, the texture coordinates are clamped.

GPU_SAMPLER_EXTEND_MODE_REPEAT 

Extrapolate by repeating the texture.

GPU_SAMPLER_EXTEND_MODE_MIRRORED_REPEAT 

Extrapolate by repeating the texture with mirroring in a ping-pong fashion.

GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER 

Extrapolate using the value of TEXTURE_BORDER_COLOR, which is always set to a transparent black color (0, 0, 0, 0) and can't be changed.

Definition at line 323 of file GPU_texture.hh.

◆ GPUSamplerFiltering

The GPUSamplerFiltering bit flag specifies the enabled filtering options of a texture sampler.

Enumerator
GPU_SAMPLER_FILTERING_DEFAULT 

Default sampler filtering with all options off. It means no linear filtering, no mipmapping, and no anisotropic filtering.

GPU_SAMPLER_FILTERING_LINEAR 

Enables hardware linear filtering. Also enables linear interpolation between MIPS if GPU_SAMPLER_FILTERING_MIPMAP is set.

GPU_SAMPLER_FILTERING_MIPMAP 

Enables mipmap access through shader samplers. Also enables linear interpolation between mips if GPU_SAMPLER_FILTER is set, otherwise the mip interpolation will be set to nearest.

The following parameters are always left to their default values and can't be changed:

  • TEXTURE_MIN_LOD is -1000.
  • TEXTURE_MAX_LOD is 1000.
  • TEXTURE_LOD_BIAS is 0.0f.
GPU_SAMPLER_FILTERING_ANISOTROPIC 

Enable Anisotropic filtering. This only has effect if GPU_SAMPLER_FILTERING_MIPMAP is set. The filtered result is implementation dependent.

The maximum amount of samples is always set to its maximum possible value and can't be changed, except by the user through the user preferences, see the use of U.anisotropic_filter.

Definition at line 279 of file GPU_texture.hh.

◆ GPUSamplerStateType

The GPUSamplerStateType specifies how the GPUSamplerState structure should be interpreted when passed around due to it being an overloaded type, see the documentation of each of the types for more information.

Enumerator
GPU_SAMPLER_STATE_TYPE_PARAMETERS 

The filtering, extend_x, and extend_yz members of the GPUSamplerState structure will be used in setting up the sampler state for the texture. The custom_type member will be ignored in that case.

GPU_SAMPLER_STATE_TYPE_CUSTOM 

The filtering, extend_x, and extend_yz members of the GPUSamplerState structure will be ignored, and the predefined custom parameters outlined in the documentation of GPUSamplerCustomType will be used in setting up the sampler state for the texture.

GPU_SAMPLER_STATE_TYPE_INTERNAL 

The members of the GPUSamplerState structure will be ignored and the internal sampler state of the texture will be used. In other words, this is a signal value and stores no useful or actual data.

Definition at line 384 of file GPU_texture.hh.

Function Documentation

◆ ENUM_OPERATORS()

◆ GPU_pixel_buffer_create()

GPUPixelBuffer * GPU_pixel_buffer_create ( size_t byte_size)

Creates a #GPUPixelBuffer object with byte_size worth of storage.

Definition at line 966 of file gpu_texture.cc.

References ceil_to_multiple_ul(), blender::gpu::GPUBackend::get(), blender::gpu::GPUBackend::pixelbuf_alloc(), size(), and blender::gpu::wrap().

Referenced by DisplayGPUPixelBuffer::gpu_resources_ensure().

◆ GPU_pixel_buffer_free()

void GPU_pixel_buffer_free ( GPUPixelBuffer * pixel_buf)

Free a #GPUPixelBuffer object. The object should be unmapped before being freed.

Definition at line 979 of file gpu_texture.cc.

References blender::gpu::unwrap().

Referenced by DisplayGPUPixelBuffer::gpu_resources_destroy().

◆ GPU_pixel_buffer_get_native_handle()

GPUPixelBufferNativeHandle GPU_pixel_buffer_get_native_handle ( GPUPixelBuffer * pixel_buf)

◆ GPU_pixel_buffer_map()

void * GPU_pixel_buffer_map ( GPUPixelBuffer * pixel_buf)

Maps a pixel buffer to RAM, giving back access rights to CPU. The returned pointer is only valid until GPU_pixel_buffer_unmap is called. A #GPUPixelBuffer needs to be unmapped before being used for GPU side operation (like texture update through GPU_texture_update_sub_from_pixel_buffer).

Definition at line 985 of file gpu_texture.cc.

References blender::gpu::unwrap().

Referenced by BlenderDisplayDriver::map_texture_buffer().

◆ GPU_pixel_buffer_size()

size_t GPU_pixel_buffer_size ( GPUPixelBuffer * pixel_buf)

Return size in bytes of the pix_buf.

Definition at line 995 of file gpu_texture.cc.

References blender::gpu::unwrap().

Referenced by DisplayGPUPixelBuffer::gpu_resources_ensure().

◆ GPU_pixel_buffer_unmap()

void GPU_pixel_buffer_unmap ( GPUPixelBuffer * pixel_buf)

Unmap a pixel buffer from RAM, giving back access rights to GPU. Any pointer previously acquired by GPU_pixel_buffer_map becomes invalid.

Definition at line 990 of file gpu_texture.cc.

References blender::gpu::unwrap().

Referenced by BlenderDisplayDriver::unmap_texture_buffer().

◆ GPU_samplers_update()

void GPU_samplers_update ( )

Update sampler states depending on user settings.

Definition at line 1014 of file gpu_texture.cc.

References blender::gpu::GPUBackend::get(), and blender::gpu::GPUBackend::samplers_update().

◆ GPU_texture_anisotropic_filter()

◆ GPU_texture_bind()

◆ GPU_texture_bind_ex()

◆ GPU_texture_clear()

void GPU_texture_clear ( blender::gpu::Texture * texture,
eGPUDataFormat data_format,
const void * data )

Fills the whole texture with the same data for all pixels.

Warning
Only works for 2D and 3D textures.
Only clears the MIP 0 of the texture.
Parameters
data_formatdata format of the pixel data.
Note
The format is float for UNORM textures.
Parameters
data1 pixel worth of data to fill the texture with.

Definition at line 544 of file gpu_texture.cc.

References BLI_assert, blender::gpu::Texture::clear(), and data.

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::accumulate_ghosts_gpu(), blender::gpu::tests::blend_test(), blender::draw::Texture::clear(), blender::draw::Texture::clear(), blender::draw::Texture::clear(), blender::nodes::node_composite_base_cryptomatte_cc::BaseCryptoMatteOperation::compute_matte_gpu(), blender::nodes::node_composite_group_output_cc::GroupOutputOperation::execute_clear(), blender::nodes::node_composite_viewer_cc::ViewerOperation::execute_clear(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_streaks(), gpu_viewport_textures_create(), pygpu_texture_clear(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_2d_array(), blender::gpu::tests::test_texture_3d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_cube(), blender::gpu::tests::test_texture_cube_array(), blender::gpu::tests::test_texture_read(), blender::gpu::tests::test_texture_update_sub_no_unpack_row_length(), blender::gpu::tests::test_texture_update_sub_unpack_row_length(), and blender::gpu::tests::vertex_buffer_fetch_mode().

◆ GPU_texture_compare_mode()

◆ GPU_texture_component_len()

◆ GPU_texture_copy()

◆ GPU_texture_create_1d()

blender::gpu::Texture * GPU_texture_create_1d ( const char * name,
int width,
int mip_len,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
const float * data )
Note
data is expected to be float. If the format is not compatible with float data or if the data is not in float format, use GPU_texture_update to upload the data with the right data format.

Textures created via other means will either inherit usage from the source resource, or also be initialized with GPU_TEXTURE_USAGE_GENERAL.

flag. mips is the number of mip level to allocate. It must be >= 1.

Definition at line 298 of file gpu_texture.cc.

References data, blender::gpu::GPU_TEXTURE_1D, gpu_texture_create(), and name.

Referenced by blender::gpu::MTLContext::get_dummy_texture(), blender::ocio::internal::GPUCurveMappping::initialize_common(), pygpu_texture__tp_new(), blender::gpu::tests::test_shader_compute_1d(), and blender::gpu::tests::test_texture_1d().

◆ GPU_texture_create_1d_array()

◆ GPU_texture_create_2d()

blender::gpu::Texture * GPU_texture_create_2d ( const char * name,
int width,
int height,
int mip_len,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
const float * data )

Definition at line 320 of file gpu_texture.cc.

References data, blender::gpu::GPU_TEXTURE_2D, gpu_texture_create(), and name.

Referenced by blender::gpu::TexturePool::acquire_texture(), blender::render::hydra::GPURenderTaskDelegate::add_aov(), blf_glyph_draw(), blender::render::hydra::DrawTexture::create_from_buffer(), blender::ed::vse::create_texture(), draw_display_buffer(), draw_plane_marker_image(), draw_select_framebuffer_depth_only_setup(), blender::ed::vse::draw_strip_thumbnails(), blender::draw::overlay::Instance::end_sync(), blender::gpu::MTLContext::get_dummy_texture(), GPU_offscreen_create(), DisplayGPUTexture::gpu_resources_ensure(), blender::gpu::tests::gpu_shader_lib_test(), gpu_viewport_textures_create(), IMB_create_gpu_texture(), IMB_touch_gpu_texture(), immDrawPixelsTexScaledFullSize(), immDrawPixelsTexTiled_scaling_clipping(), ViewportColorSampleSession::init(), blender::ed::sculpt_paint::load_tex(), blender::ed::sculpt_paint::load_tex_cursor(), pygpu_texture__tp_new(), radial_control_set_tex(), RE_pass_ensure_gpu_texture_cache(), studiolight_create_equirect_radiance_gputexture(), studiolight_create_matcap_gputexture(), blender::gpu::VKContext::sync_backbuffer(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_framebuffer_clear_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_clear_color_single_attachment(), blender::gpu::tests::test_framebuffer_clear_depth(), blender::gpu::tests::test_framebuffer_clear_multiple_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_scissor_test(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_read(), blender::gpu::tests::test_texture_update_sub_no_unpack_row_length(), blender::gpu::tests::test_texture_update_sub_unpack_row_length(), blender::gpu::tests::texture_create_upload_read(), blender::gpu::tests::texture_create_upload_read_pixel(), blender::gpu::tests::texture_create_upload_read_with_bias(), blender::ed::vse::update_gpu_scopes(), wm_software_cursor_draw_bitmap(), and workbench_render_framebuffers_init().

◆ GPU_texture_create_2d_array()

◆ GPU_texture_create_3d()

blender::gpu::Texture * GPU_texture_create_3d ( const char * name,
int width,
int height,
int depth,
int mip_len,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
const void * data )

◆ GPU_texture_create_compressed_2d()

blender::gpu::Texture * GPU_texture_create_compressed_2d ( const char * name,
int width,
int height,
int mip_len,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
const void * data )

DDS texture loading. Return nullptr if compressed texture support is not available. data should hold all the data for mip_len mipmaps. The data is expected to be in compressed form. This isn't going to compress un-compress data.

Definition at line 379 of file gpu_texture.cc.

References data, blender::gpu::GPUBackend::get(), blender::gpu::Texture::init_2D(), blender::gpu::Texture::mip_size_get(), name, size(), blender::gpu::GPUBackend::texture_alloc(), blender::gpu::to_block_size(), blender::gpu::to_texture_data_format(), blender::gpu::Texture::update_sub(), and blender::gpu::Texture::usage_set().

Referenced by IMB_create_gpu_texture().

◆ GPU_texture_create_cube()

◆ GPU_texture_create_cube_array()

blender::gpu::Texture * GPU_texture_create_cube_array ( const char * name,
int width,
int layer_len,
int mip_len,
blender::gpu::TextureFormat format,
eGPUTextureUsage usage,
const float * data )

◆ GPU_texture_create_error()

blender::gpu::Texture * GPU_texture_create_error ( int dimension,
bool array )

Create an error texture that will bind an pink texture at draw time. dimension is the number of number of dimension of the texture (1, 2, or 3). array if set to true, will make the texture be an array (layered).

Definition at line 431 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_1D, blender::gpu::GPU_TEXTURE_1D_ARRAY, blender::gpu::GPU_TEXTURE_2D, blender::gpu::GPU_TEXTURE_2D_ARRAY, blender::gpu::GPU_TEXTURE_3D, gpu_texture_create(), GPU_TEXTURE_USAGE_GENERAL, and w().

Referenced by BKE_movieclip_get_gpu_texture(), image_gpu_texture_error_create(), and blender::ocio::internal::GPUTextures::initialize_common().

◆ GPU_texture_create_from_vertbuf()

◆ GPU_texture_create_view()

blender::gpu::Texture * GPU_texture_create_view ( const char * name,
blender::gpu::Texture * source_texture,
blender::gpu::TextureFormat view_format,
int mip_start,
int mip_len,
int layer_start,
int layer_len,
bool cube_as_array,
bool use_stencil )

Create an alias of the source texture data. A view can cover the whole texture or only a range of mip levels and/or array layer range.

view_format is the format in which the view will interpret the data of source_texture. It must match the format of source_texture in size (ex: RGBA8 can be reinterpreted as R32UI). See https://www.khronos.org/opengl/wiki/Texture_Storage#View_texture_aliases for an exhaustive list.

Note
If source_texture is freed, the texture view will continue to be valid.
If mip_start or mip_len is bigger than available mips they will be clamped to the source texture available range.
If cube_as_array is true, then the created view will be a 2D array texture instead of a cube-map texture or cube-map-array texture.

For Depth-Stencil texture view formats:

Note
If use_stencil is true, the texture is expected to be bound to a UINT sampler and will return the stencil value (in a range of [0..255]) as the first component.
If use_stencil is false (default), the texture is expected to be bound to a DEPTH sampler and will return the normalized depth value (in a range of [0..1]) as the first component.

TODO(fclem): Target conversion (ex: Texture 2D as Texture 2D Array) is not implemented yet.

Definition at line 453 of file gpu_texture.cc.

References BLI_assert, BLI_assert_msg, blender::gpu::GPUBackend::get(), GPU_texture_format(), GPU_texture_usage(), GPU_TEXTURE_USAGE_FORMAT_VIEW, name, blender::gpu::GPUBackend::texture_alloc(), blender::gpu::Texture::type_get(), and view.

Referenced by blender::draw::Texture::ensure_layer_views(), blender::draw::Texture::ensure_mip_views(), blender::draw::Texture::layer_range_view(), and blender::draw::Texture::stencil_view().

◆ GPU_texture_dataformat_size()

size_t GPU_texture_dataformat_size ( eGPUDataFormat data_format)

Return the expected number of bytes for one pixel of data_format data.

Definition at line 1034 of file gpu_texture.cc.

References blender::gpu::to_bytesize().

Referenced by pygpu_buffer__bf_getbuffer(), pygpu_buffer__sq_item(), pygpu_buffer_calc_size(), pygpu_buffer_strides_calc(), pygpu_framebuffer_read_color(), and pygpu_framebuffer_read_depth().

◆ GPU_texture_depth()

int GPU_texture_depth ( const blender::gpu::Texture * texture)

Return the depth of tex . Correspond to number of layers for 2D array texture. NOTE: return 0 for 1D & 2D textures.

Definition at line 721 of file gpu_texture.cc.

References texture().

Referenced by blender::draw::Texture::depth().

◆ GPU_texture_dimensions()

int GPU_texture_dimensions ( const blender::gpu::Texture * texture)

Return the number of dimensions of the texture ignoring dimension of layers (1, 2 or 3). Cube textures are considered 2D.

Definition at line 692 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_1D, blender::gpu::GPU_TEXTURE_2D, blender::gpu::GPU_TEXTURE_3D, blender::gpu::GPU_TEXTURE_CUBE, and texture().

Referenced by blender::ocio::GPUShaderBinder::create_gpu_shader(), and blender::draw::Texture::debug_clear().

◆ GPU_texture_extend_mode()

void GPU_texture_extend_mode ( blender::gpu::Texture * texture,
GPUSamplerExtendMode extend_mode )

Set tex texture sampling method for coordinates outside of the [0..1] uv range along both the x and y axis. See GPUSamplerExtendMode for the available and meaning of different extend modes.

Definition at line 662 of file gpu_texture.cc.

References texture().

Referenced by blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost_gpu(), blender::nodes::node_composite_planetrackdeform_cc::PlaneTrackDeformOperation::compute_plane_gpu(), blender::ed::vse::draw_strip_thumbnails(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_horizontal_distortion_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_radial_distortion_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), DisplayGPUTexture::gpu_resources_ensure(), blender::compositor::horizontal_pass_gpu(), image_get_gpu_texture(), immDrawPixelsTexScaledFullSize(), immDrawPixelsTexTiled_scaling_clipping(), blender::ocio::internal::GPUCurveMappping::initialize_common(), studiolight_create_equirect_radiance_gputexture(), blender::compositor::vertical_pass_gpu(), blender::draw::volume_grid_cache_get(), blender::draw::VolumeModule::VolumeModule(), blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_gpu(), and blender::nodes::node_composite_glare_cc::GlareOperation::write_highlights_output_gpu().

◆ GPU_texture_extend_mode_x()

◆ GPU_texture_extend_mode_y()

◆ GPU_texture_filter_mode()

void GPU_texture_filter_mode ( blender::gpu::Texture * texture,
bool use_filter )

Set tex texture filter usage. If use_filter is true, the texture will use linear interpolation between neighboring texels.

Note
Does not work on non-normalized integer textures.
Does not modify the mip-map usage state.

Definition at line 624 of file gpu_texture.cc.

References BLI_assert, blender::gpu::Texture::format_flag_get(), blender::gpu::GPU_FORMAT_INTEGER, blender::gpu::GPU_FORMAT_STENCIL, GPU_SAMPLER_FILTERING_LINEAR, blender::gpu::Texture::sampler_state, GPUSamplerState::set_filtering_flag_from_test(), and texture().

Referenced by blender::workbench::AntiAliasingPass::AntiAliasingPass(), blender::nodes::node_composite_glare_cc::GlareOperation::apply_streak_filter_gpu(), blender::compositor::blend_neighborhood_gpu(), blender::compositor::calculate_blending_weights_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_base_ghost_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_downsample_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::compute_bloom_upsample_gpu(), blender::nodes::node_composite_cornerpin_cc::CornerPinOperation::compute_plane_gpu(), blender::ed::vse::create_texture(), blender::compositor::detect_edges_gpu(), draw_display_buffer(), draw_plane_marker_image(), blender::ed::vse::draw_strip_thumbnails(), blender::nodes::node_composite_defocus_cc::DefocusOperation::execute_gpu(), blender::nodes::node_composite_directionalblur_cc::DirectionalBlurOperation::execute_gpu(), blender::nodes::node_composite_displace_cc::DisplaceOperation::execute_gpu(), blender::nodes::node_composite_map_uv_cc::MapUVOperation::execute_gpu(), blender::nodes::node_composite_moviedistortion_cc::MovieDistortionOperation::execute_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_highlights_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_horizontal_distortion_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_mix_gpu(), blender::nodes::node_composite_lensdist_cc::LensDistortionOperation::execute_radial_distortion_gpu(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_sun_beams_gpu(), blender::nodes::node_composite_scale_cc::ScaleOperation::execute_variable_size_gpu(), blender::draw::Texture::filter_mode(), DisplayGPUTexture::gpu_resources_ensure(), blender::compositor::horizontal_pass_gpu(), immDrawPixelsTexScaledFullSize(), immDrawPixelsTexTiled_scaling_clipping(), blender::ocio::internal::GPUCurveMappping::initialize_common(), radial_control_set_tex(), blender::compositor::sample_pixel_gpu(), studiolight_create_equirect_radiance_gputexture(), blender::ed::vse::update_gpu_scopes(), blender::compositor::vertical_pass_gpu(), wm_software_cursor_draw_bitmap(), blender::nodes::node_composite_glare_cc::GlareOperation::write_glare_output_gpu(), and blender::nodes::node_composite_glare_cc::GlareOperation::write_highlights_output_gpu().

◆ GPU_texture_format()

◆ GPU_texture_format_name()

const char * GPU_texture_format_name ( blender::gpu::TextureFormat format)

Return the texture format as a string for display purpose. Example: blender::gpu::TextureFormat::UNORM_8_8_8_8 returns as "RGBA8".

Definition at line 757 of file gpu_texture.cc.

References BLI_assert_unreachable, and blender::gpu::Invalid.

Referenced by blender::gpu::debug_validate_binding_image_format(), and uiTemplateImageInfo().

◆ GPU_texture_free()

void GPU_texture_free ( blender::gpu::Texture * texture)

This internally decrement the reference counter. If the reference counter is 1 when calling this function the blender::gpu::Texture will be freed.

Definition at line 673 of file gpu_texture.cc.

References blender::gpu::Texture::refcount, and texture().

Referenced by blender::draw::Manager::begin_sync(), BKE_image_add_tile(), BKE_image_reassign_tile(), BKE_movieclip_free_gputexture(), BKE_previewimg_clear_single(), BKE_previewimg_free(), blf_glyph_draw(), BPyGPUTexture__tp_dealloc(), blender::render::hydra::DrawTexture::create_from_buffer(), draw_display_buffer(), draw_plane_marker_image(), draw_select_framebuffer_depth_only_setup(), blender::ed::vse::draw_strip_thumbnails(), blender::compositor::Result::free(), free_buffers(), blender::gpu::MTLContext::free_dummy_resources(), gpu_free_unused_buffers(), GPU_offscreen_free(), blender::gpu::tests::gpu_shader_lib_test(), icon_preview_endjob(), image_free_gpu(), image_free_tile(), IMB_free_gpu_textures(), immDrawPixelsTexScaledFullSize(), immDrawPixelsTexTiled_scaling_clipping(), blender::ed::sculpt_paint::load_tex(), blender::ed::sculpt_paint::load_tex_cursor(), paint_cursor_delete_textures(), radial_control_cancel(), blender::gpu::TexturePool::reset(), blender::ed::vse::sequencer_preview_region_draw(), blender::render::hydra::GPURenderTaskDelegate::set_viewport(), blender::gpu::VKContext::sync_backbuffer(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_framebuffer_clear_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_clear_color_single_attachment(), blender::gpu::tests::test_framebuffer_clear_depth(), blender::gpu::tests::test_framebuffer_clear_multiple_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_cube(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_scissor_test(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_1d_array_upload(), blender::gpu::tests::test_texture_2d_array(), blender::gpu::tests::test_texture_2d_array_upload(), blender::gpu::tests::test_texture_3d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_cube(), blender::gpu::tests::test_texture_cube_array(), blender::gpu::tests::test_texture_read(), blender::gpu::tests::test_texture_update_sub_no_unpack_row_length(), blender::gpu::tests::test_texture_update_sub_unpack_row_length(), blender::gpu::tests::texture_create_upload_read(), blender::gpu::tests::texture_create_upload_read_pixel(), blender::gpu::tests::texture_create_upload_read_with_bias(), wm_software_cursor_draw_bitmap(), blender::render::Context::~Context(), blender::render::hydra::DrawTexture::~DrawTexture(), GlyphCacheBLF::~GlyphCacheBLF(), GPUMaterial::~GPUMaterial(), blender::render::hydra::GPURenderTaskDelegate::~GPURenderTaskDelegate(), blender::ocio::internal::GPUTextures::~GPUTextures(), blender::draw::Manager::~Manager(), blender::gpu::MTLContext::~MTLContext(), blender::gpu::TexturePool::~TexturePool(), ViewportColorSampleSession::~ViewportColorSampleSession(), and blender::gpu::VKContext::~VKContext().

◆ GPU_texture_get_mipmap_size()

void GPU_texture_get_mipmap_size ( blender::gpu::Texture * texture,
int mip_level,
int * r_size )

Returns the pixel dimensions of a texture's mip-map level. size is expected to be a pointer to a vector of dimension matching the texture's dimension (including the array dimension).

Definition at line 953 of file gpu_texture.cc.

References texture().

Referenced by blender::workbench::VolumePass::object_sync_volume(), blender::draw::Texture::size(), blender::gpu::MTLFrameBuffer::update_attachments(), and blender::gpu::VKFrameBuffer::update_size().

◆ GPU_texture_has_depth_format()

bool GPU_texture_has_depth_format ( const blender::gpu::Texture * texture)

Return true if the texture format has a depth component.

Definition at line 900 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_DEPTH, and texture().

Referenced by blender::gpu::FrameBuffer::attachment_set(), GPU_framebuffer_blit(), blender::draw::Texture::is_depth(), and pygpu_framebuffer__tp_new().

◆ GPU_texture_has_float_format()

bool GPU_texture_has_float_format ( const blender::gpu::Texture * texture)

Return true if the texture format is a float type.

Definition at line 915 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_FLOAT, and texture().

Referenced by blender::draw::Texture::debug_clear().

◆ GPU_texture_has_integer_format()

bool GPU_texture_has_integer_format ( const blender::gpu::Texture * texture)

Return true if the texture format is an integer type (non-normalized integers).

Definition at line 910 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_INTEGER, and texture().

Referenced by blender::draw::Texture::debug_clear(), and blender::draw::Texture::is_integer().

◆ GPU_texture_has_normalized_format()

bool GPU_texture_has_normalized_format ( const blender::gpu::Texture * texture)

Return true if the texture format is an integer normalized type.

Definition at line 920 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_NORMALIZED_INTEGER, and texture().

Referenced by blender::draw::Texture::debug_clear().

◆ GPU_texture_has_signed_format()

bool GPU_texture_has_signed_format ( const blender::gpu::Texture * texture)

Return true if the texture format is a signed type.

Definition at line 925 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_SIGNED, and texture().

Referenced by blender::draw::Texture::debug_clear().

◆ GPU_texture_has_stencil_format()

bool GPU_texture_has_stencil_format ( const blender::gpu::Texture * texture)

Return true if the texture format has a stencil component.

Definition at line 905 of file gpu_texture.cc.

References blender::gpu::GPU_FORMAT_STENCIL, and texture().

Referenced by blender::gpu::FrameBuffer::attachment_set(), GPU_framebuffer_blit(), GPU_framebuffer_config_array(), and blender::draw::Texture::is_stencil().

◆ GPU_texture_height()

◆ GPU_texture_image_bind()

◆ GPU_texture_image_unbind()

void GPU_texture_image_unbind ( blender::gpu::Texture * texture)

Unbind tex from an arbitrary load/store image unit.

Note
this isn't strictly required but it is better for debugging purpose.

Definition at line 591 of file gpu_texture.cc.

References blender::gpu::Context::get(), blender::gpu::StateManager::image_unbind(), and blender::gpu::Context::state_manager.

Referenced by blender::compositor::parallel_reduction_dispatch(), and blender::compositor::Result::unbind_as_image().

◆ GPU_texture_image_unbind_all()

void GPU_texture_image_unbind_all ( )

◆ GPU_texture_is_array()

bool GPU_texture_is_array ( const blender::gpu::Texture * texture)

Return true if the texture is an array texture type (has layers).

Definition at line 935 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_ARRAY, and texture().

Referenced by blender::gpu::FrameBuffer::attachment_set(), and blender::draw::Texture::is_array().

◆ GPU_texture_is_cube()

bool GPU_texture_is_cube ( const blender::gpu::Texture * texture)

Return true if the texture is an cube-map texture type.

Definition at line 930 of file gpu_texture.cc.

References blender::gpu::GPU_TEXTURE_CUBE, and texture().

Referenced by blender::gpu::FrameBuffer::attachment_set(), and blender::draw::Texture::is_cube().

◆ GPU_texture_layer_count()

int GPU_texture_layer_count ( const blender::gpu::Texture * texture)

Return the number of layers of tex. Return 1 if the texture is not layered.

Definition at line 726 of file gpu_texture.cc.

References texture().

Referenced by blender::draw::Texture::ensure_layer_views(), and blender::draw::Texture::layer_range_view().

◆ GPU_texture_memory_usage_get()

unsigned int GPU_texture_memory_usage_get ( )

Returns the memory usage of all currently allocated textures in bytes.

Note
that does not mean all of the textures are inside VRAM. Drivers can swap the texture memory back and forth depending on usage.

Definition at line 244 of file gpu_texture.cc.

◆ GPU_texture_mip_count()

int GPU_texture_mip_count ( const blender::gpu::Texture * texture)

Return the number of mip-map level inside this texture.

Definition at line 731 of file gpu_texture.cc.

References texture().

Referenced by blender::draw::Texture::ensure_mip_views(), and blender::draw::Texture::mip_count().

◆ GPU_texture_mipmap_mode()

◆ GPU_texture_original_height()

int GPU_texture_original_height ( const blender::gpu::Texture * texture)

Definition at line 741 of file gpu_texture.cc.

References texture().

◆ GPU_texture_original_size_set()

void GPU_texture_original_size_set ( blender::gpu::Texture * texture,
int width,
int height )

Definition at line 746 of file gpu_texture.cc.

References texture(), and w().

Referenced by image_get_gpu_texture().

◆ GPU_texture_original_width()

int GPU_texture_original_width ( const blender::gpu::Texture * texture)

Width & Height (of source data), optional. WORKAROUND: Calling BKE_image_get_size may free the texture. Store the source image size (before down-scaling) inside the blender::gpu::Texture to retrieve the original size later (Ref #59347).

Definition at line 736 of file gpu_texture.cc.

References texture().

◆ GPU_texture_py_reference_get()

void ** GPU_texture_py_reference_get ( blender::gpu::Texture * texture)

Reference of a pointer that needs to be cleaned when deallocating the texture. Points to BPyGPUTexture.tex

Definition at line 941 of file gpu_texture.cc.

References texture().

Referenced by BPyGPUTexture_CreatePyObject().

◆ GPU_texture_py_reference_set()

void GPU_texture_py_reference_set ( blender::gpu::Texture * texture,
void ** py_ref )

Definition at line 946 of file gpu_texture.cc.

References BLI_assert, and texture().

Referenced by BPyGPUTexture__tp_dealloc(), and BPyGPUTexture_CreatePyObject().

◆ GPU_texture_read()

void * GPU_texture_read ( blender::gpu::Texture * texture,
eGPUDataFormat data_format,
int mip_level )

Read the content of a mip_level from a tex and returns a copy of its data.

Warning
the texture must have been created using GPU_TEXTURE_USAGE_HOST_READ.
Note
synchronization of shader writes via imageStore() needs to be explicitly done using GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH).

Definition at line 535 of file gpu_texture.cc.

References BLI_assert_msg, GPU_texture_usage(), GPU_TEXTURE_USAGE_HOST_READ, and texture().

Referenced by blender::nodes::node_composite_file_output_cc::FileOutputOperation::add_pass_for_result(), blender::nodes::node_composite_file_output_cc::FileOutputOperation::add_view_for_result(), blender::compositor::compute_preview_gpu(), blender::compositor::Result::download_to_cpu(), blender::nodes::node_composite_denoise_cc::DenoiseOperation::execute(), blender::nodes::node_composite_glare_cc::GlareOperation::execute_fog_glow(), blender::gpu::tests::gpu_shader_lib_test(), ViewportColorSampleSession::init(), blender::render::Context::output_to_render_result(), blender::compositor::parallel_reduction_dispatch(), pygpu_texture_read(), blender::draw::Texture::read(), blender::eevee::Film::read_aov(), blender::render::hydra::GPURenderTaskDelegate::read_aov(), blender::eevee::Film::read_pass(), blender::compositor::sample_pixel_gpu(), blender::gpu::tests::test_compute_direct(), blender::gpu::tests::test_compute_indirect(), blender::gpu::tests::test_framebuffer_clear_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_clear_color_single_attachment(), blender::gpu::tests::test_framebuffer_clear_depth(), blender::gpu::tests::test_framebuffer_clear_multiple_color_multiple_attachments(), blender::gpu::tests::test_framebuffer_cube(), blender::gpu::tests::test_framebuffer_multi_viewport(), blender::gpu::tests::test_framebuffer_scissor_test(), blender::gpu::tests::test_framebuffer_subpass_input(), blender::gpu::tests::test_shader_compute_1d(), blender::gpu::tests::test_shader_compute_2d(), blender::gpu::tests::test_texture_1d(), blender::gpu::tests::test_texture_1d_array(), blender::gpu::tests::test_texture_1d_array_upload(), blender::gpu::tests::test_texture_2d_array(), blender::gpu::tests::test_texture_2d_array_upload(), blender::gpu::tests::test_texture_3d(), blender::gpu::tests::test_texture_copy(), blender::gpu::tests::test_texture_cube(), blender::gpu::tests::test_texture_cube_array(), blender::gpu::tests::test_texture_read(), blender::gpu::tests::test_texture_update_sub_no_unpack_row_length(), blender::gpu::tests::test_texture_update_sub_unpack_row_length(), blender::gpu::tests::texture_create_upload_read(), blender::gpu::tests::texture_create_upload_read_pixel(), blender::gpu::tests::texture_create_upload_read_with_bias(), view3d_depths_create(), and blender::render::Context::viewer_output_to_viewer_image().

◆ GPU_texture_ref()

void GPU_texture_ref ( blender::gpu::Texture * texture)

Add a reference to this texture for usage. This internally increment the reference counter. This avoids the texture being free between the time it is referenced by the drawing logic and the time it is actually dereferenced.

Definition at line 687 of file gpu_texture.cc.

References texture().

Referenced by blender::draw::Manager::acquire_texture(), BPyGPUTexture_CreatePyObject(), blender::render::Context::get_pass(), and blender::eevee::LookdevWorld::sync().

◆ GPU_texture_swizzle_set()

void GPU_texture_swizzle_set ( blender::gpu::Texture * texture,
const char swizzle[4] )

Set tex texture swizzle state for swizzling sample components.

A texture sample always return 4 components in the shader. If the texture has less than 4 components, the missing ones are replaced by the matching values in the following vector (0, 0, 0, 1).

swizzle contains 1 char per component representing the source of the data for each of the component of a sample value. The possible values for each of these 4 characters are:

  • 'r' or 'x': use the texture first component.
  • 'g' or 'y': use the texture second component.
  • 'b' or 'z': use the texture third component.
  • 'a' or 'w': use the texture fourth component.
  • '0': will make the component value to always return 0.
  • '1': will make the component value to always return 1.

Definition at line 668 of file gpu_texture.cc.

References texture().

Referenced by blender::eevee::RenderBuffers::acquire(), blender::compositor::compute_preview_gpu(), IMB_create_gpu_texture(), IMB_touch_gpu_texture(), blender::ed::sculpt_paint::load_tex(), blender::ed::sculpt_paint::load_tex_cursor(), radial_control_set_tex(), blender::eevee::RenderBuffers::release(), and blender::draw::volume_grid_cache_get().

◆ GPU_texture_unbind()

◆ GPU_texture_unbind_all()

◆ GPU_texture_update()

void GPU_texture_update ( blender::gpu::Texture * texture,
eGPUDataFormat data_format,
const void * data )

Update the content of a texture's base mip-map level (mip 0). data_format is the format of the data . It needs to be compatible with the internal texture storage. The data should be the size of the entire mip 0 level.

Note
This function only update the content of mip 0. Either specify other mips or use GPU_texture_update_mipmap_chain to generate them if needed.

Definition at line 550 of file gpu_texture.cc.

References data, and blender::gpu::Texture::update().

Referenced by blender::workbench::AntiAliasingPass::AntiAliasingPass(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_alpha(), blender::nodes::node_composite_movieclip_cc::MovieClipOperation::compute_image(), blender::render::hydra::DrawTexture::create_from_buffer(), blender::ed::vse::create_texture(), draw_display_buffer(), draw_plane_marker_image(), blender::ed::vse::draw_strip_thumbnails(), blender::nodes::node_composite_denoise_cc::DenoiseOperation::execute(), IMB_create_gpu_texture(), immDrawPixelsTexScaledFullSize(), blender::ed::sculpt_paint::load_tex(), blender::ed::sculpt_paint::load_tex_cursor(), RE_pass_ensure_gpu_texture_cache(), blender::draw::gpencil::render_init_buffers(), studiolight_create_matcap_gputexture(), blender::gpu::tests::texture_create_upload_read(), blender::gpu::tests::texture_create_upload_read_pixel(), blender::gpu::tests::texture_create_upload_read_with_bias(), blender::compositor::Result::update_single_value_data(), blender::compositor::Result::upload_to_gpu(), and wm_software_cursor_draw_bitmap().

◆ GPU_texture_update_mipmap()

void GPU_texture_update_mipmap ( blender::gpu::Texture * texture,
int mip_level,
eGPUDataFormat data_format,
const void * pixels )

Update the content of a texture's specific mip-map level. data_format is the format of the pixels . It needs to be compatible with the internal texture storage. The data should be the size of the entire mip_level.

Definition at line 495 of file gpu_texture.cc.

References texture().

Referenced by blender::eevee::UtilityTexture::UtilityTexture().

◆ GPU_texture_update_mipmap_chain()

void GPU_texture_update_mipmap_chain ( blender::gpu::Texture * texture)

Update the mip-map levels using the mip 0 data.

Note
this doesn't work on depth or compressed textures.

Definition at line 601 of file gpu_texture.cc.

References blender::gpu::Texture::generate_mipmap().

Referenced by blender::compositor::CachedImage::CachedImage(), gpu_texture_create_tile_array(), gpu_texture_update_from_ibuf(), image_get_gpu_texture(), and immDrawPixelsTexScaledFullSize().

◆ GPU_texture_update_sub()

void GPU_texture_update_sub ( blender::gpu::Texture * texture,
eGPUDataFormat data_format,
const void * pixels,
int offset_x,
int offset_y,
int offset_z,
int width,
int height,
int depth )

Update the content of a region of a texture's base mip-map level (mip 0). data_format is the format of the data . It needs to be compatible with the internal texture storage. The data should be the size of the mip 0 level region.

Note
This function only update the content of mip 0. Either specify other mips or use GPU_texture_update_mipmap_chain to generate them if needed.

offset_x , offset_y , offset_z specify the bottom left corner of the updated region. width , height , depth specify the extent of the updated region.

Definition at line 505 of file gpu_texture.cc.

References blender::gpu::Texture::update_sub().

Referenced by blf_batch_cache_texture_load(), gpu_texture_update_scaled(), gpu_texture_update_unscaled(), IMB_update_gpu_texture_sub(), immDrawPixelsTexTiled_scaling_clipping(), blender::draw::overlay::Instance::init(), blender::draw::gpencil::render_init_buffers(), blender::draw::test_eevee_shadow_tilemap_amend(), blender::gpu::tests::test_texture_update_sub_no_unpack_row_length(), and blender::gpu::tests::test_texture_update_sub_unpack_row_length().

◆ GPU_texture_update_sub_from_pixel_buffer()

void GPU_texture_update_sub_from_pixel_buffer ( blender::gpu::Texture * texture,
eGPUDataFormat data_format,
GPUPixelBuffer * pixel_buf,
int offset_x,
int offset_y,
int offset_z,
int width,
int height,
int depth )

Update a sub-region of a texture using the data from a #GPUPixelBuffer as source data. The pix_buf data is expected to be contiguous and big enough to fill the described sub-region.

Definition at line 520 of file gpu_texture.cc.

References texture().

Referenced by update_tile_texture_pixels().

◆ GPU_texture_usage()

◆ GPU_texture_width()

◆ GPU_unpack_row_length_set()

void GPU_unpack_row_length_set ( uint len)

Makes data interpretation aware of the source layout. Skipping pixels correctly when changing rows when doing partial update. This affects GPU_texture_update, GPU_texture_update_sub, GPU_texture_update_mipmap. TODO(fclem): replace this by pixel buffer updates using a custom utility to do the line shifting like Cycles does.

Definition at line 555 of file gpu_texture.cc.

References blender::gpu::Context::get(), len, blender::gpu::Context::state_manager, and blender::gpu::StateManager::texture_unpack_row_length_set().

Referenced by gpu_texture_update_unscaled(), immDrawPixelsTexTiled_scaling_clipping(), and blender::gpu::tests::test_texture_update_sub_unpack_row_length().

Variable Documentation

◆ GPU_SAMPLER_FILTERING_TYPES_COUNT