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.
18 lines
365 B
GLSL
18 lines
365 B
GLSL
#version 310 es
|
|
#extension GL_EXT_tessellation_shader : require
|
|
|
|
layout(location = 0) patch out vec3 vFoo;
|
|
|
|
layout(vertices = 1) out;
|
|
|
|
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);
|
|
}
|