43 if (link->
users < 0) {
44 fprintf(stderr,
"gpu_node_link_free: negative refcount\n");
47 if (link->
users == 0) {
77 if (
STR_ELEM(name,
"set_value",
"set_rgb",
"set_rgba") && (
input->type == type)) {
80 switch (
input->source) {
85 input->uniform_attr->users++;
88 input->layer_attr->users++;
91 input->texture->users++;
100 input->link->users++;
155 "dF_branch_incomplete(%s(), %g, ",
164 memcpy(
input->vec, link->
data, type *
sizeof(
float));
186 BLI_assert_msg(0,
"No gpu function for non-supported eNodeSocketDatatype");
239 else if ((material !=
nullptr) &&
276 int cmps = strcmp(attr_a->
name, attr_b->name);
278 return cmps > 0 ? 1 : 0;
281 return (attr_a->
use_dupli && !attr_b->use_dupli);
295 if (set_a->
hash_code != set_b->hash_code || set_a->
count != set_b->count) {
302 for (; attr_a && attr_b; attr_a = attr_a->
next, attr_b = attr_b->
next) {
308 return attr_a || attr_b;
343 attr->id = next_id++;
358 switch (attr->
type) {
364 BLI_assert_msg(0,
"GPUVertAttr Prefix type not found : This should not happen!");
379 if (attr->
name[0] !=
'\0') {
390 const bool is_default_color,
391 const bool is_hair_length)
394 int num_attributes = 0;
396 for (; attr; attr = attr->
next) {
406 if (attr ==
nullptr) {
413 attr->
id = num_attributes;
417 if (attr !=
nullptr) {
433 for (; attr; attr = attr->
next) {
450 if (attr !=
nullptr) {
464 for (; attr; attr = attr->
next) {
471 if (attr ==
nullptr) {
478 if (attr !=
nullptr) {
488 GPUTexture **colorband,
494 int num_textures = 0;
496 for (; tex; tex = tex->
next) {
497 if (tex->
ima == ima && tex->
colorband == colorband && tex->
sky == sky &&
506 if (tex ==
nullptr) {
509 if (iuser !=
nullptr) {
541 if (attr ==
nullptr) {
557 if (attr ==
nullptr) {
573 if (attr ==
nullptr) {
604 if (attr ==
nullptr) {
662 graph, ima, iuser,
nullptr,
nullptr,
false, sampler_state);
679 graph,
nullptr,
nullptr,
nullptr, sky,
false, sampler_state);
692 graph, ima, iuser,
nullptr,
nullptr,
true, sampler_state);
696 (*r_image_tiled_link)->texture =
texture;
700 (*r_image_tiled_mapping_link)->texture =
texture;
729 fprintf(stderr,
"GPU failed to find function %s\n", name);
764 int i, totin, totout;
768 fprintf(stderr,
"GPU failed to find function %s\n", name);
777 for (
i = 0; !
in[
i].end;
i++) {
786 for (
i = 0; !
out[
i].end;
i++) {
845 switch (
input->source) {
847 input->attr->users--;
850 input->uniform_attr->users--;
853 input->layer_attr->users--;
856 input->texture->users--;
878 output->link->output =
nullptr;
923 if (!link || !link->
output) {
928 if (node->
tag & tag) {
978 if (attr->users == 0) {
989 if (tex->users == 0) {
997 if (attr->users == 0) {
1004 if (attr->users == 0) {
#define BLI_assert_msg(a, msg)
unsigned int BLI_ghashutil_uinthash(unsigned int key)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void BLI_listbase_sort(ListBase *listbase, int(*cmp)(const void *, const void *)) ATTR_NONNULL(1
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const size_t num
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
@ GPU_MATFLAG_OBJECT_INFO
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
static constexpr int GPU_MAX_UNIFORM_ATTR
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
GPUTexture ** gpu_material_ramp_texture_row_set(GPUMaterial *mat, int size, const float *pixels, float *r_row)
GPUTexture ** gpu_material_sky_texture_layer_set(GPUMaterial *mat, int width, int height, const float *pixels, float *row)
GPUNodeGraph * gpu_material_node_graph(GPUMaterial *material)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
GPUFunction * gpu_material_library_use_function(GSet *used_libraries, const char *name)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_attribute_hair_length(GPUMaterial *mat)
static GPUNodeLink * gpu_node_link_create()
GPUNodeLink * GPU_layer_attribute(GPUMaterial *mat, const char *name)
GPUNodeLink * GPU_attribute_default_color(GPUMaterial *mat)
bool GPU_stack_link(GPUMaterial *material, const bNode *bnode, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
static GPUMaterialAttribute * gpu_node_graph_add_attribute(GPUNodeGraph *graph, eCustomDataType type, const char *name, const bool is_default_color, const bool is_hair_length)
static GPUNode * gpu_node_create(const char *name)
static void gpu_node_free(GPUNode *node)
static void gpu_inputs_free(ListBase *inputs)
static void gpu_node_output(GPUNode *node, const eGPUType type, GPUNodeLink **link)
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row)
static void gpu_node_input_socket(GPUMaterial *material, const bNode *bnode, GPUNode *node, GPUNodeStack *sock, const int index)
static GPULayerAttr * gpu_node_graph_add_layer_attribute(GPUNodeGraph *graph, const char *name)
static GPUUniformAttr * gpu_node_graph_add_uniform_attribute(GPUNodeGraph *graph, const char *name, bool use_dupli)
void gpu_nodes_tag(GPUNodeLink *link, eGPUNodeTag tag)
void gpu_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
static void gpu_node_link_free(GPUNodeLink *link)
static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType type)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, const eCustomDataType type, const char *name)
void gpu_node_graph_optimize(GPUNodeGraph *graph)
GPUNodeLink * GPU_image(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state)
void GPU_uniform_attr_list_copy(GPUUniformAttrList *dest, const GPUUniformAttrList *src)
static uint uniform_attr_list_hash(const void *key)
GHash * GPU_uniform_attr_list_hash_new(const char *info)
void GPU_uniform_attr_list_free(GPUUniformAttrList *set)
GPUNodeLink * GPU_uniform_attribute(GPUMaterial *mat, const char *name, bool use_dupli, uint32_t *r_hash)
GPUNodeLink * GPU_image_sky(GPUMaterial *mat, int width, int height, const float *pixels, float *layer, GPUSamplerState sampler_state)
void gpu_node_graph_free(GPUNodeGraph *graph)
void gpu_node_graph_prune_unused(GPUNodeGraph *graph)
void GPU_image_tiled(GPUMaterial *mat, Image *ima, ImageUser *iuser, GPUSamplerState sampler_state, GPUNodeLink **r_image_tiled_link, GPUNodeLink **r_image_tiled_mapping_link)
static void attr_input_name(GPUMaterialAttribute *attr)
static char attr_prefix_get(const GPUMaterialAttribute *attr)
static bool uniform_attr_list_cmp(const void *a, const void *b)
GPUNodeLink * GPU_differentiate_float_function(const char *function_name, const float filter_width)
static GPUMaterialTexture * gpu_node_graph_add_texture(GPUNodeGraph *graph, Image *ima, ImageUser *iuser, GPUTexture **colorband, GPUTexture **sky, bool is_tiled, GPUSamplerState sampler_state)
static bool gpu_stack_link_v(GPUMaterial *material, const bNode *bnode, const char *name, GPUNodeStack *in, GPUNodeStack *out, va_list params)
static int uniform_attr_sort_cmp(const void *a, const void *b)
static const char * gpu_uniform_set_function_from_type(eNodeSocketDatatype type)
void gpu_node_graph_free_nodes(GPUNodeGraph *graph)
GPUNodeLink * GPU_attribute_with_default(GPUMaterial *mat, const eCustomDataType type, const char *name, eGPUDefaultValue default_value)
static GPUNodeLink * gpu_uniformbuffer_link(GPUMaterial *mat, const bNode *node, GPUNodeStack *stack, const int index, const eNodeSocketInOut in_out)
bool GPU_link(GPUMaterial *mat, const char *name,...)
GPUNodeLink * GPU_uniform(const float *num)
@ GPU_NODE_TAG_DISPLACEMENT
@ GPU_NODE_TAG_COMPOSITOR
@ GPU_SOURCE_FUNCTION_CALL
@ GPU_SOURCE_TEX_TILED_MAPPING
@ GPU_SOURCE_UNIFORM_ATTR
@ GPU_NODE_LINK_IMAGE_SKY
@ GPU_NODE_LINK_LAYER_ATTR
@ GPU_NODE_LINK_IMAGE_TILED
@ GPU_NODE_LINK_IMAGE_TILED_MAPPING
@ GPU_NODE_LINK_COLORBAND
@ GPU_NODE_LINK_UNIFORM_ATTR
@ GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN
void * MEM_callocN(size_t len, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
static blender::bke::bNodeSocketTemplate inputs[]
eGPUType paramtype[MAX_PARAMETER]
GPUFunctionQual paramqual[MAX_PARAMETER]
eGPUDefaultValue default_value
GPUMaterialAttribute * next
GPUSamplerState sampler_state
char tiled_mapping_name[32]
GPUMaterialTexture * next
ListBase outlink_compositor
GPUNodeLink * outlink_displacement
GPUNodeLink * outlink_thickness
GPUNodeLink * outlink_volume
GPUNodeLink * outlink_surface
GPUUniformAttrList uniform_attrs
ListBase material_functions
GPUMaterialTexture * texture
GPULayerAttr * layer_attr
GPUNodeLinkType link_type
struct GPUNodeLink::@226214374102223062167264062033114104247254224107::@001351171304325070155123067256244027115274121305 differentiate_float
GPUMaterialAttribute * attr
const char * function_name
GPUUniformAttr * uniform_attr
static constexpr GPUSamplerState internal_sampler()