Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (41 sloc) 2.257 kb
b9dcd3a @aras-p readme
authored
1 A small Windows / Mac app to test GLSL shader loading speed.
2
5f9a8e8 @aras-p update readme
authored
3 TL;DR: even simple offline GLSL "pre-optimization" improves shader loading
4 speed, often 2x faster to load on Mac! Loading D3D9 assembly shaders is several
5 times faster than loading GLSL ones.
6
7
b9dcd3a @aras-p readme
authored
8 Measuring process:
9 1. load shaders from files
10 2. compile super small empty shader (to load/"warmup" the compiler)
11 3. set 1x1 pixel viewport
12 4. start timer
13 5. compile & link the shaders
14 6. set the program, draw two triangles (some drivers defer final compilation until first use)
15 7. delete shader
16 8. glFinish()
17 9. stop the timer
18
19 Several shaders included:
20 * Tree Leaf shader with per pixel lighting and some translucency calculations
5f9a8e8 @aras-p update readme
authored
21 * FXAA 3.11 PC-39 preset
b9dcd3a @aras-p readme
authored
22 * Deferred Lighting light application shader
5f9a8e8 @aras-p update readme
authored
23 * Parallax normal mapping with self-illumination
24 * Naive "port" of part of Mental Ray's architectural shader (not optimized)
25 * SSAO
b9dcd3a @aras-p readme
authored
26
27
28 For each shader, it's "raw" form is there as produced by hlsl2glslfork[1] and the
5f9a8e8 @aras-p update readme
authored
29 same shader, still in GLSL, but pre-optimized offline by glsl-optimizer[2]. For some shaders,
30 D3D9 shader assembly is provided and performance of loading that is measured when on Windows.
b9dcd3a @aras-p readme
authored
31
32 See results.txt. Even loading "still a GLSL" shaders, but pre-optimized a bit, is faster.
33 On Mac it's faster quite a lot!
34
35 A big game might use 1000 to 10000 shaders. According to these results, even simple offline
5f9a8e8 @aras-p update readme
authored
36 pre-optimization can save 3-10ms from each shader loading time. That is 3 to 100 seconds saved
efb44ae @aras-p clarify readme
authored
37 from loading time. I guess loading preoptimized GLSL bytecode would be even faster, but there's
38 no way to measure that until GLSL has it. This test compares loading speed of D3D9 bytecode but
39 of course that is not a fully apples-to-apples comparison.
a9a55bf @aras-p update readme
authored
40
41
42 Source code includes parts of Ryan Gordon's Mojoshader [3] to assemble D3D9 shaders into bytecode.
43 It felt like a saner choice than depending on a D3DX DLL from DirectX SDK.
02956b2 @aras-p add TODO
authored
44
45
46 TODO:
47 * Check on Mac OS X 10.7.x with Core profile.
48 * Check on Windows with latest AMD drivers.
49 * Check on Windows on NVIDIA hardware.
50 * Check equivalent shaders (where possible) using ARB vertex/fragment program assembly.
51
5f9a8e8 @aras-p update readme
authored
52
b9dcd3a @aras-p readme
authored
53
54 [1]: https://github.com/aras-p/hlsl2glslfork
55 [2]: https://github.com/aras-p/glsl-optimizer
a9a55bf @aras-p update readme
authored
56 [3]: http://icculus.org/mojoshader/
Something went wrong with that request. Please try again.