diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index 5c960acbd78..55f67d3d981 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -417,8 +417,10 @@ void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) { WORKBENCH_PrivateData *wpd = vedata->stl->wpd; WORKBENCH_FramebufferList *fbl = vedata->fbl; + WORKBENCH_TextureList *txl = vedata->txl; WORKBENCH_PassList *psl = vedata->psl; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); + DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); if (wpd->taa_sample_len == 0) { /* AA disabled. */ @@ -440,10 +442,10 @@ void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) wpd->valid_history = true; /* In playback mode, we are sure the next redraw will not use the same viewmatrix. * In this case no need to save the depth buffer. */ - eGPUFrameBufferBits bits = GPU_COLOR_BIT | (!wpd->is_playback ? GPU_DEPTH_BIT : 0); - GPU_framebuffer_blit(dfbl->default_fb, 0, fbl->antialiasing_fb, 0, bits); + GPU_texture_copy(txl->depth_buffer_tx, dtxl->depth); + GPU_texture_copy(txl->history_buffer_tx, dtxl->color); if (workbench_in_front_history_needed(vedata)) { - GPU_framebuffer_blit(dfbl->in_front_fb, 0, fbl->antialiasing_in_front_fb, 0, GPU_DEPTH_BIT); + GPU_texture_copy(txl->depth_buffer_in_front_tx, dtxl->depth_in_front); } } else { @@ -453,9 +455,9 @@ void workbench_antialiasing_draw_pass(WORKBENCH_Data *vedata) DRW_draw_pass(psl->aa_accum_ps); } /* Copy back the saved depth buffer for correct overlays. */ - GPU_framebuffer_blit(fbl->antialiasing_fb, 0, dfbl->default_fb, 0, GPU_DEPTH_BIT); + GPU_texture_copy(dtxl->depth, txl->depth_buffer_tx); if (workbench_in_front_history_needed(vedata)) { - GPU_framebuffer_blit(fbl->antialiasing_in_front_fb, 0, dfbl->in_front_fb, 0, GPU_DEPTH_BIT); + GPU_texture_copy(dtxl->depth_in_front, txl->depth_buffer_in_front_tx); } } diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h index 892452a2738..d6e5866ae28 100644 --- a/source/blender/gpu/GPU_texture.h +++ b/source/blender/gpu/GPU_texture.h @@ -239,6 +239,8 @@ void GPU_texture_bind(GPUTexture *tex, int number); void GPU_texture_unbind(GPUTexture *tex); int GPU_texture_bound_number(GPUTexture *tex); +void GPU_texture_copy(GPUTexture *dst, GPUTexture *src); + void GPU_texture_generate_mipmap(GPUTexture *tex); void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare); void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter); diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 6d2d0f09a42..6f147deffc6 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -1719,6 +1719,27 @@ void GPU_texture_generate_mipmap(GPUTexture *tex) gpu_texture_memory_footprint_add(tex); } +void GPU_texture_copy(GPUTexture *dst, GPUTexture *src) +{ + BLI_assert(GLEW_ARB_copy_image); + + glCopyImageSubData(src->bindcode, + src->target, + 0, + 0, + 0, + 0, + dst->bindcode, + dst->target, + 0, + 0, + 0, + 0, + src->w, + src->h, + max_ii(src->d, 1)); +} + void GPU_texture_compare_mode(GPUTexture *tex, bool use_compare) { WARN_NOT_BOUND(tex);