如何测量 Android 上的 VRAM 消耗?
我想获取 Android 设备 VRAM 大小。
有没有从程序中获取的方法?
I want to acquire Android Device VRAM size.
Is there a method for acquisition from the program?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我们使用 Nexus One 来计算一下:
屏幕分辨率为 480x800。因此所需的最小视频内存大小为:
400 * 800 * 4 字节 = 1536000 字节
假设驱动程序可能(通常应该)使用多个缓冲区,我们还应该期望如下值:
1536000 * 2 字节 = 3072000 字节
1536000 * 3 字节 = 4608000 字节
etc...
如果值不是 1536000(或者通常是 W x H x 4)的倍数,那就很奇怪了。
在对 Android 内部进行一些搜索后,我发现了这个文档:
所以我尝试获取
/dev/graphics/fb0 文件(在我的设备上没有
/dev/fb0
)。但直接的方法行不通:
使用下一个技巧,您可以获得
fb0
的实际大小:>adb pull /dev/graphics/fb0
1659 KB/s(2.712 秒内 4608000 字节)
视频内存约为 4mb (Nexus One)。让我们检查一下这是否是 Nexus 屏幕尺寸的倍数:
4608000/1536000 = 3
它看起来是一个正确的值。我们还可以说驱动程序使用三个屏幕缓冲区。
因此,作为结论,您可以使用 adb 检测视频内存大小,但由于文件访问限制,您无法在运行时从 Android 应用程序使用此方法。
Let's do some calculation using Nexus One:
Screen resolution is 480x800. So minimum required video memory size would be:
400 * 800 * 4 bytes = 1536000 bytes
Assuming that driver may (and normally should) use several buffers, we should also expect values like:
1536000 * 2 bytes = 3072000 bytes
1536000 * 3 bytes = 4608000 bytes
etc...
It would be weird to have values that are not multiple of 1536000 (or W x H x 4 in general).
After some searches on Android internals I've found this documentation :
So I tried and take size of
/dev/graphics/fb0
file (on my device there is no/dev/fb0
).But a direct approach doesn't work:
Using next trick you can get actual size of
fb0
:>adb pull /dev/graphics/fb0
1659 KB/s (4608000 bytes in 2.712s)
Video memory is ~4mb (Nexus One). Let's check if this is multiple of Nexus screen size:
4608000/1536000 = 3
It looks like a right value. And we also can say that driver uses three screen buffers.
So, as a conclusion, you can detect video memory size using adb, but you can't use this approach from your android application in runtime due to file access restrictions.
您通常在移动设备上没有专用的“VRAM”。至少 PowerVR 架构不具备这种能力(该架构凭借 MBX 和 SGX 内核完全主导市场)。
也就是说,OpenGL 驱动程序会分配普通 RAM,直到您用完为止,分配的越多,留给应用程序的内存就越少。
You typically do not have a dedicated "VRAM" on mobile devices. At least you don't have it with PowerVR architectures (wich totally dominate the market with their MBX and SGX cores).
That is, the OpenGL driver allocates normal RAM until you run out of it, and the more you allocate the less you have left for your application.
Android/OpenGL API 不提供从给定设备读取 VRAM 大小的显式方法。
穷人解决方案:
您可以尝试以经验方式添加 1MB 纹理来推断 VRAM 大小,直到从
gl.glGetError()
收到内存不足错误。The Android/OpenGL APIs don't offer explicit methods to read the VRAM size from a given device.
Poor man solution:
You could try to infer the VRAM size in an empiric way adding 1MB texture until you get an out of memory error from
gl.glGetError()
.从您的“dmesg”输出中,您可以读取 VRAM,因此对于我的平板电脑:
或详细信息:
http://pastebin.com /jQSXQqHh
From your "dmesg" output u can read off the VRAM, so for my Tablet:
or details at:
http://pastebin.com/jQSXQqHh
很简单,只需计算 RAM 的可用容量和实际容量有多少 Mb RAM,例如我的联想 a369i 有 512 RAM 模块,但在设置应用程序中仅显示 471 Mb 可用,因此剩下的 41Mb 保留给 GPU,所以结论我的 a369i 有 41Mb vram
此方法基于共享图形内存 (wiki)
Is simple just count how many Mb ram that from usable to real capacity of the ram, example for my lenovo a369i has 512 RAM Module, but in setting app only showing 471 Mb usable so the 41Mb left is reserved for the GPU, so the conclusion is my a369i has 41Mb vram
This method is based from shared graphics memory (wiki)
我怀疑 android.os.StatFs 就是您正在寻找的:
http: //developer.android.com/reference/android/os/StatFs.html
I suspect that android.os.StatFs is what you're looking for:
http://developer.android.com/reference/android/os/StatFs.html