[Bf-blender-cvs] [68eeb56104d] greasepencil-object: Refactor to reduce number of textures and framebuffers used
Antonio Vazquez
noreply at git.blender.org
Sun Apr 8 12:02:14 CEST 2018
Commit: 68eeb56104ddb30a61ae992b135a7067138b73da
Author: Antonio Vazquez
Date: Sun Apr 8 11:21:04 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB68eeb56104ddb30a61ae992b135a7067138b73da
Refactor to reduce number of textures and framebuffers used
===================================================================
M source/blender/draw/engines/gpencil/gpencil_depth_of_field.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_depth_of_field.c b/source/blender/draw/engines/gpencil/gpencil_depth_of_field.c
index a34fb9031fe..97708ea5620 100644
--- a/source/blender/draw/engines/gpencil/gpencil_depth_of_field.c
+++ b/source/blender/draw/engines/gpencil/gpencil_depth_of_field.c
@@ -212,8 +212,8 @@ void GPENCIL_depth_of_field_cache_init(GPENCIL_e_data *e_data, GPENCIL_Data *ved
psl->dof_down = DRW_pass_create("DoF Downsample", DRW_STATE_WRITE_COLOR);
grp = DRW_shgroup_create(e_data->gpencil_dof_downsample_sh, psl->dof_down);
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data->input_color_tx);
- DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data->input_depth_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data->vfx_color_tx_a);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data->vfx_depth_tx_a);
DRW_shgroup_uniform_vec2(grp, "nearFar", stl->storage->dof_near_far, 1);
DRW_shgroup_uniform_vec3(grp, "dofParams", stl->storage->dof_params, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@@ -234,10 +234,10 @@ void GPENCIL_depth_of_field_cache_init(GPENCIL_e_data *e_data, GPENCIL_Data *ved
psl->dof_resolve = DRW_pass_create("DoF Resolve", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
grp = DRW_shgroup_create(e_data->gpencil_dof_resolve_sh, psl->dof_resolve);
- DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data->input_color_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &e_data->vfx_color_tx_a);
DRW_shgroup_uniform_texture_ref(grp, "nearBuffer", &e_data->gpencil_dof_near_blur);
DRW_shgroup_uniform_texture_ref(grp, "farBuffer", &e_data->gpencil_dof_far_blur);
- DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data->input_depth_tx);
+ DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &e_data->vfx_depth_tx_a);
DRW_shgroup_uniform_texture_ref(grp, "weightBuffer", &e_data->gpencil_dof_weight);
DRW_shgroup_uniform_vec2(grp, "nearFar", stl->storage->dof_near_far, 1);
DRW_shgroup_uniform_vec3(grp, "dofParams", stl->storage->dof_params, 1);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3e82c99ce14..1c8c4dbb79c 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -90,18 +90,6 @@ static void GPENCIL_create_framebuffers(void *vedata)
const float *viewport_size = DRW_viewport_size_get();
const int size[2] = { (int)viewport_size[0], (int)viewport_size[1] };
- /* temp framebuffer to store all stroke drawing before sending to default or used
- * by vfx shaders as initial input
- */
- e_data.temp_depth_tx = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_DEPTH_24_STENCIL_8,
- &draw_engine_object_type);
- e_data.temp_color_tx = DRW_texture_pool_query_2D(size[0], size[1], fb_format,
- &draw_engine_object_type);
- GPU_framebuffer_ensure_config(&fbl->temp_fb, {
- GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx),
- GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx)
- });
-
/* vfx (ping-pong textures) */
e_data.vfx_depth_tx_a = DRW_texture_pool_query_2D(size[0], size[1], DRW_TEX_DEPTH_24_STENCIL_8,
&draw_engine_object_type);
@@ -437,21 +425,12 @@ static void GPENCIL_cache_init(void *vedata)
DRWShadingGroup *mix_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_pass_noblend);
stl->g_data->tot_sh++;
DRW_shgroup_call_add(mix_shgrp_noblend, quad_noblend, NULL);
- DRW_shgroup_uniform_texture_ref(mix_shgrp_noblend, "strokeColor", &e_data.input_color_tx);
- DRW_shgroup_uniform_texture_ref(mix_shgrp_noblend, "strokeDepth", &e_data.input_depth_tx);
+ DRW_shgroup_uniform_texture_ref(mix_shgrp_noblend, "strokeColor", &e_data.vfx_color_tx_a);
+ DRW_shgroup_uniform_texture_ref(mix_shgrp_noblend, "strokeDepth", &e_data.vfx_depth_tx_a);
DRW_shgroup_uniform_int(mix_shgrp_noblend, "tonemapping", &stl->storage->tonemapping, 1);
- /* vfx setup pass to prepare txta */
- struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
- psl->vfx_setup_pass = DRW_pass_create("GPencil VFX setup Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- DRWShadingGroup *vfx_setup_shgrp = DRW_shgroup_create(e_data.gpencil_simple_fullscreen_sh, psl->vfx_setup_pass);
- stl->g_data->tot_sh++;
- DRW_shgroup_call_add(vfx_setup_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_texture_ref(vfx_setup_shgrp, "strokeColor", &e_data.temp_color_tx);
- DRW_shgroup_uniform_texture_ref(vfx_setup_shgrp, "strokeDepth", &e_data.temp_depth_tx);
-
/* vfx copy pass from txtb to txta */
- vfxquad = DRW_cache_fullscreen_quad_get();
+ struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
psl->vfx_copy_pass = DRW_pass_create("GPencil VFX Copy b to a Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
DRWShadingGroup *vfx_copy_shgrp = DRW_shgroup_create(e_data.gpencil_simple_fullscreen_sh, psl->vfx_copy_pass);
stl->g_data->tot_sh++;
@@ -629,19 +608,6 @@ static int gpencil_object_cache_compare_zdepth(const void *a1, const void *a2)
*/
static void gpencil_vfx_passes(void *vedata, tGPencilObjectCache *cache)
{
- GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
- GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
- GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
-
- /* Copy the original texture to tx_a to be used by all following vfx modifiers.
- * At the end of this passes, we can be sure the vfx_fbcolor_color_tx_a texture has
- * the final image.
- */
- float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
- GPU_framebuffer_bind(fbl->vfx_fb_a);
- GPU_framebuffer_clear_color_depth(fbl->vfx_fb_a, clearcol, 1.0f);
- DRW_draw_pass(psl->vfx_setup_pass);
-
/* draw all vfx passes */
DRW_gpencil_vfx_draw(vedata, cache);
}
@@ -729,9 +695,6 @@ static void GPENCIL_draw_scene(void *vedata)
if (DRW_state_is_fbo()) {
/* attach temp textures */
- GPU_framebuffer_texture_attach(fbl->temp_fb, e_data.temp_depth_tx, 0, 0);
- GPU_framebuffer_texture_attach(fbl->temp_fb, e_data.temp_color_tx, 0, 0);
-
GPU_framebuffer_texture_attach(fbl->vfx_fb_a, e_data.vfx_depth_tx_a, 0, 0);
GPU_framebuffer_texture_attach(fbl->vfx_fb_a, e_data.vfx_color_tx_a, 0, 0);
@@ -755,8 +718,8 @@ static void GPENCIL_draw_scene(void *vedata)
init_grp = cache->init_grp;
end_grp = cache->end_grp;
/* Render stroke in separated framebuffer */
- GPU_framebuffer_bind(fbl->temp_fb);
- GPU_framebuffer_clear_color_depth(fbl->temp_fb, clearcol, 1.0f);
+ GPU_framebuffer_bind(fbl->vfx_fb_a);
+ GPU_framebuffer_clear_color_depth(fbl->vfx_fb_a, clearcol, 1.0f);
/* Stroke Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH
* draw only a subset that usually start with a fill and end with stroke because the
@@ -781,18 +744,12 @@ static void GPENCIL_draw_scene(void *vedata)
/* vfx modifiers passes */
if ((gpencil_object_use_vfx(ob)) && (!stl->storage->simplify_vfx)) {
- /* add vfx passes */
gpencil_vfx_passes(vedata, cache);
-
- e_data.input_depth_tx = e_data.vfx_depth_tx_a;
- e_data.input_color_tx = e_data.vfx_color_tx_a;
- }
- else {
- e_data.input_depth_tx = e_data.temp_depth_tx;
- e_data.input_color_tx = e_data.temp_color_tx;
}
+ e_data.input_depth_tx = e_data.vfx_depth_tx_a;
+ e_data.input_color_tx = e_data.vfx_color_tx_a;
-#if 0 /* the reult is very low quality, disable while find a solution */
+#if 0 /* the result is very low quality, disable while find a solution */
/* depth of field effect
* send always to tx_b because other textures can be in use. Remap input
* textures too.
@@ -832,9 +789,6 @@ static void GPENCIL_draw_scene(void *vedata)
/* detach temp textures */
if (DRW_state_is_fbo()) {
- GPU_framebuffer_texture_detach(fbl->temp_fb, e_data.temp_depth_tx);
- GPU_framebuffer_texture_detach(fbl->temp_fb, e_data.temp_color_tx);
-
GPU_framebuffer_texture_detach(fbl->vfx_fb_a, e_data.vfx_depth_tx_a);
GPU_framebuffer_texture_detach(fbl->vfx_fb_a, e_data.vfx_color_tx_a);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 020058a5395..a592b401063 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -56,7 +56,7 @@ struct Object;
#define MULTISAMPLE_GP_SYNC_ENABLE(dfbl, fbl) { \
if ((U.ogl_multisamples > 0) && (dfbl->multisample_fb != NULL)) { \
DRW_stats_query_start("GP Multisample Blit"); \
- GPU_framebuffer_blit(fbl->temp_fb, 0, dfbl->multisample_fb, 0, GPU_COLOR_BIT | GPU_DEPTH_BIT); \
+ GPU_framebuffer_blit(fbl->vfx_fb_a, 0, dfbl->multisample_fb, 0, GPU_COLOR_BIT | GPU_DEPTH_BIT); \
GPU_framebuffer_bind(dfbl->multisample_fb); \
DRW_stats_query_end(); \
} \
@@ -65,8 +65,8 @@ struct Object;
#define MULTISAMPLE_GP_SYNC_DISABLE(dfbl, fbl) { \
if ((U.ogl_multisamples > 0) && (dfbl->multisample_fb != NULL)) { \
DRW_stats_query_start("GP Multisample Resolve"); \
- GPU_framebuffer_blit(dfbl->multisample_fb, 0, fbl->temp_fb, 0, GPU_COLOR_BIT | GPU_DEPTH_BIT); \
- GPU_framebuffer_bind(fbl->temp_fb); \
+ GPU_framebuffer_blit(dfbl->multisample_fb, 0, fbl->vfx_fb_a, 0, GPU_COLOR_BIT | GPU_DEPTH_BIT); \
+ GPU_framebuffer_bind(fbl->vfx_fb_a); \
DRW_stats_query_end(); \
} \
}
@@ -208,7 +208,6 @@ typedef struct GPENCIL_PassList {
struct DRWPass *drawing_pass;
struct DRWPass *mix_pass;
struct DRWPass *mix_pass_noblend;
- struct DRWPass *vfx_setup_pass;
struct DRWPass *vfx_copy_pass;
struct DRWPass *vfx_wave_pass;
struct DRWPass *vfx_blur_pass;
@@ -227,7 +226,6 @@ typedef struct GPENCIL_PassList {
typedef struct GPENCIL_FramebufferList {
struct GPUFrameBuffer *main;
- struct GPUFrameBuffer *temp_fb;
struct GPUFrameBuffer *vfx_fb_a;
struct GPUFrameBuffer *vfx_fb_b;
struct GPUFrameBuffer *painting_fb;
@@ -307,10 +305,6 @@ typedef struct GPENCIL_e_data {
struct GPUShader *gpencil_dof_scatter_sh;
struct GPUShader *gpencil_dof_resolve_sh;
- /* temp depth
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list