Skip to content
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

Virtio-gpu-gl through already existing Windows Mesa Driver #841

Open
imwhocodes opened this issue Oct 14, 2022 · 23 comments
Open

Virtio-gpu-gl through already existing Windows Mesa Driver #841

imwhocodes opened this issue Oct 14, 2022 · 23 comments

Comments

@imwhocodes
Copy link

Hi

From what I get a virtio-gpu windows guest driver already exist but there is no support for 3D acceleration with VirGL (on host) as renderer

On Linux a 3D acceleration on a virtio-gpu-gl is supported through Mesa Drivers

For windows there is support for Mesa Driver, I would like to investigate the possibility of using this drivers to interact with the virtio-gpu of this repo so to enable 3D acceleration on windows

The basic idea is:

  1. Virtio-gpu-gl driver exposing a vGPU
  2. Mesa driver using such vGPU
  3. WindowsOS using Mesa Driver

(I know about VFIO, GPUPassthrough, Nvidia Grid ecc, but this would be a more Flexible, Hardware Agnostic and Open Source option)

Is this achievable? Or am I missing something?

Thanks,
Luca

@YanVugenfirer
Copy link
Collaborator

Hi Luca,

Sorry for the late reply, had some public holidays.

Yes, in general this is something achievable, But will need some effort.
Also there is some work from Valve that can be used as reference: https://github.com/ValveSoftware/Proton

Do you want to work on it and need some guidance?

Best regards,
Yan.

@imwhocodes
Copy link
Author

Hi Yan

I would like to try to work on it on spare time

I'm experienced c++20 programmer (mostly baremetal) and IT admin but I'm getting a bit lost on the implementation details (with missing or hidden documentation).

Here is as I understood a possible complete architecture:
VirGL vGPU Windows Host Infrastructure  (5)

From what I get full Mesa already support a virtio-gpu and I think the gallium conversion is here
yet I didn't found where it hook up with the actual vGPU

On your side code I did't deep dive into it yet but seem like you already exposing virtio-gpu-gl as a pcie device and in the header the are definitions for 3D commands

What I'm missing?

Thanks,
Luca

@vrozenfe
Copy link
Collaborator

@imwhocodes
What is the "virtual pcie" device on that diagram?
In my understanding one of the critical things there is adding the WDDM RENDER stuff to the existing DOD driver.
(Some of the work toward building a FULL WDDM virtio-gpu driver has been done already but it is still not completed yet.
When this job will be done, we can add an OpenGL Installable Client Driver, or any other ICD to the project)

You can take a look at https://studiopixl.com/page3/ . But you need to understand that due to luck of Rendering Driver
functionality this project was done as a kind of hack for the POC purpose only.

Cheers,
Vadim.

@imwhocodes
Copy link
Author

Hi Vadim

Nathan Gauër blog and Talks were the first thing I checked out before opening this issue, referencing to his work this is what I mean about virtual PCIE
2017-virtio-communication

And about mesa in the stack:
2017-windows-stack

Actually I just realised checking out the ICD repo that the author himself is saying:

Once you observe the virtio-gpu implementation on the host receiving commands from the OpenGL sample app, you are good to go! Next step is to implement a proper ICD (reuse MESA), and integrate with D3DKMD properly.

and from what I get ICD was the most underdeveloped part

On the DoD Driver side it seem like only an extension of the current VirtioGPU code present in this repo (it should only move buffer around between Host and Guest)

@imwhocodes
Copy link
Author

@YanVugenfirer Do you have any clarification or hints?

Thanks

@Quackdoc
Copy link

Quackdoc commented Nov 14, 2022

I wonder if it might even wind up being easier to use vitio-gpu venus? I realize that it still isn't merged into qemu so there might not be a lot you can actually do on that end right now but the patches are being worked on. I wonder if it might be easier to get vulkan acceleration in the guest then it would be opengl via venus.

also it might not be too bad to try and port D3D10UMD to NIR from TGSI to try and get that working with virgl, or even zink if the vulkan route could wind up proving more beneficial, (I assume that the performance would be better at the very least). and if that does work I believe from there it can be extended to d3d11. IIRC that should be able to provide desktop acceleration.

well regardless, another resource is a talk that I think was from 2020? it was something called virgl and windows if I am remembering it correctly. that could be a good chunk information there.

EDIT: some potentially useful resources.

https://www.youtube.com/watch?v=aBgYNDLXuyg
https://github.com/pal1000/mesa-dist-win
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10687

@YanVugenfirer
Copy link
Collaborator

@imwhocodes Hi Luca,

I think while ICD can be most probably done with not much effort by reusing Mesa and other existing projects, I think this is a least interesting part.
We need to implement (or reuse from other projects) the layer that will translate DirectX 10+ to something that can be used on the host side.

Best regards,
Yan.

@orowith2os
Copy link

Wanted to pop in and give some bits of info.

  • Pass through Vulkan and OpenGL calls to the host via venus and the like.
  • Bundle DXVK (and VKD3D) like Intel does for their Windows driver (which doesn't have D3D11 and older support) for Direct3D support.

DXVK and VKD3D don't officially support Windows (only Linux/Wine) so you'd have to provide support for any bugs that occur there, though that could be useful for improving the projects if you were to fix the bugs and upstream them.

@YanVugenfirer
Copy link
Collaborator

Wanted to pop in and give some bits of info.

  • Pass through Vulkan and OpenGL calls to the host via venus and the like.
  • Bundle DXVK (and VKD3D) like Intel does for their Windows driver (which doesn't have D3D11 and older support) for Direct3D support.

DXVK and VKD3D don't officially support Windows (only Linux/Wine) so you'd have to provide support for any bugs that occur there, though that could be useful for improving the projects if you were to fix the bugs and upstream them.

Sure. That's the usual mode of operation for us - if needed we fix issues in other projects and upstream them.

@ss8688
Copy link

ss8688 commented Apr 8, 2023

Could something like microsoft's gpu-pv easier?

@voidpointertonull
Copy link

Could something like microsoft's gpu-pv easier?

Doesn't really seem to have anything useful to offer as it seems to just expose Windows specific features to the guest, and it heavily relies on closed source blobs both on the host and the guest side.

@imwhocodes
Copy link
Author

@voidpointertonull @YanVugenfirer @orowith2o
Any update in this features?

One other option could be wait for RADV Native context to land
From what I understood it is something similar to Nvidia Grid but open-source and for AMD commercial cards, but it is not clear to when and if it will be mainstream (and if the AMD driver will support it also on WindowsOS)
I think a more general virtio-gpu approach would be better anyway

@jorkanofaln
Copy link

jorkanofaln commented May 29, 2023

Any updates regarding this feature?

It would be a nice addition to qemu/kvm (which virtio is a part of), if it supported DirectX 3d acceleration like vmware workstation or virtualbox. There is project on github, which runs 3d acceleration for Direct3D to DirectX 9.0c games to run on older versions of Windows (Windows 9x, Windows 2000 and Windows XP) in qemu: https://github.com/kjliew/qemu-3dfx. You could provide a similar feature, but for modern Windows (Windows 7 and later). There should be an option in virtio, because not every system supports multiple gpu for pass through and many gpu models do not support virtualization: https://wiki.archlinux.org/title/QEMU/Guest_graphics_acceleration

@matheuswillder
Copy link

matheuswillder commented Jun 7, 2023

You could provide a similar feature, but for modern Windows (Windows 7 and later)

I think the chances of this supporting Windows 7/8/8.1 are minimal since they are legacy systems, and this project is only focusing on development for recent versions of Windows 10/11. But still I think it would be a good addition to the project, some Windows programs need 3D acceleration to work and Windows itself will be more responsive with that, and 3D acceleration already is supported on other platforms such as VirtualBox and VMware Workstation.

Obviously it would not be aimed to gaming, Wine is very well suited at the moment for Windows XP+ games and projects like DOSBox-X or DOSBox-Pure for retrogaming, but none these projects have the usability and stability needed for something work-oriented that only a hypervisor and a real Windows install can provide.

I think this issue has become a duplicate of #773, the one I opened is older but has less replies and information, so feel free to close one or the other as appropriate.

Edit: Off-topic but since qemu-3dfx was mentioned, SoftGPU is a free alternative if anyone wants to try it out. However I still think Wine/DOSBox-X/DOSBox-Pure are better ways to play old Windows games on Linux.

@max8rr8
Copy link

max8rr8 commented Jul 25, 2023

This feature is implemented by #943

@imwhocodes
Copy link
Author

Hi

@max8rr8 Thank you so much, I'm going to try it ASAP

I have 3 questions:

  1. Is this based on virgl or virgl-venus (from the code it seem the first)
  2. Which DirectX it support on guest? 10? 11? 12? (I suppose 10 from code)
  3. Do it support Vulkan on guest? (I suppose no)

Thank for your effort!

@max8rr8
Copy link

max8rr8 commented Jul 25, 2023

Is this based on virgl or virgl-venus (from the code it seem the first)

virgl is used by gallium frontends (opengl and directx10/11) while venus is used for vulkan. Driver currently support virgl with possibility to support venus too in future.

Which DirectX it support on guest? 10? 11? 12? (I suppose 10 from code)

10.0 is supported by default, it might be possible to enable 10.1 and 11 though not tested. 12 is quite different from 10/11 and i don't think it can be supported anytime soon.

Do it support Vulkan on guest? (I suppose no)

Vulkan support (through venus) requires support for blob resources from kernel-side driver(that is a bit tricky) and some additional work to support windows on venus from mesa. So no it is not supported now, but can be in future.

@buttonfly1000
Copy link

This feature is implemented by #943

Does this mean we can play 3d games on Windows guest without any GPU passthrough?

@max8rr8
Copy link

max8rr8 commented Jul 29, 2023

Does this mean we can play 3d games on Windows guest without any GPU passthrough?

You can try, but the performance isn't going to be great, you probably will get much better result by using proton or gpu passthrough.

My main motivation for working on this project is 3d acceleration of desktop apps like word, excel, browser, visual studio, etc... to lower cpu usage and improve UX compared to software rendering.

@matheuswillder
Copy link

I haven't had free time to test or look at the link carefully yet, but thanks in advance! Just a question: what version of Windows this driver should work? Also, are there any other version requirements (e.g. host kernel, QEMU version, etc.)?

@nooodles2023
Copy link

I have implemented opengl 3d acceleration on windows using my own hypervisor, mvisor.
Just as you said, I created a Windows WDF device for delivering mesa-virgl commands to host, and compiled opengl32.dll for Windows applications from Mesa-Virgl, which helped to translate opengl api requests to mesa-virgl commands
https://github.com/tenclass/mvisor-win-vgpu-driver @imwhocodes

@gogo2464
Copy link

gogo2464 commented Dec 3, 2024

has it been completed?

@DocMAX
Copy link

DocMAX commented Dec 22, 2024

when such a driver is comming out, this will be a gamechanger!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests