简体   繁体   English

为Android Emulator创建虚拟硬件,内核,qemu,以生成OpenGL图形

[英]Create virtual hardware, kernel, qemu for Android Emulator in order to produce OpenGL graphics

I am new to android and wish to play around with the emulator. 我是android新手,希望与模拟器一起玩。

What I want to do is to create my own piece of virtual hardware that can collect OpenGL commands and produce OpenGL graphics. 我要做的是创建自己的虚拟硬件,该硬件可以收集OpenGL命令并生成OpenGL图形。 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. 有人告诉我,为了做到这一点,我将需要编写一个Linux内核驱动程序来实现与硬件的通信。 Additionally, I will need to write an Android user space library to call the kernal driver. 另外,我将需要编写一个Android用户空间库来调用内核驱动程序。

To start with I plan on making a very simple piece of hardware that only does, say 1 or 2, commands. 首先,我计划制作一个非常简单的硬件,仅执行1或2个命令。

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. 对于任何反馈,我们都表示感谢。

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. 在您的情况下,我首先从一个简单的例子开始(因为许多库已在来宾端和主机端放置):通过qemu为普通Linux实现OpenGL直通。 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). 首先,您将一些虚拟GPU添加到qemu中,这还涉及添加一个使用OpenGL的新图形输出模块(到目前为止,qemu使用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. 接下来,您将在Linux内核中创建DRI / DRM驱动程序,该驱动程序将在guest虚拟机上运行(Android使用其自己的图形系统,但可以学习DRI / DRM很好)以及在Mesa中运行。 On the host side you must translate what comes from qemu in OpenGL calls. 在主机端,您必须在OpenGL调用中转换来自qemu的内容。 Since the host side GPU is doing all the hard work your DRI/DRM part will be quite minimal and just build a brigde. 由于主机端GPU会进行所有艰苦的工作,因此您的DRI / DRM部分将非常少,只需建立一个桥梁即可。

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/MoreTeapots Android SDK 23随附的模拟器已经运行OpenGL,您可以使用官方的MoreTeapots示例进行尝试: https : //github.com/googlesamples/android-ndk/tree/a5fdebebdb27ea29cb8a96e08e1ed8c796fa52db/MoreTeapots

I am pretty sure that it is hardware accelerated, since all those polygons are rendering at 60 FPS. 我非常确定它是硬件加速的,因为所有这些多边形均以60 FPS渲染。

The AVD creation GUI from Studio has a hardware acceleration option, which should control options like: Studio的AVD创建GUI具有硬件加速选项,该选项应控制以下选项:

==> config.ini <==
hw.gpu.enabled=yes
hw.gpu.mode=auto

==> hardware-qemu.ini <==
hw.gpu.enabled = true
hw.gpu.mode = host
hw.gpu.blacklisted = no

in ~/.android/avd/Nexus_One_API_24.a/ . ~/.android/avd/Nexus_One_API_24.a/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM