44 if (link->
users < 0) {
45 fprintf(stderr,
"gpu_node_link_free: negative refcount\n");
48 if (link->
users == 0) {
80 if (
STR_ELEM(
name,
"set_value",
"set_rgb",
"set_rgba") && (
input->type == type)) {
83 switch (
input->source) {
88 input->uniform_attr->users++;
91 input->layer_attr->users++;
94 input->texture->users++;
103 input->link->users++;
158 "dF_branch_incomplete(%s(), %g, ",
167 memcpy(
input->vec, link->
data, type *
sizeof(
float));
189 BLI_assert_msg(0,
"No gpu function for non-supported eNodeSocketDatatype");
242 else if ((material !=
nullptr) &&
279 int cmps = strcmp(attr_a->
name, attr_b->name);
281 return cmps > 0 ? 1 : 0;
284 return (attr_a->
use_dupli && !attr_b->use_dupli);
298 if (set_a->
hash_code != set_b->hash_code || set_a->
count != set_b->count) {
305 for (; attr_a && attr_b; attr_a = attr_a->
next, attr_b = attr_b->
next) {
311 return attr_a || attr_b;
346 attr->id = next_id++;
364 switch (attr->
type) {
370 BLI_assert_msg(0,
"GPUVertAttr Prefix type not found : This should not happen!");
385 if (attr->
name[0] !=
'\0') {
396 const bool is_default_color,
397 const bool is_hair_length,
398 const bool is_hair_intercept)
401 int num_attributes = 0;
403 for (; attr; attr = attr->
next) {
414 if (attr ==
nullptr) {
422 attr->
id = num_attributes;
426 if (attr !=
nullptr) {
442 for (; attr; attr = attr->
next) {
459 if (attr !=
nullptr) {
473 for (; attr; attr = attr->
next) {
480 if (attr ==
nullptr) {
487 if (attr !=
nullptr) {
503 int num_textures = 0;
505 for (; tex; tex = tex->
next) {
506 if (tex->
ima == ima && tex->
colorband == colorband && tex->
sky == sky &&
515 if (tex ==
nullptr) {
518 if (iuser !=
nullptr) {
543 graph, type,
name,
false,
false,
false);
551 if (attr ==
nullptr) {
567 if (attr ==
nullptr) {
583 if (attr ==
nullptr) {
598 if (attr ==
nullptr) {
629 if (attr ==
nullptr) {
687 graph, ima, iuser,
nullptr,
nullptr,
false, sampler_state);
699 mat, width, height, pixels, layer);
705 graph,
nullptr,
nullptr,
nullptr, sky,
false, sampler_state);
718 graph, ima, iuser,
nullptr,
nullptr,
true, sampler_state);
722 (*r_image_tiled_link)->texture =
texture;
726 (*r_image_tiled_mapping_link)->texture =
texture;
755 fprintf(stderr,
"GPU failed to find function %s\n",
name);
790 int i, totin, totout;
794 fprintf(stderr,
"GPU failed to find function %s\n",
name);
803 for (
i = 0; !
in[
i].end;
i++) {
812 for (
i = 0; !
out[
i].end;
i++) {
873 int in_argument_count,
874 int out_argument_count)
885 for (
i = 0; !
in[
i].end;
i++) {
893 for (
i = 0; !
out[
i].end;
i++) {
901 input->is_zone_io =
i >= in_argument_count;
902 input->is_duplicate =
input->is_zone_io && is_zone_end;
905 output->is_zone_io =
i >= out_argument_count;
919 switch (
input->source) {
921 input->attr->users--;
924 input->uniform_attr->users--;
927 input->layer_attr->users--;
930 input->texture->users--;
952 output->link->output =
nullptr;
990 if (!link_start || !link_start->
output) {
1001 if (node->
tag & tag) {
1016 if (node2->zone_index == node->
zone_index && !node2->is_zone_end && !(node2->tag & tag)) {
1020 zone_stack.
push(
input->link->output->node);
1067 if (attr->users == 0) {
1078 if (tex->users == 0) {
1086 if (attr->users == 0) {
1093 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_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)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
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)
void push(const T &value)
blender::gpu::Texture ** gpu_material_ramp_texture_row_set(GPUMaterial *mat, int size, const float *pixels, float *r_row)
blender::gpu::Texture ** gpu_material_sky_texture_layer_set(GPUMaterial *mat, int width, int height, const float *pixels, float *row)
GPUNodeGraph * gpu_material_node_graph(GPUMaterial *material)
GPUFunction * gpu_material_library_get_function(const char *name)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_attribute_hair_length(GPUMaterial *mat)
static GPUNodeLink * gpu_node_link_create()
static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType type)
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,...)
GPUNodeLink * GPU_attribute_with_default(GPUMaterial *mat, const eCustomDataType type, const char *name, GPUDefaultValue default_value)
static GPUNode * gpu_node_create(const char *name)
static void gpu_node_free(GPUNode *node)
static void gpu_inputs_free(ListBase *inputs)
static GPUMaterialAttribute * gpu_node_graph_add_attribute(GPUNodeGraph *graph, eCustomDataType type, const char *name, const bool is_default_color, const bool is_hair_length, const bool is_hair_intercept)
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)
void gpu_nodes_tag(GPUNodeGraph *graph, GPUNodeLink *link_start, GPUNodeTag tag)
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_node_graph_finalize_uniform_attrs(GPUNodeGraph *graph)
static void gpu_node_link_free(GPUNodeLink *link)
GPUNodeLink * GPU_attribute(GPUMaterial *mat, const eCustomDataType type, const char *name)
void gpu_node_graph_optimize(GPUNodeGraph *graph)
static GPUMaterialTexture * gpu_node_graph_add_texture(GPUNodeGraph *graph, Image *ima, ImageUser *iuser, blender::gpu::Texture **colorband, blender::gpu::Texture **sky, bool is_tiled, GPUSamplerState sampler_state)
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)
bool GPU_stack_link_zone(GPUMaterial *material, const bNode *bnode, const char *name, GPUNodeStack *in, GPUNodeStack *out, int zone_index, bool is_zone_end, int in_argument_count, int out_argument_count)
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)
GPUNodeLink * GPU_attribute_hair_intercept(GPUMaterial *mat)
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)
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,...)
static void gpu_node_output(GPUNode *node, const GPUType type, GPUNodeLink **link)
GPUNodeLink * GPU_uniform(const float *num)
@ GPU_SOURCE_FUNCTION_CALL
@ GPU_SOURCE_TEX_TILED_MAPPING
@ GPU_SOURCE_UNIFORM_ATTR
@ GPU_NODE_TAG_DISPLACEMENT
@ GPU_NODE_TAG_COMPOSITOR
@ 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
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
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[]
GPUType paramtype[MAX_PARAMETER]
GPUFunctionQual paramqual[MAX_PARAMETER]
GPUMaterialAttribute * next
GPUDefaultValue default_value
blender::gpu::Texture ** sky
GPUSamplerState sampler_state
char tiled_mapping_name[32]
GPUMaterialTexture * next
blender::gpu::Texture ** colorband
ListBase outlink_compositor
GPUNodeLink * outlink_displacement
GPUNodeLink * outlink_thickness
GPUNodeLink * outlink_volume
GPUNodeLink * outlink_surface
GPUUniformAttrList uniform_attrs
ListBase material_functions
struct GPUNodeLink::@254204117047043037024235213364262344267122011046::@006053163006010023266176363226167130142045343252 differentiate_float
GPUMaterialTexture * texture
GPULayerAttr * layer_attr
GPUNodeLinkType link_type
GPUMaterialAttribute * attr
const char * function_name
GPUUniformAttr * uniform_attr
static constexpr GPUSamplerState internal_sampler()