diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c index 23cfe82276f..2bed0327064 100644 --- a/source/blender/draw/engines/clay/clay.c +++ b/source/blender/draw/engines/clay/clay.c @@ -341,7 +341,7 @@ static void CLAY_engine_init(void *vedata) { float *viewport_size = DRW_viewport_size_get(); - DRWFboTexture tex = {&txl->depth_dup, DRW_BUF_DEPTH_24}; + DRWFboTexture tex = {&txl->depth_dup, DRW_BUF_DEPTH_24, 0}; DRW_framebuffer_init(&fbl->dupli_depth, (int)viewport_size[0], (int)viewport_size[1], &tex, 1); diff --git a/source/blender/draw/engines/eevee/eevee.c b/source/blender/draw/engines/eevee/eevee.c index d9b1ce596c6..7588ebede0c 100644 --- a/source/blender/draw/engines/eevee/eevee.c +++ b/source/blender/draw/engines/eevee/eevee.c @@ -58,7 +58,7 @@ static void EEVEE_engine_init(void *vedata) EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl; EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; - DRWFboTexture tex = {&txl->color, DRW_BUF_RGBA_16}; + DRWFboTexture tex = {&txl->color, DRW_BUF_RGBA_16, DRW_TEX_FILTER}; float *viewport_size = DRW_viewport_size_get(); DRW_framebuffer_init(&fbl->main, diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index dafe724ecbe..1e99b95f27c 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -159,6 +159,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo); typedef struct DRWFboTexture { struct GPUTexture **tex; int format; + DRWTextureFlag flag; } DRWFboTexture; void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTexture textures[MAX_FBO_TEX], int texnbr); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 1b414673f24..3f150a06cb7 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1219,8 +1219,11 @@ bool DRW_is_object_renderable(Object *ob) /* ****************************************** Framebuffers ******************************************/ -static GPUTextureFormat convert_tex_format(int fbo_format, int *channels) +static GPUTextureFormat convert_tex_format(int fbo_format, int *channels, bool *is_depth) { + *is_depth = ((fbo_format == DRW_BUF_DEPTH_16) || + (fbo_format == DRW_BUF_DEPTH_24)); + switch (fbo_format) { case DRW_BUF_RGBA_8: *channels = 4; return GPU_RGBA8; case DRW_BUF_RGBA_16: *channels = 4; return GPU_RGBA16F; @@ -1246,18 +1249,13 @@ void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRW if (!*fbotex.tex) { int channels; - GPUTextureFormat gpu_format = convert_tex_format(fbotex.format, &channels); + bool is_depth; + GPUTextureFormat gpu_format = convert_tex_format(fbotex.format, &channels, &is_depth); - /* TODO refine to opengl formats */ - if (fbotex.format == DRW_BUF_DEPTH_16 || - fbotex.format == DRW_BUF_DEPTH_24) - { - *fbotex.tex = GPU_texture_create_depth(width, height, NULL); - GPU_texture_compare_mode(*fbotex.tex, false); - GPU_texture_filter_mode(*fbotex.tex, false); - } - else { - *fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL); + *fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL); + drw_texture_set_parameters(*fbotex.tex, fbotex.flag); + + if (!is_depth) { ++color_attachment; } } diff --git a/source/blender/draw/modes/edit_curve_mode.c b/source/blender/draw/modes/edit_curve_mode.c index d70db64d946..5c60df270f9 100644 --- a/source/blender/draw/modes/edit_curve_mode.c +++ b/source/blender/draw/modes/edit_curve_mode.c @@ -123,8 +123,8 @@ static void EDIT_CURVE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 79d43c73378..ecb3844547c 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -121,8 +121,8 @@ static void EDIT_LATTICE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c index 2991d212efa..dc5c109757b 100644 --- a/source/blender/draw/modes/edit_mesh_mode.c +++ b/source/blender/draw/modes/edit_mesh_mode.c @@ -135,8 +135,8 @@ static void EDIT_MESH_engine_init(void *vedata) float *viewport_size = DRW_viewport_size_get(); - DRWFboTexture tex[2] = {{&txl->occlude_wire_depth_tx, DRW_BUF_DEPTH_24}, - {&txl->occlude_wire_color_tx, DRW_BUF_RGBA_8}}; + 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}}; DRW_framebuffer_init(&fbl->occlude_wire_fb, (int)viewport_size[0], (int)viewport_size[1], tex, 2); diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c index 098dca7ac38..989f1350f9d 100644 --- a/source/blender/draw/modes/edit_metaball_mode.c +++ b/source/blender/draw/modes/edit_metaball_mode.c @@ -121,8 +121,8 @@ static void EDIT_METABALL_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/edit_surface_mode.c b/source/blender/draw/modes/edit_surface_mode.c index fcae505a673..eb6673a52ba 100644 --- a/source/blender/draw/modes/edit_surface_mode.c +++ b/source/blender/draw/modes/edit_surface_mode.c @@ -121,8 +121,8 @@ static void EDIT_SURFACE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/edit_text_mode.c b/source/blender/draw/modes/edit_text_mode.c index 2a1b0d4e4ae..5fd14c04240 100644 --- a/source/blender/draw/modes/edit_text_mode.c +++ b/source/blender/draw/modes/edit_text_mode.c @@ -121,8 +121,8 @@ static void EDIT_TEXT_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 5a9582bd319..5588a8075fe 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -196,13 +196,13 @@ static void OBJECT_engine_init(void *vedata) float *viewport_size = DRW_viewport_size_get(); - DRWFboTexture tex[2] = {{&txl->outlines_depth_tx, DRW_BUF_DEPTH_24}, - {&txl->outlines_color_tx, DRW_BUF_RGBA_8}}; + DRWFboTexture tex[2] = {{&txl->outlines_depth_tx, DRW_BUF_DEPTH_24, 0}, + {&txl->outlines_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; DRW_framebuffer_init(&fbl->outlines, (int)viewport_size[0], (int)viewport_size[1], tex, 2); - DRWFboTexture blur_tex = {&txl->outlines_blur_tx, DRW_BUF_RGBA_8}; + DRWFboTexture blur_tex = {&txl->outlines_blur_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER}; DRW_framebuffer_init(&fbl->blur, (int)viewport_size[0], (int)viewport_size[1], &blur_tex, 1); diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c index 9d620e0ce25..4476ed69b75 100644 --- a/source/blender/draw/modes/paint_texture_mode.c +++ b/source/blender/draw/modes/paint_texture_mode.c @@ -121,8 +121,8 @@ static void PAINT_TEXTURE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c index b3b32a4d6e9..6bb8cc38488 100644 --- a/source/blender/draw/modes/paint_vertex_mode.c +++ b/source/blender/draw/modes/paint_vertex_mode.c @@ -121,8 +121,8 @@ static void PAINT_VERTEX_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c index 2d189e07fd2..72251e18067 100644 --- a/source/blender/draw/modes/paint_weight_mode.c +++ b/source/blender/draw/modes/paint_weight_mode.c @@ -121,8 +121,8 @@ static void PAINT_WEIGHT_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index aab9c41a233..611f08e8abf 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -115,8 +115,8 @@ static void PARTICLE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c index 93514701010..fc8dc4090f6 100644 --- a/source/blender/draw/modes/pose_mode.c +++ b/source/blender/draw/modes/pose_mode.c @@ -115,8 +115,8 @@ static void POSE_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 4b500c4d6fd..c21140e46d3 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -115,8 +115,8 @@ static void SCULPT_engine_init(void *vedata) /* Init Framebuffers like this: order is attachment order (for color texs) */ /* - * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, - * {&txl->color, DRW_BUF_RGBA_8}}; + * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0}, + * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}}; */ /* DRW_framebuffer_init takes care of checking if