Programmatically get GPU information on Android without using GLSurfaceView

233 views Asked by At

I need to get GPU information (including vendor, renderer, version, available extensions etc) programmatically in my Android SDK. So far, I know these ways to do this.

  1. Run dumpsys | grep GLES command (Does not work because dumpsys is a system-level command available only to some system apps or the ADB shell)
  2. Create a GLSurfaceView, attach a GLSurfaceView.Renderer, and get GPU information in its callback (Works fine but I want to know if there is a way to do that without creating a GLSurfaceView since I do not want to tinker with the host app's view hierarchy from my SDK)
1

There are 1 answers

0
Zach Dean On

Take a look at the Grafika project.

Within it there is GLESInfoActivity, which demonstrates how to obtain the information you're looking for.

The function gatherGlInfo() has the code you need and it states that:

We need a GL context to examine, which means we need an EGL surface. Create a 1x1 pbuffer.

This EGLSurface is required to obtain the information from the GLES20 class (OpenGLES information). You do not need this surface if you just want the information from the EGL14 class (EGL information). However, given your question you will need information from the GLES20 class and thus require an EGLSurface.

In your case it should suffice to copy this method and use an offscreen surface, which would avoid the need to use GLSurfaceView.

You will also need some of the code within the gles package for the EGL set up and configuration. In particular:

  • EglCore
  • EglSurfaceBase
  • OffscreenSurface