GPU: don't use multisample for entire window, only for offscreen 3D viewport.
Now that the new 3D viewport draws to a multisample offscreen buffer, there is no good reason anymore to create an entire multisample window and pay the performance/memory cost for other regions that don't need it. GL_MULTISAMPLE now only gets enabled for offscreen buffers, so we don't need to check for it throughout the UI code anymore. Differential Revision: https://developer.blender.org/D3062
This commit is contained in:
parent
8049ad21b0
commit
7028a11db9
|
@ -6515,7 +6515,6 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
|
|||
win->modalcursor = 0;
|
||||
win->grabcursor = 0;
|
||||
win->addmousemove = true;
|
||||
win->multisamples = 0;
|
||||
win->stereo3d_format = newdataadr(fd, win->stereo3d_format);
|
||||
|
||||
/* multiview always fallback to anaglyph at file opening
|
||||
|
|
|
@ -1393,7 +1393,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
|||
ARegion *ar;
|
||||
uiBut *but;
|
||||
rcti rect;
|
||||
int multisample_enabled;
|
||||
|
||||
/* get menu region or area region */
|
||||
ar = CTX_wm_menu(C);
|
||||
|
@ -1403,11 +1402,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
|||
if (!block->endblock)
|
||||
UI_block_end(C, block);
|
||||
|
||||
/* disable AA, makes widgets too blurry */
|
||||
multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
|
||||
if (multisample_enabled)
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
|
||||
/* we set this only once */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
@ -1451,9 +1445,6 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
|||
gpuPopProjectionMatrix();
|
||||
gpuPopMatrix();
|
||||
|
||||
if (multisample_enabled)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
ui_draw_links(block);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,12 +175,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
|
|||
|
||||
float background_color[3];
|
||||
float tone_bg;
|
||||
int i, multisample_enabled;
|
||||
|
||||
/* disable AA, makes widgets too blurry */
|
||||
multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
|
||||
if (multisample_enabled)
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
int i;
|
||||
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
|
||||
|
@ -285,9 +280,6 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
|
|||
|
||||
BLF_disable(data->fstyle.uifont_id, BLF_WORD_WRAP);
|
||||
BLF_disable(blf_mono_font, BLF_WORD_WRAP);
|
||||
|
||||
if (multisample_enabled)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
static void ui_tooltip_region_free_cb(ARegion *ar)
|
||||
|
|
|
@ -213,11 +213,10 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
|
|||
|
||||
static void backdrawview3d(
|
||||
const struct EvaluationContext *eval_ctx, Scene *scene, ViewLayer *view_layer,
|
||||
wmWindow *win, ARegion *ar, View3D *v3d)
|
||||
ARegion *ar, View3D *v3d)
|
||||
{
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
struct Base *base = view_layer->basact;
|
||||
int multisample_enabled;
|
||||
|
||||
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
|
||||
|
||||
|
@ -264,14 +263,13 @@ static void backdrawview3d(
|
|||
/* dithering and AA break color coding, so disable */
|
||||
glDisable(GL_DITHER);
|
||||
|
||||
multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
|
||||
if (multisample_enabled)
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
|
||||
if (win->multisamples != USER_MULTISAMPLE_NONE) {
|
||||
if (false) {
|
||||
/* for multisample we use an offscreen FBO. multisample drawing can fail
|
||||
* with color coded selection drawing, and reading back depths from such
|
||||
* a buffer can also cause a few seconds freeze on OS X / NVidia. */
|
||||
* a buffer can also cause a few seconds freeze on OS X / NVidia.
|
||||
*
|
||||
* NOTE: code is no longer used now, but offscreen drawing is likely
|
||||
* what we will always want to do for the new viewport. */
|
||||
int w = BLI_rcti_size_x(&ar->winrct);
|
||||
int h = BLI_rcti_size_y(&ar->winrct);
|
||||
char error[256];
|
||||
|
@ -327,8 +325,6 @@ static void backdrawview3d(
|
|||
v3d->zbuf = false;
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_DITHER);
|
||||
if (multisample_enabled)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
if (rv3d->rflag & RV3D_CLIPPING)
|
||||
ED_view3d_clipping_disable();
|
||||
|
@ -358,7 +354,7 @@ static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h,
|
|||
void ED_view3d_backbuf_validate(const struct EvaluationContext *eval_ctx, ViewContext *vc)
|
||||
{
|
||||
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
|
||||
backdrawview3d(eval_ctx, vc->scene, vc->view_layer, vc->win, vc->ar, vc->v3d);
|
||||
backdrawview3d(eval_ctx, vc->scene, vc->view_layer, vc->ar, vc->v3d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2007,11 +2003,6 @@ static void view3d_main_region_draw_objects(
|
|||
do_compositing = GPU_fx_compositor_initialize_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, &fx_settings);
|
||||
}
|
||||
|
||||
/* enables anti-aliasing for 3D view drawing */
|
||||
if (win->multisamples != USER_MULTISAMPLE_NONE) {
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
/* main drawing call */
|
||||
view3d_draw_objects(C, &eval_ctx, scene, v3d, ar, grid_unit, true, false, do_compositing ? rv3d->compositor : NULL);
|
||||
|
||||
|
@ -2020,11 +2011,6 @@ static void view3d_main_region_draw_objects(
|
|||
GPU_fx_do_composite_pass(rv3d->compositor, rv3d->winmat, rv3d->is_persp, scene, NULL);
|
||||
}
|
||||
|
||||
/* Disable back anti-aliasing */
|
||||
if (win->multisamples != USER_MULTISAMPLE_NONE) {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
if (v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
|
||||
/* find header and force tag redraw */
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
|
|
@ -2095,7 +2095,7 @@ int GPU_scene_object_lights(ViewLayer *view_layer, float viewmat[4][4], int orth
|
|||
return count;
|
||||
}
|
||||
|
||||
static void gpu_multisample(bool enable)
|
||||
static void gpu_disable_multisample()
|
||||
{
|
||||
#ifdef __linux__
|
||||
/* changing multisample from the default (enabled) causes problems on some
|
||||
|
@ -2111,16 +2111,10 @@ static void gpu_multisample(bool enable)
|
|||
}
|
||||
|
||||
if (toggle_ok) {
|
||||
if (enable)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
else
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
#else
|
||||
if (enable)
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
else
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2152,7 +2146,7 @@ void GPU_state_init(void)
|
|||
glCullFace(GL_BACK);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
gpu_multisample(false);
|
||||
gpu_disable_multisample();
|
||||
}
|
||||
|
||||
void GPU_enable_program_point_size(void)
|
||||
|
|
|
@ -197,8 +197,7 @@ typedef struct wmWindow {
|
|||
short modalcursor; /* the current modal cursor */
|
||||
short grabcursor; /* cursor grab mode */
|
||||
short addmousemove; /* internal: tag this for extra mousemove event, makes cursors/buttons active on UI switching */
|
||||
short multisamples; /* amount of samples for OpenGL FSA the ghost window was created with, if zero no FSA */
|
||||
short pad[3];
|
||||
short pad[4];
|
||||
|
||||
int winid; /* winid also in screens, is for retrieving this window after read */
|
||||
|
||||
|
|
|
@ -182,7 +182,6 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
|
|||
static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWindow *win)
|
||||
{
|
||||
win->ghostwin = oldwin->ghostwin;
|
||||
win->multisamples = oldwin->multisamples;
|
||||
win->active = oldwin->active;
|
||||
if (win->active)
|
||||
wm->winactive = win;
|
||||
|
@ -191,7 +190,6 @@ static void wm_window_substitute_old(wmWindowManager *wm, wmWindow *oldwin, wmWi
|
|||
GHOST_SetWindowUserData(win->ghostwin, win); /* pointer back */
|
||||
|
||||
oldwin->ghostwin = NULL;
|
||||
oldwin->multisamples = 0;
|
||||
|
||||
win->eventstate = oldwin->eventstate;
|
||||
oldwin->eventstate = NULL;
|
||||
|
|
|
@ -175,7 +175,6 @@ static void wm_ghostwindow_destroy(wmWindow *win)
|
|||
if (win->ghostwin) {
|
||||
GHOST_DisposeWindow(g_system, win->ghostwin);
|
||||
win->ghostwin = NULL;
|
||||
win->multisamples = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,16 +460,8 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
|
|||
{
|
||||
GHOST_WindowHandle ghostwin;
|
||||
GHOST_GLSettings glSettings = {0};
|
||||
static int multisamples = -1;
|
||||
int scr_w, scr_h, posy;
|
||||
|
||||
/* force setting multisamples only once, it requires restart - and you cannot
|
||||
* mix it, either all windows have it, or none (tested in OSX opengl) */
|
||||
if (multisamples == -1)
|
||||
multisamples = U.ogl_multisamples;
|
||||
|
||||
glSettings.numOfAASamples = multisamples;
|
||||
|
||||
/* a new window is created when pageflip mode is required for a window */
|
||||
if (win->stereo3d_format->display_mode == S3D_DISPLAY_PAGEFLIP)
|
||||
glSettings.flags |= GHOST_glStereoVisual;
|
||||
|
@ -508,9 +499,6 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, const char *title, wm
|
|||
if (win->eventstate == NULL)
|
||||
win->eventstate = MEM_callocN(sizeof(wmEvent), "window event state");
|
||||
|
||||
/* store multisamples window was created with, in case user prefs change */
|
||||
win->multisamples = multisamples;
|
||||
|
||||
/* store actual window size in blender window */
|
||||
bounds = GHOST_GetClientBounds(win->ghostwin);
|
||||
|
||||
|
|
|
@ -390,16 +390,9 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
|
|||
return;
|
||||
}
|
||||
|
||||
const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
|
||||
|
||||
/* TODO this will need it own shader probably? don't think it can be handled from that point though. */
|
||||
/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */
|
||||
|
||||
/* enable multisampling */
|
||||
if (draw_multisample) {
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
bool is_depth_prev = false;
|
||||
|
||||
/* draw_manipulators contains all visible manipulators - draw them */
|
||||
|
@ -435,10 +428,6 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
|
|||
if (is_depth_prev) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
if (draw_multisample) {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
}
|
||||
|
||||
void WM_manipulatormap_draw(
|
||||
|
|
Loading…
Reference in New Issue