Blender V5.3
overlay_antialiasing.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
42
43#pragma once
44
45#include "overlay_base.hh"
46
47#include "DNA_userdef_types.h"
48
50
52 private:
53 PassSimple anti_aliasing_ps_ = {"AntiAliasing"};
54
55 gpu::FrameBuffer *framebuffer_ref_ = nullptr;
56
57 public:
58 void begin_sync(Resources &res, const State &state) final
59 {
60 if (res.is_selection()) {
61 anti_aliasing_ps_.init();
62 return;
63 }
64
65 const bool do_smooth_lines = (U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0;
66 const bool do_background_fetch = state.xray_enabled_and_not_wire && state.is_space_v3d() &&
67 (state.rv3d->is_persp || state.rv3d->view == RV3D_VIEW_USER);
68
69 {
70 PassSimple &pass = anti_aliasing_ps_;
71 pass.init();
72 pass.framebuffer_set(&framebuffer_ref_);
74 pass.shader_set(res.shaders->anti_aliasing.get());
75 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
76 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
77 pass.bind_texture("depth_tx", &res.depth_target_tx);
78 pass.bind_texture("color_tx", &res.overlay_tx);
79 pass.bind_texture("line_tx", &res.line_tx);
80 pass.push_constant("do_smooth_lines", do_smooth_lines);
81 pass.push_constant("do_background_fetch", do_background_fetch);
83 }
84 }
85
86 void draw_output(Framebuffer &framebuffer, Manager &manager, View & /*view*/) final
87 {
88 framebuffer_ref_ = framebuffer;
89 manager.submit(anti_aliasing_ps_);
90 }
91};
92
93} // namespace blender::draw::overlay
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
Definition draw_pass.hh:976
void framebuffer_set(gpu::FrameBuffer **framebuffer)
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void state_set(DRWState state, int clip_plane_count=0)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
void push_constant(const char *name, const float &data)
void begin_sync(Resources &res, const State &state) final
void draw_output(Framebuffer &framebuffer, Manager &manager, View &) final
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
const int state
detail::Pass< command::DrawCommandBuf > PassSimple
UserDef U
Definition blender.cc:58
@ USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:32
@ DRW_STATE_BLEND_ALPHA_PREMUL
Definition draw_state.hh:59