[Bf-blender-cvs] [6e18b02065d] tmp-eevee-material-refactor: EEVEE: Rename / merge passes using new DRWPass chaining/instancing

Clément Foucault noreply at git.blender.org
Thu May 14 16:58:57 CEST 2020


Commit: 6e18b02065d3593e170cb07cc8b11af17e183d8e
Author: Clément Foucault
Date:   Fri May 8 16:15:21 2020 +0200
Branches: tmp-eevee-material-refactor
https://developer.blender.org/rB6e18b02065d3593e170cb07cc8b11af17e183d8e

EEVEE: Rename / merge passes using new DRWPass chaining/instancing

Now calling DRW_pass_draw on material_ps will draw all opaque passes.
Same for depth_ps for opaque prepass.

===================================================================

M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/eevee_materials.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/draw/engines/eevee/eevee_render.c
M	source/blender/draw/engines/eevee/eevee_subsurface.c

===================================================================

diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index a1112eb92df..954ba57562c 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -274,8 +274,7 @@ static void eevee_draw_scene(void *vedata)
 
     /* Depth prepass */
     DRW_stats_group_start("Prepass");
-    DRW_draw_pass(psl->depth_pass);
-    DRW_draw_pass(psl->depth_pass_cull);
+    DRW_draw_pass(psl->depth_ps);
     DRW_stats_group_end();
 
     /* Create minmax texture */
@@ -289,9 +288,9 @@ static void eevee_draw_scene(void *vedata)
     /* Shading pass */
     DRW_stats_group_start("Shading");
     if (DRW_state_draw_background()) {
-      DRW_draw_pass(psl->background_pass);
+      DRW_draw_pass(psl->background_ps);
     }
-    EEVEE_materials_draw_opaque(sldata, psl);
+    DRW_draw_pass(psl->material_ps);
     EEVEE_subsurface_data_render(sldata, vedata);
     DRW_stats_group_end();
 
@@ -306,9 +305,8 @@ static void eevee_draw_scene(void *vedata)
 
     /* Opaque refraction */
     DRW_stats_group_start("Opaque Refraction");
-    DRW_draw_pass(psl->refract_depth_pass);
-    DRW_draw_pass(psl->refract_depth_pass_cull);
-    DRW_draw_pass(psl->refract_pass);
+    DRW_draw_pass(psl->depth_refract_ps);
+    DRW_draw_pass(psl->material_refract_ps);
     DRW_stats_group_end();
 
     /* Volumetrics Resolve Opaque */
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 9816632c0c3..1e5509a6119 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -923,12 +923,10 @@ static void lightbake_render_scene_face(int face, EEVEE_BakeRenderData *user_dat
   GPU_framebuffer_bind(face_fb[face]);
   GPU_framebuffer_clear_depth(face_fb[face], 1.0f);
 
-  DRW_draw_pass(psl->depth_pass);
-  DRW_draw_pass(psl->depth_pass_cull);
+  DRW_draw_pass(psl->depth_ps);
   DRW_draw_pass(psl->probe_background);
-  EEVEE_materials_draw_opaque(sldata, psl);
-  DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
-  DRW_draw_pass(psl->sss_pass_cull);
+  DRW_draw_pass(psl->material_ps);
+  DRW_draw_pass(psl->material_sss_ps); /* Only output standard pass */
   DRW_draw_pass(psl->transparent_pass);
 }
 
@@ -987,10 +985,8 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
   /* Slight modification: we handle refraction as normal
    * shading and don't do SSRefraction. */
 
-  DRW_draw_pass(psl->depth_pass_clip);
-  DRW_draw_pass(psl->depth_pass_clip_cull);
-  DRW_draw_pass(psl->refract_depth_pass_clip);
-  DRW_draw_pass(psl->refract_depth_pass_clip_cull);
+  DRW_draw_pass(psl->depth_ps);
+  DRW_draw_pass(psl->depth_refract_ps);
 
   DRW_draw_pass(psl->probe_background);
   EEVEE_create_minmax_buffer(vedata, tmp_planar_depth, layer);
@@ -999,10 +995,9 @@ static void lightbake_render_scene_reflected(int layer, EEVEE_BakeRenderData *us
   GPU_framebuffer_bind(fbl->planarref_fb);
 
   /* Shading pass */
-  EEVEE_materials_draw_opaque(sldata, psl);
-  DRW_draw_pass(psl->sss_pass); /* Only output standard pass */
-  DRW_draw_pass(psl->sss_pass_cull);
-  DRW_draw_pass(psl->refract_pass);
+  DRW_draw_pass(psl->material_ps);
+  DRW_draw_pass(psl->material_sss_ps); /* Only output standard pass */
+  DRW_draw_pass(psl->material_refract_ps);
 
   /* Transparent */
   if (DRW_state_is_image_render()) {
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 45f1f0b28f4..9c07527c3b5 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1183,7 +1183,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
   }
 
   {
-    DRW_PASS_CREATE(psl->background_pass, DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
+    DRW_PASS_CREATE(psl->background_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
 
     struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
     DRWShadingGroup *grp = NULL;
@@ -1193,7 +1193,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 
     const float *col = G_draw.block.colorBackground;
 
-    EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->background_pass, wo, NULL);
+    EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->background_ps, wo, NULL);
 
     if (!grp && wo) {
       col = &wo->horr;
@@ -1205,7 +1205,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 
         switch (GPU_material_status(gpumat)) {
           case GPU_MAT_SUCCESS:
-            grp = DRW_shgroup_material_create(gpumat, psl->background_pass);
+            grp = DRW_shgroup_material_create(gpumat, psl->background_ps);
             add_background_uniforms(grp, sldata, vedata);
             DRW_shgroup_call(grp, geom, NULL);
             break;
@@ -1224,82 +1224,50 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 
     /* Fallback if shader fails or if not using nodetree. */
     if (grp == NULL) {
-      grp = DRW_shgroup_create(e_data.default_background, psl->background_pass);
+      grp = DRW_shgroup_create(e_data.default_background, psl->background_ps);
       DRW_shgroup_uniform_vec3(grp, "color", col, 1);
       DRW_shgroup_uniform_float(grp, "backgroundAlpha", &stl->g_data->background_alpha, 1);
       DRW_shgroup_call(grp, geom, NULL);
     }
   }
 
-  {
-    DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
-    DRW_PASS_CREATE(psl->depth_pass, state);
-    stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.default_prepass_sh, psl->depth_pass);
-
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK;
-    DRW_PASS_CREATE(psl->depth_pass_cull, state);
-    stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.default_prepass_sh,
-                                                       psl->depth_pass_cull);
-
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES;
-    DRW_PASS_CREATE(psl->depth_pass_clip, state);
-    stl->g_data->depth_shgrp_clip = DRW_shgroup_create(e_data.default_prepass_clip_sh,
-                                                       psl->depth_pass_clip);
-
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES |
-            DRW_STATE_CULL_BACK;
-    DRW_PASS_CREATE(psl->depth_pass_clip_cull, state);
-    stl->g_data->depth_shgrp_clip_cull = DRW_shgroup_create(e_data.default_prepass_clip_sh,
-                                                            psl->depth_pass_clip_cull);
-  }
+#define EEVEE_PASS_CREATE(pass, state) \
+  do { \
+    DRW_PASS_CREATE(psl->pass##_ps, state); \
+    DRW_PASS_CREATE(psl->pass##_cull_ps, state | DRW_STATE_CULL_BACK); \
+    DRW_pass_link(psl->pass##_ps, psl->pass##_cull_ps); \
+  } while (0)
 
-  {
-    DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES;
-    DRW_PASS_CREATE(psl->material_pass, state);
-    DRW_PASS_CREATE(psl->material_pass_cull, state | DRW_STATE_CULL_BACK);
-  }
+#define EEVEE_CLIP_PASS_CREATE(pass, state) \
+  do { \
+    DRWState st = state | DRW_STATE_CLIP_PLANES; \
+    DRW_PASS_INSTANCE_CREATE(psl->pass##_clip_ps, psl->pass##_ps, st); \
+    DRW_PASS_INSTANCE_CREATE( \
+        psl->pass##_clip_cull_ps, psl->pass##_cull_ps, st | DRW_STATE_CULL_BACK); \
+    DRW_pass_link(psl->pass##_clip_ps, psl->pass##_clip_cull_ps); \
+  } while (0)
 
   {
-    DRWState state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
-    DRW_PASS_CREATE(psl->refract_depth_pass, state);
-    stl->g_data->refract_depth_shgrp = DRW_shgroup_create(e_data.default_prepass_sh,
-                                                          psl->refract_depth_pass);
+    DRWState state_depth = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL;
+    DRWState state_shading = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES;
+    DRWState state_sss = DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS;
 
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK;
-    DRW_PASS_CREATE(psl->refract_depth_pass_cull, state);
-    stl->g_data->refract_depth_shgrp_cull = DRW_shgroup_create(e_data.default_prepass_sh,
-                                                               psl->refract_depth_pass_cull);
+    EEVEE_PASS_CREATE(depth, state_depth);
+    EEVEE_CLIP_PASS_CREATE(depth, state_depth);
 
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES;
-    DRW_PASS_CREATE(psl->refract_depth_pass_clip, state);
-    stl->g_data->refract_depth_shgrp_clip = DRW_shgroup_create(e_data.default_prepass_clip_sh,
-                                                               psl->refract_depth_pass_clip);
+    EEVEE_PASS_CREATE(depth_refract, state_depth);
+    EEVEE_CLIP_PASS_CREATE(depth_refract, state_depth);
 
-    state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES |
-            DRW_STATE_CULL_BACK;
-    DRW_PASS_CREATE(psl->refract_depth_pass_clip_cull, state);
-    stl->g_data->refract_depth_shgrp_clip_cull = DRW_shgroup_create(
-        e_data.default_prepass_clip_sh, psl->refract_depth_pass_clip_cull);
+    EEVEE_PASS_CREATE(material, state_shading);
+    EEVEE_PASS_CREATE(material_refract, state_shading);
+    EEVEE_PASS_CREATE(material_sss, state_shading | state_sss);
   }
-
   {
-    DRWState state = (DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES);
-    DRW_PASS_CREATE(psl->refract_pass, state);
-  }
 
-  {
-    DRWState state = (DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES |
-                      DRW_STATE_WRITE_STENCIL | DRW_STATE_STENCIL_ALWAYS);
-    DRW_PASS_CREATE(psl->sss_pass, state);
-    DRW_PASS_CREATE(psl->sss_pass_cull, state | DRW_STATE_CULL_BACK);
-    e_data.sss_count = 0;
-  }
-
-  {
+  } {
     DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CLIP_PLANES;
     DRW_PASS_CREATE(psl->transparent_pass, state);
   }
-
   {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list