Files
xemu/ui/meson.build
T
Erik Abair 99a8bd3b48 ui: Use DXGI to perform swapping on Windows
In #2691, xemu was updated to decouple the guest vblank interrupt from the host
refresh. This allows the UI thread to run at host FPS while the guest runs at
60 fps, matching HW behavior.

On Window machines using AMD drivers, this led to a major decrease in guest
performance when vsync is enabled, apparently due to locking behavior in the
driver holding the guest pfifo thread while awaiting vblank. This manifests as
reduced perf that gets worse when running at a lower display refresh rate.

This PR bypasses the GL swap entirely, utilizing Windows DXGI to perform swaps
and allowing the pfifo operations to proceed without blocking.

https://github.com/abaire/xemu-perf-tests/blob/4115d262c5e80d6b71234f8df65fa78c8ef15e12/src/tests/surface_rendering_tests.cpp#L167
reproduces the issue seen with Conker L&R (slow glo_readpixels) but it is
somewhat subtle at the given tuning. Modifying this test to perform more draws
per frame will likely produce a more obvious result w/ the pre-PR builds as
there are more opportunities for glReadPixels to stall on main thread vblank waits.
2026-09-06 16:15:06 -07:00

238 lines
6.4 KiB
Meson

system_ss.add(pixman)
system_ss.add(png)
system_ss.add(files(
'clipboard.c',
'console.c',
'cursor.c',
'dmabuf.c',
'input-keymap.c',
'input-legacy.c',
'input-barrier.c',
'input.c',
'kbd-state.c',
'keymaps.c',
'qemu-pixman.c',
'ui-hmp-cmds.c',
'ui-qmp-cmds.c',
'util.c',
))
subdir('thirdparty')
xemu_ss = ss.source_set()
xemu_ss.add(files(
'xemu-input.c',
'xemu-monitor.c',
'xemu-net.c',
'xemu-settings.cc',
'xemu-controllers.cc',
'xemu.c',
'xemu-data.c',
'xemu-snapshots.c',
'xemu-thumbnail.cc',
'xemu-widescreen.c',
))
if host_os == 'windows'
d3d11 = cc.find_library('d3d11', required: true)
dxgi = cc.find_library('dxgi', required: true)
xemu_ss.add(nvapi, d3d11, dxgi)
endif
subdir('xui')
if host_os == 'darwin'
xemu_cocoa = dependency('appleframeworks', modules: 'Cocoa')
xemu_ss.add(xemu_cocoa)
endif
if host_os == 'linux'
xemu_ss.add([gtk, files('xemu-os-utils-linux.c')])
elif host_os == 'windows'
xemu_ss.add(files('xemu-os-utils-windows.c'))
elif host_os == 'darwin'
xemu_ss.add(files('xemu-os-utils-macos.m'))
endif
xemu_ss.add(imgui, implot, stb_image, sdl, opengl, fa, fpng, json, fatx, tomlplusplus, genconfig)
system_ss.add_all(xemu_ss)
system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: files('console-vc-stubs.c'))
if dbus_display
system_ss.add(files('dbus-module.c'))
endif
system_ss.add([spice_headers, files('spice-module.c')])
system_ss.add(when: spice_protocol, if_true: files('vdagent.c'))
if host_os == 'linux'
system_ss.add(files('input-linux.c', 'udmabuf.c'))
endif
system_ss.add(when: cocoa, if_true: files('cocoa.m'))
vnc_ss = ss.source_set()
vnc_ss.add(files(
'vnc.c',
'vnc-enc-zlib.c',
'vnc-enc-hextile.c',
'vnc-enc-tight.c',
'vnc-palette.c',
'vnc-enc-zrle.c',
'vnc-auth-vencrypt.c',
'vnc-ws.c',
'vnc-jobs.c',
'vnc-clipboard.c',
))
vnc_ss.add(zlib, jpeg)
vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c'))
system_ss.add_all(when: [vnc, pixman], if_true: vnc_ss)
system_ss.add(when: vnc, if_false: files('vnc-stubs.c'))
ui_modules = {}
xemu_enable_extra_ui_modules = false
if xemu_enable_extra_ui_modules
if curses.found()
curses_ss = ss.source_set()
curses_ss.add(when: [curses, iconv], if_true: [files('curses.c'), pixman])
ui_modules += {'curses' : curses_ss}
endif
system_ss.add(opengl)
if opengl.found()
opengl_ss = ss.source_set()
opengl_ss.add(gbm, pixman)
opengl_ss.add(when: [opengl],
if_true: files('shader.c', 'console-gl.c', 'egl-helpers.c', 'egl-context.c'))
ui_modules += {'opengl' : opengl_ss}
endif
if opengl.found()
egl_headless_ss = ss.source_set()
egl_headless_ss.add(when: [opengl, pixman],
if_true: [files('egl-headless.c'), gbm])
ui_modules += {'egl-headless' : egl_headless_ss}
endif
if dbus_display
dbus_ss = ss.source_set()
env = environment()
env.set('HOST_OS', host_os)
xml = custom_target('dbus-display preprocess',
input: 'dbus-display1.xml',
output: 'dbus-display1.xml',
env: env,
command: [xml_pp, '@INPUT@', '@OUTPUT@'])
dbus_display1 = custom_target('dbus-display gdbus-codegen',
output: ['dbus-display1.h', 'dbus-display1.c'],
input: xml,
command: [gdbus_codegen, '@INPUT@',
'--glib-min-required', '2.64',
'--output-directory', meson.current_build_dir(),
'--interface-prefix', 'org.qemu.',
'--c-namespace', 'QemuDBus',
'--generate-c-code', '@BASENAME@'])
dbus_ss.add(when: gio,
if_true: [files(
'dbus-chardev.c',
'dbus-clipboard.c',
'dbus-console.c',
'dbus-error.c',
'dbus-listener.c',
'dbus.c',
), opengl, gbm, pixman, dbus_display1])
ui_modules += {'dbus' : dbus_ss}
endif
if gtk.found()
if host_os == 'windows'
system_ss.add(files('win32-kbd-hook.c'))
endif
gtk_ss = ss.source_set()
gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
if have_gtk_clipboard
gtk_ss.add(files('gtk-clipboard.c'))
endif
gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
gtk_ss.add(when: opengl, if_true: files('gtk-gl-area.c'))
gtk_ss.add(when: [x11, opengl], if_true: files('gtk-egl.c'))
ui_modules += {'gtk' : gtk_ss}
endif
if sdl.found()
sdl_ss = ss.source_set()
sdl_ss.add(sdl, sdl_image, pixman, glib, files(
'sdl2-2d.c',
'sdl2-input.c',
'sdl2.c',
))
sdl_ss.add(when: opengl, if_true: files('sdl2-gl.c'))
sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
ui_modules += {'sdl' : sdl_ss}
endif
if spice.found()
spice_core_ss = ss.source_set()
spice_core_ss.add(spice, pixman, files(
'spice-core.c',
'spice-input.c',
'spice-display.c'
))
ui_modules += {'spice-core' : spice_core_ss}
if gio.found()
spice_ss = ss.source_set()
spice_ss.add(spice, gio, pixman, files('spice-app.c'))
ui_modules += {'spice-app': spice_ss}
endif
endif
endif # xemu_enable_extra_ui_modules
keymaps = [
['atset1', 'qcode'],
['linux', 'qcode'],
['qcode', 'atset1'],
['qcode', 'atset2'],
['qcode', 'atset3'],
['qcode', 'linux'],
['qcode', 'qnum'],
['qcode', 'sun'],
['qnum', 'qcode'],
['usb', 'qcode'],
['win32', 'qcode'],
['x11', 'qcode'],
['xorgevdev', 'qcode'],
['xorgkbd', 'qcode'],
['xorgxquartz', 'qcode'],
['xorgxwin', 'qcode'],
['osx', 'qcode'],
]
if have_system or xkbcommon.found()
keycodemapdb_proj = subproject('keycodemapdb', required: true)
foreach e : keymaps
output = 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1])
genh += custom_target(output,
output: output,
capture: true,
input: keycodemapdb_proj.get_variable('keymaps_csv'),
command: [python, keycodemapdb_proj.get_variable('keymap_gen').full_path(),
'code-map', '--lang', 'glib2',
'--varname', 'qemu_input_map_@0@_to_@1@'.format(e[0], e[1]),
'@INPUT0@', e[0], e[1]])
endforeach
endif
subdir('shader')
if have_system
subdir('icons')
install_data('qemu.desktop', install_dir: qemu_desktopdir)
endif
modules += {'ui': ui_modules}