void generate_constants();
void generate_uniforms();
void generate_vs_special_vars();
+ void generate_tcs_special_vars();
+ void generate_tes_special_vars();
void generate_gs_special_vars();
void generate_fs_special_vars();
void generate_cs_special_vars();
}
+/**
+ * Generate variables which only exist in tessellation control shaders.
+ */
+void
+builtin_variable_generator::generate_tcs_special_vars()
+{
+ add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
+ add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
+ add_system_value(SYSTEM_VALUE_INVOCATION_ID, int_t, "gl_InvocationID");
+
+ add_output(VARYING_SLOT_TESS_LEVEL_OUTER,
+ array(float_t, 4), "gl_TessLevelOuter");
+ add_output(VARYING_SLOT_TESS_LEVEL_INNER,
+ array(float_t, 2), "gl_TessLevelInner");
+}
+
+
+/**
+ * Generate variables which only exist in tessellation evaluation shaders.
+ */
+void
+builtin_variable_generator::generate_tes_special_vars()
+{
+ add_system_value(SYSTEM_VALUE_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
+ add_system_value(SYSTEM_VALUE_VERTICES_IN, int_t, "gl_PatchVerticesIn");
+ add_system_value(SYSTEM_VALUE_TESS_COORD, vec3_t, "gl_TessCoord");
+ add_system_value(SYSTEM_VALUE_TESS_LEVEL_OUTER, array(float_t, 4),
+ "gl_TessLevelOuter");
+ add_system_value(SYSTEM_VALUE_TESS_LEVEL_INNER, array(float_t, 2),
+ "gl_TessLevelInner");
+}
+
+
/**
* Generate variables which only exist in geometry shaders.
*/
const char *name_as_gs_input)
{
switch (state->stage) {
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
this->per_vertex_in.add_field(slot, type, name);
/* FALLTHROUGH */
}
}
+ /* Section 7.1 (Built-In Language Variables) of the GLSL 4.00 spec
+ * says:
+ *
+ * "In the tessellation control language, built-in variables are
+ * intrinsically declared as:
+ *
+ * in gl_PerVertex {
+ * vec4 gl_Position;
+ * float gl_PointSize;
+ * float gl_ClipDistance[];
+ * } gl_in[gl_MaxPatchVertices];"
+ */
+ if (state->stage == MESA_SHADER_TESS_CTRL ||
+ state->stage == MESA_SHADER_TESS_EVAL) {
+ const glsl_type *per_vertex_in_type =
+ this->per_vertex_in.construct_interface_instance();
+ add_variable("gl_in", array(per_vertex_in_type, state->Const.MaxPatchVertices),
+ ir_var_shader_in, -1);
+ }
if (state->stage == MESA_SHADER_GEOMETRY) {
const glsl_type *per_vertex_in_type =
this->per_vertex_in.construct_interface_instance();
add_variable("gl_in", array(per_vertex_in_type, 0),
ir_var_shader_in, -1);
}
- if (state->stage == MESA_SHADER_VERTEX || state->stage == MESA_SHADER_GEOMETRY) {
+ if (state->stage == MESA_SHADER_TESS_CTRL) {
+ const glsl_type *per_vertex_out_type =
+ this->per_vertex_out.construct_interface_instance();
+ add_variable("gl_out", array(per_vertex_out_type, 0),
+ ir_var_shader_out, -1);
+ }
+ if (state->stage == MESA_SHADER_VERTEX ||
+ state->stage == MESA_SHADER_TESS_EVAL ||
+ state->stage == MESA_SHADER_GEOMETRY) {
const glsl_type *per_vertex_out_type =
this->per_vertex_out.construct_interface_instance();
const glsl_struct_field *fields = per_vertex_out_type->fields.structure;
case MESA_SHADER_VERTEX:
gen.generate_vs_special_vars();
break;
+ case MESA_SHADER_TESS_CTRL:
+ gen.generate_tcs_special_vars();
+ break;
+ case MESA_SHADER_TESS_EVAL:
+ gen.generate_tes_special_vars();
+ break;
case MESA_SHADER_GEOMETRY:
gen.generate_gs_special_vars();
break;
VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */
VARYING_SLOT_FACE, /* FS only */
VARYING_SLOT_PNTC, /* FS only */
+ VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */
+ VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
VARYING_SLOT_VAR0, /* First generic varying slot */
VARYING_SLOT_MAX = VARYING_SLOT_VAR0 + MAX_VARYING
} gl_varying_slot;
#define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
#define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
#define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
+#define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
+#define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
#define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
/*@}*/
case VARYING_SLOT_EDGE:
case VARYING_SLOT_CLIP_VERTEX:
case VARYING_SLOT_LAYER:
+ case VARYING_SLOT_TESS_LEVEL_OUTER:
+ case VARYING_SLOT_TESS_LEVEL_INNER:
return GL_FALSE;
default:
return GL_TRUE;