[Bf-blender-cvs] [1e6e4b326de] greasepencil-object: Cleanup: Reduce number of passes using pointers
Antonio Vazquez
noreply at git.blender.org
Wed Feb 7 11:04:51 CET 2018
Commit: 1e6e4b326de9fec3d737c62848a3567c9d3fc502
Author: Antonio Vazquez
Date: Wed Feb 7 11:04:44 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB1e6e4b326de9fec3d737c62848a3567c9d3fc502
Cleanup: Reduce number of passes using pointers
Instead to define different passes for mixing final result, now reuse the passes and use pointers to replace input textures.
===================================================================
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_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index f3e88328a8b..b7325f4092d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -345,23 +345,14 @@ static void GPENCIL_cache_init(void *vedata)
/* drawing buffer pass */
psl->drawing_pass = DRW_pass_create("GPencil Drawing Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND);
- /* we need a full screen pass to combine the result of zdepth */
+ /* full screen pass to combine the result */
struct Gwn_Batch *quad = DRW_cache_fullscreen_quad_get();
psl->mix_pass = DRW_pass_create("GPencil Mix Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_pass);
stl->g_data->tot_sh++;
DRW_shgroup_call_add(mix_shgrp, quad, NULL);
- DRW_shgroup_uniform_buffer(mix_shgrp, "strokeColor", &e_data.temp_fbcolor_color_tx);
- DRW_shgroup_uniform_buffer(mix_shgrp, "strokeDepth", &e_data.temp_fbcolor_depth_tx);
-
- /* mix vfx pass */
- struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
- psl->mix_vfx_pass = DRW_pass_create("GPencil Mix VFX Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- DRWShadingGroup *mix_vfx_shgrp = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_vfx_pass);
- stl->g_data->tot_sh++;
- DRW_shgroup_call_add(mix_vfx_shgrp, vfxquad, NULL);
- DRW_shgroup_uniform_buffer(mix_vfx_shgrp, "strokeColor", &e_data.vfx_fbcolor_color_tx_a);
- DRW_shgroup_uniform_buffer(mix_vfx_shgrp, "strokeDepth", &e_data.vfx_fbcolor_depth_tx_a);
+ DRW_shgroup_uniform_buffer(mix_shgrp, "strokeColor", &e_data.input_color_tx);
+ DRW_shgroup_uniform_buffer(mix_shgrp, "strokeDepth", &e_data.input_depth_tx);
/* mix pass no blend */
struct Gwn_Batch *quad_noblend = DRW_cache_fullscreen_quad_get();
@@ -369,20 +360,11 @@ 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_buffer(mix_shgrp_noblend, "strokeColor", &e_data.temp_fbcolor_color_tx);
- DRW_shgroup_uniform_buffer(mix_shgrp_noblend, "strokeDepth", &e_data.temp_fbcolor_depth_tx);
-
- /* mix vfx pass no blend */
- struct Gwn_Batch *vfxquad_noblend = DRW_cache_fullscreen_quad_get();
- psl->mix_vfx_pass_noblend = DRW_pass_create("GPencil Mix VFX Pass no blend", DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- DRWShadingGroup *mix_vfx_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_vfx_pass_noblend);
- stl->g_data->tot_sh++;
- DRW_shgroup_call_add(mix_vfx_shgrp_noblend, vfxquad_noblend, NULL);
- DRW_shgroup_uniform_buffer(mix_vfx_shgrp_noblend, "strokeColor", &e_data.vfx_fbcolor_color_tx_a);
- DRW_shgroup_uniform_buffer(mix_vfx_shgrp_noblend, "strokeDepth", &e_data.vfx_fbcolor_depth_tx_a);
+ DRW_shgroup_uniform_buffer(mix_shgrp_noblend, "strokeColor", &e_data.input_color_tx);
+ DRW_shgroup_uniform_buffer(mix_shgrp_noblend, "strokeDepth", &e_data.input_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_fullscreen_sh, psl->vfx_copy_pass);
stl->g_data->tot_sh++;
@@ -802,23 +784,19 @@ static void GPENCIL_draw_scene(void *vedata)
if ((cache->vfx_wave_sh) && (!GP_SIMPLIFY_VFX(ts, playing))) {
/* add vfx and combine result with default framebuffer */
gpencil_vfx_passes(vedata, cache);
- /* Combine with default scene buffer always using tx_a as source texture */
- DRW_framebuffer_bind(dfbl->default_fb);
-
- /* Mix VFX Pass */
- DRW_draw_pass(psl->mix_vfx_pass);
- /* prepare for fast drawing */
- gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_vfx_pass_noblend, clearcol);
+
+ e_data.input_depth_tx = e_data.vfx_fbcolor_depth_tx_a;
+ e_data.input_color_tx = e_data.vfx_fbcolor_color_tx_a;
}
else {
- /* Combine with scene buffer without more passes */
- DRW_framebuffer_bind(dfbl->default_fb);
-
- /* Mix Pass: DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS */
- DRW_draw_pass(psl->mix_pass);
- /* prepare for fast drawing */
- gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass_noblend, clearcol);
+ e_data.input_depth_tx = e_data.temp_fbcolor_depth_tx;
+ e_data.input_color_tx = e_data.temp_fbcolor_color_tx;
}
+ /* Combine with scene buffer without more passes */
+ DRW_framebuffer_bind(dfbl->default_fb);
+ DRW_draw_pass(psl->mix_pass);
+ /* prepare for fast drawing */
+ gpencil_prepare_fast_drawing(stl, dfbl, fbl, psl->mix_pass_noblend, clearcol);
}
/* edit points */
if (!playing) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index e082ea2fc95..3099d32d2d8 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -181,9 +181,7 @@ typedef struct GPENCIL_PassList {
struct DRWPass *edit_pass;
struct DRWPass *drawing_pass;
struct DRWPass *mix_pass;
- struct DRWPass *mix_vfx_pass;
struct DRWPass *mix_pass_noblend;
- struct DRWPass *mix_vfx_pass_noblend;
struct DRWPass *mix_pass_front;
struct DRWPass *vfx_copy_pass;
struct DRWPass *vfx_wave_pass;
@@ -281,6 +279,9 @@ typedef struct GPENCIL_e_data {
struct GPUTexture *painting_color_tx;
struct GPUTexture *gpencil_blank_texture;
+ /* runtime pointers texture */
+ struct GPUTexture *input_depth_tx;
+ struct GPUTexture *input_color_tx;
} GPENCIL_e_data; /* Engine data */
/* Gwn_Batch Cache */
More information about the Bf-blender-cvs
mailing list