Blender V2.61 - r43446
Functions | Variables

gpu_codegen.c File Reference

#include "GL/glew.h"
#include "MEM_guardedalloc.h"
#include "DNA_customdata_types.h"
#include "DNA_image_types.h"
#include "DNA_material_types.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
#include "BLI_heap.h"
#include "GPU_material.h"
#include "GPU_extensions.h"
#include "BLO_sys_types.h"
#include "gpu_codegen.h"
#include "node_util.h"
#include <string.h>
#include <stdarg.h>

Go to the source code of this file.

Functions

static int gpu_str_prefix (const char *str, const char *prefix)
static char * gpu_str_skip_token (char *str, char *token, int max)
static void gpu_parse_functions_string (GHash *hash, char *code)
GPUFunctionGPU_lookup_function (const char *name)
void GPU_codegen_init (void)
void GPU_codegen_exit (void)
static void codegen_convert_datatype (DynStr *ds, int from, int to, const char *tmp, int id)
static void codegen_print_datatype (DynStr *ds, int type, float *data)
static int codegen_input_has_texture (GPUInput *input)
const char * GPU_builtin_name (GPUBuiltin builtin)
static void codegen_set_unique_ids (ListBase *nodes)
static void codegen_print_uniforms_functions (DynStr *ds, ListBase *nodes)
static void codegen_declare_tmps (DynStr *ds, ListBase *nodes)
static void codegen_call_functions (DynStr *ds, ListBase *nodes, GPUOutput *finaloutput)
static char * code_generate_fragment (ListBase *nodes, GPUOutput *output, const char *UNUSED(name))
static char * code_generate_vertex (ListBase *nodes)
int GPU_bicubic_bump_support (void)
void GPU_code_generate_glsl_lib (void)
GPUShaderGPU_pass_shader (GPUPass *pass)
static void GPU_nodes_extract_dynamic_inputs (GPUPass *pass, ListBase *nodes)
void GPU_pass_bind (GPUPass *pass, double time, int mipmap)
void GPU_pass_update_uniforms (GPUPass *pass)
void GPU_pass_unbind (GPUPass *pass)
static GPUNodeLinkGPU_node_link_create (int type)
static void GPU_node_link_free (GPUNodeLink *link)
static GPUNodeGPU_node_begin (const char *name)
static void GPU_node_end (GPUNode *UNUSED(node))
static void gpu_node_input_link (GPUNode *node, GPUNodeLink *link, int type)
static void gpu_node_input_socket (GPUNode *node, GPUNodeStack *sock)
static void GPU_node_output (GPUNode *node, int type, const char *UNUSED(name), GPUNodeLink **link)
static void GPU_inputs_free (ListBase *inputs)
static void GPU_node_free (GPUNode *node)
static void GPU_nodes_free (ListBase *nodes)
static void gpu_nodes_get_vertex_attributes (ListBase *nodes, GPUVertexAttribs *attribs)
static void gpu_nodes_get_builtin_flag (ListBase *nodes, int *builtin)
GPUNodeLinkGPU_attribute (int type, const char *name)
GPUNodeLinkGPU_uniform (float *num)
GPUNodeLinkGPU_dynamic_uniform (float *num, int dynamictype, void *data)
GPUNodeLinkGPU_image (Image *ima, ImageUser *iuser)
GPUNodeLinkGPU_texture (int size, float *pixels)
GPUNodeLinkGPU_dynamic_texture (GPUTexture *tex, int dynamictype, void *data)
GPUNodeLinkGPU_socket (GPUNodeStack *sock)
GPUNodeLinkGPU_builtin (GPUBuiltin builtin)
int GPU_link (GPUMaterial *mat, const char *name,...)
int GPU_stack_link (GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
int GPU_stack_link_mute (GPUMaterial *mat, const char *name, LinkInOutsMuteNode *mlnk)
int GPU_link_changed (GPUNodeLink *link)
static void gpu_nodes_tag (GPUNodeLink *link)
static void gpu_nodes_prune (ListBase *nodes, GPUNodeLink *outlink)
GPUPassGPU_generate_pass (ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttribs *attribs, int *builtins, const char *name)
void GPU_pass_free (GPUPass *pass)

Variables

char datatoc_gpu_shader_material_glsl []
char datatoc_gpu_shader_vertex_glsl []
static char * glsl_material_library = NULL
static const char * GPU_DATATYPE_STR [17]
static GHashFUNCTION_HASH = NULL

Detailed Description

Definition in file gpu_codegen.c.


Function Documentation

static char* code_generate_fragment ( ListBase nodes,
GPUOutput output,
const char *  UNUSEDname 
) [static]
static char* code_generate_vertex ( ListBase nodes) [static]
static void codegen_call_functions ( DynStr ds,
ListBase nodes,
GPUOutput finaloutput 
) [static]
static void codegen_convert_datatype ( DynStr ds,
int  from,
int  to,
const char *  tmp,
int  id 
) [static]
static void codegen_declare_tmps ( DynStr ds,
ListBase nodes 
) [static]
static int codegen_input_has_texture ( GPUInput input) [static]
static void codegen_print_datatype ( DynStr ds,
int  type,
float *  data 
) [static]
static void codegen_print_uniforms_functions ( DynStr ds,
ListBase nodes 
) [static]
static void codegen_set_unique_ids ( ListBase nodes) [static]
GPUNodeLink* GPU_attribute ( int  type,
const char *  name 
)
int GPU_bicubic_bump_support ( void  )

Definition at line 654 of file gpu_codegen.c.

Referenced by do_material_tex(), and GPU_code_generate_glsl_lib().

GPUNodeLink* GPU_builtin ( GPUBuiltin  builtin)
const char* GPU_builtin_name ( GPUBuiltin  builtin)
void GPU_code_generate_glsl_lib ( void  )
void GPU_codegen_exit ( void  )
void GPU_codegen_init ( void  )

Definition at line 244 of file gpu_codegen.c.

References GPU_code_generate_glsl_lib().

Referenced by GPU_extensions_init().

GPUNodeLink* GPU_dynamic_texture ( GPUTexture tex,
int  dynamictype,
void *  data 
)
GPUNodeLink* GPU_dynamic_uniform ( float *  num,
int  dynamictype,
void *  data 
)
GPUPass* GPU_generate_pass ( ListBase nodes,
GPUNodeLink outlink,
GPUVertexAttribs attribs,
int *  builtins,
const char *  name 
)
GPUNodeLink* GPU_image ( Image ima,
ImageUser iuser 
)
static void GPU_inputs_free ( ListBase inputs) [static]
int GPU_link ( GPUMaterial mat,
const char *  name,
  ... 
)
int GPU_link_changed ( GPUNodeLink link)
GPUFunction* GPU_lookup_function ( const char *  name)
static GPUNode* GPU_node_begin ( const char *  name) [static]

Definition at line 833 of file gpu_codegen.c.

References MEM_callocN(), and GPUNode::name.

Referenced by GPU_link(), GPU_stack_link(), and GPU_stack_link_mute().

static void GPU_node_end ( GPUNode UNUSEDnode) [static]

Definition at line 842 of file gpu_codegen.c.

Referenced by GPU_link(), GPU_stack_link(), and GPU_stack_link_mute().

static void GPU_node_free ( GPUNode node) [static]
static void gpu_node_input_link ( GPUNode node,
GPUNodeLink link,
int  type 
) [static]
static void gpu_node_input_socket ( GPUNode node,
GPUNodeStack sock 
) [static]
static GPUNodeLink* GPU_node_link_create ( int  type) [static]
static void GPU_node_link_free ( GPUNodeLink link) [static]

Definition at line 817 of file gpu_codegen.c.

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

Referenced by GPU_inputs_free(), and GPU_node_free().

static void GPU_node_output ( GPUNode node,
int  type,
const char *  UNUSEDname,
GPUNodeLink **  link 
) [static]
static void GPU_nodes_extract_dynamic_inputs ( GPUPass pass,
ListBase nodes 
) [static]
static void GPU_nodes_free ( ListBase nodes) [static]

Definition at line 1010 of file gpu_codegen.c.

References BLI_remlink(), ListBase::first, and GPU_node_free().

Referenced by GPU_generate_pass().

static void gpu_nodes_get_builtin_flag ( ListBase nodes,
int *  builtin 
) [static]
static void gpu_nodes_get_vertex_attributes ( ListBase nodes,
GPUVertexAttribs attribs 
) [static]
static void gpu_nodes_prune ( ListBase nodes,
GPUNodeLink outlink 
) [static]
static void gpu_nodes_tag ( GPUNodeLink link) [static]
static void gpu_parse_functions_string ( GHash hash,
char *  code 
) [static]
void GPU_pass_bind ( GPUPass pass,
double  time,
int  mipmap 
)
void GPU_pass_free ( GPUPass pass)
GPUShader* GPU_pass_shader ( GPUPass pass) [read]
void GPU_pass_unbind ( GPUPass pass)
void GPU_pass_update_uniforms ( GPUPass pass)
GPUNodeLink* GPU_socket ( GPUNodeStack sock)

Definition at line 1141 of file gpu_codegen.c.

References GPU_node_link_create(), link(), and GPUNodeLink::socket.

Referenced by gpu_shader_math(), and gpu_shader_vect_math().

int GPU_stack_link ( GPUMaterial mat,
const char *  name,
GPUNodeStack in,
GPUNodeStack out,
  ... 
)

Definition at line 1195 of file gpu_codegen.c.

References FUNCTION_QUAL_IN, GPU_lookup_function(), gpu_material_add_node(), GPU_node_begin(), GPU_node_end(), gpu_node_input_link(), gpu_node_input_socket(), GPU_node_output(), GPU_NONE, i, link(), GPUFunction::paramqual, GPUFunction::paramtype, GPUNodeLink::socket, GPUFunction::totparam, and GPUNodeStack::type.

Referenced by gpu_shader_camera(), gpu_shader_combrgb(), gpu_shader_curve_rgb(), gpu_shader_curve_vec(), gpu_shader_geom(), gpu_shader_hue_sat(), gpu_shader_invert(), gpu_shader_mapping(), gpu_shader_math(), gpu_shader_mix_rgb(), gpu_shader_normal(), gpu_shader_output(), gpu_shader_rgb(), gpu_shader_rgbtobw(), gpu_shader_seprgb(), gpu_shader_squeeze(), gpu_shader_texture(), gpu_shader_valtorgb(), gpu_shader_value(), gpu_shader_vect_math(), node_shader_gpu_add_shader(), node_shader_gpu_bsdf_anisotropic(), node_shader_gpu_bsdf_diffuse(), node_shader_gpu_bsdf_glass(), node_shader_gpu_bsdf_glossy(), node_shader_gpu_bsdf_translucent(), node_shader_gpu_bsdf_transparent(), node_shader_gpu_bsdf_velvet(), node_shader_gpu_emission(), node_shader_gpu_fresnel(), node_shader_gpu_geometry(), node_shader_gpu_light_path(), node_shader_gpu_mix_shader(), node_shader_gpu_output_material(), 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_musgrave(), node_shader_gpu_tex_noise(), node_shader_gpu_tex_sky(), node_shader_gpu_tex_voronoi(), and node_shader_gpu_tex_wave().

int GPU_stack_link_mute ( GPUMaterial mat,
const char *  name,
LinkInOutsMuteNode mlnk 
)
static int gpu_str_prefix ( const char *  str,
const char *  prefix 
) [static]

Definition at line 78 of file gpu_codegen.c.

Referenced by codegen_print_uniforms_functions(), and gpu_parse_functions_string().

static char* gpu_str_skip_token ( char *  str,
char *  token,
int  max 
) [static]

Definition at line 91 of file gpu_codegen.c.

References ELEM6, ELEM7, len(), and str.

Referenced by gpu_parse_functions_string().

GPUNodeLink* GPU_texture ( int  size,
float *  pixels 
)
GPUNodeLink* GPU_uniform ( float *  num)

Variable Documentation

Definition at line 4 of file gpu_shader_material.glsl.c.

Referenced by GPU_code_generate_glsl_lib().

Definition at line 7 of file gpu_shader_vertex.glsl.c.

Referenced by code_generate_vertex().

GHash* FUNCTION_HASH = NULL [static]

Definition at line 74 of file gpu_codegen.c.

char* glsl_material_library = NULL [static]
const char* GPU_DATATYPE_STR[17] [static]
Initial value:
 {"", "float", "vec2", "vec3", "vec4",
    NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"}

Definition at line 68 of file gpu_codegen.c.

Referenced by code_generate_vertex(), codegen_declare_tmps(), codegen_print_datatype(), codegen_print_uniforms_functions(), and gpu_parse_functions_string().