Graphics Reference
In-Depth Information
code remains constant. In other words, the packing rules will not do
reordering that requires the compiler to generate extra instructions to
merge unpacked data. Rather, the packing rules seek to optimize the
use of the physical address space without negatively impacting runtime
performance.
Let's look at an example group of uniform declarations and see how these
would be packed:
uniform mat3 m;
uniform float f[6];
uniform vec3 v;
If no packing were done at all, you can see that a lot of constant storage
space would be wasted. The matrix m would take up three rows, the array
f would take up six rows, and the vector v would take up one row. This
would use a total of 10 rows to store the variables. Table 5-6 shows what
the results would be without any packing. With the packing rules, the
variables will get organized such that they pack into the grid as shown in
Table 5-7.
Table 5-6
Uniform Storage without Packing
Location
X
Y
Z
W
0
m[0].x
m[0].y
m[0].z
1
m[l].x
m[l].y
m[l].z
2
m[2].x
m[2].y
m[2].z
3
f[0]
4
f[l]
5
f[2]
6
f[3]
f[4]
7
f[5]
8
v.x
v.y
v.z
-6
9
 
Search WWH ::




Custom Search