diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-06-02 21:45:03 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-06-02 22:16:40 +0300 |
commit | f25e459f8f9231a4e8a827149b35dfb38c4aea1d (patch) | |
tree | adccb7aa05d4ff0d1f69baec561b99e1c4dd99f0 /source | |
parent | 98e4d548a16c6533eadbe619f78cf1dda1a5c7a4 (diff) |
DRW: Make the Procedural hair update part of the drawmanager.
Instead of relying on the engine integration which is redundant.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_engine.c | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_materials.c | 14 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_private.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_hair.c | 23 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 12 |
6 files changed, 38 insertions, 21 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index c922ee61700..f159bf21d03 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -193,9 +193,6 @@ static void eevee_draw_background(void *vedata) DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - /* Refresh Hair */ - DRW_draw_pass(psl->hair_tf_pass); - /* Sort transparents before the loop. */ DRW_pass_sort_shgroup_z(psl->transparent_pass); diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index bad8178e8ab..52c8ec985b8 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -894,7 +894,7 @@ static struct DRWShadingGroup *EEVEE_default_shading_group_get( if (is_hair) { DRWShadingGroup *shgrp = DRW_shgroup_hair_create(ob, psys, md, - vedata->psl->default_pass[options], vedata->psl->hair_tf_pass, + vedata->psl->default_pass[options], e_data.default_lit[options]); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false); return shgrp; @@ -1071,10 +1071,6 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) DRW_shgroup_uniform_vec3(grp, "offsets", e_data.noise_offsets, 1); DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL); } - - { - psl->hair_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_TRANS_FEEDBACK); - } } #define ADD_SHGROUP_CALL(shgrp, ob, geom, oedata) do { \ @@ -1619,12 +1615,12 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, shgrp = DRW_shgroup_hair_create( ob, psys, md, - psl->depth_pass, psl->hair_tf_pass, + psl->depth_pass, e_data.default_hair_prepass_sh); shgrp = DRW_shgroup_hair_create( ob, psys, md, - psl->depth_pass_clip, psl->hair_tf_pass, + psl->depth_pass_clip, e_data.default_hair_prepass_clip_sh); DRW_shgroup_uniform_block(shgrp, "clip_block", sldata->clip_ubo); @@ -1642,7 +1638,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, { shgrp = DRW_shgroup_material_hair_create( ob, psys, md, - psl->material_pass, psl->hair_tf_pass, + psl->material_pass, gpumat); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, false, false); break; @@ -1677,7 +1673,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, /* Shadows */ DRW_shgroup_hair_create( ob, psys, md, - psl->shadow_pass, psl->hair_tf_pass, + psl->shadow_pass, e_data.default_hair_prepass_sh); *cast_shadow = true; } diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index c7fe5e30c0f..9feac625f10 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -212,7 +212,6 @@ typedef struct EEVEE_PassList { struct DRWPass *background_pass; struct DRWPass *update_noise_pass; struct DRWPass *lookdev_pass; - struct DRWPass *hair_tf_pass; } EEVEE_PassList; typedef struct EEVEE_FramebufferList { diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index e4c038006b5..6227130fb05 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -162,14 +162,16 @@ void DRW_shgroup_armature_edit(struct Object *ob, struct DRWArmaturePasses passe * The draw call is already added by this function, just add additional uniforms. */ struct DRWShadingGroup *DRW_shgroup_hair_create( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, - struct DRWPass *hair_pass, struct DRWPass *tf_pass, + struct DRWPass *hair_pass, struct GPUShader *shader); struct DRWShadingGroup *DRW_shgroup_material_hair_create( struct Object *object, struct ParticleSystem *psys, struct ModifierData *md, - struct DRWPass *hair_pass, struct DRWPass *tf_pass, + struct DRWPass *hair_pass, struct GPUMaterial *material); +void DRW_hair_init(void); +void DRW_hair_update(void); void DRW_hair_free(void); /* pose_mode.c */ diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index 8cb9e0886a9..2c03caf0ac3 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -57,6 +57,7 @@ typedef enum ParticleRefineShader { } ParticleRefineShader; static GPUShader *g_refine_shaders[PART_REFINE_MAX_SHADER] = {NULL}; +static DRWPass *g_tf_pass; /* XXX can be a problem with mulitple DRWManager in the future */ extern char datatoc_common_hair_lib_glsl[]; extern char datatoc_common_hair_refine_vert_glsl[]; @@ -79,9 +80,14 @@ static GPUShader *hair_refine_shader_get(ParticleRefineShader sh) return g_refine_shaders[sh]; } +void DRW_hair_init(void) +{ + g_tf_pass = DRW_pass_create("Update Hair Pass", DRW_STATE_TRANS_FEEDBACK); +} + static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex( Object *object, ParticleSystem *psys, ModifierData *md, - DRWPass *hair_pass, DRWPass *tf_pass, + DRWPass *hair_pass, struct GPUMaterial *gpu_mat, GPUShader *gpu_shader) { /* TODO(fclem): Pass the scene as parameter */ @@ -132,7 +138,7 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex( if (need_ft_update) { int final_points_ct = hair_cache->final[subdiv].strands_res * hair_cache->strands_count; GPUShader *tf_shader = hair_refine_shader_get(PART_REFINE_CATMULL_ROM); - DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, tf_pass, + DRWShadingGroup *tf_shgrp = DRW_shgroup_transform_feedback_create(tf_shader, g_tf_pass, hair_cache->final[subdiv].proc_buf); DRW_shgroup_uniform_texture(tf_shgrp, "hairPointBuffer", hair_cache->point_tex); DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex); @@ -145,18 +151,23 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex( DRWShadingGroup *DRW_shgroup_hair_create( Object *object, ParticleSystem *psys, ModifierData *md, - DRWPass *hair_pass, DRWPass *tf_pass, + DRWPass *hair_pass, GPUShader *shader) { - return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, tf_pass, NULL, shader); + return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, NULL, shader); } DRWShadingGroup *DRW_shgroup_material_hair_create( Object *object, ParticleSystem *psys, ModifierData *md, - DRWPass *hair_pass, DRWPass *tf_pass, + DRWPass *hair_pass, struct GPUMaterial *material) { - return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, tf_pass, material, NULL); + return drw_shgroup_create_hair_procedural_ex(object, psys, md, hair_pass, material, NULL); +} + +void DRW_hair_update(void) +{ + DRW_draw_pass(g_tf_pass); } void DRW_hair_free(void) diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 60e9af78df9..e8ea2c58056 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1279,6 +1279,7 @@ void DRW_draw_render_loop_ex( DRW_globals_update(); drw_debug_init(); + DRW_hair_init(); /* No framebuffer allowed before drawing. */ BLI_assert(GPU_framebuffer_current_get() == 0); @@ -1308,6 +1309,7 @@ void DRW_draw_render_loop_ex( } DRW_stats_begin(); + DRW_hair_update(); GPU_framebuffer_bind(DST.default_framebuffer); @@ -1540,12 +1542,16 @@ void DRW_render_object_iter( void *vedata, RenderEngine *engine, struct Depsgraph *depsgraph, void (*callback)(void *vedata, Object *ob, RenderEngine *engine, struct Depsgraph *depsgraph)) { + DRW_hair_init(); + DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN(depsgraph, ob, DRW_iterator_mode_get()) { DST.ob_state = NULL; callback(vedata, ob, engine, depsgraph); } DEG_OBJECT_ITER_FOR_RENDER_ENGINE_END + + DRW_hair_update(); } static struct DRWSelectBuffer { @@ -1666,6 +1672,7 @@ void DRW_draw_select_loop( /* Init engines */ drw_engines_init(); + DRW_hair_init(); { drw_engines_cache_init(); @@ -1700,6 +1707,8 @@ void DRW_draw_select_loop( DRW_render_instance_buffer_finish(); } + DRW_hair_update(); + /* Setup framebuffer */ draw_select_framebuffer_setup(rect); GPU_framebuffer_bind(g_select_buffer.framebuffer); @@ -1839,6 +1848,7 @@ void DRW_draw_depth_loop( /* Init engines */ drw_engines_init(); + DRW_hair_init(); /* TODO : tag to refresh by the dependency graph */ /* ideally only refresh when objects are added/removed */ @@ -1857,6 +1867,8 @@ void DRW_draw_depth_loop( DRW_render_instance_buffer_finish(); } + DRW_hair_update(); + /* Start Drawing */ DRW_state_reset(); DRW_draw_callbacks_pre_scene(); |