Draw: Removal of MultiSample Buffers
Multisample buffers were used for smooth line drawing. As we now have an algorithm that doesn't need the multisample buffers we can remove them. The user preference for viewport multi_sampling is replaced by single toggle overlay `use_overlay_smooth_wire`. By default this setting is enabled as the new drawing is really quick (<1ms) and uses zero hacks. Reviewed By: fclem Differential Revision: https://developer.blender.org/D6367
This commit is contained in:
parent
601eafd104
commit
15abc9fe74
|
@ -62,7 +62,7 @@ const UserDef U_default = {
|
|||
USER_HIDE_DOT | USER_SHOW_GIZMO_NAVIGATE | USER_SHOW_VIEWPORTNAME | USER_SHOW_FPS |
|
||||
USER_CONTINUOUS_MOUSE | USER_SAVE_PROMPT),
|
||||
.uiflag2 = USER_REGION_OVERLAP,
|
||||
.gpu_flag = 0,
|
||||
.gpu_flag = USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE,
|
||||
.app_flag = 0,
|
||||
.language = 0,
|
||||
.viewzoom = USER_ZOOM_DOLLY,
|
||||
|
@ -160,7 +160,6 @@ const UserDef U_default = {
|
|||
NDOF_ROTX_INVERT_AXIS | NDOF_ROTY_INVERT_AXIS | NDOF_ROTZ_INVERT_AXIS |
|
||||
NDOF_PANX_INVERT_AXIS | NDOF_PANY_INVERT_AXIS | NDOF_PANZ_INVERT_AXIS |
|
||||
NDOF_ZOOM_INVERT),
|
||||
.ogl_multisamples = 0,
|
||||
.image_draw_method = IMAGE_DRAW_METHOD_AUTO,
|
||||
.glalphaclip = 0.004,
|
||||
.autokey_mode = (AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON),
|
||||
|
|
|
@ -675,8 +675,8 @@ class USERPREF_PT_viewport_quality(PreferencePanel, Panel):
|
|||
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
|
||||
|
||||
flow.prop(system, "viewport_aa")
|
||||
flow.prop(system, "multi_sample", text="Multisampling")
|
||||
flow.prop(system, "gpencil_multi_sample", text="Grease Pencil Multisampling")
|
||||
flow.prop(system, "use_overlay_smooth_wire")
|
||||
flow.prop(system, "use_edit_mode_smooth_wire")
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* \note Use #STRINGIFY() rather than defining with quotes.
|
||||
*/
|
||||
#define BLENDER_VERSION 282
|
||||
#define BLENDER_SUBVERSION 3
|
||||
#define BLENDER_SUBVERSION 4
|
||||
/** Several breakages with 280, e.g. collections vs layers. */
|
||||
#define BLENDER_MINVERSION 280
|
||||
#define BLENDER_MINSUBVERSION 0
|
||||
|
|
|
@ -531,7 +531,6 @@ typedef struct ImBuf *(*SequencerDrawView)(struct Depsgraph *depsgraph,
|
|||
unsigned int flag,
|
||||
unsigned int draw_flags,
|
||||
int alpha_mode,
|
||||
int samples,
|
||||
const char *viewname,
|
||||
struct GPUOffScreen *ofs,
|
||||
char err_out[256]);
|
||||
|
|
|
@ -3558,7 +3558,6 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
|
|||
IB_rect,
|
||||
draw_flags,
|
||||
scene->r.alphamode,
|
||||
U.ogl_multisamples,
|
||||
viewname,
|
||||
context->gpu_offscreen,
|
||||
err_out);
|
||||
|
|
|
@ -667,10 +667,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
|||
userdef->file_space_data.filter_id = U_default.file_space_data.filter_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include next version bump.
|
||||
*/
|
||||
{
|
||||
if (!USER_VERSION_ATLEAST(282, 4)) {
|
||||
if (userdef->view_rotate_sensitivity_turntable == 0.0f) {
|
||||
userdef->view_rotate_sensitivity_turntable = DEG2RADF(0.4f);
|
||||
userdef->view_rotate_sensitivity_trackball = 1.0f;
|
||||
|
@ -678,6 +675,15 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
|||
if (userdef->scrollback == 0) {
|
||||
userdef->scrollback = U_default.scrollback;
|
||||
}
|
||||
|
||||
/* Enable Overlay Engine Smooth Wire by default */
|
||||
userdef->gpu_flag |= USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include next version bump.
|
||||
*/
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata)
|
|||
}
|
||||
|
||||
bool need_wire_expansion = (G_draw.block.sizePixel > 1.0f);
|
||||
/* TODO Get real userpref option and remove MSAA buffer. */
|
||||
pd->antialiasing.enabled = (dtxl->multisample_color != NULL) || need_wire_expansion;
|
||||
pd->antialiasing.enabled = need_wire_expansion ||
|
||||
((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) > 0);
|
||||
|
||||
GPUTexture *color_tex = NULL;
|
||||
GPUTexture *line_tex = NULL;
|
||||
|
@ -122,8 +122,9 @@ void OVERLAY_antialiasing_cache_init(OVERLAY_Data *vedata)
|
|||
DRWShadingGroup *grp;
|
||||
|
||||
if (pd->antialiasing.enabled) {
|
||||
/* TODO Get real userpref option and remove MSAA buffer. */
|
||||
const bool do_smooth_lines = (dtxl->multisample_color != NULL);
|
||||
/* `antialiasing.enabled` is also enabled for wire expansion. Check here if
|
||||
* anti aliasing is needed. */
|
||||
const bool do_smooth_lines = (U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) > 0;
|
||||
|
||||
DRW_PASS_CREATE(psl->antialiasing_ps, DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_PREMUL);
|
||||
|
||||
|
|
|
@ -101,41 +101,6 @@ typedef char DRWViewportEmptyList;
|
|||
DRW_VIEWPORT_LIST_SIZE(*(((ty *)NULL)->stl)), \
|
||||
}
|
||||
|
||||
/* Use of multisample framebuffers. */
|
||||
#define MULTISAMPLE_SYNC_ENABLE(dfbl, dtxl) \
|
||||
{ \
|
||||
if (dfbl->multisample_fb != NULL && DRW_state_is_fbo()) { \
|
||||
DRW_stats_query_start("Multisample Blit"); \
|
||||
GPU_framebuffer_bind(dfbl->multisample_fb); \
|
||||
/* TODO clear only depth but need to do alpha to coverage for transparencies. */ \
|
||||
GPU_framebuffer_clear_color_depth(dfbl->multisample_fb, (const float[4]){0.0f}, 1.0f); \
|
||||
DRW_stats_query_end(); \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define MULTISAMPLE_SYNC_DISABLE(dfbl, dtxl) \
|
||||
{ \
|
||||
if (dfbl->multisample_fb != NULL && DRW_state_is_fbo()) { \
|
||||
DRW_stats_query_start("Multisample Resolve"); \
|
||||
GPU_framebuffer_bind(dfbl->default_fb); \
|
||||
DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, true); \
|
||||
DRW_stats_query_end(); \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define MULTISAMPLE_SYNC_DISABLE_NO_DEPTH(dfbl, dtxl) \
|
||||
{ \
|
||||
if (dfbl->multisample_fb != NULL && DRW_state_is_fbo()) { \
|
||||
DRW_stats_query_start("Multisample Resolve"); \
|
||||
GPU_framebuffer_bind(dfbl->default_fb); \
|
||||
DRW_multisamples_resolve(dtxl->multisample_depth, dtxl->multisample_color, false); \
|
||||
DRW_stats_query_end(); \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
typedef struct DrawEngineDataSize {
|
||||
int fbl_len;
|
||||
int txl_len;
|
||||
|
@ -176,15 +141,12 @@ typedef struct DefaultFramebufferList {
|
|||
struct GPUFrameBuffer *in_front_fb;
|
||||
struct GPUFrameBuffer *color_only_fb;
|
||||
struct GPUFrameBuffer *depth_only_fb;
|
||||
struct GPUFrameBuffer *multisample_fb;
|
||||
} DefaultFramebufferList;
|
||||
|
||||
typedef struct DefaultTextureList {
|
||||
struct GPUTexture *color;
|
||||
struct GPUTexture *depth;
|
||||
struct GPUTexture *depth_in_front;
|
||||
struct GPUTexture *multisample_color;
|
||||
struct GPUTexture *multisample_depth;
|
||||
} DefaultTextureList;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -593,7 +593,6 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Depsgraph *depsgraph,
|
|||
int sizey,
|
||||
unsigned int flag,
|
||||
int alpha_mode,
|
||||
int samples,
|
||||
const char *viewname,
|
||||
struct GPUOffScreen *ofs,
|
||||
char err_out[256]);
|
||||
|
@ -607,7 +606,6 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Depsgraph *depsgraph,
|
|||
unsigned int flag,
|
||||
unsigned int draw_flags,
|
||||
int alpha_mode,
|
||||
int samples,
|
||||
const char *viewname,
|
||||
struct GPUOffScreen *ofs,
|
||||
char err_out[256]);
|
||||
|
|
|
@ -114,7 +114,6 @@ typedef struct OGLRender {
|
|||
ImageUser iuser;
|
||||
|
||||
GPUOffScreen *ofs;
|
||||
int ofs_samples;
|
||||
int sizex, sizey;
|
||||
int write_still;
|
||||
|
||||
|
@ -371,7 +370,6 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
|
|||
sizey,
|
||||
output_flags,
|
||||
alpha_mode,
|
||||
oglrender->ofs_samples,
|
||||
viewname,
|
||||
oglrender->ofs,
|
||||
err_out);
|
||||
|
@ -392,7 +390,6 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R
|
|||
output_flags,
|
||||
V3D_OFSDRAW_SHOW_ANNOTATION,
|
||||
alpha_mode,
|
||||
oglrender->ofs_samples,
|
||||
viewname,
|
||||
oglrender->ofs,
|
||||
err_out);
|
||||
|
@ -539,7 +536,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
|
|||
const bool is_write_still = RNA_boolean_get(op->ptr, "write_still");
|
||||
const eImageFormatDepth color_depth = (is_animation) ? scene->r.im_format.depth :
|
||||
R_IMF_CHAN_DEPTH_32;
|
||||
const int samples = U.ogl_multisamples;
|
||||
char err_out[256] = "unknown";
|
||||
|
||||
if (G.background) {
|
||||
|
@ -584,7 +580,7 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
|
|||
|
||||
/* corrects render size with actual size, not every card supports non-power-of-two dimensions */
|
||||
DRW_opengl_context_enable(); /* Offscreen creation needs to be done in DRW context. */
|
||||
ofs = GPU_offscreen_create(sizex, sizey, samples, true, true, err_out);
|
||||
ofs = GPU_offscreen_create(sizex, sizey, 0, true, true, err_out);
|
||||
DRW_opengl_context_disable();
|
||||
|
||||
if (!ofs) {
|
||||
|
@ -607,7 +603,6 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
|
|||
* output video handles, which does need evaluated scene. */
|
||||
oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
oglrender->cfrao = scene->r.cfra;
|
||||
oglrender->ofs_samples = samples;
|
||||
|
||||
oglrender->write_still = is_write_still && !is_animation;
|
||||
oglrender->is_animation = is_animation;
|
||||
|
|
|
@ -6209,7 +6209,6 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
|
|||
h,
|
||||
IB_rect,
|
||||
R_ALPHAPREMUL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
err_out);
|
||||
|
|
|
@ -1688,7 +1688,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
|
|||
int sizey,
|
||||
uint flag,
|
||||
int alpha_mode,
|
||||
int samples,
|
||||
const char *viewname,
|
||||
/* output vars */
|
||||
GPUOffScreen *ofs,
|
||||
|
@ -1717,7 +1716,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph,
|
|||
|
||||
if (own_ofs) {
|
||||
/* bind */
|
||||
ofs = GPU_offscreen_create(sizex, sizey, samples, true, false, err_out);
|
||||
ofs = GPU_offscreen_create(sizex, sizey, 0, true, false, err_out);
|
||||
if (ofs == NULL) {
|
||||
DRW_opengl_context_disable();
|
||||
return NULL;
|
||||
|
@ -1835,7 +1834,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
|
|||
uint flag,
|
||||
uint draw_flags,
|
||||
int alpha_mode,
|
||||
int samples,
|
||||
const char *viewname,
|
||||
GPUOffScreen *ofs,
|
||||
char err_out[256])
|
||||
|
@ -1909,7 +1907,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Depsgraph *depsgraph,
|
|||
height,
|
||||
flag,
|
||||
alpha_mode,
|
||||
samples,
|
||||
viewname,
|
||||
ofs,
|
||||
err_out);
|
||||
|
|
|
@ -1042,6 +1042,7 @@ typedef enum eUserpref_UI_Flag2 {
|
|||
typedef enum eUserpref_GPU_Flag {
|
||||
USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0),
|
||||
USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1),
|
||||
USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE = (1 << 2),
|
||||
} eUserpref_GPU_Flag;
|
||||
|
||||
/** #UserDef.tablet_api */
|
||||
|
|
|
@ -5062,12 +5062,11 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
|||
|
||||
/* OpenGL */
|
||||
|
||||
/* Full scene anti-aliasing */
|
||||
prop = RNA_def_property(srna, "multi_sample", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_bitflag_sdna(prop, NULL, "ogl_multisamples");
|
||||
RNA_def_property_enum_items(prop, multi_sample_levels);
|
||||
/* Viewport anti-aliasing */
|
||||
prop = RNA_def_property(srna, "use_overlay_smooth_wire", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gpu_flag", USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "MultiSample", "Enable OpenGL multi-sampling, only for systems that support it");
|
||||
prop, "Overlay Smooth Wires", "Enable overlay smooth wires, reducing aliasing");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_dpi_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_edit_mode_smooth_wire", PROP_BOOLEAN, PROP_NONE);
|
||||
|
|
|
@ -1251,7 +1251,6 @@ static ImBuf *blend_file_thumb(const bContext *C,
|
|||
IB_rect,
|
||||
V3D_OFSDRAW_NONE,
|
||||
R_ALPHAPREMUL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
err_out);
|
||||
|
@ -1266,7 +1265,6 @@ static ImBuf *blend_file_thumb(const bContext *C,
|
|||
BLEN_THUMB_SIZE * 2,
|
||||
IB_rect,
|
||||
R_ALPHAPREMUL,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
err_out);
|
||||
|
|
Loading…
Reference in New Issue