[vim/vim] Optimize DirectX rendering (#2560)

143 views
Skip to first unread message

K.Takata

unread,
Jan 18, 2018, 8:46:41 AM1/18/18
to vim/vim, Subscribed

As reported in the following thread, Vim 8.0.1343 becomes slower on some
environments (when using some kind of commands like :ver, :dig, ...):
https://groups.google.com/d/topic/vim_dev/2AaZMN1T6K8/discussion

This PR optimizes text rendering and makes scrolling faster.
Also fixes that sometimes the cursor flickers when DirectX is used.

The important point is that gui_mch_flush() is very slow on DirectX.
(It takes about 5 ms or more on some environment.)
I found that gui_mch_flush() was called unnecessarily, especially when
updating the cursor. For example, there are many parts like this:

            out_flush();
# ifdef FEAT_GUI
            if (gui.in_use)
            {
                gui_update_cursor(TRUE, FALSE);
                gui_mch_flush();
            }
# endif

gui_mch_flush() is called from the function out_flush(), then it is called
again right after gui_update_cursor(). I don't think the first call of
gui_mch_flush() is needed. I added two functions mch_disable_flush() and
mch_enable_flush() to control this. gui_mch_flush() is not called between
the two functions. I also added another function to make the above code
simpler. Now the above code becomes:

            out_flush_cursor(TRUE, FALSE);

This calls gui_mch_flush() only once.
After disabling unnecessary calls of gui_mch_flush(), scrolling becomes
faster and cursor flickering is fixed.

Actually, this change affects all GUIs.
I hope someone tries this on GTK 2/3 or other platforms.

I also stop using ScrollWindowEx() on DirectX to optimize scrolling.
After the optimization, scrlines option in 'renderoptions' becomes
useless now. So I made it deprecated.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/2560

Commit Summary

  • directx: Make scroll faster when scrlines:1
  • Don't issue gui_mch_flush() twice when updating cursor
  • Fix cursor updating issue
  • More optimization for gui_mch_flush()
  • Revise the implementation
  • Fix cursor updating issue
  • Make scroll faster when scrlines:0
  • Merge branch 'master' into optimize-directx
  • Refactor flush functions
  • Scroll by using DirectX instead of ScrollWindowEx
  • directx: Deprecate scrlines

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Ni Va

unread,
Jan 19, 2018, 5:31:13 AM1/19/18
to vim_dev
Hi,

Patch merged with gvim 8.0.1428.

Font used Inconsolata_for_powerline OK in directx renderoption:
Classical commands that were very Very VERY slow and made gvim unusable are now in a good response time.

Platform : dxdiag returns  Directx 11 enabled on AMD opteron Procc 6180 SE 2CPUS 2.5Ghz
Tested on VMware SVGA 3D (Microsoft Corporation WDDM)


Although, deoplete response time is acceptable.

Hope this help.
Niva


In my _vimrc
set rop=type:directx,
\gamma:1.0,
\contrast:1.0,
\level:0.0,
\geom:0,
\renmode:2,
\taamode:0,
set guifont=Inconsolata_for_Powerline:h9:cANSI:qDRAFT


VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jan 18 2018 16:03:34)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-1428
Huge version with GUI. Features included (+) or not (-):
+acl +byte_offset +comments +digraphs +farsi +iconv/dyn +linebreak +mouse +packages +python3/dyn +startuptime -termguicolors +user_commands +wildmenu
+arabic +channel +conceal +directx +file_in_path +insert_expand +lispindent +mouseshape +path_extra +quickfix +statusline +terminal +vertsplit +windows
+autocmd +cindent +cryptv -dnd +find_in_path +job +listcmds +multi_byte -perl +reltime -sun_workshop -tgetent +virtualedit +writebackup
+autoservername +clientserver -cscope -ebcdic +float +jumplist +localmap +multi_lang +persistent_undo +rightleft +syntax -termresponse +visual -xfontset
+balloon_eval +clipboard +cursorbind +emacs_tags +folding +keymap +lua/dyn -mzscheme -postscript +ruby/dyn +tag_binary +textobjects +visualextra -xim
-balloon_eval_term +cmdline_compl +cursorshape +eval -footer +lambda +menu -netbeans_intg +printer +scrollbind +tag_old_static +timers +viminfo -xpm_w32
+browse +cmdline_hist +dialog_con_gui +ex_extra +gettext/dyn +langmap +mksession +num64 +profile +signs -tag_any_white +title +vreplace -xterm_save
++builtin_terms +cmdline_info +diff +extra_search -hangul_input +libcall +modify_fname +ole +python/dyn +smartindent -tcl +toolbar +wildignore
system vimrc file: "$VIM\vimrc"
user vimrc file: "$HOME\_vimrc"
2nd user vimrc file: "$HOME\vimfiles\vimrc"
3rd user vimrc file: "$VIM\_vimrc"
user exrc file: "$HOME\_exrc"
2nd user exrc file: "$VIM\_exrc"
system gvimrc file: "$VIM\gvimrc"
user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
defaults file: "$VIMRUNTIME\defaults.vim"
system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_TERMINAL -DFEAT_JOB_CHANNEL -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /O2 /GL -DNDEBUG /Zl /MT -DFEAT_OLE -DFEAT_MBYTE -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DFEAT_DIRECTX_COLOR_EMOJI -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python36.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjGXOUYHRAMD64/ /Zi
Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib uuid.lib /machine:AMD64 gdi32.lib version.lib winspool.lib comctl32.lib advapi32.lib shell32.lib /machine:AMD64 libcmt.lib oleaut32.lib user32.lib /nodefaultlib:lua53.lib /nodefaultlib:python27.lib /nodefaultlib:python36.lib WSock32.lib /PDB:gvim.pdb -debug

Bram Moolenaar

unread,
Jan 31, 2018, 2:52:29 PM1/31/18
to vim/vim, Subscribed

Closed #2560 via a338adc.

Ni Va

unread,
Jan 31, 2018, 2:59:20 PM1/31/18
to vim_dev
Thank you !!
Reply all
Reply to author
Forward
0 new messages