LekKit / RVVM

The RISC-V Virtual Machine
GNU General Public License v3.0
936 stars 65 forks source link

VirGL + Virtio GPU support for GPU accel #144

Closed ZLangJIT closed 3 weeks ago

ZLangJIT commented 1 month ago

how might i go about implementing GPU acceleration support via rvvm and a custom riscv kernel, specifically

GL INSTANCE - RENDERER - PID 284 - HOST SHELL - RVVM - KERNEL - PID 382 = GUEST

as im thinking of something like https://github.com/dmaivel/sharedgl for api remoting from the guest to the host (android EGL host context) tho im not sure how to go about such

most implementations (using qemu) seem to expose shared memory (eg /dev/shm/foo or /dev/ashmem/foo (not sure what win32 equivilant would be) ) from host to guest which can be used for the custom guest driver to communicate with the host remoting server among other purposes

LekKit commented 1 month ago

I think it would be better to invest into a virtio-gpu device implementation and reuse existing virglrenderer on host and Mesa virgl driver in guest.

ZLangJIT commented 1 month ago

I think it would be better to invest into a virtio-gpu device implementation and reuse existing virglrenderer on host and Mesa virgl driver in guest.

would that work on windows OS host as well as unix* hosts ?

hmm https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24223

ZLangJIT commented 1 month ago

ok i managed to get https://gitlab.freedesktop.org/virgl/virglrenderer compiling for the ndk (api 28) in cmake with meson

ZLangJIT commented 1 month ago

https://github.com/ZLangJIT/riscv-kernel/actions/runs/11163610342/job/31030971191

ZLangJIT commented 1 month ago

specifically, to clarify the above

but i do not know how to make virglrenderer and virgl talk to eachother

ZLangJIT commented 1 month ago

apparently the vm must support a virtio gpu

ZLangJIT commented 1 month ago

hmm

https://gitlab.com/qemu-project/qemu/-/blob/master/include/hw/virtio/virtio-gpu.h

https://gitlab.com/qemu-project/qemu/-/blob/master/hw/display/virtio-gpu-gl.c

https://developer.ibm.com/articles/l-virtio/ - Virtio Architecture

hmm https://www.intel.com/content/www/us/en/docs/programmable/683140/24-2-12-1-0/virtio.html

ZLangJIT commented 1 month ago

@LekKit how might i go about beginning to port this from qemu over to rvvm ?

ZLangJIT commented 1 month ago

https://gitlab.com/qemu-project/qemu/-/tree/master/hw/virtio oof, lots of files

ZLangJIT commented 1 month ago

hmm https://docs.oasis-open.org/virtio/virtio/v1.2/virtio-v1.2.html appears to be the reference for the HOST implementation of virtio (vm/hyperv/kvm/ect side) and for the CLIENT implementation of virtio (guest/kernel side)

ZLangJIT commented 1 month ago

the only implementation of virt-gpu i can find is qemu's hw/display/virtio*.c

not even the kernel has a virt-gpu implementation, just seems to have a guest implementation even though the kernel has a KVM hypervisor implementation

ZLangJIT commented 1 month ago

hmm https://github.com/sysprog21/semu/pull/34 - implement virtio-gpu + utilize kernel virgl + host virglrenderer

LekKit commented 1 month ago

I hope they won't be mad if we look at their implementation and reuse it somewhat :)

@X547 Could you please look at this whenever you have free time? It seems that GUI backends don't need any changes for this.

ZLangJIT commented 1 month ago

imma move to a new issue

LekKit commented 1 month ago

Nah it's fine here