diff options
Diffstat (limited to 'source/blender/gpu/GPU_material.h')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index e229afd3323..1d2b234e7f3 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -43,30 +43,33 @@ extern "C" { struct Image; struct ImageUser; +struct ListBase; struct Material; struct Object; -struct Image; struct Scene; -struct SceneRenderLayer; struct GPUVertexAttribs; struct GPUNode; struct GPUNodeLink; struct GPUNodeStack; struct GPUMaterial; struct GPUTexture; +struct GPUUniformBuffer; struct GPULamp; struct PreviewImage; struct World; +struct bNode; +struct bNodeTree; typedef struct GPUNode GPUNode; typedef struct GPUNodeLink GPUNodeLink; typedef struct GPUMaterial GPUMaterial; -typedef struct GPULamp GPULamp; + typedef struct GPUParticleInfo GPUParticleInfo; /* Functions to create GPU Materials nodes */ typedef enum GPUType { + /* Keep in sync with GPU_DATATYPE_STR */ /* The value indicates the number of elements in each type */ GPU_NONE = 0, GPU_FLOAT = 1, @@ -76,9 +79,16 @@ typedef enum GPUType { GPU_MAT3 = 9, GPU_MAT4 = 16, + /* Values not in GPU_DATATYPE_STR */ GPU_TEX2D = 1002, - GPU_SHADOW2D = 1003, - GPU_TEXCUBE = 1004, + GPU_TEX3D = 1003, + GPU_SHADOW2D = 1004, + GPU_TEXCUBE = 1005, + + /* GLSL Struct types */ + GPU_CLOSURE = 1006, + + /* Opengl Attributes */ GPU_ATTRIB = 3001 } GPUType; @@ -98,7 +108,10 @@ typedef enum GPUBuiltin { GPU_PARTICLE_ANG_VELOCITY = (1 << 12), GPU_LOC_TO_VIEW_MATRIX = (1 << 13), GPU_INVERSE_LOC_TO_VIEW_MATRIX = (1 << 14), - GPU_OBJECT_INFO = (1 << 15) + GPU_OBJECT_INFO = (1 << 15), + GPU_VOLUME_DENSITY = (1 << 16), + GPU_VOLUME_FLAME = (1 << 17), + GPU_VOLUME_TEMPERATURE = (1 << 18) } GPUBuiltin; typedef enum GPUOpenGLBuiltin { @@ -123,14 +136,19 @@ typedef enum GPUBlendMode { typedef struct GPUNodeStack { GPUType type; - const char *name; float vec[4]; struct GPUNodeLink *link; bool hasinput; bool hasoutput; short sockettype; + bool end; } GPUNodeStack; +typedef enum GPUMaterialStatus { + GPU_MAT_FAILED = 0, + GPU_MAT_QUEUED, + GPU_MAT_SUCCESS, +} GPUMaterialStatus; #define GPU_DYNAMIC_GROUP_FROM_TYPE(f) ((f) & 0xFFFF0000) @@ -141,6 +159,7 @@ typedef struct GPUNodeStack { #define GPU_DYNAMIC_GROUP_MIST 0x00050000 #define GPU_DYNAMIC_GROUP_WORLD 0x00060000 #define GPU_DYNAMIC_GROUP_MAT 0x00070000 +#define GPU_DYNAMIC_UBO 0x00080000 typedef enum GPUDynamicType { @@ -200,6 +219,7 @@ typedef enum GPUDynamicType { GPUNodeLink *GPU_attribute(CustomDataType type, const char *name); GPUNodeLink *GPU_uniform(float *num); GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data); +GPUNodeLink *GPU_uniform_buffer(float *num, GPUType gputype); GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data); GPUNodeLink *GPU_cube_map(struct Image *ima, struct ImageUser *iuser, bool is_data); GPUNodeLink *GPU_image_preview(struct PreviewImage *prv); @@ -210,26 +230,38 @@ GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin); void GPU_node_link_set_type(GPUNodeLink *link, GPUType type); bool GPU_link(GPUMaterial *mat, const char *name, ...); -bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...); +bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out, ...); +GPUNodeLink *GPU_uniformbuffer_link_out( + struct GPUMaterial *mat, struct bNode *node, + struct GPUNodeStack *stack, const int index); void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link); void GPU_material_enable_alpha(GPUMaterial *material); GPUBuiltin GPU_get_material_builtins(GPUMaterial *material); GPUBlendMode GPU_material_alpha_blend(GPUMaterial *material, float obcol[4]); +void GPU_material_sss_profile_create(GPUMaterial *material, float *radii, short *falloff_type, float *sharpness); +struct GPUUniformBuffer *GPU_material_sss_profile_get( + GPUMaterial *material, int sample_ct, struct GPUTexture **tex_profile); + /* High level functions to create and use GPU materials */ GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo); - +GPUMaterial *GPU_material_from_nodetree_find( + struct ListBase *gpumaterials, const void *engine_type, int options); +GPUMaterial *GPU_material_from_nodetree( + struct Scene *scene, struct bNodeTree *ntree, struct ListBase *gpumaterials, const void *engine_type, int options, + const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, bool deferred); GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma, bool use_opensubdiv); GPUMaterial *GPU_material_matcap(struct Scene *scene, struct Material *ma, bool use_opensubdiv); +void GPU_material_generate_pass( + GPUMaterial *mat, const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines); void GPU_material_free(struct ListBase *gpumaterial); void GPU_materials_free(void); -bool GPU_lamp_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma); void GPU_material_bind( GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, - float viewmat[4][4], float viewinv[4][4], float cameraborder[4], bool scenelock); + float viewmat[4][4], float viewinv[4][4], float cameraborder[4]); void GPU_material_bind_uniforms( GPUMaterial *material, float obmat[4][4], float viewmat[4][4], float obcol[4], float autobumpscale, GPUParticleInfo *pi, float object_info[3]); @@ -237,6 +269,13 @@ void GPU_material_unbind(GPUMaterial *material); bool GPU_material_bound(GPUMaterial *material); struct Scene *GPU_material_scene(GPUMaterial *material); GPUMatType GPU_Material_get_type(GPUMaterial *material); +struct GPUPass *GPU_material_get_pass(GPUMaterial *material); +struct ListBase *GPU_material_get_inputs(GPUMaterial *material); +GPUMaterialStatus GPU_material_status(GPUMaterial *mat); + +struct GPUUniformBuffer *GPU_material_get_uniform_buffer(GPUMaterial *material); +void GPU_material_create_uniform_buffer(GPUMaterial *material, struct ListBase *inputs); +void GPU_material_uniform_buffer_tag_dirty(struct ListBase *gpumaterials); void GPU_material_vertex_attributes(GPUMaterial *material, struct GPUVertexAttribs *attrib); @@ -244,6 +283,8 @@ void GPU_material_vertex_attributes(GPUMaterial *material, bool GPU_material_do_color_management(GPUMaterial *mat); bool GPU_material_use_new_shading_nodes(GPUMaterial *mat); bool GPU_material_use_world_space_shading(GPUMaterial *mat); +bool GPU_material_use_domain_surface(GPUMaterial *mat); +bool GPU_material_use_domain_volume(GPUMaterial *mat); /* Exported shading */ @@ -312,26 +353,8 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma); void GPU_free_shader_export(GPUShaderExport *shader); /* Lamps */ - -GPULamp *GPU_lamp_from_blender(struct Scene *scene, struct Object *ob, struct Object *par); -void GPU_lamp_free(struct Object *ob); - -bool GPU_lamp_has_shadow_buffer(GPULamp *lamp); -void GPU_lamp_update_buffer_mats(GPULamp *lamp); -void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[4][4], int *winsize, float winmat[4][4]); -void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp); -int GPU_lamp_shadow_buffer_type(GPULamp *lamp); -int GPU_lamp_shadow_bind_code(GPULamp *lamp); -float *GPU_lamp_dynpersmat(GPULamp *lamp); - -void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[4][4]); -void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy); -void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2, - float coeff_const, float coeff_lin, float coeff_quad); -void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend); -int GPU_lamp_shadow_layer(GPULamp *lamp); GPUNodeLink *GPU_lamp_get_data( - GPUMaterial *mat, GPULamp *lamp, + GPUMaterial *mat, struct GPULamp *lamp, GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy); /* World */ @@ -355,6 +378,9 @@ void GPU_material_update_fvar_offset(GPUMaterial *gpu_material, struct DerivedMesh *dm); #endif +void GPU_pass_cache_garbage_collect(void); +void GPU_pass_cache_free(void); + #ifdef __cplusplus } #endif |