Eevee: Replace DRW_shgroup_empty_tri_batch_create by procedural calls
authorClément Foucault <foucault.clem@gmail.com>
Sat, 11 May 2019 15:42:36 +0000 (17:42 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 14 May 2019 08:57:03 +0000 (10:57 +0200)
source/blender/draw/engines/eevee/eevee_depth_of_field.c
source/blender/draw/engines/eevee/eevee_lightprobes.c
source/blender/draw/engines/eevee/eevee_volumes.c

index 8fb73bd605f68c893b4ed046a3ea746c7c14003a..f09be2324a6fc6b08db81b458492f5b02366bb3a 100644 (file)
@@ -222,13 +222,14 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
     const float *viewport_size = DRW_viewport_size_get();
     const int sprite_len = ((int)viewport_size[0] / 2) *
                            ((int)viewport_size[1] / 2); /* brackets matters */
-    grp = DRW_shgroup_empty_tri_batch_create(
-        e_data.dof_scatter_sh[use_alpha], psl->dof_scatter, sprite_len);
+    grp = DRW_shgroup_create(e_data.dof_scatter_sh[use_alpha], psl->dof_scatter);
     DRW_shgroup_uniform_texture_ref(grp, "nearBuffer", &effects->dof_down_near);
     DRW_shgroup_uniform_texture_ref(grp, "farBuffer", &effects->dof_down_far);
     DRW_shgroup_uniform_texture_ref(grp, "cocBuffer", &effects->dof_coc);
     DRW_shgroup_uniform_vec4(grp, "bokehParams", effects->dof_bokeh, 2);
 
+    DRW_shgroup_call_procedural_triangles_add(grp, sprite_len, NULL);
+
     psl->dof_resolve = DRW_pass_create("DoF Resolve", DRW_STATE_WRITE_COLOR);
 
     grp = DRW_shgroup_create(e_data.dof_resolve_sh[use_alpha], psl->dof_resolve);
index 71c1aa99ed2365ae76e1a2627b7b7f98889f1df0..5976a30232e6e60d601be13b7e84efaec2065c06 100644 (file)
@@ -386,8 +386,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
     /* Cube Display */
     if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_CUBEMAPS && lcache->cube_len > 1) {
       int cube_len = lcache->cube_len - 1; /* don't count the world. */
-      DRWShadingGroup *grp = DRW_shgroup_empty_tri_batch_create(
-          EEVEE_shaders_probe_cube_display_sh_get(), psl->probe_display, cube_len * 2);
+      DRWShadingGroup *grp = DRW_shgroup_create(EEVEE_shaders_probe_cube_display_sh_get(),
+                                                psl->probe_display);
 
       DRW_shgroup_uniform_texture_ref(grp, "probeCubes", &lcache->cube_tx.tex);
       DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
@@ -398,6 +398,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
       /* TODO (fclem) get rid of those UBO. */
       DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
       DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
+
+      DRW_shgroup_call_procedural_triangles_add(grp, cube_len * 2, NULL);
     }
 
     /* Grid Display */
index d2b3439133febd63e75048e0b52f4b259b123ac8..8e4a2da7743c87232ae00beff78fdcc2fe3018cb 100644 (file)
@@ -400,8 +400,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
         !LOOK_DEV_STUDIO_LIGHT_ENABLED(draw_ctx->v3d)) {
       struct GPUMaterial *mat = EEVEE_material_world_volume_get(scene, wo);
 
-      grp = DRW_shgroup_material_empty_tri_batch_create(
-          mat, psl->volumetric_world_ps, common_data->vol_tex_size[2]);
+      grp = DRW_shgroup_material_create(mat, psl->volumetric_world_ps);
 
       if (grp) {
         DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
@@ -416,15 +415,18 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
         DRW_shgroup_uniform_texture(grp, "sampdensity", e_data.dummy_density);
         DRW_shgroup_uniform_texture(grp, "sampflame", e_data.dummy_flame);
         DRW_shgroup_uniform_vec2(grp, "unftemperature", (float[2]){0.0f, 1.0f}, 1);
+
+        DRW_shgroup_call_procedural_triangles_add(grp, common_data->vol_tex_size[2], NULL);
       }
     }
 
     if (grp == NULL) {
       /* If no world or volume material is present just clear the buffer with this drawcall */
-      grp = DRW_shgroup_empty_tri_batch_create(
-          e_data.volumetric_clear_sh, psl->volumetric_world_ps, common_data->vol_tex_size[2]);
+      grp = DRW_shgroup_create(e_data.volumetric_clear_sh, psl->volumetric_world_ps);
 
       DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
+
+      DRW_shgroup_call_procedural_triangles_add(grp, common_data->vol_tex_size[2], NULL);
     }
 
     /* Volumetric Objects */
@@ -435,8 +437,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
                                        e_data.volumetric_scatter_with_lights_sh :
                                        e_data.volumetric_scatter_sh;
     psl->volumetric_scatter_ps = DRW_pass_create("Volumetric Scattering", DRW_STATE_WRITE_COLOR);
-    grp = DRW_shgroup_empty_tri_batch_create(
-        scatter_sh, psl->volumetric_scatter_ps, common_data->vol_tex_size[2]);
+    grp = DRW_shgroup_create(scatter_sh, psl->volumetric_scatter_ps);
     DRW_shgroup_uniform_texture_ref(grp, "irradianceGrid", &lcache->grid_tx.tex);
     DRW_shgroup_uniform_texture_ref(grp, "shadowCubeTexture", &sldata->shadow_cube_pool);
     DRW_shgroup_uniform_texture_ref(grp, "shadowCascadeTexture", &sldata->shadow_cascade_pool);
@@ -451,15 +452,17 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
+    DRW_shgroup_call_procedural_triangles_add(grp, common_data->vol_tex_size[2], NULL);
+
     psl->volumetric_integration_ps = DRW_pass_create("Volumetric Integration",
                                                      DRW_STATE_WRITE_COLOR);
-    grp = DRW_shgroup_empty_tri_batch_create(e_data.volumetric_integration_sh,
-                                             psl->volumetric_integration_ps,
-                                             common_data->vol_tex_size[2]);
+    grp = DRW_shgroup_create(e_data.volumetric_integration_sh, psl->volumetric_integration_ps);
     DRW_shgroup_uniform_texture_ref(grp, "volumeScattering", &txl->volume_scatter);
     DRW_shgroup_uniform_texture_ref(grp, "volumeExtinction", &txl->volume_transmittance);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
+    DRW_shgroup_call_procedural_triangles_add(grp, common_data->vol_tex_size[2], NULL);
+
     psl->volumetric_resolve_ps = DRW_pass_create("Volumetric Resolve", DRW_STATE_WRITE_COLOR);
     grp = DRW_shgroup_create(e_data.volumetric_resolve_sh, psl->volumetric_resolve_ps);
     DRW_shgroup_uniform_texture_ref(grp, "inScattering", &txl->volume_scatter);
@@ -500,8 +503,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
     return;
   }
 
-  DRWShadingGroup *grp = DRW_shgroup_material_empty_tri_batch_create(
-      mat, vedata->psl->volumetric_objects_ps, sldata->common_data.vol_tex_size[2]);
+  DRWShadingGroup *grp = DRW_shgroup_material_create(mat, vedata->psl->volumetric_objects_ps);
 
   BKE_mesh_texspace_get_reference((struct Mesh *)ob->data, NULL, &texcoloc, NULL, &texcosize);
 
@@ -575,6 +577,10 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
     DRW_shgroup_uniform_vec3(grp, "volumeColor", white, 1);
     DRW_shgroup_uniform_vec2(grp, "unftemperature", (float[2]){0.0f, 1.0f}, 1);
   }
+
+  /* TODO Reduce to number of slices intersecting. */
+  /* TODO Preemptive culling. */
+  DRW_shgroup_call_procedural_triangles_add(grp, sldata->common_data.vol_tex_size[2], NULL);
 }
 
 void EEVEE_volumes_compute(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *vedata)