Fix T65955: GPencil: drawing shapes on surface causes intense viewport flickering
There were some problems in the engine because the data was saved inside e_data struct, but this struct is reset sometimes and the background texture is not valid. Now, the data has been moved to stl->g_data and all creation and free has been moved to use stl->g_data. This fix also some small memory leak for the Buffer GPUBatch data. The background texture has been moved to texture list because must be available all the time. When is not drawing, the texture is removed to safe memory. Also, if the mode is painting and the texture is not ready because it was removed by Draw Manager, the texture is reloaded with the background image again. This ensure the background image is always visible when painting. Also I have used this patch to reduce the size of texture used for background to 16F instead of 32F and the blank texture to 1x1 pixels instead of 16x16. Reviewed by: @fclem See D5115 for more details
This commit is contained in:
@@ -478,7 +478,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(GPENCIL_e_data *e_data,
|
||||
}
|
||||
else {
|
||||
/* if no texture defined, need a blank texture to avoid errors in draw manager */
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture);
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture);
|
||||
stl->shgroups[id].texture_clamp = 0;
|
||||
DRW_shgroup_uniform_int(grp, "texture_clamp", &stl->shgroups[id].texture_clamp, 1);
|
||||
}
|
||||
@@ -643,7 +643,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(GPENCIL_e_data *e_data,
|
||||
}
|
||||
else {
|
||||
/* if no texture defined, need a blank texture to avoid errors in draw manager */
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture);
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture);
|
||||
}
|
||||
|
||||
return grp;
|
||||
@@ -801,7 +801,7 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(GPENCIL_e_data *e_data,
|
||||
}
|
||||
else {
|
||||
/* if no texture defined, need a blank texture to avoid errors in draw manager */
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", e_data->gpencil_blank_texture);
|
||||
DRW_shgroup_uniform_texture(grp, "myTexture", stl->g_data->gpencil_blank_texture);
|
||||
}
|
||||
|
||||
return grp;
|
||||
@@ -1539,23 +1539,17 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
|
||||
(const int *)stl->storage->shade_render);
|
||||
}
|
||||
|
||||
/* clean previous version of the batch */
|
||||
if (stl->storage->buffer_stroke) {
|
||||
GPU_BATCH_DISCARD_SAFE(e_data->batch_buffer_stroke);
|
||||
MEM_SAFE_FREE(e_data->batch_buffer_stroke);
|
||||
stl->storage->buffer_stroke = false;
|
||||
}
|
||||
|
||||
/* use unit matrix because the buffer is in screen space and does not need conversion */
|
||||
if (gpd->runtime.mode == GP_STYLE_MODE_LINE) {
|
||||
e_data->batch_buffer_stroke = DRW_gpencil_get_buffer_stroke_geom(gpd, lthick);
|
||||
stl->g_data->batch_buffer_stroke = DRW_gpencil_get_buffer_stroke_geom(gpd, lthick);
|
||||
}
|
||||
else {
|
||||
e_data->batch_buffer_stroke = DRW_gpencil_get_buffer_point_geom(gpd, lthick);
|
||||
stl->g_data->batch_buffer_stroke = DRW_gpencil_get_buffer_point_geom(gpd, lthick);
|
||||
}
|
||||
|
||||
/* buffer strokes, must show stroke always */
|
||||
DRW_shgroup_call(stl->g_data->shgrps_drawing_stroke, e_data->batch_buffer_stroke, NULL);
|
||||
DRW_shgroup_call(
|
||||
stl->g_data->shgrps_drawing_stroke, stl->g_data->batch_buffer_stroke, NULL);
|
||||
|
||||
if ((gpd->runtime.sbuffer_size >= 3) &&
|
||||
(gpd->runtime.sfill[3] > GPENCIL_ALPHA_OPACITY_THRESH) &&
|
||||
@@ -1569,18 +1563,9 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
|
||||
stl->g_data->shgrps_drawing_fill = DRW_shgroup_create(e_data->gpencil_drawing_fill_sh,
|
||||
psl->drawing_pass);
|
||||
|
||||
/* clean previous version of the batch */
|
||||
if (stl->storage->buffer_fill) {
|
||||
GPU_BATCH_DISCARD_SAFE(e_data->batch_buffer_fill);
|
||||
MEM_SAFE_FREE(e_data->batch_buffer_fill);
|
||||
stl->storage->buffer_fill = false;
|
||||
}
|
||||
|
||||
e_data->batch_buffer_fill = DRW_gpencil_get_buffer_fill_geom(gpd);
|
||||
DRW_shgroup_call(stl->g_data->shgrps_drawing_fill, e_data->batch_buffer_fill, NULL);
|
||||
stl->storage->buffer_fill = true;
|
||||
stl->g_data->batch_buffer_fill = DRW_gpencil_get_buffer_fill_geom(gpd);
|
||||
DRW_shgroup_call(stl->g_data->shgrps_drawing_fill, stl->g_data->batch_buffer_fill, NULL);
|
||||
}
|
||||
stl->storage->buffer_stroke = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1598,18 +1583,9 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
|
||||
const float *viewport_size = DRW_viewport_size_get();
|
||||
DRW_shgroup_uniform_vec2(shgrp, "Viewport", viewport_size, 1);
|
||||
|
||||
/* clean previous version of the batch */
|
||||
if (stl->storage->buffer_ctrlpoint) {
|
||||
GPU_BATCH_DISCARD_SAFE(e_data->batch_buffer_ctrlpoint);
|
||||
MEM_SAFE_FREE(e_data->batch_buffer_ctrlpoint);
|
||||
stl->storage->buffer_ctrlpoint = false;
|
||||
}
|
||||
stl->g_data->batch_buffer_ctrlpoint = DRW_gpencil_get_buffer_ctrlpoint_geom(gpd);
|
||||
|
||||
e_data->batch_buffer_ctrlpoint = DRW_gpencil_get_buffer_ctrlpoint_geom(gpd);
|
||||
|
||||
DRW_shgroup_call(shgrp, e_data->batch_buffer_ctrlpoint, NULL);
|
||||
|
||||
stl->storage->buffer_ctrlpoint = true;
|
||||
DRW_shgroup_call(shgrp, stl->g_data->batch_buffer_ctrlpoint, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ static void GPENCIL_create_framebuffers(void *vedata)
|
||||
{
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_TextureList *txl = ((GPENCIL_Data *)vedata)->txl;
|
||||
|
||||
/* Go full 32bits for rendering */
|
||||
eGPUTextureFormat fb_format = DRW_state_is_image_render() ? GPU_RGBA32F : GPU_RGBA16F;
|
||||
@@ -119,50 +120,57 @@ static void GPENCIL_create_framebuffers(void *vedata)
|
||||
/* Framebufers for basic object drawing */
|
||||
if (stl->storage->framebuffer_flag & GP_FRAMEBUFFER_BASIC) {
|
||||
/* temp textures for ping-pong buffers */
|
||||
e_data.temp_depth_tx_a = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_tx_a = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
|
||||
e_data.temp_color_tx_a = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_tx_a = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_a,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_a),
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_a),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_a),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_a),
|
||||
});
|
||||
|
||||
e_data.temp_depth_tx_b = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_tx_b = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
|
||||
e_data.temp_color_tx_b = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_tx_b = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_b,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_b),
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_b),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_b),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_b),
|
||||
});
|
||||
|
||||
/* used for FX effects and Layer blending */
|
||||
e_data.temp_depth_tx_fx = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_depth_tx_fx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
|
||||
e_data.temp_color_tx_fx = DRW_texture_pool_query_2d(
|
||||
stl->g_data->temp_color_tx_fx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], fb_format, &draw_engine_gpencil_type);
|
||||
GPU_framebuffer_ensure_config(&fbl->temp_fb_fx,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_depth_tx_fx),
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.temp_color_tx_fx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_depth_tx_fx),
|
||||
GPU_ATTACHMENT_TEXTURE(stl->g_data->temp_color_tx_fx),
|
||||
});
|
||||
}
|
||||
|
||||
/* background framebuffer to speed up drawing process (always 16 bits) */
|
||||
/* background framebuffer to speed up drawing process */
|
||||
if (stl->storage->framebuffer_flag & GP_FRAMEBUFFER_DRAW) {
|
||||
e_data.background_depth_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_DEPTH_COMPONENT24, &draw_engine_gpencil_type);
|
||||
e_data.background_color_tx = DRW_texture_pool_query_2d(
|
||||
size[0], size[1], GPU_RGBA32F, &draw_engine_gpencil_type);
|
||||
if (txl->background_color_tx == NULL) {
|
||||
stl->storage->background_ready = false;
|
||||
}
|
||||
DRW_texture_ensure_2d(
|
||||
&txl->background_depth_tx, size[0], size[1], GPU_DEPTH_COMPONENT24, DRW_TEX_FILTER);
|
||||
DRW_texture_ensure_2d(
|
||||
&txl->background_color_tx, size[0], size[1], GPU_RGBA16F, DRW_TEX_FILTER);
|
||||
GPU_framebuffer_ensure_config(&fbl->background_fb,
|
||||
{
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.background_depth_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(e_data.background_color_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(txl->background_depth_tx),
|
||||
GPU_ATTACHMENT_TEXTURE(txl->background_color_tx),
|
||||
});
|
||||
}
|
||||
else {
|
||||
DRW_TEXTURE_FREE_SAFE(txl->background_depth_tx);
|
||||
DRW_TEXTURE_FREE_SAFE(txl->background_color_tx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,13 +270,6 @@ void GPENCIL_engine_init(void *vedata)
|
||||
/* create shaders */
|
||||
GPENCIL_create_shaders();
|
||||
GPENCIL_create_fx_shaders(&e_data);
|
||||
|
||||
/* blank texture used if no texture defined for fill shader */
|
||||
if (!e_data.gpencil_blank_texture) {
|
||||
float rect[16][16][4] = {{{0.0f}}};
|
||||
e_data.gpencil_blank_texture = DRW_texture_create_2d(
|
||||
16, 16, GPU_RGBA8, DRW_TEX_FILTER, (float *)rect);
|
||||
}
|
||||
}
|
||||
|
||||
static void GPENCIL_engine_free(void)
|
||||
@@ -284,20 +285,6 @@ static void GPENCIL_engine_free(void)
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_background_sh);
|
||||
DRW_SHADER_FREE_SAFE(e_data.gpencil_paper_sh);
|
||||
|
||||
DRW_TEXTURE_FREE_SAFE(e_data.gpencil_blank_texture);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(e_data.batch_buffer_stroke);
|
||||
MEM_SAFE_FREE(e_data.batch_buffer_stroke);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(e_data.batch_buffer_fill);
|
||||
MEM_SAFE_FREE(e_data.batch_buffer_fill);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(e_data.batch_buffer_ctrlpoint);
|
||||
MEM_SAFE_FREE(e_data.batch_buffer_ctrlpoint);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(e_data.batch_grid);
|
||||
MEM_SAFE_FREE(e_data.batch_grid);
|
||||
|
||||
/* effects */
|
||||
GPENCIL_delete_fx_shaders(&e_data);
|
||||
}
|
||||
@@ -306,6 +293,7 @@ void GPENCIL_cache_init(void *vedata)
|
||||
{
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_TextureList *txl = ((GPENCIL_Data *)vedata)->txl;
|
||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||
Scene *scene = draw_ctx->scene;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
@@ -341,6 +329,18 @@ void GPENCIL_cache_init(void *vedata)
|
||||
stl->g_data->shgrps_edit_line = NULL;
|
||||
stl->g_data->shgrps_edit_point = NULL;
|
||||
|
||||
/* reset textures */
|
||||
stl->g_data->gpencil_blank_texture = NULL;
|
||||
stl->g_data->batch_buffer_stroke = NULL;
|
||||
stl->g_data->batch_buffer_fill = NULL;
|
||||
stl->g_data->batch_buffer_ctrlpoint = NULL;
|
||||
stl->g_data->batch_grid = NULL;
|
||||
|
||||
/* blank texture used if no texture defined for fill shader */
|
||||
float rect[1][1][4] = {{{0.0f}}};
|
||||
stl->g_data->gpencil_blank_texture = DRW_texture_create_2d(
|
||||
1, 1, GPU_RGBA8, DRW_TEX_FILTER, (float *)rect);
|
||||
|
||||
if (!stl->shgroups) {
|
||||
/* Alloc maximum size because count strokes is very slow and can be very complex due onion
|
||||
* skinning.
|
||||
@@ -424,7 +424,7 @@ void GPENCIL_cache_init(void *vedata)
|
||||
|
||||
/* detect if painting session */
|
||||
if ((obact_gpd) && (obact_gpd->flag & GP_DATA_STROKE_PAINTMODE) &&
|
||||
(stl->storage->is_playing == false)) {
|
||||
(stl->storage->is_playing == false) && (stl->storage->background_ready == true)) {
|
||||
/* need the original to avoid cow overhead while drawing */
|
||||
bGPdata *gpd_orig = (bGPdata *)DEG_get_original_id(&obact_gpd->id);
|
||||
if (((gpd_orig->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) &&
|
||||
@@ -470,8 +470,8 @@ void GPENCIL_cache_init(void *vedata)
|
||||
DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
|
||||
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.gpencil_fullscreen_sh, psl->mix_pass);
|
||||
DRW_shgroup_call(mix_shgrp, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeColor", &e_data.input_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeDepth", &e_data.input_depth_tx);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeColor", &stl->g_data->input_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(mix_shgrp, "strokeDepth", &stl->g_data->input_depth_tx);
|
||||
DRW_shgroup_uniform_int(mix_shgrp, "tonemapping", &stl->storage->tonemapping, 1);
|
||||
DRW_shgroup_uniform_int(mix_shgrp, "do_select", &stl->storage->do_select_outline, 1);
|
||||
DRW_shgroup_uniform_vec4(mix_shgrp, "select_color", stl->storage->select_color, 1);
|
||||
@@ -488,8 +488,10 @@ void GPENCIL_cache_init(void *vedata)
|
||||
DRWShadingGroup *mix_shgrp_noblend = DRW_shgroup_create(e_data.gpencil_fullscreen_sh,
|
||||
psl->mix_pass_noblend);
|
||||
DRW_shgroup_call(mix_shgrp_noblend, quad, 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", &stl->g_data->input_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(
|
||||
mix_shgrp_noblend, "strokeDepth", &stl->g_data->input_depth_tx);
|
||||
DRW_shgroup_uniform_int(mix_shgrp_noblend, "tonemapping", &stl->storage->tonemapping, 1);
|
||||
DRW_shgroup_uniform_int(mix_shgrp_noblend, "do_select", &stl->storage->do_select_outline, 1);
|
||||
DRW_shgroup_uniform_vec4(mix_shgrp_noblend, "select_color", stl->storage->select_color, 1);
|
||||
@@ -506,8 +508,8 @@ void GPENCIL_cache_init(void *vedata)
|
||||
DRWShadingGroup *background_shgrp = DRW_shgroup_create(e_data.gpencil_background_sh,
|
||||
psl->background_pass);
|
||||
DRW_shgroup_call(background_shgrp, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(background_shgrp, "strokeColor", &e_data.background_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(background_shgrp, "strokeDepth", &e_data.background_depth_tx);
|
||||
DRW_shgroup_uniform_texture_ref(background_shgrp, "strokeColor", &txl->background_color_tx);
|
||||
DRW_shgroup_uniform_texture_ref(background_shgrp, "strokeDepth", &txl->background_depth_tx);
|
||||
|
||||
/* pass for drawing paper (only if viewport)
|
||||
* In render, the v3d is null so the paper is disabled
|
||||
@@ -538,10 +540,10 @@ void GPENCIL_cache_init(void *vedata)
|
||||
DRWShadingGroup *blend_shgrp = DRW_shgroup_create(e_data.gpencil_blend_fullscreen_sh,
|
||||
psl->blend_pass);
|
||||
DRW_shgroup_call(blend_shgrp, quad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &e_data.temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeDepth", &e_data.temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendColor", &e_data.temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &e_data.temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(blend_shgrp, "blendDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_int(blend_shgrp, "mode", &stl->storage->blend_mode, 1);
|
||||
DRW_shgroup_uniform_int(blend_shgrp, "clamp_layer", &stl->storage->clamp_layer, 1);
|
||||
DRW_shgroup_uniform_int(mix_shgrp, "tonemapping", &stl->storage->tonemapping, 1);
|
||||
@@ -655,10 +657,8 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
|
||||
(ob->type == OB_GPENCIL) && (ob == draw_ctx->obact) &&
|
||||
((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_VIEW) == 0) &&
|
||||
((ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) == 0)) {
|
||||
GPU_BATCH_DISCARD_SAFE(e_data.batch_grid);
|
||||
MEM_SAFE_FREE(e_data.batch_grid);
|
||||
|
||||
e_data.batch_grid = DRW_gpencil_get_grid(ob);
|
||||
stl->g_data->batch_grid = DRW_gpencil_get_grid(ob);
|
||||
|
||||
/* define grid orientation */
|
||||
switch (ts->gp_sculpt.lock_axis) {
|
||||
@@ -688,7 +688,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
|
||||
copy_v3_v3(grid_matrix[3], ob->obmat[3]);
|
||||
}
|
||||
|
||||
DRW_shgroup_call_obmat(stl->g_data->shgrps_grid, e_data.batch_grid, grid_matrix);
|
||||
DRW_shgroup_call_obmat(stl->g_data->shgrps_grid, stl->g_data->batch_grid, grid_matrix);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -762,11 +762,28 @@ static void gpencil_prepare_fast_drawing(GPENCIL_StorageList *stl,
|
||||
DRW_draw_pass(pass);
|
||||
/* set default framebuffer again */
|
||||
GPU_framebuffer_bind(dfbl->default_fb);
|
||||
|
||||
stl->storage->background_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void gpencil_free_obj_runtime(GPENCIL_StorageList *stl)
|
||||
static void gpencil_free_runtime_data(GPENCIL_StorageList *stl)
|
||||
{
|
||||
/* free gpu data */
|
||||
DRW_TEXTURE_FREE_SAFE(stl->g_data->gpencil_blank_texture);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(stl->g_data->batch_buffer_stroke);
|
||||
MEM_SAFE_FREE(stl->g_data->batch_buffer_stroke);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(stl->g_data->batch_buffer_fill);
|
||||
MEM_SAFE_FREE(stl->g_data->batch_buffer_fill);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(stl->g_data->batch_buffer_ctrlpoint);
|
||||
MEM_SAFE_FREE(stl->g_data->batch_buffer_ctrlpoint);
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(stl->g_data->batch_grid);
|
||||
MEM_SAFE_FREE(stl->g_data->batch_grid);
|
||||
|
||||
if (stl->g_data->gp_object_cache == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -892,7 +909,7 @@ void GPENCIL_draw_scene(void *ved)
|
||||
if (DRW_state_is_select() || DRW_state_is_depth()) {
|
||||
drw_gpencil_select_render(stl, psl);
|
||||
/* free memory */
|
||||
gpencil_free_obj_runtime(stl);
|
||||
gpencil_free_runtime_data(stl);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -915,15 +932,16 @@ void GPENCIL_draw_scene(void *ved)
|
||||
|
||||
MULTISAMPLE_GP_SYNC_DISABLE(stl->storage->multisamples, fbl, dfbl->default_fb, txl);
|
||||
|
||||
/* free memory */
|
||||
gpencil_free_obj_runtime(stl);
|
||||
|
||||
/* grid pass */
|
||||
if ((!is_render) && (obact) && (obact->type == OB_GPENCIL)) {
|
||||
if (((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0) && (v3d->gp_flag & V3D_GP_SHOW_GRID)) {
|
||||
DRW_draw_pass(psl->grid_pass);
|
||||
}
|
||||
}
|
||||
|
||||
/* free memory */
|
||||
gpencil_free_runtime_data(stl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -988,8 +1006,8 @@ void GPENCIL_draw_scene(void *ved)
|
||||
stl->storage->tonemapping = 0;
|
||||
|
||||
/* Copy B texture to A texture to follow loop */
|
||||
e_data.input_depth_tx = e_data.temp_depth_tx_b;
|
||||
e_data.input_color_tx = e_data.temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
@@ -1014,8 +1032,8 @@ void GPENCIL_draw_scene(void *ved)
|
||||
DRW_gpencil_fx_draw(&e_data, vedata, cache_ob);
|
||||
}
|
||||
|
||||
e_data.input_depth_tx = e_data.temp_depth_tx_a;
|
||||
e_data.input_color_tx = e_data.temp_color_tx_a;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_a;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_a;
|
||||
|
||||
/* Combine with scene buffer */
|
||||
if ((!is_render) || (fbl->main == NULL)) {
|
||||
@@ -1072,7 +1090,7 @@ void GPENCIL_draw_scene(void *ved)
|
||||
}
|
||||
}
|
||||
/* free memory */
|
||||
gpencil_free_obj_runtime(stl);
|
||||
gpencil_free_runtime_data(stl);
|
||||
|
||||
/* reset */
|
||||
if (DRW_state_is_fbo()) {
|
||||
|
||||
@@ -158,11 +158,9 @@ typedef struct GPENCIL_Storage {
|
||||
bool is_playing;
|
||||
bool is_render;
|
||||
bool is_mat_preview;
|
||||
bool background_ready;
|
||||
int is_xray;
|
||||
bool reset_cache;
|
||||
bool buffer_stroke;
|
||||
bool buffer_fill;
|
||||
bool buffer_ctrlpoint;
|
||||
const float *pixsize;
|
||||
float render_pixsize;
|
||||
int tonemapping;
|
||||
@@ -243,6 +241,10 @@ typedef struct GPENCIL_TextureList {
|
||||
struct GPUTexture *multisample_color;
|
||||
struct GPUTexture *multisample_depth;
|
||||
|
||||
/* Background textures for speed-up drawing. */
|
||||
struct GPUTexture *background_depth_tx;
|
||||
struct GPUTexture *background_color_tx;
|
||||
|
||||
} GPENCIL_TextureList;
|
||||
|
||||
typedef struct GPENCIL_Data {
|
||||
@@ -270,6 +272,31 @@ typedef struct g_data {
|
||||
int gp_cache_size; /* size of the cache */
|
||||
struct tGPencilObjectCache *gp_object_cache;
|
||||
|
||||
/* for buffer only one batch is nedeed because the drawing is only of one stroke */
|
||||
GPUBatch *batch_buffer_stroke;
|
||||
GPUBatch *batch_buffer_fill;
|
||||
GPUBatch *batch_buffer_ctrlpoint;
|
||||
|
||||
/* grid geometry */
|
||||
GPUBatch *batch_grid;
|
||||
|
||||
/* textures */
|
||||
struct GPUTexture *gpencil_blank_texture;
|
||||
|
||||
/* runtime pointers texture */
|
||||
struct GPUTexture *input_depth_tx;
|
||||
struct GPUTexture *input_color_tx;
|
||||
|
||||
/* working textures */
|
||||
struct GPUTexture *temp_color_tx_a;
|
||||
struct GPUTexture *temp_depth_tx_a;
|
||||
|
||||
struct GPUTexture *temp_color_tx_b;
|
||||
struct GPUTexture *temp_depth_tx_b;
|
||||
|
||||
struct GPUTexture *temp_color_tx_fx;
|
||||
struct GPUTexture *temp_depth_tx_fx;
|
||||
|
||||
int session_flag;
|
||||
bool do_instances;
|
||||
|
||||
@@ -313,34 +340,6 @@ typedef struct GPENCIL_e_data {
|
||||
struct GPUShader *gpencil_fx_swirl_sh;
|
||||
struct GPUShader *gpencil_fx_wave_sh;
|
||||
|
||||
/* textures */
|
||||
struct GPUTexture *background_depth_tx;
|
||||
struct GPUTexture *background_color_tx;
|
||||
|
||||
struct GPUTexture *gpencil_blank_texture;
|
||||
|
||||
/* runtime pointers texture */
|
||||
struct GPUTexture *input_depth_tx;
|
||||
struct GPUTexture *input_color_tx;
|
||||
|
||||
/* working textures */
|
||||
struct GPUTexture *temp_color_tx_a;
|
||||
struct GPUTexture *temp_depth_tx_a;
|
||||
|
||||
struct GPUTexture *temp_color_tx_b;
|
||||
struct GPUTexture *temp_depth_tx_b;
|
||||
|
||||
struct GPUTexture *temp_color_tx_fx;
|
||||
struct GPUTexture *temp_depth_tx_fx;
|
||||
|
||||
/* for buffer only one batch is nedeed because the drawing is only of one stroke */
|
||||
GPUBatch *batch_buffer_stroke;
|
||||
GPUBatch *batch_buffer_fill;
|
||||
GPUBatch *batch_buffer_ctrlpoint;
|
||||
|
||||
/* grid geometry */
|
||||
GPUBatch *batch_grid;
|
||||
|
||||
} GPENCIL_e_data; /* Engine data */
|
||||
|
||||
/* GPUBatch Cache */
|
||||
|
||||
@@ -202,8 +202,8 @@ static void DRW_gpencil_fx_blur(ShaderFxData *fx,
|
||||
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -220,6 +220,7 @@ static void DRW_gpencil_fx_colorize(ShaderFxData *fx, GPENCIL_e_data *e_data, GP
|
||||
if (fx == NULL) {
|
||||
return;
|
||||
}
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
ColorizeShaderFxData *fxd = (ColorizeShaderFxData *)fx;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
DRWShadingGroup *fx_shgrp;
|
||||
@@ -227,8 +228,8 @@ static void DRW_gpencil_fx_colorize(ShaderFxData *fx, GPENCIL_e_data *e_data, GP
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_colorize_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "low_color", &fxd->low_color[0], 1);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "high_color", &fxd->high_color[0], 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "mode", &fxd->mode, 1);
|
||||
@@ -243,6 +244,7 @@ static void DRW_gpencil_fx_flip(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCI
|
||||
if (fx == NULL) {
|
||||
return;
|
||||
}
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
FlipShaderFxData *fxd = (FlipShaderFxData *)fx;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
DRWShadingGroup *fx_shgrp;
|
||||
@@ -259,8 +261,8 @@ static void DRW_gpencil_fx_flip(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCI
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_flip_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "flipmode", &fxd->flipmode, 1);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "wsize", DRW_viewport_size_get(), 1);
|
||||
@@ -289,8 +291,8 @@ static void DRW_gpencil_fx_light(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_light_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
@@ -344,8 +346,8 @@ static void DRW_gpencil_fx_pixel(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_pixel_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "size", &fxd->size[0], 3);
|
||||
DRW_shgroup_uniform_vec4(fx_shgrp, "color", &fxd->rgba[0], 1);
|
||||
|
||||
@@ -378,8 +380,8 @@ static void DRW_gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_rim_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "offset", &fxd->offset[0], 2);
|
||||
@@ -395,8 +397,8 @@ static void DRW_gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -409,9 +411,9 @@ static void DRW_gpencil_fx_rim(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_rim_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeRim", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeRim", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "mask_color", &fxd->mask_rgb[0], 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "mode", &fxd->mode, 1);
|
||||
|
||||
@@ -445,8 +447,8 @@ static void DRW_gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_shadow_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "offset", &fxd->offset[0], 2);
|
||||
@@ -480,8 +482,8 @@ static void DRW_gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -494,10 +496,10 @@ static void DRW_gpencil_fx_shadow(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_shadow_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowColor", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowDepth", &e_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "shadowDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
|
||||
fxd->runtime.fx_sh_c = fx_shgrp;
|
||||
}
|
||||
@@ -523,8 +525,8 @@ static void DRW_gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* prepare pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_glow_prepare_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "glow_color", &fxd->glow_color[0], 1);
|
||||
DRW_shgroup_uniform_vec3(fx_shgrp, "select_color", &fxd->select_color[0], 1);
|
||||
@@ -536,8 +538,8 @@ static void DRW_gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* blur pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_blur_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "blur", &fxd->blur[0], 2);
|
||||
|
||||
@@ -550,10 +552,10 @@ static void DRW_gpencil_fx_glow(ShaderFxData *fx,
|
||||
/* resolve pass */
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_glow_resolve_sh, psl->fx_shader_pass_blend);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowColor", &e_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowDepth", &e_data->temp_depth_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowColor", &stl->g_data->temp_color_tx_fx);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "glowDepth", &stl->g_data->temp_depth_tx_fx);
|
||||
|
||||
/* reuse field */
|
||||
DRW_shgroup_uniform_int(fx_shgrp, "alpha_mode", &fxd->blur[1], 1);
|
||||
@@ -585,8 +587,8 @@ static void DRW_gpencil_fx_swirl(ShaderFxData *fx,
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_swirl_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
|
||||
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
|
||||
|
||||
@@ -611,13 +613,14 @@ static void DRW_gpencil_fx_wave(ShaderFxData *fx, GPENCIL_e_data *e_data, GPENCI
|
||||
|
||||
WaveShaderFxData *fxd = (WaveShaderFxData *)fx;
|
||||
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPUBatch *fxquad = DRW_cache_fullscreen_quad_get();
|
||||
|
||||
DRWShadingGroup *fx_shgrp = DRW_shgroup_create(e_data->gpencil_fx_wave_sh, psl->fx_shader_pass);
|
||||
DRW_shgroup_call(fx_shgrp, fxquad, NULL);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &e_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &e_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeColor", &stl->g_data->temp_color_tx_a);
|
||||
DRW_shgroup_uniform_texture_ref(fx_shgrp, "strokeDepth", &stl->g_data->temp_depth_tx_a);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "amplitude", &fxd->amplitude, 1);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "period", &fxd->period, 1);
|
||||
DRW_shgroup_uniform_float(fx_shgrp, "phase", &fxd->phase, 1);
|
||||
@@ -769,8 +772,7 @@ void DRW_gpencil_fx_prepare(GPENCIL_e_data *e_data,
|
||||
|
||||
/* helper to draw one FX pass and do ping-pong copy */
|
||||
static void gpencil_draw_fx_pass(GPENCIL_e_data *e_data,
|
||||
GPENCIL_PassList *psl,
|
||||
GPENCIL_FramebufferList *fbl,
|
||||
GPENCIL_Data *vedata,
|
||||
DRWShadingGroup *shgrp,
|
||||
bool blend)
|
||||
{
|
||||
@@ -778,6 +780,10 @@ static void gpencil_draw_fx_pass(GPENCIL_e_data *e_data,
|
||||
return;
|
||||
}
|
||||
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
const float clearcol[4] = {0.0f};
|
||||
GPU_framebuffer_bind(fbl->temp_fb_b);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);
|
||||
@@ -792,8 +798,8 @@ static void gpencil_draw_fx_pass(GPENCIL_e_data *e_data,
|
||||
}
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
e_data->input_depth_tx = e_data->temp_depth_tx_b;
|
||||
e_data->input_color_tx = e_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
@@ -809,8 +815,6 @@ static void draw_gpencil_blur_passes(GPENCIL_e_data *e_data,
|
||||
return;
|
||||
}
|
||||
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
DRWShadingGroup *shgrp = fxd->runtime.fx_sh;
|
||||
int samples = fxd->samples;
|
||||
|
||||
@@ -829,13 +833,13 @@ static void draw_gpencil_blur_passes(GPENCIL_e_data *e_data,
|
||||
if (bx > 0) {
|
||||
fxd->blur[0] = bx;
|
||||
fxd->blur[1] = 0;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, shgrp, true);
|
||||
gpencil_draw_fx_pass(e_data, vedata, shgrp, true);
|
||||
}
|
||||
/* vertical */
|
||||
if (by > 0) {
|
||||
fxd->blur[0] = 0;
|
||||
fxd->blur[1] = by;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, shgrp, true);
|
||||
gpencil_draw_fx_pass(e_data, vedata, shgrp, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -866,8 +870,10 @@ static void draw_gpencil_do_blur(GPENCIL_e_data *e_data,
|
||||
int by,
|
||||
int blur[2])
|
||||
{
|
||||
e_data->input_depth_tx = e_data->temp_depth_tx_b;
|
||||
e_data->input_color_tx = e_data->temp_color_tx_b;
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
if ((samples > 0) && ((bx > 0) || (by > 0))) {
|
||||
for (int x = 0; x < samples; x++) {
|
||||
@@ -897,6 +903,7 @@ static void draw_gpencil_rim_passes(GPENCIL_e_data *e_data,
|
||||
return;
|
||||
}
|
||||
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
@@ -917,8 +924,8 @@ static void draw_gpencil_rim_passes(GPENCIL_e_data *e_data,
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
e_data->input_depth_tx = e_data->temp_depth_tx_b;
|
||||
e_data->input_color_tx = e_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
@@ -934,6 +941,7 @@ static void draw_gpencil_shadow_passes(GPENCIL_e_data *e_data,
|
||||
return;
|
||||
}
|
||||
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
const float clearcol[4] = {0.0f};
|
||||
@@ -953,8 +961,8 @@ static void draw_gpencil_shadow_passes(GPENCIL_e_data *e_data,
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
e_data->input_depth_tx = e_data->temp_depth_tx_b;
|
||||
e_data->input_color_tx = e_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
@@ -970,6 +978,7 @@ static void draw_gpencil_glow_passes(GPENCIL_e_data *e_data,
|
||||
return;
|
||||
}
|
||||
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
@@ -994,8 +1003,8 @@ static void draw_gpencil_glow_passes(GPENCIL_e_data *e_data,
|
||||
DRW_draw_pass_subset(psl->fx_shader_pass_blend, fxd->runtime.fx_sh_c, fxd->runtime.fx_sh_c);
|
||||
|
||||
/* copy pass from b to a for ping-pong frame buffers */
|
||||
e_data->input_depth_tx = e_data->temp_depth_tx_b;
|
||||
e_data->input_color_tx = e_data->temp_color_tx_b;
|
||||
stl->g_data->input_depth_tx = stl->g_data->temp_depth_tx_b;
|
||||
stl->g_data->input_color_tx = stl->g_data->temp_color_tx_b;
|
||||
|
||||
GPU_framebuffer_bind(fbl->temp_fb_a);
|
||||
GPU_framebuffer_clear_color_depth(fbl->temp_fb_a, clearcol, 1.0f);
|
||||
@@ -1008,8 +1017,6 @@ void DRW_gpencil_fx_draw(GPENCIL_e_data *e_data,
|
||||
tGPencilObjectCache *cache_ob)
|
||||
{
|
||||
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
|
||||
GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
|
||||
GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
|
||||
|
||||
/* loop FX modifiers */
|
||||
for (ShaderFxData *fx = cache_ob->shader_fx.first; fx; fx = fx->next) {
|
||||
@@ -1023,22 +1030,22 @@ void DRW_gpencil_fx_draw(GPENCIL_e_data *e_data,
|
||||
}
|
||||
case eShaderFxType_Colorize: {
|
||||
ColorizeShaderFxData *fxd = (ColorizeShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
case eShaderFxType_Flip: {
|
||||
FlipShaderFxData *fxd = (FlipShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
case eShaderFxType_Light: {
|
||||
LightShaderFxData *fxd = (LightShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
case eShaderFxType_Pixel: {
|
||||
PixelShaderFxData *fxd = (PixelShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
case eShaderFxType_Rim: {
|
||||
@@ -1058,12 +1065,12 @@ void DRW_gpencil_fx_draw(GPENCIL_e_data *e_data,
|
||||
}
|
||||
case eShaderFxType_Swirl: {
|
||||
SwirlShaderFxData *fxd = (SwirlShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
case eShaderFxType_Wave: {
|
||||
WaveShaderFxData *fxd = (WaveShaderFxData *)fx;
|
||||
gpencil_draw_fx_pass(e_data, psl, fbl, fxd->runtime.fx_sh, false);
|
||||
gpencil_draw_fx_pass(e_data, vedata, fxd->runtime.fx_sh, false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user