Draw Manager: Make use of texture reuse.

This commit is contained in:
Clément Foucault 2017-05-16 03:03:58 +02:00
parent 7a029f4e00
commit 2e8cb8d836
13 changed files with 116 additions and 86 deletions

View File

@ -137,7 +137,7 @@ static void BASIC_engine_init(void *vedata)
if (DRW_state_is_fbo()) {
const float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex = {&txl->depth_dup, DRW_BUF_DEPTH_24, 0};
DRW_framebuffer_init(&fbl->dupli_depth,
DRW_framebuffer_init(&fbl->dupli_depth, &draw_engine_basic_type,
(int)viewport_size[0], (int)viewport_size[1],
&tex, 1);
}

View File

@ -26,6 +26,7 @@
#ifndef __BASIC_ENGINE_H__
#define __BASIC_ENGINE_H__
extern DrawEngineType draw_engine_basic_type;
extern RenderEngineType DRW_engine_viewport_basic_type;
#endif /* __BASIC_ENGINE_H__ */

View File

@ -109,14 +109,6 @@ typedef struct CLAY_FramebufferList {
struct GPUFrameBuffer *dupli_depth;
} CLAY_FramebufferList;
typedef struct CLAY_TextureList {
/* default */
struct GPUTexture *color;
struct GPUTexture *depth;
/* engine specific */
struct GPUTexture *depth_dup;
} CLAY_TextureList;
typedef struct CLAY_PassList {
struct DRWPass *depth_pass;
struct DRWPass *depth_pass_cull;
@ -127,7 +119,7 @@ typedef struct CLAY_PassList {
typedef struct CLAY_Data {
void *engine_type;
CLAY_FramebufferList *fbl;
CLAY_TextureList *txl;
DRWViewportEmptyList *txl;
CLAY_PassList *psl;
CLAY_StorageList *stl;
} CLAY_Data;
@ -155,6 +147,10 @@ static struct {
/* Just a serie of int from 0 to MAX_CLAY_MAT-1 */
int ubo_mat_idxs[MAX_CLAY_MAT];
int hair_ubo_mat_idxs[MAX_CLAY_MAT];
/* engine specific */
struct GPUTexture *depth_dup;
} e_data = {NULL}; /* Engine data */
typedef struct CLAY_PrivateData {
@ -281,7 +277,6 @@ static struct GPUTexture *create_jitter_texture(void)
static void CLAY_engine_init(void *vedata)
{
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
CLAY_TextureList *txl = ((CLAY_Data *)vedata)->txl;
CLAY_FramebufferList *fbl = ((CLAY_Data *)vedata)->fbl;
/* Create Texture Array */
@ -374,8 +369,8 @@ static void CLAY_engine_init(void *vedata)
if (DRW_state_is_fbo()) {
const float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex = {&txl->depth_dup, DRW_BUF_DEPTH_24, 0};
DRW_framebuffer_init(&fbl->dupli_depth,
DRWFboTexture tex = {&e_data.depth_dup, DRW_BUF_DEPTH_24, DRW_TEX_TEMP};
DRW_framebuffer_init(&fbl->dupli_depth, &draw_engine_clay_type,
(int)viewport_size[0], (int)viewport_size[1],
&tex, 1);
}
@ -448,14 +443,12 @@ static void CLAY_engine_init(void *vedata)
}
}
static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *vedata, DRWPass *pass, int *material_id)
static DRWShadingGroup *CLAY_shgroup_create(CLAY_Data *UNUSED(vedata), DRWPass *pass, int *material_id)
{
CLAY_TextureList *txl = ((CLAY_Data *)vedata)->txl;
DRWShadingGroup *grp = DRW_shgroup_create(e_data.clay_sh, pass);
DRW_shgroup_uniform_vec2(grp, "screenres", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_buffer(grp, "depthtex", &txl->depth_dup);
DRW_shgroup_uniform_buffer(grp, "depthtex", &e_data.depth_dup);
DRW_shgroup_uniform_texture(grp, "matcaps", e_data.matcap_array);
DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)e_data.winmat);
DRW_shgroup_uniform_vec4(grp, "viewvecs[0]", (float *)e_data.viewvecs, 3);
@ -803,7 +796,16 @@ static void CLAY_draw_scene(void *vedata)
/* Pass 2 : Duplicate depth */
/* Unless we go for deferred shading we need this to avoid manual depth test and artifacts */
if (DRW_state_is_fbo()) {
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->dupli_depth, e_data.depth_dup, 0, 0);
DRW_framebuffer_blit(dfbl->default_fb, fbl->dupli_depth, true);
/* detach temp textures */
DRW_framebuffer_texture_detach(e_data.depth_dup);
/* restore default fb */
DRW_framebuffer_bind(dfbl->default_fb);
}
/* Pass 3 : Shading */

View File

@ -26,6 +26,7 @@
#ifndef __CLAY_ENGINE_H__
#define __CLAY_ENGINE_H__
extern DrawEngineType draw_engine_clay_type;
extern RenderEngineType DRW_engine_viewport_clay_type;
struct IDProperty;

View File

@ -229,7 +229,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
effects->blit_texel_size[1] = 1.0f / (float)blitsize[1];
DRWFboTexture tex_blit = {&txl->bloom_blit, DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->bloom_blit_fb,
DRW_framebuffer_init(&fbl->bloom_blit_fb, &draw_engine_eevee_type,
(int)blitsize[0], (int)blitsize[1],
&tex_blit, 1);
@ -264,7 +264,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
effects->downsamp_texel_size[i][1] = 1.0f / (float)texsize[1];
DRWFboTexture tex_bloom = {&txl->bloom_downsample[i], DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->bloom_down_fb[i],
DRW_framebuffer_init(&fbl->bloom_down_fb[i], &draw_engine_eevee_type,
(int)texsize[0], (int)texsize[1],
&tex_bloom, 1);
}
@ -277,7 +277,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
texsize[1] = MAX2(texsize[1], 2);
DRWFboTexture tex_bloom = {&txl->bloom_upsample[i], DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->bloom_accum_fb[i],
DRW_framebuffer_init(&fbl->bloom_accum_fb[i], &draw_engine_eevee_type,
(int)texsize[0], (int)texsize[1],
&tex_bloom, 1);
}
@ -302,13 +302,13 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
DRWFboTexture tex_down[3] = {{&txl->dof_down_near, DRW_BUF_RGBA_16, 0},
{&txl->dof_down_far, DRW_BUF_RGBA_16, 0},
{&txl->dof_coc, DRW_BUF_RG_16, 0}};
DRW_framebuffer_init(&fbl->dof_down_fb, buffer_size[0], buffer_size[1], tex_down, 3);
DRW_framebuffer_init(&fbl->dof_down_fb, &draw_engine_eevee_type, buffer_size[0], buffer_size[1], tex_down, 3);
DRWFboTexture tex_scatter_far = {&txl->dof_far_blur, DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->dof_scatter_far_fb, buffer_size[0], buffer_size[1], &tex_scatter_far, 1);
DRW_framebuffer_init(&fbl->dof_scatter_far_fb, &draw_engine_eevee_type, buffer_size[0], buffer_size[1], &tex_scatter_far, 1);
DRWFboTexture tex_scatter_near = {&txl->dof_near_blur, DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->dof_scatter_near_fb, buffer_size[0], buffer_size[1], &tex_scatter_near, 1);
DRW_framebuffer_init(&fbl->dof_scatter_near_fb, &draw_engine_eevee_type, buffer_size[0], buffer_size[1], &tex_scatter_near, 1);
/* Parameters */
/* TODO UI Options */
@ -351,7 +351,7 @@ void EEVEE_effects_init(EEVEE_Data *vedata)
/* Ping Pong buffer */
DRWFboTexture tex = {&txl->color_post, DRW_BUF_RGBA_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->effect_fb,
DRW_framebuffer_init(&fbl->effect_fb, &draw_engine_eevee_type,
(int)viewport_size[0], (int)viewport_size[1],
&tex, 1);
}

View File

@ -166,7 +166,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h))
tex = DRW_texture_create_2D(w, h, DRW_TEX_RG_16, DRW_TEX_FILTER, (float *)texels);
DRWFboTexture tex_filter = {&tex, DRW_BUF_RG_16, DRW_TEX_FILTER};
DRW_framebuffer_init(&fb, w, h, &tex_filter, 1);
DRW_framebuffer_init(&fb, &draw_engine_eevee_type, w, h, &tex_filter, 1);
DRW_framebuffer_bind(fb);
DRW_draw_pass(pass);
@ -215,7 +215,7 @@ static void EEVEE_engine_init(void *ved)
DRWFboTexture tex = {&txl->color, DRW_BUF_RGBA_16, DRW_TEX_FILTER};
const float *viewport_size = DRW_viewport_size_get();
DRW_framebuffer_init(&fbl->main,
DRW_framebuffer_init(&fbl->main, &draw_engine_eevee_type,
(int)viewport_size[0], (int)viewport_size[1],
&tex, 1);

View File

@ -168,13 +168,13 @@ void EEVEE_lights_cache_finish(EEVEE_StorageList *stl, EEVEE_TextureList *txl, E
}
DRWFboTexture tex_cube = {&txl->shadow_depth_cube_pool, DRW_BUF_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE};
DRW_framebuffer_init(&fbl->shadow_cube_fb, 512, 512, &tex_cube, 1);
DRW_framebuffer_init(&fbl->shadow_cube_fb, &draw_engine_eevee_type, 512, 512, &tex_cube, 1);
DRWFboTexture tex_map = {&txl->shadow_depth_map_pool, DRW_BUF_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE};
DRW_framebuffer_init(&fbl->shadow_map_fb, 512, 512, &tex_map, 1);
DRW_framebuffer_init(&fbl->shadow_map_fb, &draw_engine_eevee_type, 512, 512, &tex_map, 1);
DRWFboTexture tex_cascade = {&txl->shadow_depth_cascade_pool, DRW_BUF_DEPTH_24, DRW_TEX_FILTER | DRW_TEX_COMPARE};
DRW_framebuffer_init(&fbl->shadow_cascade_fb, 512, 512, &tex_cascade, 1);
DRW_framebuffer_init(&fbl->shadow_cascade_fb, &draw_engine_eevee_type, 512, 512, &tex_cascade, 1);
}
/* Update buffer with lamp data */

View File

@ -28,6 +28,8 @@
struct Object;
extern struct DrawEngineType draw_engine_eevee_type;
/* Minimum UBO is 16384 bytes */
#define MAX_LIGHT 128 /* TODO : find size by dividing UBO max size by light data size */
#define MAX_SHADOW_CUBE 42 /* TODO : Make this depends on GL_MAX_ARRAY_TEXTURE_LAYERS */

View File

@ -75,7 +75,7 @@ void EEVEE_probes_init(EEVEE_Data *vedata)
DRWFboTexture tex_probe[2] = {{&txl->probe_depth_rt, DRW_BUF_DEPTH_24, DRW_TEX_FILTER},
{&txl->probe_rt, DRW_BUF_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP}};
DRW_framebuffer_init(&fbl->probe_fb, PROBE_SIZE, PROBE_SIZE, tex_probe, 2);
DRW_framebuffer_init(&fbl->probe_fb, &draw_engine_eevee_type, PROBE_SIZE, PROBE_SIZE, tex_probe, 2);
if (!txl->probe_pool) {
float *test_tex;
@ -97,12 +97,12 @@ void EEVEE_probes_init(EEVEE_Data *vedata)
DRWFboTexture tex_filter = {&txl->probe_pool, DRW_BUF_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
DRW_framebuffer_init(&fbl->probe_filter_fb, PROBE_SIZE, PROBE_SIZE, &tex_filter, 1);
DRW_framebuffer_init(&fbl->probe_filter_fb, &draw_engine_eevee_type, PROBE_SIZE, PROBE_SIZE, &tex_filter, 1);
/* Spherical Harmonic Buffer */
DRWFboTexture tex_sh = {&txl->probe_sh, DRW_BUF_RGBA_16, DRW_TEX_FILTER | DRW_TEX_MIPMAP};
DRW_framebuffer_init(&fbl->probe_sh_fb, 9, 1, &tex_sh, 1);
DRW_framebuffer_init(&fbl->probe_sh_fb, &draw_engine_eevee_type, 9, 1, &tex_sh, 1);
}
void EEVEE_probes_cache_init(EEVEE_Data *UNUSED(vedata))

View File

@ -150,6 +150,7 @@ typedef enum {
DRW_TEX_WRAP = (1 << 1),
DRW_TEX_COMPARE = (1 << 2),
DRW_TEX_MIPMAP = (1 << 3),
DRW_TEX_TEMP = (1 << 4),
} DRWTextureFlag;
struct GPUTexture *DRW_texture_create_1D(
@ -198,7 +199,7 @@ typedef struct DRWFboTexture {
} DRWFboTexture;
void DRW_framebuffer_init(
struct GPUFrameBuffer **fb, int width, int height,
struct GPUFrameBuffer **fb, void *engine_type, int width, int height,
DRWFboTexture textures[MAX_FBO_TEX], int textures_len);
void DRW_framebuffer_bind(struct GPUFrameBuffer *fb);
void DRW_framebuffer_clear(bool color, bool depth, bool stencil, float clear_col[4], float clear_depth);

View File

@ -1869,7 +1869,7 @@ static GPUTextureFormat convert_tex_format(int fbo_format, int *channels, bool *
}
void DRW_framebuffer_init(
struct GPUFrameBuffer **fb, int width, int height,
struct GPUFrameBuffer **fb, void *engine_type, int width, int height,
DRWFboTexture textures[MAX_FBO_TEX], int textures_len)
{
BLI_assert(textures_len <= MAX_FBO_TEX);
@ -1883,10 +1883,17 @@ void DRW_framebuffer_init(
bool is_depth;
DRWFboTexture fbotex = textures[i];
bool is_temp = (fbotex.flag & DRW_TEX_TEMP) != 0;
GPUTextureFormat gpu_format = convert_tex_format(fbotex.format, &channels, &is_depth);
if (!*fbotex.tex) {
*fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL);
if (!*fbotex.tex || is_temp) {
if (is_temp) {
*fbotex.tex = GPU_viewport_texture_pool_query(DST.viewport, engine_type, width, height, channels, gpu_format);
}
else {
*fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL);
}
drw_texture_set_parameters(*fbotex.tex, fbotex.flag);
}
@ -1894,13 +1901,22 @@ void DRW_framebuffer_init(
++color_attachment;
}
GPU_framebuffer_texture_attach(*fb, *fbotex.tex, color_attachment, 0);
GPU_framebuffer_texture_attach(*fb, *fbotex.tex, color_attachment, 0);
}
if (!GPU_framebuffer_check_valid(*fb, NULL)) {
printf("Error invalid framebuffer\n");
}
/* Detach temp textures */
for (int i = 0; i < textures_len; ++i) {
DRWFboTexture fbotex = textures[i];
if ((fbotex.flag & DRW_TEX_TEMP) != 0) {
GPU_framebuffer_texture_detach(*fbotex.tex);
}
}
GPU_framebuffer_bind(DST.default_framebuffer);
}
}

View File

@ -68,11 +68,6 @@ typedef struct EDIT_MESH_FramebufferList {
struct GPUFrameBuffer *occlude_wire_fb;
} EDIT_MESH_FramebufferList;
typedef struct EDIT_MESH_TextureList {
struct GPUTexture *occlude_wire_depth_tx;
struct GPUTexture *occlude_wire_color_tx;
} EDIT_MESH_TextureList;
typedef struct EDIT_MESH_StorageList {
struct EDIT_MESH_PrivateData *g_data;
} EDIT_MESH_StorageList;
@ -80,7 +75,7 @@ typedef struct EDIT_MESH_StorageList {
typedef struct EDIT_MESH_Data {
void *engine_type;
EDIT_MESH_FramebufferList *fbl;
EDIT_MESH_TextureList *txl;
DRWViewportEmptyList *txl;
EDIT_MESH_PassList *psl;
EDIT_MESH_StorageList *stl;
} EDIT_MESH_Data;
@ -104,6 +99,9 @@ static struct {
GPUShader *normals_loop_sh;
GPUShader *normals_sh;
GPUShader *depth_sh;
/* temp buffer texture */
struct GPUTexture *occlude_wire_depth_tx;
struct GPUTexture *occlude_wire_color_tx;
} e_data = {NULL}; /* Engine data */
typedef struct EDIT_MESH_PrivateData {
@ -132,17 +130,16 @@ typedef struct EDIT_MESH_PrivateData {
static void EDIT_MESH_engine_init(void *vedata)
{
EDIT_MESH_TextureList *txl = ((EDIT_MESH_Data *)vedata)->txl;
EDIT_MESH_FramebufferList *fbl = ((EDIT_MESH_Data *)vedata)->fbl;
const float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex[2] = {{
&txl->occlude_wire_depth_tx, DRW_BUF_DEPTH_24, 0},
{&txl->occlude_wire_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER}
&e_data.occlude_wire_depth_tx, DRW_BUF_DEPTH_24, DRW_TEX_TEMP},
{&e_data.occlude_wire_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER | DRW_TEX_TEMP}
};
DRW_framebuffer_init(
&fbl->occlude_wire_fb,
&fbl->occlude_wire_fb, &draw_engine_edit_mesh_type,
(int)viewport_size[0], (int)viewport_size[1],
tex, ARRAY_SIZE(tex));
@ -304,7 +301,6 @@ static float size_normal;
static void EDIT_MESH_cache_init(void *vedata)
{
EDIT_MESH_TextureList *txl = ((EDIT_MESH_Data *)vedata)->txl;
EDIT_MESH_PassList *psl = ((EDIT_MESH_Data *)vedata)->psl;
EDIT_MESH_StorageList *stl = ((EDIT_MESH_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
@ -393,8 +389,8 @@ static void EDIT_MESH_cache_init(void *vedata)
DRWShadingGroup *mix_shgrp = DRW_shgroup_create(e_data.overlay_mix_sh, psl->mix_occlude);
DRW_shgroup_call_add(mix_shgrp, quad, NULL);
DRW_shgroup_uniform_float(mix_shgrp, "alpha", &backwire_opacity, 1);
DRW_shgroup_uniform_buffer(mix_shgrp, "wireColor", &txl->occlude_wire_color_tx);
DRW_shgroup_uniform_buffer(mix_shgrp, "wireDepth", &txl->occlude_wire_depth_tx);
DRW_shgroup_uniform_buffer(mix_shgrp, "wireColor", &e_data.occlude_wire_color_tx);
DRW_shgroup_uniform_buffer(mix_shgrp, "wireDepth", &e_data.occlude_wire_depth_tx);
DRW_shgroup_uniform_buffer(mix_shgrp, "sceneDepth", &dtxl->depth);
}
}
@ -510,6 +506,10 @@ static void EDIT_MESH_draw_scene(void *vedata)
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* render facefill */
DRW_draw_pass(psl->facefill_occlude);
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->occlude_wire_fb, e_data.occlude_wire_depth_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->occlude_wire_fb, e_data.occlude_wire_color_tx, 0, 0);
/* Render wires on a separate framebuffer */
DRW_framebuffer_bind(fbl->occlude_wire_fb);
@ -524,6 +524,10 @@ static void EDIT_MESH_draw_scene(void *vedata)
DRW_framebuffer_bind(dfbl->default_fb);
DRW_draw_pass(psl->mix_occlude);
/* detach temp textures */
DRW_framebuffer_texture_detach(e_data.occlude_wire_depth_tx);
DRW_framebuffer_texture_detach(e_data.occlude_wire_color_tx);
/* reattach */
DRW_framebuffer_texture_attach(dfbl->default_fb, dtxl->depth, 0, 0);
}

View File

@ -84,12 +84,6 @@ typedef struct OBJECT_FramebufferList {
struct GPUFrameBuffer *blur;
} OBJECT_FramebufferList;
typedef struct OBJECT_TextureList {
struct GPUTexture *outlines_depth_tx;
struct GPUTexture *outlines_color_tx;
struct GPUTexture *outlines_blur_tx;
} OBJECT_TextureList;
typedef struct OBJECT_StorageList {
struct OBJECT_PrivateData *g_data;
} OBJECT_StorageList;
@ -97,7 +91,7 @@ typedef struct OBJECT_StorageList {
typedef struct OBJECT_Data {
void *engine_type;
OBJECT_FramebufferList *fbl;
OBJECT_TextureList *txl;
DRWViewportEmptyList *txl;
OBJECT_PassList *psl;
OBJECT_StorageList *stl;
} OBJECT_Data;
@ -192,6 +186,10 @@ static struct {
int grid_flag;
int zpos_flag;
int zneg_flag;
/* Temp buffer textures */
struct GPUTexture *outlines_depth_tx;
struct GPUTexture *outlines_color_tx;
struct GPUTexture *outlines_blur_tx;
} e_data = {NULL}; /* Engine data */
@ -211,25 +209,24 @@ enum {
static void OBJECT_engine_init(void *vedata)
{
OBJECT_TextureList *txl = ((OBJECT_Data *)vedata)->txl;
OBJECT_FramebufferList *fbl = ((OBJECT_Data *)vedata)->fbl;
const float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex[2] = {
{&txl->outlines_depth_tx, DRW_BUF_DEPTH_24, 0},
{&txl->outlines_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER},
};
if (DRW_state_is_fbo()) {
DRWFboTexture tex[2] = {
{&e_data.outlines_depth_tx, DRW_BUF_DEPTH_24, DRW_TEX_TEMP},
{&e_data.outlines_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER | DRW_TEX_TEMP},
};
DRW_framebuffer_init(
&fbl->outlines,
&fbl->outlines, &draw_engine_object_type,
(int)viewport_size[0], (int)viewport_size[1],
tex, 2);
DRWFboTexture blur_tex = {&txl->outlines_blur_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER};
DRWFboTexture blur_tex = {&e_data.outlines_blur_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER | DRW_TEX_TEMP};
DRW_framebuffer_init(
&fbl->blur,
&fbl->blur, &draw_engine_object_type,
(int)viewport_size[0], (int)viewport_size[1],
&blur_tex, 1);
}
@ -451,7 +448,6 @@ static DRWShadingGroup *shgroup_theme_id_to_wire_or(
static void OBJECT_cache_init(void *vedata)
{
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
OBJECT_TextureList *txl = ((OBJECT_Data *)vedata)->txl;
OBJECT_StorageList *stl = ((OBJECT_Data *)vedata)->stl;
DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
@ -494,8 +490,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_search = DRW_pass_create("Outlines Expand Pass", state);
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_detect_sh, psl->outlines_search);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "sceneDepth", &dtxl->depth);
DRW_shgroup_uniform_float(grp, "alphaOcclu", &alphaOcclu, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -503,8 +499,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_expand = DRW_pass_create("Outlines Expand Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_expand);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &one, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bTrue, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -512,8 +508,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_fade1 = DRW_pass_create("Outlines Fade 1 Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade1);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &alpha1, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -521,8 +517,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_fade2 = DRW_pass_create("Outlines Fade 2 Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade2);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &alpha2, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -530,8 +526,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_fade3 = DRW_pass_create("Outlines Fade 3 Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade3);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &alpha3, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -539,8 +535,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_fade4 = DRW_pass_create("Outlines Fade 4 Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade4);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &alpha4, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -548,8 +544,8 @@ static void OBJECT_cache_init(void *vedata)
psl->outlines_fade5 = DRW_pass_create("Outlines Fade 5 Pass", state);
grp = DRW_shgroup_create(e_data.outline_fade_sh, psl->outlines_fade5);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &txl->outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &txl->outlines_depth_tx);
DRW_shgroup_uniform_buffer(grp, "outlineColor", &e_data.outlines_color_tx);
DRW_shgroup_uniform_buffer(grp, "outlineDepth", &e_data.outlines_depth_tx);
DRW_shgroup_uniform_float(grp, "alpha", &alpha5, 1);
DRW_shgroup_uniform_bool(grp, "doExpand", &bFalse, 1);
DRW_shgroup_call_add(grp, quad, NULL);
@ -562,7 +558,7 @@ static void OBJECT_cache_init(void *vedata)
struct Batch *quad = DRW_cache_fullscreen_quad_get();
DRWShadingGroup *grp = DRW_shgroup_create(e_data.outline_resolve_sh, psl->outlines_resolve);
DRW_shgroup_uniform_buffer(grp, "outlineBluredColor", &txl->outlines_blur_tx);
DRW_shgroup_uniform_buffer(grp, "outlineBluredColor", &e_data.outlines_blur_tx);
DRW_shgroup_call_add(grp, quad, NULL);
}
@ -1295,18 +1291,22 @@ static void OBJECT_draw_scene(void *vedata)
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
OBJECT_FramebufferList *fbl = ((OBJECT_Data *)vedata)->fbl;
OBJECT_TextureList *txl = ((OBJECT_Data *)vedata)->txl;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f};
if (DRW_state_is_fbo()) {
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->outlines, e_data.outlines_depth_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->outlines, e_data.outlines_color_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->blur, e_data.outlines_blur_tx, 0, 0);
/* Render filled polygon on a separate framebuffer */
DRW_framebuffer_bind(fbl->outlines);
DRW_framebuffer_clear(true, true, false, clearcol, 1.0f);
DRW_draw_pass(psl->outlines);
/* detach textures */
DRW_framebuffer_texture_detach(txl->outlines_depth_tx);
DRW_framebuffer_texture_detach(e_data.outlines_depth_tx);
/* Search outline pixels */
DRW_framebuffer_bind(fbl->blur);
@ -1331,8 +1331,11 @@ static void OBJECT_draw_scene(void *vedata)
DRW_framebuffer_bind(fbl->blur);
DRW_draw_pass(psl->outlines_fade5);
/* reattach */
DRW_framebuffer_texture_attach(fbl->outlines, txl->outlines_depth_tx, 0, 0);
/* detach temp textures */
DRW_framebuffer_texture_detach(e_data.outlines_color_tx);
DRW_framebuffer_texture_detach(e_data.outlines_blur_tx);
/* restore main framebuffer */
DRW_framebuffer_bind(dfbl->default_fb);
}