Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_antialiasing.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_antialiasing.c.
| Show All 37 Lines | |||||
| * - Only uses one additional lightweight full-screen buffer (compared to MSAA/SMAA). | * - Only uses one additional lightweight full-screen buffer (compared to MSAA/SMAA). | ||||
| * - No convergence time (compared to TAA). | * - No convergence time (compared to TAA). | ||||
| */ | */ | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) | void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_FramebufferList *fbl = vedata->fbl; | OVERLAY_FramebufferList *fbl = vedata->fbl; | ||||
| OVERLAY_TextureList *txl = vedata->txl; | OVERLAY_TextureList *txl = vedata->txl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| /* Small texture which will have very small impact on render-time. */ | /* Small texture which will have very small impact on render-time. */ | ||||
| if (txl->dummy_depth_tx == NULL) { | if (txl->dummy_depth_tx == NULL) { | ||||
| const float pixel[1] = {1.0f}; | const float pixel[1] = {1.0f}; | ||||
| txl->dummy_depth_tx = DRW_texture_create_2d(1, 1, GPU_DEPTH_COMPONENT24, 0, pixel); | txl->dummy_depth_tx = DRW_texture_create_2d( | ||||
| 1, 1, GPU_DEPTH_COMPONENT24, DRWTextureFlag(0), pixel); | |||||
| } | } | ||||
| if (!DRW_state_is_fbo()) { | if (!DRW_state_is_fbo()) { | ||||
| pd->antialiasing.enabled = false; | pd->antialiasing.enabled = false; | ||||
| return; | return; | ||||
| } | } | ||||
| bool need_wire_expansion = (G_draw.block.size_pixel > 1.0f); | bool need_wire_expansion = (G_draw.block.size_pixel > 1.0f); | ||||
| pd->antialiasing.enabled = need_wire_expansion || | pd->antialiasing.enabled = need_wire_expansion || | ||||
| ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); | ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); | ||||
| GPUTexture *color_tex = NULL; | GPUTexture *color_tex = NULL; | ||||
| GPUTexture *line_tex = NULL; | GPUTexture *line_tex = NULL; | ||||
| if (pd->antialiasing.enabled) { | if (pd->antialiasing.enabled) { | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->overlay_color_tx, GPU_SRGB8_A8, DRW_TEX_FILTER); | DRW_texture_ensure_fullscreen_2d(&txl->overlay_color_tx, GPU_SRGB8_A8, DRW_TEX_FILTER); | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->overlay_line_tx, GPU_RGBA8, 0); | DRW_texture_ensure_fullscreen_2d(&txl->overlay_line_tx, GPU_RGBA8, DRWTextureFlag(0)); | ||||
| color_tex = txl->overlay_color_tx; | color_tex = txl->overlay_color_tx; | ||||
| line_tex = txl->overlay_line_tx; | line_tex = txl->overlay_line_tx; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Just a copy of the defaults frame-buffers. */ | /* Just a copy of the defaults frame-buffers. */ | ||||
| color_tex = dtxl->color_overlay; | color_tex = dtxl->color_overlay; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | pd->antialiasing.do_depth_copy = !(psl->wireframe_ps == NULL || | ||||
| DRW_pass_is_empty(psl->wireframe_ps)) || | DRW_pass_is_empty(psl->wireframe_ps)) || | ||||
| (pd->xray_enabled && pd->xray_opacity > 0.0f); | (pd->xray_enabled && pd->xray_opacity > 0.0f); | ||||
| pd->antialiasing.do_depth_infront_copy = !(psl->wireframe_xray_ps == NULL || | pd->antialiasing.do_depth_infront_copy = !(psl->wireframe_xray_ps == NULL || | ||||
| DRW_pass_is_empty(psl->wireframe_xray_ps)); | DRW_pass_is_empty(psl->wireframe_xray_ps)); | ||||
| const bool do_wireframe = pd->antialiasing.do_depth_copy || | const bool do_wireframe = pd->antialiasing.do_depth_copy || | ||||
| pd->antialiasing.do_depth_infront_copy; | pd->antialiasing.do_depth_infront_copy; | ||||
| if (pd->xray_enabled || do_wireframe) { | if (pd->xray_enabled || do_wireframe) { | ||||
| DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, 0); | DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0)); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_antialiasing_start(OVERLAY_Data *vedata) | void OVERLAY_antialiasing_start(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_FramebufferList *fbl = vedata->fbl; | OVERLAY_FramebufferList *fbl = vedata->fbl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| ▲ Show 20 Lines • Show All 67 Lines • Show Last 20 Lines | |||||