Blender V5.0
blender::gpu::shader Namespace Reference

Namespaces

namespace  parser

Classes

class  Preprocessor
struct  SpecializationConstant
struct  SpecializationConstants
struct  CompilationConstant
struct  GPUCodegenCreateInfo
class  GPUCodegen
struct  StageInterfaceInfo
struct  GeneratedSource
struct  ShaderCreateInfo
 Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correctly provided, this is all that is needed to create and compile a blender::gpu::Shader. More...
struct  PrintfFormat

Typedefs

using CreateInfoDictionary = Map<StringRef, ShaderCreateInfo *>
using InterfaceDictionary = Map<StringRef, StageInterfaceInfo *>
using GeneratedSourceList = Vector<shader::GeneratedSource, 0>

Enumerations

enum class  Type : int8_t {
  float_t = 0 , float2_t , float3_t , float4_t ,
  float3x3_t , float4x4_t , uint_t , uint2_t ,
  uint3_t , uint4_t , int_t , int2_t ,
  int3_t , int4_t , bool_t , float3_10_10_10_2_t ,
  uchar_t , uchar2_t , uchar3_t , uchar4_t ,
  char_t , char2_t , char3_t , char4_t ,
  ushort_t , ushort2_t , ushort3_t , ushort4_t ,
  short_t , short2_t , short3_t , short4_t
}
enum class  BuiltinBits {
  NONE = 0 , BARYCENTRIC_COORD = (1 << 0) , STENCIL_REF = (1 << 1) , FRAG_COORD = (1 << 2) ,
  FRONT_FACING = (1 << 4) , GLOBAL_INVOCATION_ID = (1 << 5) , INSTANCE_ID = (1 << 6) , LAYER = (1 << 7) ,
  LOCAL_INVOCATION_ID = (1 << 8) , LOCAL_INVOCATION_INDEX = (1 << 9) , NUM_WORK_GROUP = (1 << 10) , POINT_COORD = (1 << 11) ,
  POINT_SIZE = (1 << 12) , PRIMITIVE_ID = (1 << 13) , VERTEX_ID = (1 << 14) , WORK_GROUP_ID = (1 << 15) ,
  WORK_GROUP_SIZE = (1 << 16) , VIEWPORT_INDEX = (1 << 17) , TEXTURE_ATOMIC = (1 << 18) , CLIP_CONTROL = (1 << 19) ,
  USE_PRINTF = (1 << 28) , USE_DEBUG_DRAW = (1 << 29) , RUNTIME_GENERATED = (1 << 30)
}
enum class  DepthWrite { UNCHANGED = 0 , ANY , GREATER , LESS }
enum class  ImageType {
  undefined = 0 , TYPES_EXPAND =(1D) , TYPES_EXPAND =(1DArray) , TYPES_EXPAND =(2D) ,
  TYPES_EXPAND =(2DArray) , TYPES_EXPAND =(3D) , TYPES_EXPAND =(Cube) , TYPES_EXPAND =(CubeArray) ,
  TYPES_EXPAND =(Buffer) , TYPES_EXPAND =(2D) , TYPES_EXPAND =(2DArray) , TYPES_EXPAND =(Cube) ,
  TYPES_EXPAND =(CubeArray) , TYPES_EXPAND =(2D) , TYPES_EXPAND =(2DArray) , TYPES_EXPAND =(3D)
}
enum class  ImageReadWriteType {
  undefined = 0 , TYPES_EXPAND =(1D) , TYPES_EXPAND =(1DArray) , TYPES_EXPAND =(2D) ,
  TYPES_EXPAND =(2DArray) , TYPES_EXPAND =(3D) , TYPES_EXPAND =(2D) , TYPES_EXPAND =(2DArray) ,
  TYPES_EXPAND =(3D)
}
enum class  Qualifier {
  no_restrict = (1 << 0) , read = (1 << 1) , write = (1 << 2) , read_write = read | write ,
  QUALIFIER_MAX = (write << 1) - 1
}
enum class  Frequency { BATCH = 0 , PASS , GEOMETRY }
enum class  DualBlend { NONE = 0 , SRC_0 , SRC_1 }
enum class  Interpolation { SMOOTH = 0 , FLAT , NO_PERSPECTIVE }
enum class  PrimitiveIn {
  POINTS = 0 , LINES , LINES_ADJACENCY , TRIANGLES ,
  TRIANGLES_ADJACENCY
}
enum class  PrimitiveOut {
  POINTS = 0 , LINE_STRIP , TRIANGLE_STRIP , LINES ,
  TRIANGLES
}

Functions

BLI_INLINE int to_component_count (const Type &type)
static Type to_type (const GPUType type)
static std::ostream & operator<< (std::ostream &stream, const Type type)
static std::ostream & operator<< (std::ostream &stream, const GPUType type)
 ENUM_OPERATORS (BuiltinBits, BuiltinBits::USE_DEBUG_DRAW)
 ENUM_OPERATORS (Qualifier, Qualifier::QUALIFIER_MAX)
bool gpu_shader_dependency_force_gpu_print_injection ()
bool gpu_shader_dependency_has_printf ()
const PrintfFormatgpu_shader_dependency_get_printf_format (uint32_t format_hash)
BuiltinBits gpu_shader_dependency_get_builtins (const StringRefNull shader_source_name)
Vector< StringRefNullgpu_shader_dependency_get_resolved_source (const StringRefNull shader_source_name, const shader::GeneratedSourceList &generated_sources, const StringRefNull shader_name)
StringRefNull gpu_shader_dependency_get_source (const StringRefNull shader_source_name)
StringRefNull gpu_shader_dependency_get_filename_from_source_string (StringRef source_string)
 Find the name of the file from which the given string was generated.
Check Backend Support
static bool is_vulkan_compatible_interface (const StageInterfaceInfo &iface)

Variables

static CreateInfoDictionaryg_create_infos = nullptr
static InterfaceDictionaryg_interfaces = nullptr

Typedef Documentation

◆ CreateInfoDictionary

◆ GeneratedSourceList

◆ InterfaceDictionary

Enumeration Type Documentation

◆ BuiltinBits

Enumerator
NONE 
BARYCENTRIC_COORD 

Allow getting barycentric coordinates inside the fragment shader.

Note
Emulated on OpenGL.
STENCIL_REF 
FRAG_COORD 
FRONT_FACING 
GLOBAL_INVOCATION_ID 
INSTANCE_ID 
LAYER 

Allow setting the target layer when the output is a layered frame-buffer.

Note
Emulated through geometry shader on older hardware.
LOCAL_INVOCATION_ID 
LOCAL_INVOCATION_INDEX 
NUM_WORK_GROUP 
POINT_COORD 
POINT_SIZE 
PRIMITIVE_ID 
VERTEX_ID 
WORK_GROUP_ID 
WORK_GROUP_SIZE 
VIEWPORT_INDEX 

Allow setting the target viewport when using multi viewport feature.

Note
Emulated through geometry shader on older hardware.
TEXTURE_ATOMIC 
CLIP_CONTROL 
USE_PRINTF 
USE_DEBUG_DRAW 
RUNTIME_GENERATED 

Definition at line 442 of file gpu_shader_create_info.hh.

◆ DepthWrite

Follow convention described in: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_conservative_depth.txt

Enumerator
UNCHANGED 
ANY 
GREATER 
LESS 

Definition at line 494 of file gpu_shader_create_info.hh.

◆ DualBlend

Dual Source Blending Index.

Enumerator
NONE 
SRC_0 
SRC_1 

Definition at line 596 of file gpu_shader_create_info.hh.

◆ Frequency

Maps to different descriptor sets.

Enumerator
BATCH 
PASS 
GEOMETRY 

Special frequency tag that will automatically source storage buffers from GPUBatch.

Definition at line 588 of file gpu_shader_create_info.hh.

◆ ImageReadWriteType

Enumerator
undefined 
TYPES_EXPAND 

Color image.

TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 

Atomic texture type wrappers. For OpenGL, these map to the equivalent (U)INT_* types. NOTE: Atomic variants MUST be used if the texture bound to this resource has usage flag: GPU_TEXTURE_USAGE_ATOMIC, even if atomic texture operations are not used in the given shader. The shader source MUST also utilize the correct atomic sampler handle e.g. usampler2DAtomic in conjunction with these types, for passing texture/image resources into functions.

TYPES_EXPAND 
TYPES_EXPAND 

Definition at line 545 of file gpu_shader_create_info.hh.

◆ ImageType

Enumerator
undefined 
TYPES_EXPAND 

Color samplers/image.

TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 

Depth samplers (not supported as image).

TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 
TYPES_EXPAND 

Atomic texture type wrappers. For OpenGL, these map to the equivalent (U)INT_* types. NOTE: Atomic variants MUST be used if the texture bound to this resource has usage flag: GPU_TEXTURE_USAGE_ATOMIC, even if atomic texture operations are not used in the given shader. The shader source MUST also utilize the correct atomic sampler handle e.g. usampler2DAtomic in conjunction with these types, for passing texture/image resources into functions.

TYPES_EXPAND 
TYPES_EXPAND 

Definition at line 503 of file gpu_shader_create_info.hh.

◆ Interpolation

Interpolation qualifiers.

Enumerator
SMOOTH 
FLAT 
NO_PERSPECTIVE 

Definition at line 603 of file gpu_shader_create_info.hh.

◆ PrimitiveIn

Input layout for geometry shader.

Enumerator
POINTS 
LINES 
LINES_ADJACENCY 
TRIANGLES 
TRIANGLES_ADJACENCY 

Definition at line 610 of file gpu_shader_create_info.hh.

◆ PrimitiveOut

Output layout for geometry shader.

Enumerator
POINTS 
LINE_STRIP 
TRIANGLE_STRIP 
LINES 
TRIANGLES 

Definition at line 619 of file gpu_shader_create_info.hh.

◆ Qualifier

Enumerator
no_restrict 

Restrict flag is set by default. Unless specified otherwise.

read 
write 
read_write 

Shorthand version of combined flags.

QUALIFIER_MAX 

Definition at line 576 of file gpu_shader_create_info.hh.

◆ Type

enum class blender::gpu::shader::Type : int8_t
strong
Enumerator
float_t 
float2_t 
float3_t 
float4_t 
float3x3_t 
float4x4_t 
uint_t 
uint2_t 
uint3_t 
uint4_t 
int_t 
int2_t 
int3_t 
int4_t 
bool_t 
float3_10_10_10_2_t 
uchar_t 
uchar2_t 
uchar3_t 
uchar4_t 
char_t 
char2_t 
char3_t 
char4_t 
ushort_t 
ushort2_t 
ushort3_t 
ushort4_t 
short_t 
short2_t 
short3_t 
short4_t 

Definition at line 79 of file GPU_common_types.hh.

Function Documentation

◆ ENUM_OPERATORS() [1/2]

blender::gpu::shader::ENUM_OPERATORS ( BuiltinBits ,
BuiltinBits::USE_DEBUG_DRAW  )

References USE_DEBUG_DRAW.

◆ ENUM_OPERATORS() [2/2]

blender::gpu::shader::ENUM_OPERATORS ( Qualifier ,
Qualifier::QUALIFIER_MAX  )

References QUALIFIER_MAX.

◆ gpu_shader_dependency_force_gpu_print_injection()

bool blender::gpu::shader::gpu_shader_dependency_force_gpu_print_injection ( )

Definition at line 563 of file gpu_shader_dependency.cc.

References force_printf_injection.

Referenced by gpu_shader_create_info_init().

◆ gpu_shader_dependency_get_builtins()

BuiltinBits blender::gpu::shader::gpu_shader_dependency_get_builtins ( const StringRefNull shader_source_name)

◆ gpu_shader_dependency_get_filename_from_source_string()

StringRefNull blender::gpu::shader::gpu_shader_dependency_get_filename_from_source_string ( StringRef source_string)

Find the name of the file from which the given string was generated.

Returns
filename or empty string.
Note
source_string needs to be identical to the one given by gpu_shader_dependency_get_source()

Definition at line 625 of file gpu_shader_dependency.cc.

References g_sources.

Referenced by blender::gpu::GLSource::GLSource(), and blender::gpu::Shader::print_log().

◆ gpu_shader_dependency_get_printf_format()

const PrintfFormat & blender::gpu::shader::gpu_shader_dependency_get_printf_format ( uint32_t format_hash)

Definition at line 575 of file gpu_shader_dependency.cc.

References g_formats.

Referenced by blender::gpu::printf_end().

◆ gpu_shader_dependency_get_resolved_source()

◆ gpu_shader_dependency_get_source()

StringRefNull blender::gpu::shader::gpu_shader_dependency_get_source ( const StringRefNull shader_source_name)

◆ gpu_shader_dependency_has_printf()

bool blender::gpu::shader::gpu_shader_dependency_has_printf ( )

Definition at line 570 of file gpu_shader_dependency.cc.

References g_formats.

Referenced by blender::gpu::printf_begin().

◆ is_vulkan_compatible_interface()

◆ operator<<() [1/2]

std::ostream & blender::gpu::shader::operator<< ( std::ostream & stream,
const GPUType type )
inlinestatic

Definition at line 432 of file gpu_shader_create_info.hh.

References GPU_CLOSURE, and to_type().

◆ operator<<() [2/2]

std::ostream & blender::gpu::shader::operator<< ( std::ostream & stream,
const Type type )
inlinestatic

◆ to_component_count()

◆ to_type()

Type blender::gpu::shader::to_type ( const GPUType type)
inlinestatic

Definition at line 338 of file gpu_shader_create_info.hh.

References BLI_assert_msg, float2_t, float3_t, float3x3_t, float4_t, float4x4_t, float_t, GPU_FLOAT, GPU_MAT3, GPU_MAT4, GPU_VEC2, GPU_VEC3, and GPU_VEC4.

Referenced by blender::nodes::build_implicit_conversion_lazy_function(), blender::nodes::materialx::NodeParser::compute(), blender::nodes::materialx::NodeItem::convert(), blender::nodes::evaluate_closure_eagerly(), blender::gpu::shader::GPUCodegen::generate_attribs(), blender::nodes::materialx::NodeParser::get_input_default(), blender::nodes::materialx::NodeParser::get_input_default(), blender::nodes::materialx::NodeParser::get_input_link(), blender::nodes::materialx::NodeParser::get_input_link(), blender::nodes::materialx::NodeParser::get_input_value(), blender::nodes::materialx::NodeParser::get_input_value(), blender::nodes::materialx::NodeParser::get_output_default(), blender::nodes::materialx::NodeParser::get_output_default(), blender::nodes::materialx::GroupNodeParser::GroupNodeParser(), blender::nodes::materialx::NodeItem::if_else(), blender::nodes::implicitly_convert_socket_value(), blender::nodes::LazyFunctionForEvaluateClosureNode::initialize_execution_graph(), blender::compositor::is_conversion_supported(), blender::nodes::materialx::NodeItem::is_convertible(), blender::nodes::materialx::NodeItem::mix(), blender::nodes::materialx::NodeParser::node_name(), blender::nodes::materialx::NodeParser::NodeParser(), operator<<(), blender::nodes::materialx::NodeItem::operator==(), blender::nodes::materialx::NodeGraph::unique_node_name(), and blender::nodes::materialx::NodeItem::~NodeItem().

Variable Documentation

◆ g_create_infos

◆ g_interfaces

InterfaceDictionary* blender::gpu::shader::g_interfaces = nullptr
static