Blender  V2.93
Functions
gpu_node_graph.c File Reference
#include <stdio.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_node_types.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "GPU_texture.h"
#include "gpu_material_library.h"
#include "gpu_node_graph.h"

Go to the source code of this file.

Functions

static GPUNodeLinkgpu_node_link_create (void)
 
static void gpu_node_link_free (GPUNodeLink *link)
 
static GPUNodegpu_node_create (const char *name)
 
static void gpu_node_input_link (GPUNode *node, GPUNodeLink *link, const eGPUType type)
 
static const char * gpu_uniform_set_function_from_type (eNodeSocketDatatype type)
 
static GPUNodeLinkgpu_uniformbuffer_link (GPUMaterial *mat, bNode *node, GPUNodeStack *stack, const int index, const eNodeSocketInOut in_out)
 
static void gpu_node_input_socket (GPUMaterial *material, bNode *bnode, GPUNode *node, GPUNodeStack *sock, const int index)
 
static void gpu_node_output (GPUNode *node, const eGPUType type, GPUNodeLink **link)
 
static int uniform_attr_sort_cmp (const void *a, const void *b)
 
static unsigned int uniform_attr_list_hash (const void *key)
 
static bool uniform_attr_list_cmp (const void *a, const void *b)
 
struct GHashGPU_uniform_attr_list_hash_new (const char *info)
 
void GPU_uniform_attr_list_copy (GPUUniformAttrList *dest, GPUUniformAttrList *src)
 
void GPU_uniform_attr_list_free (GPUUniformAttrList *set)
 
void gpu_node_graph_finalize_uniform_attrs (GPUNodeGraph *graph)
 
static GPUMaterialAttributegpu_node_graph_add_attribute (GPUNodeGraph *graph, CustomDataType type, const char *name)
 
static GPUUniformAttrgpu_node_graph_add_uniform_attribute (GPUNodeGraph *graph, const char *name, bool use_dupli)
 
static GPUMaterialTexturegpu_node_graph_add_texture (GPUNodeGraph *graph, Image *ima, ImageUser *iuser, struct GPUTexture **colorband, GPUNodeLinkType link_type, eGPUSamplerState sampler_state)
 
static GPUMaterialVolumeGridgpu_node_graph_add_volume_grid (GPUNodeGraph *graph, const char *name, eGPUVolumeDefaultValue default_value)
 
GPUNodeLinkGPU_attribute (GPUMaterial *mat, const CustomDataType type, const char *name)
 
GPUNodeLinkGPU_uniform_attribute (GPUMaterial *mat, const char *name, bool use_dupli)
 
GPUNodeLinkGPU_constant (const float *num)
 
GPUNodeLinkGPU_uniform (const float *num)
 
GPUNodeLinkGPU_image (GPUMaterial *mat, Image *ima, ImageUser *iuser, eGPUSamplerState sampler_state)
 
GPUNodeLinkGPU_image_tiled (GPUMaterial *mat, Image *ima, ImageUser *iuser, eGPUSamplerState sampler_state)
 
GPUNodeLinkGPU_image_tiled_mapping (GPUMaterial *mat, Image *ima, ImageUser *iuser)
 
GPUNodeLinkGPU_color_band (GPUMaterial *mat, int size, float *pixels, float *row)
 
GPUNodeLinkGPU_volume_grid (GPUMaterial *mat, const char *name, eGPUVolumeDefaultValue default_value)
 
GPUNodeLinkGPU_builtin (eGPUBuiltin builtin)
 
bool GPU_link (GPUMaterial *mat, const char *name,...)
 
bool GPU_stack_link (GPUMaterial *material, bNode *bnode, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
 
GPUNodeLinkGPU_uniformbuf_link_out (GPUMaterial *mat, bNode *node, GPUNodeStack *stack, const int index)
 
static void gpu_inputs_free (ListBase *inputs)
 
static void gpu_node_free (GPUNode *node)
 
void gpu_node_graph_free_nodes (GPUNodeGraph *graph)
 
void gpu_node_graph_free (GPUNodeGraph *graph)
 
static void gpu_nodes_tag (GPUNodeLink *link)
 
void gpu_node_graph_prune_unused (GPUNodeGraph *graph)
 

Detailed Description

Intermediate node graph for generating GLSL shaders.

Definition in file gpu_node_graph.c.

Function Documentation

◆ GPU_attribute()

GPUNodeLink* GPU_attribute ( GPUMaterial mat,
const CustomDataType  type,
const char *  name 
)

◆ GPU_builtin()

GPUNodeLink* GPU_builtin ( eGPUBuiltin  builtin)

◆ GPU_color_band()

GPUNodeLink* GPU_color_band ( GPUMaterial mat,
int  size,
float pixels,
float row 
)

◆ GPU_constant()

GPUNodeLink* GPU_constant ( const float num)

◆ GPU_image()

GPUNodeLink* GPU_image ( GPUMaterial mat,
Image ima,
ImageUser iuser,
eGPUSamplerState  sampler_state 
)

◆ GPU_image_tiled()

GPUNodeLink* GPU_image_tiled ( GPUMaterial mat,
Image ima,
ImageUser iuser,
eGPUSamplerState  sampler_state 
)

◆ GPU_image_tiled_mapping()

GPUNodeLink* GPU_image_tiled_mapping ( GPUMaterial mat,
Image ima,
ImageUser iuser 
)

◆ gpu_inputs_free()

static void gpu_inputs_free ( ListBase inputs)
static

◆ GPU_link()

bool GPU_link ( GPUMaterial mat,
const char *  name,
  ... 
)

◆ gpu_node_create()

static GPUNode* gpu_node_create ( const char *  name)
static

Definition at line 71 of file gpu_node_graph.c.

References MEM_callocN, and node.

Referenced by GPU_link(), and GPU_stack_link().

◆ gpu_node_free()

static void gpu_node_free ( GPUNode node)
static

◆ gpu_node_graph_add_attribute()

static GPUMaterialAttribute* gpu_node_graph_add_attribute ( GPUNodeGraph graph,
CustomDataType  type,
const char *  name 
)
static

Add a new varying attribute of given type and name. Returns NULL if out of slots.

Definition at line 354 of file gpu_node_graph.c.

References BLI_addtail(), CD_AUTO_FROM_NAME, CD_MTFACE, GPU_MAX_ATTR, graph, GPUMaterialAttribute::id, MEM_callocN, GPUMaterialAttribute::name, GPUMaterialAttribute::next, NULL, STREQ, STRNCPY, type, GPUMaterialAttribute::type, and GPUMaterialAttribute::users.

Referenced by GPU_attribute().

◆ gpu_node_graph_add_texture()

static GPUMaterialTexture* gpu_node_graph_add_texture ( GPUNodeGraph graph,
Image ima,
ImageUser iuser,
struct GPUTexture **  colorband,
GPUNodeLinkType  link_type,
eGPUSamplerState  sampler_state 
)
static

◆ gpu_node_graph_add_uniform_attribute()

static GPUUniformAttr* gpu_node_graph_add_uniform_attribute ( GPUNodeGraph graph,
const char *  name,
bool  use_dupli 
)
static

◆ gpu_node_graph_add_volume_grid()

static GPUMaterialVolumeGrid* gpu_node_graph_add_volume_grid ( GPUNodeGraph graph,
const char *  name,
eGPUVolumeDefaultValue  default_value 
)
static

◆ gpu_node_graph_finalize_uniform_attrs()

void gpu_node_graph_finalize_uniform_attrs ( GPUNodeGraph graph)

◆ gpu_node_graph_free()

void gpu_node_graph_free ( GPUNodeGraph graph)

◆ gpu_node_graph_free_nodes()

void gpu_node_graph_free_nodes ( GPUNodeGraph graph)

◆ gpu_node_graph_prune_unused()

void gpu_node_graph_prune_unused ( GPUNodeGraph graph)

◆ gpu_node_input_link()

static void gpu_node_input_link ( GPUNode node,
GPUNodeLink link,
const eGPUType  type 
)
static

◆ gpu_node_input_socket()

static void gpu_node_input_socket ( GPUMaterial material,
bNode bnode,
GPUNode node,
GPUNodeStack sock,
const int  index 
)
static

◆ gpu_node_link_create()

static GPUNodeLink* gpu_node_link_create ( void  )
static

◆ gpu_node_link_free()

static void gpu_node_link_free ( GPUNodeLink link)
static

Definition at line 53 of file gpu_node_graph.c.

References GPUOutput::link, MEM_freeN, NULL, GPUNodeLink::output, and GPUNodeLink::users.

Referenced by gpu_inputs_free(), and gpu_node_free().

◆ gpu_node_output()

static void gpu_node_output ( GPUNode node,
const eGPUType  type,
GPUNodeLink **  link 
)
static

◆ gpu_nodes_tag()

static void gpu_nodes_tag ( GPUNodeLink link)
static

◆ GPU_stack_link()

bool GPU_stack_link ( GPUMaterial material,
bNode bnode,
const char *  name,
GPUNodeStack in,
GPUNodeStack out,
  ... 
)

Definition at line 665 of file gpu_node_graph.c.

References BLI_addtail(), GPUNodeStack::end, FUNCTION_QUAL_IN, gpu_material_library_use_function(), gpu_material_node_graph(), gpu_material_used_libraries(), gpu_node_create(), gpu_node_input_link(), gpu_node_input_socket(), gpu_node_output(), GPU_NONE, graph, material, node, NULL, params, GPUNodeLink::socket, and type.

Referenced by gpu_shader_bevel(), gpu_shader_brightcontrast(), gpu_shader_bump(), gpu_shader_camera(), gpu_shader_clamp(), gpu_shader_combhsv(), gpu_shader_combrgb(), gpu_shader_combxyz(), gpu_shader_curve_rgb(), gpu_shader_curve_vec(), gpu_shader_displacement(), gpu_shader_hue_sat(), gpu_shader_invert(), gpu_shader_map_range(), gpu_shader_mapping(), gpu_shader_math(), gpu_shader_mix_rgb(), gpu_shader_normal(), gpu_shader_particle_info(), gpu_shader_rgb(), gpu_shader_rgbtobw(), gpu_shader_sephsv(), gpu_shader_seprgb(), gpu_shader_sepxyz(), gpu_shader_squeeze(), gpu_shader_tex_white_noise(), gpu_shader_valtorgb(), gpu_shader_value(), gpu_shader_vector_displacement(), gpu_shader_vector_math(), gpu_shader_vector_rotate(), node_shader_gpu_add_shader(), node_shader_gpu_ambient_occlusion(), node_shader_gpu_attribute(), node_shader_gpu_background(), node_shader_gpu_blackbody(), node_shader_gpu_bsdf_anisotropic(), node_shader_gpu_bsdf_diffuse(), node_shader_gpu_bsdf_glass(), node_shader_gpu_bsdf_glossy(), node_shader_gpu_bsdf_hair(), node_shader_gpu_bsdf_principled(), node_shader_gpu_bsdf_refraction(), node_shader_gpu_bsdf_toon(), node_shader_gpu_bsdf_translucent(), node_shader_gpu_bsdf_transparent(), node_shader_gpu_bsdf_velvet(), node_shader_gpu_eevee_specular(), node_shader_gpu_emission(), node_shader_gpu_fresnel(), node_shader_gpu_gamma(), node_shader_gpu_geometry(), node_shader_gpu_hair_info(), node_shader_gpu_layer_weight(), node_shader_gpu_light_falloff(), node_shader_gpu_light_path(), node_shader_gpu_mix_shader(), node_shader_gpu_object_info(), node_shader_gpu_output_aov(), node_shader_gpu_output_material(), node_shader_gpu_output_world(), node_shader_gpu_shadertorgb(), node_shader_gpu_subsurface_scattering(), node_shader_gpu_tangent(), node_shader_gpu_tex_brick(), node_shader_gpu_tex_checker(), node_shader_gpu_tex_coord(), node_shader_gpu_tex_environment(), node_shader_gpu_tex_gradient(), node_shader_gpu_tex_image(), node_shader_gpu_tex_magic(), node_shader_gpu_tex_sky(), node_shader_gpu_tex_voronoi(), node_shader_gpu_tex_wave(), node_shader_gpu_uvmap(), node_shader_gpu_vertex_color(), node_shader_gpu_volume_absorption(), node_shader_gpu_volume_principled(), node_shader_gpu_volume_scatter(), and node_shader_gpu_wireframe().

◆ GPU_uniform()

GPUNodeLink* GPU_uniform ( const float num)

◆ GPU_uniform_attr_list_copy()

void GPU_uniform_attr_list_copy ( GPUUniformAttrList dest,
GPUUniformAttrList src 
)

◆ GPU_uniform_attr_list_free()

void GPU_uniform_attr_list_free ( GPUUniformAttrList set)

◆ GPU_uniform_attr_list_hash_new()

struct GHash* GPU_uniform_attr_list_hash_new ( const char *  info)

◆ GPU_uniform_attribute()

GPUNodeLink* GPU_uniform_attribute ( GPUMaterial mat,
const char *  name,
bool  use_dupli 
)

◆ gpu_uniform_set_function_from_type()

static const char* gpu_uniform_set_function_from_type ( eNodeSocketDatatype  type)
static

Definition at line 165 of file gpu_node_graph.c.

References BLI_assert, NULL, SOCK_FLOAT, SOCK_INT, SOCK_RGBA, SOCK_VECTOR, and type.

Referenced by gpu_uniformbuffer_link().

◆ GPU_uniformbuf_link_out()

GPUNodeLink* GPU_uniformbuf_link_out ( GPUMaterial mat,
bNode node,
GPUNodeStack stack,
const int  index 
)

Definition at line 741 of file gpu_node_graph.c.

References gpu_uniformbuffer_link(), node, and SOCK_OUT.

Referenced by gpu_shader_rgb(), and gpu_shader_value().

◆ gpu_uniformbuffer_link()

static GPUNodeLink* gpu_uniformbuffer_link ( GPUMaterial mat,
bNode node,
GPUNodeStack stack,
const int  index,
const eNodeSocketInOut  in_out 
)
static

◆ GPU_volume_grid()

GPUNodeLink* GPU_volume_grid ( GPUMaterial mat,
const char *  name,
eGPUVolumeDefaultValue  default_value 
)

◆ uniform_attr_list_cmp()

static bool uniform_attr_list_cmp ( const void *  a,
const void *  b 
)
static

◆ uniform_attr_list_hash()

static unsigned int uniform_attr_list_hash ( const void *  key)
static

Definition at line 284 of file gpu_node_graph.c.

References GPUUniformAttrList::hash_code.

Referenced by GPU_uniform_attr_list_hash_new().

◆ uniform_attr_sort_cmp()

static int uniform_attr_sort_cmp ( const void *  a,
const void *  b 
)
static