Skip to content

Implement VirtIO GPU and input devices #34

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

shengwen-tw
Copy link
Collaborator

@shengwen-tw shengwen-tw commented Nov 9, 2023

Summary

This pull request introduces initial support for virtio-gpu and virtio-input devices in semu, conforming to the VirtIO specification 1.3.

VirtIO-GPU

  • Implements basic 2D rendering support.
  • Provides two rendering backends:
    • Software-based backend (supports 2D rendering only).
    • virglrenderer backend (to enable hardware-accelerated 3D rendering in a future patch).
  • Compatible with:
  • Successfully tested with:

VirtIO-Input

  • Implements basic keyboard emulation.
  • Implements basic mouse emulation.

Prerequisites

Yet incomprehensive...

$ sudo apt install libsdl2-dev libsdl2-2.0-0 libsdl2-image-dev libsdl2-image-2.0-0

Build kernel and test disk image

$ ./scripts/build-image.sh
$ ./scripts/virt-disk-img.sh

Run X11

  1. Launch semu:
$ make check
  1. Run startx
$ startx
  1. After X11 shows up, launch the benchmark programs:
$ glmark2
$ glxgears

Run DirectFB2

  1. Launch semu:
$ make check
  1. Kill X11
$ ps
   86 root     /usr/bin/Xorg :0.0 vt01 -s 0 -noreset -allowMouseOpenFail
$ kill 86
  1. Mount test disk and execute run.sh:
$ mkdir mnt
$ mount /dev/vda mnt
$ cd mnt
$ sh ./run.sh
  1. Run DirectFB2 test programs:
df_andi        df_fire df_neo     df_window
df_texture     df_video           df_knuckles
df_input       df_neo             df_window
df_matrix      df_dok             df_fire
df_palette     df_cpuload         df_spacedream
df_layers      df_pss             df_input

Run kmscube

  1. Launch semu:
$ make check
  1. Kill X11
$ ps
   86 root     /usr/bin/Xorg :0.0 vt01 -s 0 -noreset -allowMouseOpenFail
$ kill 86
  1. Run kmscube
$ kmscube

Run modetest

The simplest method to test VirtIO-GPU.

  1. Enable BR2_PACKAGE_LIBDRM_INSTALL_TESTS in the Buildroot then rebuild the image.

  2. Launch semu:

$ make check
  1. Run modetest program
$ modetest -M virtio_gpu -s 34:1024x768

A test image should then show up in the display window.

@shengwen-tw shengwen-tw requested a review from jserv November 9, 2023 14:42
@shengwen-tw shengwen-tw added the enhancement New feature or request label Nov 9, 2023
@jserv
Copy link
Collaborator

jserv commented Nov 11, 2023

@shengwen-tw
Copy link
Collaborator Author

Yes, I do plan to support VirGL for acceleration.

As far as I know, the offloading of rendering operations to the host GPU is called 3D mode by VirtIO's spec, whereas this pull request only implemented 2D mode due to the overall complexity.

Before implementing 3D rendering mode with VirGL, I think we need to configure the Buildroot to have a minimal desktop environment or set the Mesa benchmark tools without a desktop manager (I'm not sure if this is feasible).

In conclusion, I'll recommend first merging this pull request as a checkpoint for virtio-gpu and then adding support for VirGL in a later pull request.

jserv

This comment was marked as resolved.

@shengwen-tw shengwen-tw force-pushed the master branch 5 times, most recently from e87c823 to f77276f Compare January 25, 2024 08:48
@shengwen-tw
Copy link
Collaborator Author

@shengwen-tw shengwen-tw force-pushed the master branch 5 times, most recently from e549465 to 8459dc3 Compare January 25, 2024 09:08
@jserv
Copy link
Collaborator

jserv commented Jan 26, 2024

Rather than relying on Xvfb as a heavy-duty solution for validating Linux DRM/framebuffer, it might be more efficient to use lighter tools like drm-framebuffer. This tool, designed for testing drm devices, takes data from stdin and displays it, offering a simpler and more straightforward approach.

@shengwen-tw
Copy link
Collaborator Author

shengwen-tw commented Jan 27, 2024

Rather than relying on Xvfb as a heavy-duty solution for validating Linux DRM/framebuffer, it might be more efficient to use lighter tools like drm-framebuffer. This tool, designed for testing drm devices, takes data from stdin and displays it, offering a simpler and more straightforward approach.

Actually, the intention of using Xvfb here is to make sure the SDL window can be launched in the CI environment by GitHub Action.

@jserv
Copy link
Collaborator

jserv commented Feb 1, 2024

Merely executing Xvfb :1 -screen 0 1600x1200x24 is inadequate because, although it confirms the initialization of SDL with libX11, it does not guarantee the accuracy of the window content rendered in Xvfb.

@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
@sysprog21 sysprog21 deleted a comment from bito-code-review bot Mar 25, 2025
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase the latest master branch.

@shengwen-tw
Copy link
Collaborator Author

Rebase the latest master branch.

I'll rebase the code after some cleanup, and maybe request a code review now that we’ve made some progress.

@shengwen-tw shengwen-tw force-pushed the master branch 4 times, most recently from 1d6ac07 to a5d1866 Compare March 27, 2025 13:27
@shengwen-tw shengwen-tw marked this pull request as ready for review May 13, 2025 12:40
@shengwen-tw
Copy link
Collaborator Author

shengwen-tw commented May 13, 2025

@jserv :
I propose we begin the code review to merge the current progress in this pull request.
This will also make it easier to offload some tasks to additional contributors, if needed.
I will open a separate pull request to add support for the 3D rendering mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants