diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-03-25 18:46:48 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-03-25 21:06:12 +0300 |
commit | bc15ec0896c2deba2e2a45581fd0f408d4906df4 (patch) | |
tree | 97f7f0a32a92fc441226c89fc09b80dbdc5e343f /source/blender/draw/engines/eevee/eevee_temporal_sampling.c | |
parent | f937123116abd4ba34ff858fa03415362d6c07cf (diff) |
GPUFramebuffer: Refactor (Part 2)
This refactor modernise the use of framebuffers.
It also touches a lot of files so breaking down changes we have:
- GPUTexture: Allow textures to be attached to more than one GPUFrameBuffer.
This allows to create and configure more FBO without the need to attach
and detach texture at drawing time.
- GPUFrameBuffer: The wrapper starts to mimic opengl a bit closer. This
allows to configure the framebuffer inside a context other than the one
that will be rendering the framebuffer. We do the actual configuration
when binding the FBO. We also Keep track of config validity and save
drawbuffers state in the FBO. We remove the different bind/unbind
functions. These make little sense now that we have separate contexts.
- DRWFrameBuffer: We replace DRW_framebuffer functions by GPU_framebuffer
ones to avoid another layer of abstraction. We move the DRW convenience
functions to GPUFramebuffer instead and even add new ones. The MACRO
GPU_framebuffer_ensure_config is pretty much all you need to create and
config a GPUFramebuffer.
- DRWTexture: Due to the removal of DRWFrameBuffer, we needed to create
functions to create textures for thoses framebuffers. Pool textures are
now using default texture parameters for the texture type asked.
- DRWManager: Make sure no framebuffer object is bound when doing cache
filling.
- GPUViewport: Add new color_only_fb and depth_only_fb along with FB API
usage update. This let draw engines render to color/depth only target
and without the need to attach/detach textures.
- WM_window: Assert when a framebuffer is bound when changing context.
This balance the fact we are not track ogl context inside GPUFramebuffer.
- Eevee, Clay, Mode engines: Update to new API. This comes with a lot of
code simplification.
This also come with some cleanups in some engine codes.
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_temporal_sampling.c')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_temporal_sampling.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index a417a9bdf56..25dbf4d4802 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -179,7 +179,6 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data (effects->enabled_effects & EFFECT_MOTION_BLUR) == 0) || DRW_state_is_image_render()) { - const float *viewport_size = DRW_viewport_size_get(); float persmat[4][4], viewmat[4][4]; if (!e_data.taa_resolve_sh) { @@ -239,11 +238,11 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data effects->taa_current_sample = 1; } - DRWFboTexture tex_double_buffer = {&txl->depth_double_buffer, DRW_TEX_DEPTH_24_STENCIL_8, 0}; + DRW_texture_ensure_fullscreen_2D(&txl->depth_double_buffer, DRW_TEX_DEPTH_24_STENCIL_8, 0); - DRW_framebuffer_init(&fbl->depth_double_buffer_fb, &draw_engine_eevee_type, - (int)viewport_size[0], (int)viewport_size[1], - &tex_double_buffer, 1); + GPU_framebuffer_ensure_config(&fbl->double_buffer_depth_fb, { + GPU_ATTACHMENT_TEXTURE(txl->depth_double_buffer) + }); return EFFECT_TAA | EFFECT_DOUBLE_BUFFER | EFFECT_POST_BUFFER; } @@ -252,7 +251,7 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data /* Cleanup to release memory */ DRW_TEXTURE_FREE_SAFE(txl->depth_double_buffer); - DRW_FRAMEBUFFER_FREE_SAFE(fbl->depth_double_buffer_fb); + GPU_FRAMEBUFFER_FREE_SAFE(fbl->double_buffer_depth_fb); return 0; } @@ -293,27 +292,28 @@ void EEVEE_temporal_sampling_draw(EEVEE_Data *vedata) effects->taa_alpha = 1.0f / (float)(effects->taa_current_sample); } - DRW_framebuffer_bind(fbl->effect_fb); + GPU_framebuffer_bind(fbl->effect_color_fb); DRW_draw_pass(psl->taa_resolve); /* Restore the depth from sample 1. */ if (!DRW_state_is_image_render()) { - DRW_framebuffer_blit(fbl->depth_double_buffer_fb, fbl->main, true, false); + GPU_framebuffer_blit(fbl->double_buffer_depth_fb, 0, fbl->main_fb, 0, GPU_DEPTH_BIT); } /* Special Swap */ - SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer); + SWAP(struct GPUFrameBuffer *, fbl->effect_fb, fbl->double_buffer_fb); + SWAP(struct GPUFrameBuffer *, fbl->effect_color_fb, fbl->double_buffer_color_fb); SWAP(GPUTexture *, txl->color_post, txl->color_double_buffer); effects->swap_double_buffer = false; effects->source_buffer = txl->color_double_buffer; - effects->target_buffer = fbl->main; + effects->target_buffer = fbl->main_fb; } else { /* Save the depth buffer for the next frame. * This saves us from doing anything special * in the other mode engines. */ if (!DRW_state_is_image_render()) { - DRW_framebuffer_blit(fbl->main, fbl->depth_double_buffer_fb, true, false); + GPU_framebuffer_blit(fbl->main_fb, 0, fbl->double_buffer_depth_fb, 0, GPU_DEPTH_BIT); } } |