Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_materials.c
| Show First 20 Lines • Show All 608 Lines • ▼ Show 20 Lines | DRWPass *shading_pass = (DRWPass *[]){ | ||||
| psl->material_cull_ps, | psl->material_cull_ps, | ||||
| }[option]; | }[option]; | ||||
| /* Hair are rendered inside the non-cull pass but needs to have a separate cache key */ | /* Hair are rendered inside the non-cull pass but needs to have a separate cache key */ | ||||
| option = option * 2 + is_hair; | option = option * 2 + is_hair; | ||||
| /* Search for the same shaders usage in the pass. */ | /* Search for the same shaders usage in the pass. */ | ||||
| /* HACK: Assume the struct will never be smaller than our variations. | /* HACK: Assume the struct will never be smaller than our variations. | ||||
| * This allow us to only keep one ghash and avoid bigger keys comparisons/hashing. */ | * This allow us to only keep one ghash and avoid bigger keys comparisons/hashing. */ | ||||
| BLI_assert(option <= 16); | BLI_assert(option <= 16); | ||||
jbakker: Could be removed as GPUMaterial is large... | |||||
| struct GPUShader *sh = GPU_material_get_shader(gpumat); | struct GPUShader *sh = GPU_material_get_shader(gpumat); | ||||
| void *cache_key = (char *)sh + option; | void *cache_key = (char *)sh + option; | ||||
| DRWShadingGroup *grp, **grp_p; | DRWShadingGroup *grp, **grp_p; | ||||
| if (BLI_ghash_ensure_p(pd->material_hash, cache_key, (void ***)&grp_p)) { | if (BLI_ghash_ensure_p(pd->material_hash, cache_key, (void ***)&grp_p)) { | ||||
| /* This GPUShader has already been used by another material. | /* This GPUShader has already been used by another material. | ||||
| * Add new shading group just after to avoid shader switching cost. */ | * Add new shading group just after to avoid shader switching cost. */ | ||||
| grp = DRW_shgroup_create_sub(*grp_p); | grp = DRW_shgroup_create_sub(*grp_p); | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | static void eevee_hair_cache_populate(EEVEE_Data *vedata, | ||||
| ModifierData *md, | ModifierData *md, | ||||
| int matnr, | int matnr, | ||||
| bool *cast_shadow) | bool *cast_shadow) | ||||
| { | { | ||||
| EeveeMaterialCache matcache = eevee_material_cache_get(vedata, sldata, ob, matnr - 1, true); | EeveeMaterialCache matcache = eevee_material_cache_get(vedata, sldata, ob, matnr - 1, true); | ||||
| if (matcache.depth_grp) { | if (matcache.depth_grp) { | ||||
| *matcache.depth_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.depth_grp); | *matcache.depth_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.depth_grp); | ||||
| DRW_shgroup_add_material_resources(*matcache.depth_grp_p, matcache.shading_gpumat); | |||||
| } | } | ||||
| if (matcache.shading_grp) { | if (matcache.shading_grp) { | ||||
| *matcache.shading_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.shading_grp); | *matcache.shading_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.shading_grp); | ||||
| DRW_shgroup_add_material_resources(*matcache.shading_grp_p, matcache.shading_gpumat); | |||||
| } | } | ||||
| if (matcache.shadow_grp) { | if (matcache.shadow_grp) { | ||||
| *matcache.shadow_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.shadow_grp); | *matcache.shadow_grp_p = DRW_shgroup_hair_create_sub(ob, psys, md, matcache.shadow_grp); | ||||
| DRW_shgroup_add_material_resources(*matcache.shadow_grp_p, matcache.shading_gpumat); | |||||
| *cast_shadow = true; | *cast_shadow = true; | ||||
| } | } | ||||
| EEVEE_motion_blur_hair_cache_populate(sldata, vedata, ob, psys, md); | EEVEE_motion_blur_hair_cache_populate(sldata, vedata, ob, psys, md); | ||||
| } | } | ||||
| #define ADD_SHGROUP_CALL(shgrp, ob, geom, oedata) \ | #define ADD_SHGROUP_CALL(shgrp, ob, geom, oedata) \ | ||||
| do { \ | do { \ | ||||
| ▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines | |||||
Could be removed as GPUMaterial is large...