OpenGL / OpenGL ES2.0 のパフォーマンスを確認する（glmark2/glmark2-es2 を使う）

# 背景

OpenGL / OpenGL ES2.0 のパフォーマンスを確認したいときありますよね！
GL の性能が出なかったり、自作アプリのパフォーマンスが悪かったり。。（泣）

# 準備

## 簡単に

apt-get で。 ubuntu12.04 で動作確認。

```
$ sudo apt-get install glmark2
```

```
$ sudo apt-get install glmark2-es2
```

## 自分でビルド

試したのは glmark2-es2 のみ。

```
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/g/glmark2/glmark2_2011.09.orig.tar.gz
$ tar xzvf glmark2_2011.09.orig.tar.gz
$ cd glmark2-2011.09/
$ ./waf configure --enable-glesv2 --data-path=<directory>/glmark2-2011.09/data
$ ./waf
$ cd ./build/src
// ./glmark2-es2 で実行
```


# 実行

./glmark2 ./glmark2-es2 と打つと、以下のようなサンプルアプリが動作しつつ、FPS が測定される。


## glmark2

```
$ glmark2
** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!
** Failed to set swap interval. Results may be bounded above by refresh rate.
=======================================================
    glmark2 2011.09
=======================================================
    OpenGL Information
    GL_VENDOR:     VMware, Inc.
    GL_RENDERER:   Gallium 0.4 on llvmpipe (LLVM 0x300)
    GL_VERSION:    2.1 Mesa 8.0.4
=======================================================
[build] use-vbo=false:  FPS: 330
[build] use-vbo=true:  FPS: 310
[texture] texture-filter=nearest:  FPS: 329
[texture] texture-filter=linear:  FPS: 348
[texture] texture-filter=mipmap:  FPS: 362
[shading] shading=gouraud:  FPS: 259
[shading] shading=blinn-phong-inf:  FPS: 273
[shading] shading=phong:  FPS: 245
[bump] bump-render=high-poly:  FPS: 141
[bump] bump-render=normals:  FPS: 346
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;:  FPS: 293
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;:  FPS: 217
[pulsar] light=false:quads=5:texture=false:  FPS: 356
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:  FPS: 0
[conditionals] fragment-steps=0:vertex-steps=0:  FPS: 338
[conditionals] fragment-steps=5:vertex-steps=0:  FPS: 298
[conditionals] fragment-steps=0:vertex-steps=5:  FPS: 332
[function] fragment-complexity=low:fragment-steps=5:  FPS: 323
[function] fragment-complexity=medium:fragment-steps=5:  FPS: 272
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5:  FPS: 327
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5:  FPS: 330
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5:  FPS: 304
=======================================================
                                  glmark2 Score: 287 
=======================================================
$
```

## glmark2-es2

```
$ glmark2-es2 
libEGL warning: DRI2: failed to authenticate
=======================================================
    glmark2 2011.09
=======================================================
    OpenGL Information
    GL_VENDOR:     VMware, Inc.
    GL_RENDERER:   Gallium 0.4 on llvmpipe (LLVM 0x300)
    GL_VERSION:    OpenGL ES 2.0 Mesa 8.0.4
=======================================================
[build] use-vbo=false:  FPS: 270
[build] use-vbo=true:  FPS: 282
[texture] texture-filter=nearest:  FPS: 277
[texture] texture-filter=linear:  FPS: 296
[texture] texture-filter=mipmap:  FPS: 306
[shading] shading=gouraud:  FPS: 271
[shading] shading=blinn-phong-inf:  FPS: 251
[shading] shading=phong:  FPS: 238
[bump] bump-render=high-poly:  FPS: 144
[bump] bump-render=normals:  FPS: 306
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;:  FPS: 293
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;:  FPS: 200
[pulsar] light=false:quads=5:texture=false:  FPS: 293
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:  FPS: 0
[conditionals] fragment-steps=0:vertex-steps=0:  FPS: 277
[conditionals] fragment-steps=5:vertex-steps=0:  FPS: 264
[conditionals] fragment-steps=0:vertex-steps=5:  FPS: 281
[function] fragment-complexity=low:fragment-steps=5:  FPS: 280
[function] fragment-complexity=medium:fragment-steps=5:  FPS: 256
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5:  FPS: 275
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5:  FPS: 272
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5:  FPS: 236
=======================================================
                                  glmark2 Score: 253 
=======================================================
$
```

# スクリーンショット

こういう見た目のオブジェクトが回転したり動いたり、
10~20個程度表示される。

![Screenshot_from_2014-12-29 22:31:20.png](https://qiita-image-store.s3.amazonaws.com/0/35514/15c5cc48-4501-5eaf-8a99-0ecd88872e6e.png)

![Screenshot_from_2014-12-29 22:31:38.png](https://qiita-image-store.s3.amazonaws.com/0/35514/e9bb9e3c-3509-a0b9-cfc0-dfda567cbccb.png)

![Screenshot_from_2014-12-29 11:55:09.png](https://qiita-image-store.s3.amazonaws.com/0/35514/ed03866f-a58c-c37b-c331-15580bfd1ef7.png)

# まとめ

```
$ sudo apt-get install glmark2
$ glmark2
```

```
$ sudo apt-get install glmark2-es2
$ glmark2-es2
```

などと打つのみで、 OpenGL / OpenGL ES 2.0 のパフォーマンスが測定出来る。

# 参考

https://github.com/glmark2/glmark2