It feels weird using GL_* enums in a Vulkan driver.
v2: Fix the TESS_SPACING -> PIPE_TESS_SPACING conversion.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
ast_layout_expression *local_size[3];
/** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */
- GLenum vertex_spacing;
+ enum gl_tess_spacing vertex_spacing;
/** Tessellation evaluation shader: vertex ordering (CW or CCW) */
GLenum ordering;
if (!$$.flags.i) {
static const struct {
const char *s;
- GLenum e;
+ enum gl_tess_spacing e;
} map[] = {
- { "equal_spacing", GL_EQUAL },
- { "fractional_odd_spacing", GL_FRACTIONAL_ODD },
- { "fractional_even_spacing", GL_FRACTIONAL_EVEN },
+ { "equal_spacing", TESS_SPACING_EQUAL },
+ { "fractional_odd_spacing", TESS_SPACING_FRACTIONAL_ODD },
+ { "fractional_even_spacing", TESS_SPACING_FRACTIONAL_EVEN },
};
for (unsigned i = 0; i < ARRAY_SIZE(map); i++) {
if (match_layout_qualifier($1, map[i].s, state) == 0) {
if (state->in_qualifier->flags.q.prim_type)
shader->info.TessEval.PrimitiveMode = state->in_qualifier->prim_type;
- shader->info.TessEval.Spacing = 0;
+ shader->info.TessEval.Spacing = TESS_SPACING_UNSPECIFIED;
if (state->in_qualifier->flags.q.vertex_spacing)
shader->info.TessEval.Spacing = state->in_qualifier->vertex_spacing;
unsigned num_shaders)
{
linked_shader->info.TessEval.PrimitiveMode = PRIM_UNKNOWN;
- linked_shader->info.TessEval.Spacing = 0;
+ linked_shader->info.TessEval.Spacing = TESS_SPACING_UNSPECIFIED;
linked_shader->info.TessEval.VertexOrder = 0;
linked_shader->info.TessEval.PointMode = -1;
return;
}
- if (linked_shader->info.TessEval.Spacing == 0)
- linked_shader->info.TessEval.Spacing = GL_EQUAL;
+ if (linked_shader->info.TessEval.Spacing == TESS_SPACING_UNSPECIFIED)
+ linked_shader->info.TessEval.Spacing = TESS_SPACING_EQUAL;
if (linked_shader->info.TessEval.VertexOrder == 0)
linked_shader->info.TessEval.VertexOrder = GL_CCW;
BLEND_ALL = 0x7fff,
};
+enum gl_tess_spacing
+{
+ TESS_SPACING_UNSPECIFIED,
+ TESS_SPACING_EQUAL,
+ TESS_SPACING_FRACTIONAL_ODD,
+ TESS_SPACING_FRACTIONAL_EVEN,
+};
+
#ifdef __cplusplus
} /* extern "C" */
#endif
struct {
uint32_t primitive_mode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
- uint32_t spacing; /* GL_EQUAL, GL_FRACTIONAL_EVEN, GL_FRACTIONAL_ODD */
+ enum gl_tess_spacing spacing;
/** Is the vertex order counterclockwise? */
bool ccw;
bool point_mode;
key->tes_primitive_mode = tep->program.info.tes.primitive_mode;
key->quads_workaround = brw->gen < 9 &&
tep->program.info.tes.primitive_mode == GL_QUADS &&
- tep->program.info.tes.spacing == GL_EQUAL;
+ tep->program.info.tes.spacing == TESS_SPACING_EQUAL;
if (tcp) {
key->program_string_id = tcp->id;
key.tes_primitive_mode = tes->info.TessEval.PrimitiveMode;
key.quads_workaround = brw->gen < 9 &&
tes->info.TessEval.PrimitiveMode == GL_QUADS &&
- tes->info.TessEval.Spacing == GL_EQUAL;
+ tes->info.TessEval.Spacing == TESS_SPACING_EQUAL;
} else {
btep = NULL;
key.tes_primitive_mode = GL_TRIANGLES;
brw_assign_common_binding_table_offsets(devinfo, &tep->program,
&prog_data.base.base, 0);
- switch (tep->program.info.tes.spacing) {
- case GL_EQUAL:
- prog_data.partitioning = BRW_TESS_PARTITIONING_INTEGER;
- break;
- case GL_FRACTIONAL_ODD:
- prog_data.partitioning = BRW_TESS_PARTITIONING_ODD_FRACTIONAL;
- break;
- case GL_FRACTIONAL_EVEN:
- prog_data.partitioning = BRW_TESS_PARTITIONING_EVEN_FRACTIONAL;
- break;
- default:
- unreachable("invalid domain shader spacing");
- }
+ STATIC_ASSERT(BRW_TESS_PARTITIONING_INTEGER == TESS_SPACING_EQUAL - 1);
+ STATIC_ASSERT(BRW_TESS_PARTITIONING_ODD_FRACTIONAL ==
+ TESS_SPACING_FRACTIONAL_ODD - 1);
+ STATIC_ASSERT(BRW_TESS_PARTITIONING_EVEN_FRACTIONAL ==
+ TESS_SPACING_FRACTIONAL_EVEN - 1);
+
+ prog_data.partitioning = tep->program.info.tes.spacing - 1;
switch (tep->program.info.tes.primitive_mode) {
case GL_QUADS:
* in this shader.
*/
GLenum PrimitiveMode;
- /**
- * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
- * in this shader.
- */
- GLenum Spacing;
+
+ enum gl_tess_spacing Spacing;
+
/**
* GL_CW, GL_CCW, or 0 if it's not set in this shader.
*/
if (!has_tess)
break;
if (check_tes_query(ctx, shProg)) {
- *params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
- info.TessEval.Spacing;
+ const struct gl_linked_shader *tes =
+ shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ switch (tes->info.TessEval.Spacing) {
+ case TESS_SPACING_EQUAL:
+ *params = GL_EQUAL;
+ break;
+ case TESS_SPACING_FRACTIONAL_ODD:
+ *params = GL_FRACTIONAL_ODD;
+ break;
+ case TESS_SPACING_FRACTIONAL_EVEN:
+ *params = GL_FRACTIONAL_EVEN;
+ break;
+ case TESS_SPACING_UNSPECIFIED:
+ *params = 0;
+ break;
+ }
}
return;
case GL_TESS_GEN_VERTEX_ORDER:
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE,
sttep->Base.info.tes.primitive_mode);
- switch (sttep->Base.info.tes.spacing) {
- case GL_EQUAL:
- ureg_property(ureg, TGSI_PROPERTY_TES_SPACING, PIPE_TESS_SPACING_EQUAL);
- break;
- case GL_FRACTIONAL_EVEN:
- ureg_property(ureg, TGSI_PROPERTY_TES_SPACING,
- PIPE_TESS_SPACING_FRACTIONAL_EVEN);
- break;
- case GL_FRACTIONAL_ODD:
- ureg_property(ureg, TGSI_PROPERTY_TES_SPACING,
- PIPE_TESS_SPACING_FRACTIONAL_ODD);
- break;
- default:
- assert(0);
- }
+ STATIC_ASSERT((TESS_SPACING_EQUAL + 1) % 3 == PIPE_TESS_SPACING_EQUAL);
+ STATIC_ASSERT((TESS_SPACING_FRACTIONAL_ODD + 1) % 3 ==
+ PIPE_TESS_SPACING_FRACTIONAL_ODD);
+ STATIC_ASSERT((TESS_SPACING_FRACTIONAL_EVEN + 1) % 3 ==
+ PIPE_TESS_SPACING_FRACTIONAL_EVEN);
+
+ ureg_property(ureg, TGSI_PROPERTY_TES_SPACING,
+ (sttep->Base.info.tes.spacing + 1) % 3);
ureg_property(ureg, TGSI_PROPERTY_TES_VERTEX_ORDER_CW,
!sttep->Base.info.tes.ccw);