开发者

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

开发者 https://www.devze.com 2023-02-28 10:10 出处:网络
I开发者_JAVA技巧 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 graph

I开发者_JAVA技巧 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.


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.


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

I 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:

==> 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/.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号