Is there any way to get GPU information?

后端 未结 4 1239
我寻月下人不归
我寻月下人不归 2020-12-30 01:46

I know how to get CPU info inside /proc/, but is there any way to get GPU info? Something like the CPU one?

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 02:22

    Here is a SampleActivity to get GPU info:

    public class MainActivity extends Activity implements GLSurfaceView.Renderer{
        private TextView textView;
        private GLSurfaceView glSurfaceView;
        private StringBuilder sb;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            textView = (TextView) findViewById(R.id.textView);
    
            final ActivityManager activityManager =  (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
            final ConfigurationInfo configurationInfo = activityManager
                    .getDeviceConfigurationInfo();
            sb=new StringBuilder();
            sb.append("GL version:").append(configurationInfo.getGlEsVersion()).append("\n");
    
            textView.setText(sb.toString());
            this.glSurfaceView = new GLSurfaceView(this);
            this.glSurfaceView.setRenderer(this);
            ((ViewGroup)textView.getParent()).addView(this.glSurfaceView);
        }
    
        @Override
        public void onClick(View v) {
        }
    
        @Override
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
           sb.append("RENDERER").append(gl.glGetString(GL10.GL_RENDERER)).append("\n");
            sb.append("VENDOR").append( gl.glGetString(GL10.GL_VENDOR)).append("\n");
            sb.append("VERSION").append(gl.glGetString(GL10.GL_VERSION)).append("\n");
            sb.append("EXTENSIONS").append(gl.glGetString(GL10.GL_EXTENSIONS));
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    textView.setText(sb.toString());
                    glSurfaceView.setVisibility(View.GONE);
                }
            });
        }
    
        @Override
        public void onSurfaceChanged(GL10 gl, int width, int height) {
        }
    
        @Override
        public void onDrawFrame(GL10 gl) {
        }
    }
    

提交回复
热议问题