-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[viogpu3d] Virtio GPU 3D acceleration for windows #943
base: master
Are you sure you want to change the base?
Conversation
@max8rr8 Thank for a very impressive work you've done. Nice work! |
viogpu/viogpu3d/BUILDING.md
Outdated
5. Build and install mesa binaries: `ninja install` | ||
6. Go to `viogpu` directory of this repository | ||
7. Run: `.\build_AllNoSdv.bat` | ||
8. Compiled drivers will be available in `viogpu\viogpu3d\objfre_win10_amd64\amd64\viogpu3d` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @max8rr8,
This instruction is not clear to me. Can you please describe it more with directory examples? What dependencies should be installed and how configured? (Example: https://github.com/virtio-win/kvm-guest-drivers-windows/wiki/Building-the-drivers-using-Windows-11-21H2-EWDK).
I looked into the mesa compilation guide and it looks completely different.
meson setup builddir/
meson compile -C builddir/
sudo meson install -C builddir/
Several questions:
- What is
%MESA_PREFIX%
and where it defined? - Can we use any precompiled MESA for Windows (for example https://fdossena.com/?p=mesa/index.frag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is %MESA_PREFIX% and where it defined?
%MESA_PREFIX% environment variable is set during build process, it points to directory where mesa installs its files.
Can we use any precompiled MESA for Windows
I don't think so, as pointed out in mesa MR when building user-mode driver we have to build it with specific mesa flags to build only virgl driver (to avoid conflicts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building instruction
NOTE 1: this is valid for now, until changes are not in upstream repositories
NOTE 2: this assumes that all build dependencies(meson, WDK, ninja, etc...) are installed
Part 1: Virglrenderer
On host machine it is required that patched version of virglrenderer is used.
- Acquire source code
git clone --branch viogpu_win https://gitlab.freedesktop.org/max8rr8/virglrenderer && cd virglrenderer
- Create install directory
mkdir install
and build directory:mkdir build && cd build
- Configure build
meson --prefix=$(pwd)/../install
(we set prefix to install libvirglrenderer not globally but to previously created dir install) - Compile and install
ninja install
Now ensure that qemu loads libvirglrenderer from install directory, this can be done by settingLD_LIBRARY_PATH
to something like/some/path/to/starter_dir/virglrenderer/install
Part 2: Build mesa
Now inside virtual machine with build tools installed create working directory, then inside it (this assumes use of Powershell):
- Create mesa prefix dir
mkdir mesa_prefix
and set envMESA_PREFIX
to its path:$env:MESA_PREFIX="$PWD\mesa_prefix"
- Get patched mesa source code
git clone --depth 10 --branch viogpu_win https://gitlab.freedesktop.org/max8rr8/mesa
and then cd into itcd mesa
- Create build directory
mkdir build && cd build
- Configure build
meson .. --prefix=$env:MESA_PREFIX -Dgallium-drivers=virgl -Dgallium-d3d10umd=true -Dgallium-wgl-dll-name=viogpu_wgl -Dgallium-d3d10-dll-name=viogpu_d3d10 -Db_vscrt=mt
, build options explained:
--prefix=$env:MESA_PREFIX
set installation path to dir created in step 1-Dgallium-drivers=virgl
build only virgl driver-Dgallium-d3d10umd=true
build DirectX 10 user-mode driver (opengl one is build by default)-Dgallium-d3d10-dll-name=viogpu_d3d10
name of generated d3d10 dll toviogpu_d3d10.dll
-Dgallium-wgl-dll-name=viogpu_wgl
name of generated wgl dll toviogpu_wgl.dll
-Db_vscrt=mt
use static c runtime (see this comment)
- Build and install (to mesa prefix):
ninja install
Part 3: Build driver
Now that mesa is build and installed into %MESA_PREFIX%
viogpu3d will be built (in case %MESA_PREFIX
is not set viogpu3d inf generation is skipped)
- Acquire source code
git clone --branch viogpu_win https://github.com/max8rr8/kvm-guest-drivers-windows
and cd into itcd kvm-guest-drivers-windows
- Go to viogpu
cd viogpu
- (optional, but very useful) setup test code signning from visual studio
- Call build
.\build_AllNoSdv.bat
Part 4: Installation
Now copy kvm-guest-drivers-windows\viogpu\viogpu3d\objfre_win10_amd64\amd64\viogpu3d
to target VM and install it.
EDIT: Added gallium-windows-dll-name
to mesa parameters.
EDIT2: More changes related to dll naming in mesa parameters
Changes:
|
Changes:
Pre-built driver provided in description was updated with these changes. |
I've tested the driver on win10, and got a black screen. But if change the guest os to ubuntu(same qemu command line), glxgears performs well. (glxinfo shows that the renderer is NVIDIA gpu) envguest os: host os: qemu command line-display egl-headless,rendernode=/dev/dri/card1 -device virtio-vga-gl -trace enable="virtio_gpu*" -D qemu.log virglrenderer.loggl_version 46 - core profile enabled
GLSL feature level 460
vrend_check_no_error: context error reported 3 "" Unknown 1282
context 3 failed to dispatch DRAW_VBO: 22
vrend_decode_ctx_submit_cmd: context error reported 3 "" Illegal command buffer 786440
GLSL feature level 460
vrend_check_no_error: context error reported 5 "" Unknown 1282
context 5 failed to dispatch DRAW_VBO: 22
vrend_decode_ctx_submit_cmd: context error reported 5 "" Illegal command buffer 786440
GLSL feature level 460
GLSL feature level 460
GLSL feature level 460
GLSL feature level 460
GLSL feature level 460
vrend_check_no_error: context error reported 9 "" Unknown 1282
context 9 failed to dispatch DRAW_VBO: 22 qemu_strace.logvirtio_gpu_features virgl 0
virtio_gpu_features virgl 0
virtio_gpu_cmd_get_edid scanout 0
virtio_gpu_cmd_get_display_info
virtio_gpu_cmd_ctx_create ctx 0x1, name
virtio_gpu_cmd_ctx_create ctx 0x2, name
virtio_gpu_cmd_res_create_3d res 0x1, fmt 0x1, w 1280, h 1024, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x2, res 0x1
virtio_gpu_cmd_res_back_attach res 0x1
virtio_gpu_cmd_res_create_3d res 0x2, fmt 0x1, w 1280, h 1024, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x2, res 0x2
virtio_gpu_cmd_res_create_2d res 0x3, fmt 0x2, w 1280, h 1024
virtio_gpu_cmd_res_back_attach res 0x3
virtio_gpu_cmd_set_scanout id 0, res 0x1, w 1280, h 1024, x 0, y 0
virtio_gpu_cmd_res_flush res 0x1, w 1280, h 1024, x 0, y 0
virtio_gpu_cmd_set_scanout id 0, res 0x1, w 1280, h 1024, x 0, y 0
virtio_gpu_cmd_res_flush res 0x1, w 1280, h 1024, x 0, y 0
virtio_gpu_cmd_ctx_create ctx 0x3, name
virtio_gpu_cmd_ctx_destroy ctx 0x3
virtio_gpu_cmd_ctx_create ctx 0x3, name
virtio_gpu_cmd_res_create_3d res 0x4, fmt 0xb1, w 48, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x4
virtio_gpu_cmd_res_create_3d res 0x5, fmt 0xb1, w 4000, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x5
virtio_gpu_cmd_res_create_3d res 0x6, fmt 0xb1, w 16, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x6
virtio_gpu_cmd_res_create_3d res 0x7, fmt 0xb1, w 48, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x7
virtio_gpu_cmd_res_create_3d res 0x8, fmt 0xb1, w 240012, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x8
virtio_gpu_cmd_res_create_3d res 0x9, fmt 0xb1, w 102400, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x9
virtio_gpu_cmd_res_create_3d res 0xa, fmt 0xb1, w 144, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xa
virtio_gpu_cmd_res_create_3d res 0xb, fmt 0xb1, w 160000, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xb
virtio_gpu_cmd_res_create_3d res 0xc, fmt 0xb1, w 16000, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xc
virtio_gpu_cmd_res_create_3d res 0xd, fmt 0xb1, w 240000, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xd
virtio_gpu_cmd_res_create_3d res 0xe, fmt 0xb1, w 192, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xe
virtio_gpu_cmd_res_create_3d res 0xf, fmt 0xb1, w 16, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0xf
virtio_gpu_cmd_res_create_3d res 0x10, fmt 0xb1, w 272, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x10
virtio_gpu_cmd_res_create_3d res 0x11, fmt 0xb1, w 240, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x11
virtio_gpu_cmd_res_create_3d res 0x12, fmt 0xb1, w 272, h 1, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x12
virtio_gpu_cmd_res_create_3d res 0x13, fmt 0x1, w 50, h 50, d 1
virtio_gpu_cmd_ctx_res_attach ctx 0x3, res 0x13
virtio_gpu_cmd_ctx_create ctx 0x4, name
virtio_gpu_cmd_res_back_attach res 0x13
virtio_gpu_cmd_res_back_attach res 0x4
virtio_gpu_cmd_res_back_attach res 0x5
virtio_gpu_cmd_res_back_attach res 0x6
virtio_gpu_cmd_res_back_attach res 0xa
virtio_gpu_cmd_res_back_attach res 0xe
virtio_gpu_cmd_res_back_attach res 0xf
virtio_gpu_cmd_res_back_attach res 0x10
virtio_gpu_cmd_res_back_attach res 0x11
virtio_gpu_cmd_res_back_attach res 0x12
virtio_gpu_cmd_ctx_submit ctx 0x3, size 74220 |
It seems to be an bug in virglrenderer on nvidia related to GL_PRIMITIVE_RESTART_NV. You can try to apply this diff to fix it, but it's a bit hacky solution. |
What versions of windows does it go down to? |
I tried the pre-built driver on Windows 10 22H2 and it only showed a black screen before hard-locking and resetting. Also tested the same config with Ubuntu which had working virgl. Using |
Can we validate that this works with Windows 7 too? It's a fairly common virtualization guest for playing older games, and it's still WDDM class. |
Current driver theoretically supports windows 8.1, but it is built for and tested only on Windows 10 22H2. But it is important to note that support for blob resources which are required to improve performance and support vulkan will require using WDDM 2 which lift minimum windows version to 10.
I doubt it will work with current code, it might be possible to adapt it for windows 7, but i do not have interest in doing that (though wouldn't mind if someone else will adapt code). Plus at some point driver will have to use WDDM 2 which will splitting codebases or more likely require either dropping support for older OS.
Nothing seems wrong in attached |
That's great @max8rr8!
For the retro direction, above was mentioned Win7 and in addition I think such virgl/venus GPU will be very useful also for:
|
I compiled and tried it, but I got the BSOD First, I compiled QEMU in MSYS2 like this:
I compiled virglrenderer (upstream) like your comment above, then replaced the dll in QEMU dir with the newly built one. Then I compiled mesa with VS (MinGW GCC prints a bunch of errors related to the WDK headers, so I gave up):
It outputs to my root folder ( I signed the output in
Then I booted up the VM, enabled test signing and then install the driver. The screen instantly went black and Windows crashes. WinDBG, qemu logs and VM command line attached. I tried using serial kernel debug but it just hangs forever at boot so I analyzed the dump file instead. |
Additionally, I tried booting Linux Mint 20.2 live cd but QEMU itself crashed on some heap corruption issue. I replaced the original MSYS2 virglrenderer dll which fixed it. The Windows 10 guest BSOD remains. |
Hi @RedGreenBlue09, it seems that kernel crash happened during driver unloading ( You should try to attach windbg to running vm (try to use network debugging instead of serial, it works for me). Additionally when connecting to vm from windbg enable break on connection and run following command
This windbg command should add backtrace logging to all errors happening in dxgkrnl. After you ran that command continue kernel execution with windbg command |
I will test again later. Also, if I use VGA + virtio-gpu-gl setup the driver don't load and it have error 49 in device manager. The error message is something like "Windows unloaded the driver because it has reported problems" |
... Network debug also hangs like serial. Interestingly that doesn't happen with ReactOS. |
I have no luck with live kernel debug. I tried using accel tcg, official qemu, none of these helps. If Edit: Even ditching OVMF for SeaBIOS, it still freezes. |
@max8rr8 Okay, I'm sorry for the rant. It doesn't hang forever, just 30 minutes :((. I tried your command and got an error:
|
After reloading symbols, the error is gone. Here is the new log. |
I was able to write a more detailed instruction guide. I will be able to provide you info on monday Nikos |
Hi, can we get the pre compiled drivers link updated, can't download viogpu3d.zip |
Please find my notes to compile driver : Build virtual machine (really on a VM, not on production machine or your own machine) requirements:
Open VS code 2022 with admin privileges, reopen your previous project and select the viogpu3d projet in the
Once compiled, your driver will be available in Note : I was able to install driver with Note 2 : I 'm no Windows expert nor driver developer, only a simple tech guy following this project and trying to understand this project. Hope this will help you. Best regards |
Hi, if it is possible, would you be able to upload a prebuilt version of the driver files? |
Download link in this issue: (#1076) Also, has anybody tried to cross compile it in Linux like debian bookworm? I'm getting an error regarding "d3dkmthk.h: No such file or directory" "Compiling C object src/gallium/auxiliary/libgallium.a.p/gdikmt_gdikmt_d3dkmt.c.obj "In file included from ../src/gallium/auxiliary/gdikmt/gdikmt_d3dkmt.c:2: |
Our team tried driver cross-compilation in the past. Unfortunately, WDK in MinGW headers is too old and a lot of functions are missing. Currently, we expect to compile drivers with WDK for Server 2022 with a lot of new APIs (like memory management). "d3dkmthk.h" is a WDK header (https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/d3dkmthk/) that just missing in MinGW headers. |
If compiling in windows one stills needs those header files from WDK right? Is there a way when cross compiling in linux to make MinGW locate those header files? |
Yes, you must install SDK and WDK.
Yes, but very complicated. Install WDK on Windows and copy everything that is needed for compilation (lib, dll, pdb, header, etc) to Linux MinGW headers directory. Don't forget that MinGW uses *so instead of *dll, *a instead of *lib, so you also need to rename files and maybe strip or something else. |
Where would MinGW headers directory be located in debian or Ubuntu? |
Hi @Usulyre, firstly thanks for your guide ! It was really helpful, and I managed to compile the driver, even if they needed specter library, idk why... Can you tell me what was your method to install the drivers, please ? Thank you ! |
Few months ago I tried this aswell and came to same conclusion.
Yep I tried this and unfortunately it's not really doable without a lot of work. Another way might be to try and get MSVC build with Wine or something like that.
Don't know but in Arch they are in |
Is there an upstream bug in MinGW for this, while it won't help in the short term, in the longer term it gives a chance for it to be resolved. |
I beleive there is a |
I think that there's also a version of the d3dkmthk.h header in the mesa repo here: https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/include/drm-uapi/d3dkmthk.h?ref_type=heads
Instead of trying to compile on linux using gcc, I think you may want to try compiling using either clang or this custom version of llvm patched to be more compatible with msvc features: https://github.com/backengineering/llvm-msvc Note that this custom version of llvm is more meant for windows users who want llvm to work more like msvc, but according to the README:
|
I'm not a coder. To be able to compile the whole thing will take ages for me. Can some one point me to a pre compiled version that I can test out of the box ? thanks. |
Here is one but I am not sure it is up to date. https://gitlab.freedesktop.org/mesa/mesa/uploads/195b600a19ee5dacdf9f217066b99505/viogpu3d.zip |
Hi, did you cross compile it successfully in linux? If you did, is it the most up to date version? If so, can you show the steps for that? Or do you have a upload link to share with others? I haven't yet installed the current version because I didn't get it to compile correctly. |
Might try this as well. |
It is dated : 24.07.2023 16:05 ; is it up to date ? if not,can someone upload an up to date precompiled version ? thanks. |
I'm trying to install it,but it won't. Can you explain what should I do to install it ? (on Windows 7 x64 bit) This is the error that it gives : translation : the selected INF does not support this installation method. It can't be installed neither using the traditional method : Translation : The folder does not contains a driver compatible with the device. Please be sure that it is compatible with Windows 64 bit. Yes,I'm using Windows 7 x64 bit. |
That driver is built for Windows 10. No support for Windows 7 yet. |
:-( |
Looks like you use the latest EWDK/WDK. Microsoft changed the requirements for driver in it. You should use this instruction for building virtio-win drivers https://virtio-win.github.io/Development/Building-the-drivers-using-Windows-11-21H2-EWDK |
I have a question for you: is this driver compatible with Windows XP? Is there any third party driver for this Windows? |
Guys/gals come on don't overhead the development. Stop asking stuff unless you have something helpful to add. |
If there is a driver that's compatible with windows xp,maybe there is one compatible with windows 7 ? |
Hello! This series of changes spanning across multiple repositories introduce support for 3d accelerated virtiogpu windows guests.
How to test
NOTE: This driver does have some rendering glitches and might crash. Try at your own risk.
0. Create qemu windows VM with VirtIO GPU with 3d acceleration enabled. It is highly recommended to use "disposable" virtual machine to test, loss of data might occur.
viogpu_win
Known issues
FIXED:
Frames displayed on screen are lagging behindFIXED:
D3d10 clearing color is not supportedFIXED:
D3d10 applications using DXGI_SWAP_EFFECT_DISCARD and DXGI_SWAP_EFFECT_SEQUENTIAL are not displayed.Rendering glitches in WinUI3 apps.
There are some rendering glitches in apps based on WinUI3 (maybe other apps too), best way to see them is to install WinUI3 Gallery from microsoft store and navigate around it. Haven't yet invistigated.
Vscode (possibly other electron apps) does not render
Black window. Requires implementation of PIPE_QUERY_TIMESTAMP_DISJOINT in virglrenderer.
No preemption
Kernel-mode driver does not implement preemption, and i am very confised about how to implement it in WDDM. VioGpu3D disables preemption systemwide to workaround lack of preemption implementation, but this is not ideal. Would appreciate some help.
Siblings