为 Android 模拟器创建虚拟硬件、内核、qemu 以生成 OpenGL 图形
我是 Android 新手,希望使用模拟器。
我想做的是创建自己的虚拟硬件,可以收集 OpenGL 命令并生成 OpenGL 图形。 有人告诉我,为了做到这一点,我需要编写一个 Linux 内核驱动程序来实现与硬件的通信。此外,我需要编写一个 Android 用户空间库来调用内核驱动程序。
首先,我计划制作一个非常简单的硬件,它只执行 1 或 2 个命令。
这里有人做过这样的事吗?如果是这样,您有任何提示或可能的额外信息链接吗? 任何反馈将不胜感激。
I am new to android and wish to play around with the emulator.
What I want to do is to create my own piece of virtual hardware that can collect OpenGL commands and produce OpenGL graphics.
I have been told that in order to do this I will need to write a linux kernal driver to enable communication with the hardware. Additionally, I will need to write an Android user space library to call the kernal driver.
To start with I plan on making a very simple piece of hardware that only does, say 1 or 2, commands.
Has anyone here done something like this? If so, do you have any tips or possible links to extra information?
Any feedback would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编写硬件仿真是一项棘手的任务,而且绝非易事。所以如果你真的想这么做,我不会从头开始。对于您的情况,我首先从一些更简单的开始(因为许多库已经在来宾和主机端就位):通过 qemu 为普通 Linux 实现 OpenGL 直通。需要做什么:
首先将一些虚拟 GPU 添加到 qemu 中,这还涉及添加一个使用 OpenGL 的新图形输出模块(到目前为止 qemu 使用 SDL)。接下来,您在 Linux 内核中创建 DRI/DRM 驱动程序,该驱动程序将在 guest 虚拟机上运行(Android 使用自己的图形系统,但对于学习 DRI/DRM 没问题)以及 Mesa 中。在主机端,您必须在 OpenGL 调用中翻译来自 qemu 的内容。由于主机端 GPU 正在完成所有艰苦的工作,因此您的 DRI/DRM 部分将非常小,只需构建一个桥即可。
Writing a hardware emulation is a tricky task and by no means easy. So if you really want to do this, I'd not start from scratch. In your case I'd first start with some simpler (because many of the libraries are already in place on guest and the host side): Implementing a OpenGL passthrough for ordinary Linux through qemu. What does it take:
First you add some virtual GPU into qemu, which also involves adding a new graphics output module that uses OpenGL (so far qemu uses SDL). Next you create DRI/DRM drivers in the Linux kernel, that will run on the guest (Android uses its own graphics system, but for learning DRI/DRM are fine), as well as in Mesa. On the host side you must translate what comes from qemu in OpenGL calls. Since the host side GPU is doing all the hard work your DRI/DRM part will be quite minimal and just build a brigde.
Android SDK 23 附带的模拟器已经运行 OpenGL,您可以使用官方
MoreTeapots
示例进行尝试:https://github.com/googlesamples/android-ndk/tree/a5fdebebdb27ea29cb8a96e08e1ed8c796fa52db/MoreTeapots我很确定它是硬件加速的,因为所有这些多边形正在渲染60 FPS。
Studio 中的 AVD 创建 GUI 具有硬件加速选项,该选项应控制如下选项:
在
~/.android/avd/Nexus_One_API_24.a/
中。The emulator that comes with Android SDK 23 already runs OpenGL, you can try this out with the official
MoreTeapots
example: https://github.com/googlesamples/android-ndk/tree/a5fdebebdb27ea29cb8a96e08e1ed8c796fa52db/MoreTeapotsI am pretty sure that it is hardware accelerated, since all those polygons are rendering at 60 FPS.
The AVD creation GUI from Studio has a hardware acceleration option, which should control options like:
in
~/.android/avd/Nexus_One_API_24.a/
.