Skip to content

Commit

Permalink
[WIP] Support VirGL
Browse files Browse the repository at this point in the history
Follow the installation guide from:
https://gitlab.freedesktop.org/virgl/virglrenderer

Prerequisite:
`sudo apt install libepoxy-dev`
  • Loading branch information
shengwen-tw committed Sep 11, 2024
1 parent d3a00da commit bb98469
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ ifneq ($(UNAME_S),Linux)
ENABLE_VIRTIOGPU := 0
endif

# VirGL
ENABLE_VIRGL ?= 1
ifneq (ENABLE_VIRTIOGPU,0)
CFLAGS += $(shell pkg-config virglrenderer --cflags)
LDFLAGS += $(shell pkg-config virglrenderer --libs)
endif

$(call set-feature, VIRGL)

# SDL2
ENABLE_SDL ?= 1
ifeq (, $(shell which sdl2-config))
Expand Down
2 changes: 2 additions & 0 deletions device.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ void virtio_gpu_write(hart_t *vm,
uint8_t width,
uint32_t value);

void semu_virgl_init(void);

void virtio_gpu_init(virtio_gpu_state_t *vgpu);
void virtio_gpu_add_scanout(virtio_gpu_state_t *vgpu,
uint32_t width,
Expand Down
5 changes: 5 additions & 0 deletions feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#define SEMU_FEATURE_VIRTIOGPU 1
#endif

/* VirGL */
#ifndef SEMU_FEATURE_VIRGL
#define SEMU_FEATURE_VIRGL 1
#endif

/* virtio-input */
#ifndef SEMU_FEATURE_VIRTIOINPUT
#define SEMU_FEATURE_VIRTIOINPUT 1
Expand Down
2 changes: 2 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ static int semu_start(int argc, char **argv)
virtio_input_init(&(emu.vmouse));
#endif
#if SEMU_HAS(VIRTIOGPU)
semu_virgl_init();

emu.vgpu.ram = emu.ram;
virtio_gpu_init(&(emu.vgpu));
virtio_gpu_add_scanout(&(emu.vgpu), 1024, 768);
Expand Down
Loading

0 comments on commit bb98469

Please sign in to comment.