Draw Manager: Use Texture flag in Framebuffer init.

This commit is contained in:
Clément Foucault
2017-04-05 12:57:32 +02:00
parent fad3fe4ed1
commit 0811d089b4
17 changed files with 40 additions and 41 deletions

View File

@@ -341,7 +341,7 @@ static void CLAY_engine_init(void *vedata)
{ {
float *viewport_size = DRW_viewport_size_get(); 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, DRW_framebuffer_init(&fbl->dupli_depth,
(int)viewport_size[0], (int)viewport_size[1], (int)viewport_size[0], (int)viewport_size[1],
&tex, 1); &tex, 1);

View File

@@ -58,7 +58,7 @@ static void EEVEE_engine_init(void *vedata)
EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl; EEVEE_FramebufferList *fbl = ((EEVEE_Data *)vedata)->fbl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl; 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(); float *viewport_size = DRW_viewport_size_get();
DRW_framebuffer_init(&fbl->main, DRW_framebuffer_init(&fbl->main,

View File

@@ -159,6 +159,7 @@ void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
typedef struct DRWFboTexture { typedef struct DRWFboTexture {
struct GPUTexture **tex; struct GPUTexture **tex;
int format; int format;
DRWTextureFlag flag;
} DRWFboTexture; } DRWFboTexture;
void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTexture textures[MAX_FBO_TEX], int texnbr); void DRW_framebuffer_init(struct GPUFrameBuffer **fb, int width, int height, DRWFboTexture textures[MAX_FBO_TEX], int texnbr);

View File

@@ -1219,8 +1219,11 @@ bool DRW_is_object_renderable(Object *ob)
/* ****************************************** Framebuffers ******************************************/ /* ****************************************** 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) { switch (fbo_format) {
case DRW_BUF_RGBA_8: *channels = 4; return GPU_RGBA8; case DRW_BUF_RGBA_8: *channels = 4; return GPU_RGBA8;
case DRW_BUF_RGBA_16: *channels = 4; return GPU_RGBA16F; 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) { if (!*fbotex.tex) {
int channels; 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 */ *fbotex.tex = GPU_texture_create_2D_custom(width, height, channels, gpu_format, NULL, NULL);
if (fbotex.format == DRW_BUF_DEPTH_16 || drw_texture_set_parameters(*fbotex.tex, fbotex.flag);
fbotex.format == DRW_BUF_DEPTH_24)
{ if (!is_depth) {
*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);
++color_attachment; ++color_attachment;
} }
} }

View File

@@ -123,8 +123,8 @@ static void EDIT_CURVE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -121,8 +121,8 @@ static void EDIT_LATTICE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -135,8 +135,8 @@ static void EDIT_MESH_engine_init(void *vedata)
float *viewport_size = DRW_viewport_size_get(); float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex[2] = {{&txl->occlude_wire_depth_tx, DRW_BUF_DEPTH_24}, DRWFboTexture tex[2] = {{&txl->occlude_wire_depth_tx, DRW_BUF_DEPTH_24, 0},
{&txl->occlude_wire_color_tx, DRW_BUF_RGBA_8}}; {&txl->occlude_wire_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
DRW_framebuffer_init(&fbl->occlude_wire_fb, DRW_framebuffer_init(&fbl->occlude_wire_fb,
(int)viewport_size[0], (int)viewport_size[1], (int)viewport_size[0], (int)viewport_size[1],
tex, 2); tex, 2);

View File

@@ -121,8 +121,8 @@ static void EDIT_METABALL_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -121,8 +121,8 @@ static void EDIT_SURFACE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -121,8 +121,8 @@ static void EDIT_TEXT_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -196,13 +196,13 @@ static void OBJECT_engine_init(void *vedata)
float *viewport_size = DRW_viewport_size_get(); float *viewport_size = DRW_viewport_size_get();
DRWFboTexture tex[2] = {{&txl->outlines_depth_tx, DRW_BUF_DEPTH_24}, DRWFboTexture tex[2] = {{&txl->outlines_depth_tx, DRW_BUF_DEPTH_24, 0},
{&txl->outlines_color_tx, DRW_BUF_RGBA_8}}; {&txl->outlines_color_tx, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
DRW_framebuffer_init(&fbl->outlines, DRW_framebuffer_init(&fbl->outlines,
(int)viewport_size[0], (int)viewport_size[1], (int)viewport_size[0], (int)viewport_size[1],
tex, 2); 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, DRW_framebuffer_init(&fbl->blur,
(int)viewport_size[0], (int)viewport_size[1], (int)viewport_size[0], (int)viewport_size[1],
&blur_tex, 1); &blur_tex, 1);

View File

@@ -121,8 +121,8 @@ static void PAINT_TEXTURE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -121,8 +121,8 @@ static void PAINT_VERTEX_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -121,8 +121,8 @@ static void PAINT_WEIGHT_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -115,8 +115,8 @@ static void PARTICLE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -115,8 +115,8 @@ static void POSE_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if

View File

@@ -115,8 +115,8 @@ static void SCULPT_engine_init(void *vedata)
/* Init Framebuffers like this: order is attachment order (for color texs) */ /* Init Framebuffers like this: order is attachment order (for color texs) */
/* /*
* DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24}, * DRWFboTexture tex[2] = {{&txl->depth, DRW_BUF_DEPTH_24, 0},
* {&txl->color, DRW_BUF_RGBA_8}}; * {&txl->color, DRW_BUF_RGBA_8, DRW_TEX_FILTER}};
*/ */
/* DRW_framebuffer_init takes care of checking if /* DRW_framebuffer_init takes care of checking if