Skip to content

Commit b3dd073

Browse files
author
Dorinda Bassey
committed
vhost-device-gpu: Refactor vhost-device-gpu
This commit refactors vhost-device-gpu by separating virglrenderer from rutabaga, and using gfxstream via rutabaga, Simplifying future backend development. This commit introduces a significant refactor of the virtio-gpu backend architecture: - Transition `gfxstream` support to use `Rutabaga` abstraction. - Decouple `virglrenderer` from `Rutabaga`, allowing it to be used as standalone. - Unify backend handling using thread-local storage and macro-based runtime dispatch. Key Changes: VirglRenderer Backend: - `virgl.rs` is now a standalone backend that directly calls `libvirglrenderer` functions. - Removed reliance on `rutabaga` for virgl path. Gfxstream Backend via Rutabaga: - Introduced `gfxstream.rs` backend using `rutabaga` - Thread-local `GfxstreamAdapter` manages its own `Rutabaga` instance, initialized lazily. - Preserved internal `GfxstreamResource` tracking with scanout support and memory handling. Renderer Selection Logic: - In `device.rs`, `lazy_init_and_handle_event()` now: - Dispatches `VirglRendererAdapter` and `GfxstreamAdapter` using thread-local storage(TLS) - Introduced `extract_backend_and_vring()` helper for reusing backend setup logic. Code Deduplication: - Abstracted common logic for both backends to common.rs. - Shared helpers reused between gfxstream and virgl. - Improved modularity with fewer duplicated error handling branches. Testing and Validation: - Replaced `virtio_gpu.rs` testing paths with new unit tests for `gfxstream.rs` and `virgl.rs`. - Added code coverage for the new refactored crate. - Update coverage file to reflect the drop in coverage due to exclusion of some gfxstream tests from CI since they can't run in CI without GPU drivers. Signed-off-by: Dorinda Bassey <[email protected]>
1 parent ffbf81b commit b3dd073

File tree

14 files changed

+3521
-1759
lines changed

14 files changed

+3521
-1759
lines changed

coverage_config_x86_64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 86.60,
2+
"coverage_score": 85.19,
33
"exclude_path": "xtask",
44
"crate_features": ""
55
}

vhost-device-gpu/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
### Changed
77

8+
- [[#852]] (https://github.com/rust-vmm/vhost-device/pull/890) vhost-device-gpu: Refactor vhost-device-gpu
9+
810
### Fixed
911

1012
### Deprecated

0 commit comments

Comments
 (0)