f3c0942d10
The tessellation levels in Metal are stored as a densely-packed array of half-precision floating point values. But, stage-in attributes in Metal have to have offsets and strides aligned to a multiple of four, so we can't add them individually. Luckily for us, the arrays have lengths less than 4. So, let's use vectors for them! Triangles get a single attribute with a `float4`, where the outer levels are in `.xyz` and the inner levels are in `.w`. The arrays are unpacked as though we had added the elements individually. Quads get two: a `float4` with the outer levels and a `float2` with the inner levels. Further, since vectors can be indexed as arrays, there's no need to unpack them in this case. This also saves on precious vertex attributes. Before, we were using up to 6 of them. Now we need two at most.
14 lines
404 B
GLSL
14 lines
404 B
GLSL
#version 310 es
|
|
#extension GL_EXT_tessellation_shader : require
|
|
|
|
layout(cw, triangles, fractional_even_spacing) in;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = vec4(gl_TessCoord.x * gl_TessLevelInner[0] * gl_TessLevelOuter[0],
|
|
gl_TessCoord.y * gl_TessLevelInner[0] * gl_TessLevelOuter[1],
|
|
gl_TessCoord.z * gl_TessLevelInner[0] * gl_TessLevelOuter[2],
|
|
1);
|
|
}
|
|
|