Blender  V2.59
Classes | Typedefs | Enumerations | 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 <string.h>
#include <stdarg.h>

Go to the source code of this file.

Classes

struct  GPUNode
struct  GPUNodeLink
struct  GPUOutput
struct  GPUInput
struct  GPUPass

Typedefs

typedef enum GPUDataSource GPUDataSource
typedef struct GPUOutput GPUOutput
typedef struct GPUInput GPUInput

Enumerations

enum  GPUDataSource {
  GPU_SOURCE_VEC_UNIFORM, GPU_SOURCE_BUILTIN, GPU_SOURCE_TEX_PIXEL, GPU_SOURCE_TEX,
  GPU_SOURCE_ATTRIB
}

Functions

static void BLI_dynstr_printf (DynStr *dynstr, const char *format,...)
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_extensions_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)
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)
GPUNodeLinkGPU_image (Image *ima, ImageUser *iuser)
GPUNodeLinkGPU_texture (int size, float *pixels)
GPUNodeLinkGPU_dynamic_texture (GPUTexture *tex)
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_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 const char * GPU_DATATYPE_STR [17]
static GHashFUNCTION_HASH = NULL

Detailed Description

Definition in file gpu_codegen.c.


Typedef Documentation

typedef struct GPUInput GPUInput
typedef struct GPUOutput GPUOutput

Enumeration Type Documentation

Enumerator:
GPU_SOURCE_VEC_UNIFORM 
GPU_SOURCE_BUILTIN 
GPU_SOURCE_TEX_PIXEL 
GPU_SOURCE_TEX 
GPU_SOURCE_ATTRIB 

Definition at line 76 of file gpu_codegen.c.


Function Documentation

static void BLI_dynstr_printf ( DynStr dynstr,
const char *  format,
  ... 
) [static]
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]

Definition at line 389 of file gpu_codegen.c.

References BLI_dynstr_append(), BLI_dynstr_printf(), GPU_FLOAT, GPU_VEC2, GPU_VEC3, and GPU_VEC4.

Referenced by codegen_call_functions().

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]

Definition at line 432 of file gpu_codegen.c.

References BLI_dynstr_append(), BLI_dynstr_printf(), GPU_DATATYPE_STR, and i.

Referenced by codegen_print_uniforms_functions().

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 
)
GPUNodeLink* GPU_builtin ( GPUBuiltin  builtin)
const char* GPU_builtin_name ( GPUBuiltin  builtin)
GPUNodeLink* GPU_dynamic_texture ( GPUTexture tex)

Definition at line 1211 of file gpu_codegen.c.

References GPUNodeLink::dynamic, GPUNodeLink::dynamictex, GPU_node_link_create(), and link().

Referenced by shade_one_light().

GPUNodeLink* GPU_dynamic_uniform ( float *  num)
void GPU_extensions_exit ( void  )
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 916 of file gpu_codegen.c.

References MEM_callocN(), and GPUNode::name.

Referenced by GPU_link(), and GPU_stack_link().

static void GPU_node_end ( GPUNode UNUSEDnode) [static]

Definition at line 925 of file gpu_codegen.c.

Referenced by GPU_link(), and GPU_stack_link().

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 900 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 1094 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 1221 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,
  ... 
)
static int gpu_str_prefix ( const char *  str,
const char *  prefix 
) [static]

Definition at line 196 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 209 of file gpu_codegen.c.

References ELEM5, ELEM6, 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_generate_pass(), and GPU_lookup_function().

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

Referenced by code_generate_vertex().

GHash* FUNCTION_HASH = NULL [static]

Definition at line 192 of file gpu_codegen.c.

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

Definition at line 84 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().