Skip to content

Commit ddf3d8b

Browse files
committed
[WIP] Support VirGL
Follow the installation guide from: https://gitlab.freedesktop.org/virgl/virglrenderer Prerequisite: `sudo apt install libepoxy-dev`
1 parent f5e97d7 commit ddf3d8b

File tree

6 files changed

+417
-4
lines changed

6 files changed

+417
-4
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ ifneq ($(UNAME_S),Linux)
6262
ENABLE_VIRTIOGPU := 0
6363
endif
6464

65+
# VirGL
66+
ENABLE_VIRGL ?= 1
67+
ifneq (ENABLE_VIRTIOGPU,0)
68+
CFLAGS += $(shell pkg-config virglrenderer --cflags)
69+
LDFLAGS += $(shell pkg-config virglrenderer --libs)
70+
endif
71+
72+
$(call set-feature, VIRGL)
73+
6574
# SDL2
6675
ENABLE_SDL ?= 1
6776
ifeq (, $(shell which sdl2-config))

device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ void virtio_gpu_write(hart_t *vm,
220220
uint8_t width,
221221
uint32_t value);
222222

223+
void semu_virgl_init(void);
224+
223225
void virtio_gpu_init(virtio_gpu_state_t *vgpu);
224226
void virtio_gpu_add_scanout(virtio_gpu_state_t *vgpu,
225227
uint32_t width,

feature.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#define SEMU_FEATURE_VIRTIOGPU 1
1818
#endif
1919

20+
/* VirGL */
21+
#ifndef SEMU_FEATURE_VIRGL
22+
#define SEMU_FEATURE_VIRGL 1
23+
#endif
24+
2025
/* virtio-input */
2126
#ifndef SEMU_FEATURE_VIRTIOINPUT
2227
#define SEMU_FEATURE_VIRTIOINPUT 1

main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static int semu_start(int argc, char **argv)
695695
emu.mswi.msip = calloc(vm.n_hart, sizeof(uint32_t));
696696
emu.sswi.ssip = calloc(vm.n_hart, sizeof(uint32_t));
697697
#if SEMU_HAS(VIRTIOGPU)
698+
semu_virgl_init();
699+
698700
emu.vgpu.ram = emu.ram;
699701
virtio_gpu_init(&(emu.vgpu));
700702
virtio_gpu_add_scanout(&(emu.vgpu), 1024, 768);

0 commit comments

Comments
 (0)