Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_material.c
| Show All 31 Lines | |||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_world_types.h" | #include "DNA_world_types.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "BLI_string_utils.h" | #include "BLI_string_utils.h" | ||||
| #include "BLI_ghash.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_node.h" | #include "BKE_node.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "GPU_material.h" | #include "GPU_material.h" | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_texture.h" | #include "GPU_texture.h" | ||||
| ▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | struct GPUMaterial { | ||||
| int sss_samples; | int sss_samples; | ||||
| short int sss_falloff; | short int sss_falloff; | ||||
| float sss_sharpness; | float sss_sharpness; | ||||
| bool sss_dirty; | bool sss_dirty; | ||||
| GPUTexture *coba_tex; /* 1D Texture array containing all color bands. */ | GPUTexture *coba_tex; /* 1D Texture array containing all color bands. */ | ||||
| GPUColorBandBuilder *coba_builder; | GPUColorBandBuilder *coba_builder; | ||||
| GSet *used_glsl_files; | |||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||
| char name[64]; | char name[64]; | ||||
| #endif | #endif | ||||
| }; | }; | ||||
| enum { | enum { | ||||
| GPU_DOMAIN_SURFACE = (1 << 0), | GPU_DOMAIN_SURFACE = (1 << 0), | ||||
| GPU_DOMAIN_VOLUME = (1 << 1), | GPU_DOMAIN_VOLUME = (1 << 1), | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | if (material->sss_tex_profile != NULL) { | ||||
| GPU_texture_free(material->sss_tex_profile); | GPU_texture_free(material->sss_tex_profile); | ||||
| } | } | ||||
| if (material->sss_profile != NULL) { | if (material->sss_profile != NULL) { | ||||
| GPU_uniformbuffer_free(material->sss_profile); | GPU_uniformbuffer_free(material->sss_profile); | ||||
| } | } | ||||
| if (material->coba_tex != NULL) { | if (material->coba_tex != NULL) { | ||||
| GPU_texture_free(material->coba_tex); | GPU_texture_free(material->coba_tex); | ||||
| } | } | ||||
| BLI_gset_free(material->used_glsl_files, NULL); | |||||
| } | } | ||||
| void GPU_material_free(ListBase *gpumaterial) | void GPU_material_free(ListBase *gpumaterial) | ||||
| { | { | ||||
| for (LinkData *link = gpumaterial->first; link; link = link->next) { | for (LinkData *link = gpumaterial->first; link; link = link->next) { | ||||
| GPUMaterial *material = link->data; | GPUMaterial *material = link->data; | ||||
| gpu_material_free_single(material); | gpu_material_free_single(material); | ||||
| MEM_freeN(material); | MEM_freeN(material); | ||||
| ▲ Show 20 Lines • Show All 383 Lines • ▼ Show 20 Lines | void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link) | ||||
| } | } | ||||
| } | } | ||||
| void gpu_material_add_node(GPUMaterial *material, GPUNode *node) | void gpu_material_add_node(GPUMaterial *material, GPUNode *node) | ||||
| { | { | ||||
| BLI_addtail(&material->nodes, node); | BLI_addtail(&material->nodes, node); | ||||
| } | } | ||||
| GSet *gpu_material_used_glsl_files(GPUMaterial *material) | |||||
| { | |||||
| return material->used_glsl_files; | |||||
| } | |||||
| /* Return true if the material compilation has not yet begin or begin. */ | /* Return true if the material compilation has not yet begin or begin. */ | ||||
| eGPUMaterialStatus GPU_material_status(GPUMaterial *mat) | eGPUMaterialStatus GPU_material_status(GPUMaterial *mat) | ||||
| { | { | ||||
| return mat->status; | return mat->status; | ||||
| } | } | ||||
| /* Code generation */ | /* Code generation */ | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | GPUMaterial *GPU_material_from_nodetree(Scene *scene, | ||||
| mat->engine_type = engine_type; | mat->engine_type = engine_type; | ||||
| mat->options = options; | mat->options = options; | ||||
| #ifndef NDEBUG | #ifndef NDEBUG | ||||
| BLI_snprintf(mat->name, sizeof(mat->name), "%s", name); | BLI_snprintf(mat->name, sizeof(mat->name), "%s", name); | ||||
| #else | #else | ||||
| UNUSED_VARS(name); | UNUSED_VARS(name); | ||||
| #endif | #endif | ||||
| mat->used_glsl_files = BLI_gset_new( | |||||
| BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "GPUMaterial.used_glsl_files"); | |||||
| /* localize tree to create links for reroute and mute */ | /* localize tree to create links for reroute and mute */ | ||||
| bNodeTree *localtree = ntreeLocalize(ntree); | bNodeTree *localtree = ntreeLocalize(ntree); | ||||
| ntreeGPUMaterialNodes(localtree, mat, &has_surface_output, &has_volume_output); | ntreeGPUMaterialNodes(localtree, mat, &has_surface_output, &has_volume_output); | ||||
| gpu_material_ramp_texture_build(mat); | gpu_material_ramp_texture_build(mat); | ||||
| SET_FLAG_FROM_TEST(mat->domain, has_surface_output, GPU_DOMAIN_SURFACE); | SET_FLAG_FROM_TEST(mat->domain, has_surface_output, GPU_DOMAIN_SURFACE); | ||||
| SET_FLAG_FROM_TEST(mat->domain, has_volume_output, GPU_DOMAIN_VOLUME); | SET_FLAG_FROM_TEST(mat->domain, has_volume_output, GPU_DOMAIN_VOLUME); | ||||
| ▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines | |||||