eb89c3a428
These are transpiled to kernel functions that write the output of the shader to three buffers: one for per-vertex varyings, one for per-patch varyings, and one for the tessellation levels. This structure is mandated by the way Metal works, where the tessellation factors are supplied to the draw method in their own buffer, while the per-patch and per-vertex varyings are supplied as though they were vertex attributes; since they have different step rates, they must be in separate buffers. The kernel is expected to be run in a workgroup whose size is the greater of the number of input or output control points. It uses Metal's support for vertex-style stage input to a compute shader to get the input values; therefore, at least one instance must run per input point. Meanwhile, Vulkan mandates that it run at least once per output point. Overrunning the output array is a concern, but any values written should either be discarded or overwritten by subsequent patches. I'm probably going to put some slop space in the buffer when I integrate this into MoltenVK to be on the safe side.
33 lines
570 B
GLSL
33 lines
570 B
GLSL
#version 450
|
|
layout(vertices = 1) out;
|
|
|
|
in gl_PerVertex
|
|
{
|
|
vec4 gl_Position;
|
|
} gl_in[gl_MaxPatchVertices];
|
|
|
|
out gl_PerVertex
|
|
{
|
|
vec4 gl_Position;
|
|
} gl_out[1];
|
|
|
|
layout(location = 0) patch out vec3 vFoo;
|
|
|
|
void set_position()
|
|
{
|
|
gl_out[gl_InvocationID].gl_Position = gl_in[0].gl_Position + gl_in[1].gl_Position;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
gl_TessLevelInner[0] = 8.9;
|
|
gl_TessLevelInner[1] = 6.9;
|
|
gl_TessLevelOuter[0] = 8.9;
|
|
gl_TessLevelOuter[1] = 6.9;
|
|
gl_TessLevelOuter[2] = 3.9;
|
|
gl_TessLevelOuter[3] = 4.9;
|
|
vFoo = vec3(1.0);
|
|
|
|
set_position();
|
|
}
|