goldfish-opengl: introduce VirtGpuDevice class
In this repository, there are multiple accesses to the goldfish or
virtio-gpu system call interface.
For example, both the Vulkan ResourceTracker and HWC3 import the
../egl/goldfish_sync.h header and open /dev/goldfish_sync, even
though that necessarily has nothing to with EGL specifically.
In addition, there are several layers of abstraction. For example,
both goldfish_address_space_open(..) and create_address_space_fd(..)
seem to do the exact same thing (opening /dev/goldfish_address_space),
although through the address_space_ops (used by ASG) and
GoldfishAddressSpaceBlockProvider (used by Vulkan ResourceTracker.cpp)
interfaces respectively.
In addition, GPUs typically combine memory and synchronization, and
don't separate them into separate address space and sync devices. This
is just a legacy due the fact gfxstream GLES needed EGL sync before
gfxstream VK needed zero-copy memory.
Since the Cuttlefish ecosystem is already using virtgpu, and AEMU
plans to do so in the near future, this CL adds a simple singleton
C++ class over virtgpu DRM ioctl interfaces. The idea is for all
virtgpu accesses to flow through this class eventually.
This -- if used elsewhere throughout the codebase -- can reduce the
amount of #ifdefs and extraneous abstractions.
In the future, we could use RAII with managed memory objects and
even make it an abstract class for non-Unix platforms. In theory,
FEMU may be able to adopt a virtgpu FIDL, where the corresponding
Fuchsia service would translate to virtio-gpu hypercalls.
BUG=202552093
TEST=compile
Change-Id: Idae9b3659f5ff4964f3bfc1874b2ce863839f933
9 files changed