summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-09-24 17:59:55 -0700
committerKenneth Graunke <[email protected]>2017-01-07 22:22:28 -0800
commita4fd84ef5f247f50a3683ecdf7f9d801a6e3cf15 (patch)
treedcf2a26e9a8cde7d6bc77fee2aaf8b655fe11adc /src/mesa
parent9bb89175e6487186389b69e8ee0b587d38ed8015 (diff)
mesa: Introduce a compiler enum for tessellation spacing.
It feels weird using GL_* enums in a Vulkan driver. v2: Fix the TESS_SPACING -> PIPE_TESS_SPACING conversion. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_tcs.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_tes.c20
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/shaderapi.c18
-rw-r--r--src/mesa/state_tracker/st_program.c23
5 files changed, 36 insertions, 37 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index b6251d52f60..9e9d9eb00d2 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -331,7 +331,7 @@ brw_tcs_populate_key(struct brw_context *brw,
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;
@@ -403,7 +403,7 @@ brw_tcs_precompile(struct gl_context *ctx,
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;
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index 2dae1e57f41..2729d29239b 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -93,19 +93,13 @@ brw_codegen_tes_prog(struct brw_context *brw,
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:
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index dadedb145ad..691323d8f3c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2279,11 +2279,9 @@ struct gl_shader_info
* 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.
*/
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index f198a3c6302..7771b7ce7da 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -838,8 +838,22 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
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:
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 7d548d51c13..96c6bb3fcf8 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1607,21 +1607,14 @@ st_translate_tesseval_program(struct st_context *st,
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);