From b18c2a3c413b7741b2a854b7bd25721352be2589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 2 Jun 2020 16:58:07 +0200 Subject: EEVEE: Refactor of eevee_material.c These are the modifications: -With DRW modification we reduce the number of passes we need to populate. -Rename passes for consistent naming. -Reduce complexity in code compilation -Cleanup how renderpass accumulation passes are setup, using pass instances. -Make sculpt mode compatible with shadows -Make hair passes compatible with SSS -Error shader and lookdev materials now use standalone materials. -Support default shader (world and material) using a default nodetree internally. -Change BLEND_CLIP to be emulated by gpu nodetree. Making less shader variations. -Use BLI_memblock for cache memory allocation. -Renderpasses are handled by switching a UBO ref bind. One major hack in this patch is the use of modified pointer as ghash keys. This rely on the assumption that the keys will never overlap because the number of options per key will never be bigger than the pointed struct. The use of one single nodetree to support default material is also a bit hacky since it won't support concurent usage of this nodetree. (see EEVEE_shader_default_surface_nodetree) Another change is that objects with shader errors now appear solid magenta instead of shaded magenta. This is only because of code reuse purpose but could be changed if really needed. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7642 --- source/blender/gpu/intern/gpu_material.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/gpu/intern/gpu_material.c') diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 97e4c880644..d2384b9c065 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -209,6 +209,11 @@ GPUPass *GPU_material_get_pass(GPUMaterial *material) return material->pass; } +GPUShader *GPU_material_get_shader(GPUMaterial *material) +{ + return material->pass ? GPU_pass_shader_get(material->pass) : NULL; +} + /* Return can be NULL if it's a world material. */ Material *GPU_material_get_material(GPUMaterial *material) { @@ -662,6 +667,9 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene, /* Caller must re-use materials. */ BLI_assert(GPU_material_from_nodetree_find(gpumaterials, engine_type, options) == NULL); + /* HACK: Eevee assume this to create Ghash keys. */ + BLI_assert(sizeof(GPUPass) > 16); + /* allocate material */ GPUMaterial *mat = MEM_callocN(sizeof(GPUMaterial), "GPUMaterial"); mat->ma = ma; -- cgit v1.2.3