mesa/*: use an internal enum for tessellation primitive types.

To avoid dragging gl.h into places it has no business being,
defined tessellation primitive mode to an enum.

This has a lot of fallout all over the place.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14605>
This commit is contained in:
Dave Airlie
2022-01-19 11:43:15 +10:00
committed by Marge Bot
parent 537a0ee3b7
commit d54c07b4c4
43 changed files with 234 additions and 156 deletions

View File

@@ -474,16 +474,16 @@ hs_emit_write_tess_factors(nir_shader *shader,
unsigned outer_comps;
unsigned inner_comps;
switch (shader->info.tess.primitive_mode) {
case GL_ISOLINES:
switch (shader->info.tess._primitive_mode) {
case TESS_PRIMITIVE_ISOLINES:
outer_comps = 2;
inner_comps = 0;
break;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
outer_comps = 3;
inner_comps = 1;
break;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
outer_comps = 4;
inner_comps = 2;
break;
@@ -541,11 +541,11 @@ hs_emit_write_tess_factors(nir_shader *shader,
}
/* Store tess factors for the tessellator */
if (shader->info.tess.primitive_mode == GL_ISOLINES) {
if (shader->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES) {
/* LINES reversal */
nir_ssa_def *t = nir_vec2(b, nir_channel(b, tessfactors_outer, 1), nir_channel(b, tessfactors_outer, 0));
nir_build_store_buffer_amd(b, t, tessfactor_ring, tess_factors_offset, tess_factors_base, .base = tess_factors_const_offset, .write_mask = 0x3);
} else if (shader->info.tess.primitive_mode == GL_TRIANGLES) {
} else if (shader->info.tess._primitive_mode == TESS_PRIMITIVE_TRIANGLES) {
nir_ssa_def *t = nir_vec4(b, nir_channel(b, tessfactors_outer, 0), nir_channel(b, tessfactors_outer, 1),
nir_channel(b, tessfactors_outer, 2), nir_channel(b, tessfactors_inner, 0));
nir_build_store_buffer_amd(b, t, tessfactor_ring, tess_factors_offset, tess_factors_base, .base = tess_factors_const_offset, .write_mask = 0xf);

View File

@@ -5391,7 +5391,7 @@ visit_load_tess_coord(isel_context* ctx, nir_intrinsic_instr* instr)
Operand tes_v(get_arg(ctx, ctx->args->ac.tes_v));
Operand tes_w = Operand::zero();
if (ctx->shader->info.tess.primitive_mode == GL_TRIANGLES) {
if (ctx->shader->info.tess._primitive_mode == TESS_PRIMITIVE_TRIANGLES) {
Temp tmp = bld.vop2(aco_opcode::v_add_f32, bld.def(v1), tes_u, tes_v);
tmp = bld.vop2(aco_opcode::v_sub_f32, bld.def(v1), Operand::c32(0x3f800000u /* 1.0f */), tmp);
tes_w = Operand(tmp);

View File

@@ -3963,7 +3963,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
};
/* For triangles, the vector should be (u, v, 1-u-v). */
if (ctx->info->tess.primitive_mode == GL_TRIANGLES) {
if (ctx->info->tess._primitive_mode == TESS_PRIMITIVE_TRIANGLES) {
coord[2] = LLVMBuildFSub(ctx->ac.builder, ctx->ac.f32_1,
LLVMBuildFAdd(ctx->ac.builder, coord[0], coord[1], ""), "");
}

View File

@@ -1590,7 +1590,7 @@ handle_ngg_outputs_post_2(struct radv_shader_context *ctx)
if (ctx->shader->info.tess.point_mode)
num_vertices = 1;
else if (ctx->shader->info.tess.primitive_mode == GL_ISOLINES)
else if (ctx->shader->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
num_vertices = 2;
else
num_vertices = 3;

View File

@@ -1283,6 +1283,21 @@ radv_prim_can_use_guardband(enum VkPrimitiveTopology topology)
}
}
static uint32_t
si_conv_tess_prim_to_gs_out(enum tess_primitive_mode prim)
{
switch (prim) {
case TESS_PRIMITIVE_TRIANGLES:
case TESS_PRIMITIVE_QUADS:
return V_028A6C_TRISTRIP;
case TESS_PRIMITIVE_ISOLINES:
return V_028A6C_LINESTRIP;
default:
assert(0);
return 0;
}
}
static uint32_t
si_conv_gl_prim_to_gs_out(unsigned gl_prim)
{
@@ -1566,7 +1581,7 @@ radv_pipeline_init_input_assembly_state(struct radv_pipeline *pipeline,
pipeline->graphics.can_use_guardband = true;
} else if (radv_pipeline_has_tess(pipeline)) {
if (!tes->info.tes.point_mode &&
si_conv_gl_prim_to_gs_out(tes->info.tes.primitive_mode) == V_028A6C_TRISTRIP)
tes->info.tes._primitive_mode != TESS_PRIMITIVE_ISOLINES)
pipeline->graphics.can_use_guardband = true;
}
@@ -2052,7 +2067,7 @@ radv_get_num_input_vertices(nir_shader **nir)
if (tes->info.tess.point_mode)
return 1;
if (tes->info.tess.primitive_mode == GL_ISOLINES)
if (tes->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
return 2;
return 3;
}
@@ -2988,7 +3003,7 @@ radv_determine_ngg_settings(struct radv_pipeline *pipeline,
unsigned num_vertices_per_prim = si_conv_prim_to_gs_out(pipeline_key->vs.topology) + 1;
if (es_stage == MESA_SHADER_TESS_EVAL)
num_vertices_per_prim = nir[es_stage]->info.tess.point_mode ? 1
: nir[es_stage]->info.tess.primitive_mode == GL_ISOLINES ? 2
: nir[es_stage]->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES ? 2
: 3;
infos[es_stage].has_ngg_culling = radv_consider_culling(
@@ -3260,16 +3275,17 @@ merge_tess_info(struct shader_info *tes_info, struct shader_info *tcs_info)
tcs_info->tess.spacing == tes_info->tess.spacing);
tes_info->tess.spacing |= tcs_info->tess.spacing;
assert(tcs_info->tess.primitive_mode == 0 || tes_info->tess.primitive_mode == 0 ||
tcs_info->tess.primitive_mode == tes_info->tess.primitive_mode);
tes_info->tess.primitive_mode |= tcs_info->tess.primitive_mode;
assert(tcs_info->tess._primitive_mode == TESS_PRIMITIVE_UNSPECIFIED ||
tes_info->tess._primitive_mode == TESS_PRIMITIVE_UNSPECIFIED ||
tcs_info->tess._primitive_mode == tes_info->tess._primitive_mode);
tes_info->tess._primitive_mode |= tcs_info->tess._primitive_mode;
tes_info->tess.ccw |= tcs_info->tess.ccw;
tes_info->tess.point_mode |= tcs_info->tess.point_mode;
/* Copy the merged info back to the TCS */
tcs_info->tess.tcs_vertices_out = tes_info->tess.tcs_vertices_out;
tcs_info->tess.spacing = tes_info->tess.spacing;
tcs_info->tess.primitive_mode = tes_info->tess.primitive_mode;
tcs_info->tess._primitive_mode = tes_info->tess._primitive_mode;
tcs_info->tess.ccw = tes_info->tess.ccw;
tcs_info->tess.point_mode = tes_info->tess.point_mode;
}
@@ -5077,16 +5093,18 @@ radv_pipeline_generate_tess_state(struct radeon_cmdbuf *ctx_cs,
radeon_set_context_reg(ctx_cs, R_028B58_VGT_LS_HS_CONFIG, ls_hs_config);
}
switch (tes->info.tes.primitive_mode) {
case GL_TRIANGLES:
switch (tes->info.tes._primitive_mode) {
case TESS_PRIMITIVE_TRIANGLES:
type = V_028B6C_TESS_TRIANGLE;
break;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
type = V_028B6C_TESS_QUAD;
break;
case GL_ISOLINES:
case TESS_PRIMITIVE_ISOLINES:
type = V_028B6C_TESS_ISOLINE;
break;
default:
break;
}
switch (tes->info.tes.spacing) {
@@ -5114,7 +5132,7 @@ radv_pipeline_generate_tess_state(struct radeon_cmdbuf *ctx_cs,
if (tes->info.tes.point_mode)
topology = V_028B6C_OUTPUT_POINT;
else if (tes->info.tes.primitive_mode == GL_ISOLINES)
else if (tes->info.tes._primitive_mode == TESS_PRIMITIVE_ISOLINES)
topology = V_028B6C_OUTPUT_LINE;
else if (ccw)
topology = V_028B6C_OUTPUT_TRIANGLE_CCW;
@@ -5630,8 +5648,8 @@ radv_pipeline_generate_vgt_gs_out(struct radeon_cmdbuf *ctx_cs,
if (pipeline->shaders[MESA_SHADER_TESS_EVAL]->info.tes.point_mode) {
gs_out = V_028A6C_POINTLIST;
} else {
gs_out = si_conv_gl_prim_to_gs_out(
pipeline->shaders[MESA_SHADER_TESS_EVAL]->info.tes.primitive_mode);
gs_out = si_conv_tess_prim_to_gs_out(
pipeline->shaders[MESA_SHADER_TESS_EVAL]->info.tes._primitive_mode);
}
} else if (radv_pipeline_has_mesh(pipeline)) {
gs_out =

View File

@@ -1021,7 +1021,7 @@ void radv_lower_ngg(struct radv_device *device, struct nir_shader *nir,
if (nir->info.stage == MESA_SHADER_TESS_EVAL) {
if (nir->info.tess.point_mode)
num_vertices_per_prim = 1;
else if (nir->info.tess.primitive_mode == GL_ISOLINES)
else if (nir->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
num_vertices_per_prim = 2;
/* Manually mark the primitive ID used, so the shader can repack it. */
@@ -1566,7 +1566,7 @@ radv_postprocess_config(const struct radv_device *device, const struct ac_shader
bool nggc = info->has_ngg_culling; /* Culling uses GS vertex offsets 0, 1, 2. */
bool tes_triangles =
stage == MESA_SHADER_TESS_EVAL && info->tes.primitive_mode >= 4; /* GL_TRIANGLES */
stage == MESA_SHADER_TESS_EVAL && info->tes._primitive_mode != TESS_PRIMITIVE_ISOLINES;
if (info->uses_invocation_id) {
gs_vgpr_comp_cnt = 3; /* VGPR3 contains InvocationID. */
} else if (info->uses_prim_id || (es_stage == MESA_SHADER_VERTEX &&

View File

@@ -287,7 +287,7 @@ struct radv_shader_info {
struct radv_vs_output_info outinfo;
struct radv_es_output_info es_info;
bool as_es;
unsigned primitive_mode;
enum tess_primitive_mode _primitive_mode;
enum gl_tess_spacing spacing;
bool ccw;
bool point_mode;

View File

@@ -759,7 +759,7 @@ radv_nir_shader_info_pass(struct radv_device *device, const struct nir_shader *n
info->gs.invocations = nir->info.gs.invocations;
break;
case MESA_SHADER_TESS_EVAL:
info->tes.primitive_mode = nir->info.tess.primitive_mode;
info->tes._primitive_mode = nir->info.tess._primitive_mode;
info->tes.spacing = nir->info.tess.spacing;
info->tes.ccw = nir->info.tess.ccw;
info->tes.point_mode = nir->info.tess.point_mode;

View File

@@ -1829,9 +1829,20 @@ set_shader_inout_layout(struct gl_shader *shader,
}
break;
case MESA_SHADER_TESS_EVAL:
shader->info.TessEval.PrimitiveMode = PRIM_UNKNOWN;
if (state->in_qualifier->flags.q.prim_type)
shader->info.TessEval.PrimitiveMode = state->in_qualifier->prim_type;
shader->info.TessEval._PrimitiveMode = TESS_PRIMITIVE_UNSPECIFIED;
if (state->in_qualifier->flags.q.prim_type) {
switch (state->in_qualifier->prim_type) {
case GL_TRIANGLES:
shader->info.TessEval._PrimitiveMode = TESS_PRIMITIVE_TRIANGLES;
break;
case GL_QUADS:
shader->info.TessEval._PrimitiveMode = TESS_PRIMITIVE_QUADS;
break;
case GL_ISOLINES:
shader->info.TessEval._PrimitiveMode = TESS_PRIMITIVE_ISOLINES;
break;
}
}
shader->info.TessEval.Spacing = TESS_SPACING_UNSPECIFIED;
if (state->in_qualifier->flags.q.vertex_spacing)

View File

@@ -1971,7 +1971,7 @@ link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
int point_mode = -1;
unsigned vertex_order = 0;
gl_prog->info.tess.primitive_mode = PRIM_UNKNOWN;
gl_prog->info.tess._primitive_mode = TESS_PRIMITIVE_UNSPECIFIED;
gl_prog->info.tess.spacing = TESS_SPACING_UNSPECIFIED;
/* From the GLSL 4.0 spec (chapter 4.3.8.1):
@@ -1991,16 +1991,16 @@ link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
for (unsigned i = 0; i < num_shaders; i++) {
struct gl_shader *shader = shader_list[i];
if (shader->info.TessEval.PrimitiveMode != PRIM_UNKNOWN) {
if (gl_prog->info.tess.primitive_mode != PRIM_UNKNOWN &&
gl_prog->info.tess.primitive_mode !=
shader->info.TessEval.PrimitiveMode) {
if (shader->info.TessEval._PrimitiveMode != TESS_PRIMITIVE_UNSPECIFIED) {
if (gl_prog->info.tess._primitive_mode != TESS_PRIMITIVE_UNSPECIFIED &&
gl_prog->info.tess._primitive_mode !=
shader->info.TessEval._PrimitiveMode) {
linker_error(prog, "tessellation evaluation shader defined with "
"conflicting input primitive modes.\n");
return;
}
gl_prog->info.tess.primitive_mode =
shader->info.TessEval.PrimitiveMode;
gl_prog->info.tess._primitive_mode =
shader->info.TessEval._PrimitiveMode;
}
if (shader->info.TessEval.Spacing != 0) {
@@ -2039,7 +2039,7 @@ link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
* since we already know we're in the right type of shader program
* for doing it.
*/
if (gl_prog->info.tess.primitive_mode == PRIM_UNKNOWN) {
if (gl_prog->info.tess._primitive_mode == TESS_PRIMITIVE_UNSPECIFIED) {
linker_error(prog,
"tessellation evaluation shader didn't declare input "
"primitive modes.\n");

View File

@@ -994,6 +994,14 @@ enum gl_tess_spacing
TESS_SPACING_FRACTIONAL_EVEN,
};
enum tess_primitive_mode
{
TESS_PRIMITIVE_UNSPECIFIED,
TESS_PRIMITIVE_TRIANGLES,
TESS_PRIMITIVE_QUADS,
TESS_PRIMITIVE_ISOLINES,
};
/**
* A compare function enum for use in compiler lowering passes. This is in
* the same order as GL's compare functions (shifted down by GL_NEVER), and is

View File

@@ -466,7 +466,7 @@ typedef struct shader_info {
/* Applies to both TCS and TES. */
struct {
uint16_t primitive_mode; /* GL_TRIANGLES, GL_QUADS or GL_ISOLINES */
enum tess_primitive_mode _primitive_mode;
/** The number of vertices in the TCS output patch. */
uint8_t tcs_vertices_out;

View File

@@ -4265,6 +4265,23 @@ vtn_handle_barrier(struct vtn_builder *b, SpvOp opcode,
}
}
static enum tess_primitive_mode
tess_primitive_mode_from_spv_execution_mode(struct vtn_builder *b,
SpvExecutionMode mode)
{
switch (mode) {
case SpvExecutionModeTriangles:
return TESS_PRIMITIVE_TRIANGLES;
case SpvExecutionModeQuads:
return TESS_PRIMITIVE_QUADS;
case SpvExecutionModeIsolines:
return TESS_PRIMITIVE_ISOLINES;
default:
vtn_fail("Invalid tess primitive type: %s (%u)",
spirv_executionmode_to_string(mode), mode);
}
}
static unsigned
gl_primitive_from_spv_execution_mode(struct vtn_builder *b,
SpvExecutionMode mode)
@@ -5016,8 +5033,8 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
case SpvExecutionModeIsolines:
if (b->shader->info.stage == MESA_SHADER_TESS_CTRL ||
b->shader->info.stage == MESA_SHADER_TESS_EVAL) {
b->shader->info.tess.primitive_mode =
gl_primitive_from_spv_execution_mode(b, mode->exec_mode);
b->shader->info.tess._primitive_mode =
tess_primitive_mode_from_spv_execution_mode(b, mode->exec_mode);
} else {
vtn_assert(b->shader->info.stage == MESA_SHADER_GEOMETRY);
b->shader->info.gs.vertices_in =

View File

@@ -345,14 +345,14 @@ struct ir3_shader_key {
};
static inline unsigned
ir3_tess_mode(unsigned gl_tess_mode)
ir3_tess_mode(enum tess_primitive_mode tess_mode)
{
switch (gl_tess_mode) {
case GL_ISOLINES:
switch (tess_mode) {
case TESS_PRIMITIVE_ISOLINES:
return IR3_TESS_ISOLINES;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
return IR3_TESS_TRIANGLES;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
return IR3_TESS_QUADS;
default:
unreachable("bad tessmode");

View File

@@ -1202,7 +1202,7 @@ tu6_emit_vpc(struct tu_cs *cs,
uint32_t output;
if (tess_info->tess.point_mode)
output = TESS_POINTS;
else if (tess_info->tess.primitive_mode == GL_ISOLINES)
else if (tess_info->tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
output = TESS_LINES;
else if (tess_info->tess.ccw)
output = TESS_CCW_TRIS;
@@ -2309,15 +2309,15 @@ tu_pipeline_shader_key_init(struct ir3_shader_key *key,
static uint32_t
tu6_get_tessmode(struct tu_shader* shader)
{
uint32_t primitive_mode = shader->ir3_shader->nir->info.tess.primitive_mode;
enum tess_primitive_mode primitive_mode = shader->ir3_shader->nir->info.tess._primitive_mode;
switch (primitive_mode) {
case GL_ISOLINES:
case TESS_PRIMITIVE_ISOLINES:
return IR3_TESS_ISOLINES;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
return IR3_TESS_TRIANGLES;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
return IR3_TESS_QUADS;
case GL_NONE:
case TESS_PRIMITIVE_UNSPECIFIED:
return IR3_TESS_NONE;
default:
unreachable("bad tessmode");

View File

@@ -29,6 +29,7 @@
#include "nir_to_tgsi_info.h"
#include "util/u_math.h"
#include "util/u_prim.h"
#include "nir.h"
#include "nir_deref.h"
#include "tgsi/tgsi_scan.h"
@@ -433,10 +434,7 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
}
if (nir->info.stage == MESA_SHADER_TESS_EVAL) {
if (nir->info.tess.primitive_mode == GL_ISOLINES)
info->properties[TGSI_PROPERTY_TES_PRIM_MODE] = PIPE_PRIM_LINES;
else
info->properties[TGSI_PROPERTY_TES_PRIM_MODE] = nir->info.tess.primitive_mode;
info->properties[TGSI_PROPERTY_TES_PRIM_MODE] = u_tess_prim_from_shader(nir->info.tess._primitive_mode);
STATIC_ASSERT((TESS_SPACING_EQUAL + 1) % 3 == PIPE_TESS_SPACING_EQUAL);
STATIC_ASSERT((TESS_SPACING_FRACTIONAL_ODD + 1) % 3 ==

View File

@@ -39,6 +39,7 @@
#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_prim.h"
#include "util/u_bitmask.h"
#include "GL/gl.h"
#include "compiler/shader_info.h"
@@ -2297,11 +2298,7 @@ static void
ureg_setup_tess_eval_shader(struct ureg_program *ureg,
const struct shader_info *info)
{
if (info->tess.primitive_mode == GL_ISOLINES)
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE, GL_LINES);
else
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE,
info->tess.primitive_mode);
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE, u_tess_prim_from_shader(info->tess._primitive_mode));
STATIC_ASSERT((TESS_SPACING_EQUAL + 1) % 3 == PIPE_TESS_SPACING_EQUAL);
STATIC_ASSERT((TESS_SPACING_FRACTIONAL_ODD + 1) % 3 ==

View File

@@ -33,6 +33,7 @@
#include "pipe/p_defines.h"
#include "util/compiler.h"
#include "util/u_debug.h"
#include "compiler/shader_enums.h"
#ifdef __cplusplus
extern "C" {
@@ -314,6 +315,21 @@ u_base_prim_type(enum pipe_prim_type prim_type)
}
}
static inline enum pipe_prim_type
u_tess_prim_from_shader(enum tess_primitive_mode shader_mode)
{
switch (shader_mode) {
case TESS_PRIMITIVE_TRIANGLES:
return PIPE_PRIM_TRIANGLES;
case TESS_PRIMITIVE_QUADS:
return PIPE_PRIM_QUADS;
case TESS_PRIMITIVE_ISOLINES:
return PIPE_PRIM_LINES;
default:
return PIPE_PRIM_POINTS;
}
}
static inline unsigned
u_vertices_for_prims(enum pipe_prim_type prim_type, int count)
{

View File

@@ -1436,19 +1436,19 @@ crocus_compile_tcs(struct crocus_context *ice,
prog_data->param = rzalloc_array(mem_ctx, uint32_t, num_system_values);
prog_data->nr_params = num_system_values;
if (key->tes_primitive_mode == GL_QUADS) {
if (key->_tes_primitive_mode == TESS_PRIMITIVE_QUADS) {
for (int i = 0; i < 4; i++)
system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
system_values[3] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
system_values[2] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y;
} else if (key->tes_primitive_mode == GL_TRIANGLES) {
} else if (key->_tes_primitive_mode == TESS_PRIMITIVE_TRIANGLES) {
for (int i = 0; i < 3; i++)
system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
system_values[4] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
} else {
assert(key->tes_primitive_mode == GL_ISOLINES);
assert(key->_tes_primitive_mode == TESS_PRIMITIVE_ISOLINES);
system_values[7] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_Y;
system_values[6] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X;
}
@@ -1522,9 +1522,9 @@ crocus_update_compiled_tcs(struct crocus_context *ice)
struct brw_tcs_prog_key key = {
KEY_INIT_NO_ID(),
.base.program_string_id = tcs ? tcs->program_id : 0,
.tes_primitive_mode = tes_info->tess.primitive_mode,
._tes_primitive_mode = tes_info->tess._primitive_mode,
.input_vertices = ice->state.vertices_per_patch,
.quads_workaround = tes_info->tess.primitive_mode == GL_QUADS &&
.quads_workaround = tes_info->tess._primitive_mode == TESS_PRIMITIVE_QUADS &&
tes_info->tess.spacing == TESS_SPACING_EQUAL,
};
@@ -2787,13 +2787,12 @@ crocus_create_tcs_state(struct pipe_context *ctx,
ish->nos |= (1ull << CROCUS_NOS_TEXTURES);
if (screen->precompile) {
const unsigned _GL_TRIANGLES = 0x0004;
struct brw_tcs_prog_key key = {
KEY_INIT(),
// XXX: make sure the linker fills this out from the TES...
.tes_primitive_mode =
info->tess.primitive_mode ? info->tess.primitive_mode
: _GL_TRIANGLES,
._tes_primitive_mode =
info->tess._primitive_mode ? info->tess._primitive_mode
: TESS_PRIMITIVE_TRIANGLES,
.outputs_written = info->outputs_written,
.patch_outputs_written = info->patch_outputs_written,
};

View File

@@ -175,7 +175,7 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
return false;
struct shader_info *ds_info = ir3_get_shader_info(emit.key.ds);
emit.key.key.tessellation = ir3_tess_mode(ds_info->tess.primitive_mode);
emit.key.key.tessellation = ir3_tess_mode(ds_info->tess._primitive_mode);
ctx->gen_dirty |= BIT(FD6_GROUP_PRIMITIVE_PARAMS);
struct shader_info *fs_info = ir3_get_shader_info(emit.key.fs);

View File

@@ -765,7 +765,7 @@ setup_stateobj(struct fd_ringbuffer *ring, struct fd_context *ctx,
uint32_t output;
if (ds_info->tess.point_mode)
output = TESS_POINTS;
else if (ds_info->tess.primitive_mode == GL_ISOLINES)
else if (ds_info->tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
output = TESS_LINES;
else if (ds_info->tess.ccw)
output = TESS_CCW_TRIS;

View File

@@ -193,7 +193,7 @@ create_initial_variants(struct ir3_shader_state *hwcso,
switch (nir->info.stage) {
case MESA_SHADER_TESS_EVAL:
key.tessellation = ir3_tess_mode(nir->info.tess.primitive_mode);
key.tessellation = ir3_tess_mode(nir->info.tess._primitive_mode);
break;
case MESA_SHADER_TESS_CTRL:

View File

@@ -228,7 +228,7 @@ struct iris_vs_prog_key {
struct iris_tcs_prog_key {
struct iris_vue_prog_key vue;
uint16_t tes_primitive_mode;
enum tess_primitive_mode _tes_primitive_mode;
uint8_t input_vertices;

View File

@@ -114,7 +114,7 @@ iris_to_brw_tcs_key(const struct intel_device_info *devinfo,
{
return (struct brw_tcs_prog_key) {
BRW_KEY_INIT(devinfo->ver, key->vue.base.program_string_id),
.tes_primitive_mode = key->tes_primitive_mode,
._tes_primitive_mode = key->_tes_primitive_mode,
.input_vertices = key->input_vertices,
.patch_outputs_written = key->patch_outputs_written,
.outputs_written = key->outputs_written,
@@ -1523,19 +1523,19 @@ iris_compile_tcs(struct iris_screen *screen,
prog_data->param = rzalloc_array(mem_ctx, uint32_t, num_system_values);
prog_data->nr_params = num_system_values;
if (key->tes_primitive_mode == GL_QUADS) {
if (key->_tes_primitive_mode == TESS_PRIMITIVE_QUADS) {
for (int i = 0; i < 4; i++)
system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
system_values[3] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
system_values[2] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y;
} else if (key->tes_primitive_mode == GL_TRIANGLES) {
} else if (key->_tes_primitive_mode == TESS_PRIMITIVE_TRIANGLES) {
for (int i = 0; i < 3; i++)
system_values[7 - i] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X + i;
system_values[4] = BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X;
} else {
assert(key->tes_primitive_mode == GL_ISOLINES);
assert(key->_tes_primitive_mode == TESS_PRIMITIVE_ISOLINES);
system_values[7] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_Y;
system_values[6] = BRW_PARAM_BUILTIN_TESS_LEVEL_OUTER_X;
}
@@ -1603,11 +1603,11 @@ iris_update_compiled_tcs(struct iris_context *ice)
iris_get_shader_info(ice, MESA_SHADER_TESS_EVAL);
struct iris_tcs_prog_key key = {
.vue.base.program_string_id = tcs ? tcs->program_id : 0,
.tes_primitive_mode = tes_info->tess.primitive_mode,
._tes_primitive_mode = tes_info->tess._primitive_mode,
.input_vertices =
!tcs || compiler->use_tcs_8_patch ? ice->state.vertices_per_patch : 0,
.quads_workaround = devinfo->ver < 9 &&
tes_info->tess.primitive_mode == GL_QUADS &&
tes_info->tess._primitive_mode == TESS_PRIMITIVE_QUADS &&
tes_info->tess.spacing == TESS_SPACING_EQUAL,
};
get_unified_tess_slots(ice, &key.outputs_written,
@@ -2604,14 +2604,12 @@ iris_create_shader_state(struct pipe_context *ctx,
break;
case MESA_SHADER_TESS_CTRL: {
const unsigned _GL_TRIANGLES = 0x0004;
key.tcs = (struct iris_tcs_prog_key) {
KEY_ID(vue.base),
// XXX: make sure the linker fills this out from the TES...
.tes_primitive_mode =
info->tess.primitive_mode ? info->tess.primitive_mode
: _GL_TRIANGLES,
._tes_primitive_mode =
info->tess._primitive_mode ? info->tess._primitive_mode
: TESS_PRIMITIVE_TRIANGLES,
.outputs_written = info->outputs_written,
.patch_outputs_written = info->patch_outputs_written,
};

View File

@@ -25,6 +25,7 @@
#include "compiler/nir/nir.h"
#include "util/u_debug.h"
#include "util/u_prim.h"
#include "codegen/nv50_ir.h"
#include "codegen/nv50_ir_from_common.h"
@@ -1325,10 +1326,7 @@ Converter::parseNIR()
break;
case Program::TYPE_TESSELLATION_CONTROL:
case Program::TYPE_TESSELLATION_EVAL:
if (nir->info.tess.primitive_mode == GL_ISOLINES)
info_out->prop.tp.domain = GL_LINES;
else
info_out->prop.tp.domain = nir->info.tess.primitive_mode;
info_out->prop.tp.domain = u_tess_prim_from_shader(nir->info.tess._primitive_mode);
info_out->prop.tp.outputPatchSize = nir->info.tess.tcs_vertices_out;
info_out->prop.tp.outputPrim =
nir->info.tess.point_mode ? PIPE_PRIM_POINTS : PIPE_PRIM_TRIANGLES;

View File

@@ -30,6 +30,8 @@
#include "../r600_pipe.h"
#include "../r600_shader.h"
#include "util/u_prim.h"
#include "sfn_instruction_tex.h"
#include "sfn_shader_vertex.h"
@@ -901,7 +903,7 @@ int r600_shader_from_nir(struct r600_context *rctx,
sh->info.stage == MESA_SHADER_TESS_EVAL ||
(sh->info.stage == MESA_SHADER_VERTEX && key->vs.as_ls)) {
auto prim_type = sh->info.stage == MESA_SHADER_TESS_EVAL ?
sh->info.tess.primitive_mode: key->tcs.prim_mode;
u_tess_prim_from_shader(sh->info.tess._primitive_mode) : key->tcs.prim_mode;
NIR_PASS_V(sh, r600_lower_tess_io, static_cast<pipe_prim_type>(prim_type));
}
@@ -909,9 +911,9 @@ int r600_shader_from_nir(struct r600_context *rctx,
NIR_PASS_V(sh, r600_append_tcs_TF_emission,
(pipe_prim_type)key->tcs.prim_mode);
if (sh->info.stage == MESA_SHADER_TESS_EVAL)
NIR_PASS_V(sh, r600_lower_tess_coord,
static_cast<pipe_prim_type>(sh->info.tess.primitive_mode));
if (sh->info.stage == MESA_SHADER_TESS_EVAL) {
NIR_PASS_V(sh, r600_lower_tess_coord, u_tess_prim_from_shader(sh->info.tess._primitive_mode));
}
NIR_PASS_V(sh, nir_lower_ubo_vec4);
if (lower_64bit)

View File

@@ -105,7 +105,7 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, uns
if (info->base.tess.point_mode)
*num_vertices = 1;
else if (info->base.tess.primitive_mode == GL_LINES)
else if (info->base.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
*num_vertices = 2;
else
*num_vertices = 3;

View File

@@ -579,11 +579,6 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
}
}
if (nir->info.stage == MESA_SHADER_TESS_EVAL) {
if (info->base.tess.primitive_mode == GL_ISOLINES)
info->base.tess.primitive_mode = GL_LINES;
}
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
/* post_depth_coverage implies early_fragment_tests */
info->base.fs.early_fragment_tests |= info->base.fs.post_depth_coverage;

View File

@@ -693,17 +693,17 @@ static void si_write_tess_factors(struct si_shader_context *ctx, LLVMValueRef re
/* Determine the layout of one tess factor element in the buffer. */
switch (shader->key.ge.part.tcs.epilog.prim_mode) {
case GL_LINES:
case TESS_PRIMITIVE_ISOLINES:
stride = 2; /* 2 dwords, 1 vec2 store */
outer_comps = 2;
inner_comps = 0;
break;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
stride = 4; /* 4 dwords, 1 vec4 store */
outer_comps = 3;
inner_comps = 1;
break;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
stride = 6; /* 6 dwords, 2 stores (vec4 + vec2) */
outer_comps = 4;
inner_comps = 2;
@@ -745,7 +745,7 @@ static void si_write_tess_factors(struct si_shader_context *ctx, LLVMValueRef re
}
}
if (shader->key.ge.part.tcs.epilog.prim_mode == GL_LINES) {
if (shader->key.ge.part.tcs.epilog.prim_mode == TESS_PRIMITIVE_ISOLINES) {
/* For isolines, the hardware expects tess factors in the
* reverse order from what NIR specifies.
*/

View File

@@ -515,20 +515,20 @@ static void si_set_tesseval_regs(struct si_screen *sscreen, const struct si_shad
struct si_shader *shader)
{
const struct si_shader_info *info = &tes->info;
unsigned tes_prim_mode = info->base.tess.primitive_mode;
enum tess_primitive_mode tes_prim_mode = info->base.tess._primitive_mode;
unsigned tes_spacing = info->base.tess.spacing;
bool tes_vertex_order_cw = !info->base.tess.ccw;
bool tes_point_mode = info->base.tess.point_mode;
unsigned type, partitioning, topology, distribution_mode;
switch (tes_prim_mode) {
case GL_LINES:
case TESS_PRIMITIVE_ISOLINES:
type = V_028B6C_TESS_ISOLINE;
break;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
type = V_028B6C_TESS_TRIANGLE;
break;
case GL_QUADS:
case TESS_PRIMITIVE_QUADS:
type = V_028B6C_TESS_QUAD;
break;
default:
@@ -553,7 +553,7 @@ static void si_set_tesseval_regs(struct si_screen *sscreen, const struct si_shad
if (tes_point_mode)
topology = V_028B6C_OUTPUT_POINT;
else if (tes_prim_mode == GL_LINES)
else if (tes_prim_mode == TESS_PRIMITIVE_ISOLINES)
topology = V_028B6C_OUTPUT_LINE;
else if (tes_vertex_order_cw)
/* for some reason, this must be the other way around */
@@ -1272,7 +1272,7 @@ unsigned si_get_input_prim(const struct si_shader_selector *gs, const union si_s
if (gs->info.stage == MESA_SHADER_TESS_EVAL) {
if (gs->info.base.tess.point_mode)
return PIPE_PRIM_POINTS;
if (gs->info.base.tess.primitive_mode == GL_LINES)
if (gs->info.base.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
return PIPE_PRIM_LINES;
return PIPE_PRIM_TRIANGLES;
}
@@ -3151,7 +3151,7 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
if (sel->info.stage == MESA_SHADER_TESS_EVAL) {
if (sel->info.base.tess.point_mode)
sel->rast_prim = PIPE_PRIM_POINTS;
else if (sel->info.base.tess.primitive_mode == GL_LINES)
else if (sel->info.base.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
sel->rast_prim = PIPE_PRIM_LINE_STRIP;
else
sel->rast_prim = PIPE_PRIM_TRIANGLES;
@@ -3532,7 +3532,7 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
sctx->shader.tcs.key.ge.part.tcs.epilog.prim_mode =
sctx->fixed_func_tcs_shader.key.ge.part.tcs.epilog.prim_mode =
sel ? sel->info.base.tess.primitive_mode : 0;
sel ? sel->info.base.tess._primitive_mode : 0;
sctx->shader.tcs.key.ge.part.tcs.epilog.tes_reads_tess_factors =
sctx->fixed_func_tcs_shader.key.ge.part.tcs.epilog.tes_reads_tess_factors =

View File

@@ -3529,12 +3529,12 @@ get_depth_layout_mode(enum gl_frag_depth_layout depth_layout)
}
static SpvExecutionMode
get_primitive_mode(uint16_t primitive_mode)
get_primitive_mode(enum tess_primitive_mode primitive_mode)
{
switch (primitive_mode) {
case GL_TRIANGLES: return SpvExecutionModeTriangles;
case GL_QUADS: return SpvExecutionModeQuads;
case GL_ISOLINES: return SpvExecutionModeIsolines;
case TESS_PRIMITIVE_TRIANGLES: return SpvExecutionModeTriangles;
case TESS_PRIMITIVE_QUADS: return SpvExecutionModeQuads;
case TESS_PRIMITIVE_ISOLINES: return SpvExecutionModeIsolines;
default:
unreachable("unknown tess prim type!");
}
@@ -3781,7 +3781,7 @@ nir_to_spirv(struct nir_shader *s, const struct zink_so_info *so_info, uint32_t
break;
case MESA_SHADER_TESS_EVAL:
spirv_builder_emit_exec_mode(&ctx.builder, entry_point,
get_primitive_mode(s->info.tess.primitive_mode));
get_primitive_mode(s->info.tess._primitive_mode));
spirv_builder_emit_exec_mode(&ctx.builder, entry_point,
s->info.tess.ccw ? SpvExecutionModeVertexOrderCcw
: SpvExecutionModeVertexOrderCw);

View File

@@ -1623,6 +1623,17 @@ gl_prim_to_pipe(unsigned primitive_type)
}
}
static enum pipe_prim_type
tess_prim_to_pipe(enum tess_primitive_mode prim_mode)
{
switch (prim_mode) {
case TESS_PRIMITIVE_ISOLINES:
return PIPE_PRIM_LINES;
default:
return PIPE_PRIM_TRIANGLES;
}
}
static enum pipe_prim_type
get_shader_base_prim_type(struct nir_shader *nir)
{
@@ -1630,7 +1641,7 @@ get_shader_base_prim_type(struct nir_shader *nir)
case MESA_SHADER_GEOMETRY:
return gl_prim_to_pipe(nir->info.gs.output_primitive);
case MESA_SHADER_TESS_EVAL:
return nir->info.tess.point_mode ? PIPE_PRIM_POINTS : gl_prim_to_pipe(nir->info.tess.primitive_mode);
return nir->info.tess.point_mode ? PIPE_PRIM_POINTS : tess_prim_to_pipe(nir->info.tess._primitive_mode);
default:
break;
}

View File

@@ -694,10 +694,10 @@ merge_tess_info(struct shader_info *tes_info,
tcs_info->tess.spacing == tes_info->tess.spacing);
tes_info->tess.spacing |= tcs_info->tess.spacing;
assert(tcs_info->tess.primitive_mode == 0 ||
tes_info->tess.primitive_mode == 0 ||
tcs_info->tess.primitive_mode == tes_info->tess.primitive_mode);
tes_info->tess.primitive_mode |= tcs_info->tess.primitive_mode;
assert(tcs_info->tess._primitive_mode == 0 ||
tes_info->tess._primitive_mode == 0 ||
tcs_info->tess._primitive_mode == tes_info->tess._primitive_mode);
tes_info->tess._primitive_mode |= tcs_info->tess._primitive_mode;
tes_info->tess.ccw |= tcs_info->tess.ccw;
tes_info->tess.point_mode |= tcs_info->tess.point_mode;
}

View File

@@ -336,7 +336,7 @@ struct brw_tcs_prog_key
{
struct brw_base_prog_key base;
GLenum tes_primitive_mode;
enum tess_primitive_mode _tes_primitive_mode;
unsigned input_vertices;

View File

@@ -125,7 +125,7 @@ debug_tcs_recompile(const struct brw_compiler *c, void *log,
found |= check("input vertices", input_vertices);
found |= check("outputs written", outputs_written);
found |= check("patch outputs written", patch_outputs_written);
found |= check("tes primitive mode", tes_primitive_mode);
found |= check("tes primitive mode", _tes_primitive_mode);
found |= check("quads and equal_spacing workaround", quads_workaround);
if (!found) {

View File

@@ -30,33 +30,33 @@
static bool
remap_tess_levels(nir_builder *b, nir_intrinsic_instr *intr,
GLenum primitive_mode)
enum tess_primitive_mode _primitive_mode)
{
const int location = nir_intrinsic_base(intr);
const unsigned component = nir_intrinsic_component(intr);
bool out_of_bounds;
if (location == VARYING_SLOT_TESS_LEVEL_INNER) {
switch (primitive_mode) {
case GL_QUADS:
switch (_primitive_mode) {
case TESS_PRIMITIVE_QUADS:
/* gl_TessLevelInner[0..1] lives at DWords 3-2 (reversed). */
nir_intrinsic_set_base(intr, 0);
nir_intrinsic_set_component(intr, 3 - component);
out_of_bounds = false;
break;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
/* gl_TessLevelInner[0] lives at DWord 4. */
nir_intrinsic_set_base(intr, 1);
out_of_bounds = component > 0;
break;
case GL_ISOLINES:
case TESS_PRIMITIVE_ISOLINES:
out_of_bounds = true;
break;
default:
unreachable("Bogus tessellation domain");
}
} else if (location == VARYING_SLOT_TESS_LEVEL_OUTER) {
if (primitive_mode == GL_ISOLINES) {
if (_primitive_mode == TESS_PRIMITIVE_ISOLINES) {
/* gl_TessLevelOuter[0..1] lives at DWords 6-7 (in order). */
nir_intrinsic_set_base(intr, 1);
nir_intrinsic_set_component(intr, 2 + nir_intrinsic_component(intr));
@@ -65,7 +65,7 @@ remap_tess_levels(nir_builder *b, nir_intrinsic_instr *intr,
/* Triangles use DWords 7-5 (reversed); Quads use 7-4 (reversed) */
nir_intrinsic_set_base(intr, 1);
nir_intrinsic_set_component(intr, 3 - nir_intrinsic_component(intr));
out_of_bounds = component == 3 && primitive_mode == GL_TRIANGLES;
out_of_bounds = component == 3 && _primitive_mode == TESS_PRIMITIVE_TRIANGLES;
}
} else {
return false;
@@ -104,7 +104,7 @@ is_output(nir_intrinsic_instr *intrin)
static bool
remap_patch_urb_offsets(nir_block *block, nir_builder *b,
const struct brw_vue_map *vue_map,
GLenum tes_primitive_mode)
enum tess_primitive_mode tes_primitive_mode)
{
const bool is_passthrough_tcs = b->shader->info.name &&
strcmp(b->shader->info.name, "passthrough TCS") == 0;
@@ -366,7 +366,7 @@ brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map)
nir_builder_init(&b, function->impl);
nir_foreach_block(block, function->impl) {
remap_patch_urb_offsets(block, &b, vue_map,
nir->info.tess.primitive_mode);
nir->info.tess._primitive_mode);
}
}
}
@@ -475,7 +475,7 @@ brw_nir_lower_vue_outputs(nir_shader *nir)
void
brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map,
GLenum tes_primitive_mode)
enum tess_primitive_mode tes_primitive_mode)
{
nir_foreach_shader_out_variable(var, nir) {
var->data.driver_location = var->data.location;

View File

@@ -113,7 +113,7 @@ void brw_nir_lower_fs_inputs(nir_shader *nir,
const struct brw_wm_prog_key *key);
void brw_nir_lower_vue_outputs(nir_shader *nir);
void brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue,
GLenum tes_primitive_mode);
enum tess_primitive_mode tes_primitive_mode);
void brw_nir_lower_fs_outputs(nir_shader *nir);
bool brw_nir_lower_conversions(nir_shader *nir);

View File

@@ -1387,14 +1387,14 @@ brw_compile_tes(const struct brw_compiler *compiler,
prog_data->partitioning =
(enum brw_tess_partitioning) (nir->info.tess.spacing - 1);
switch (nir->info.tess.primitive_mode) {
case GL_QUADS:
switch (nir->info.tess._primitive_mode) {
case TESS_PRIMITIVE_QUADS:
prog_data->domain = BRW_TESS_DOMAIN_QUAD;
break;
case GL_TRIANGLES:
case TESS_PRIMITIVE_TRIANGLES:
prog_data->domain = BRW_TESS_DOMAIN_TRI;
break;
case GL_ISOLINES:
case TESS_PRIMITIVE_ISOLINES:
prog_data->domain = BRW_TESS_DOMAIN_ISOLINE;
break;
default:
@@ -1403,7 +1403,7 @@ brw_compile_tes(const struct brw_compiler *compiler,
if (nir->info.tess.point_mode) {
prog_data->output_topology = BRW_TESS_OUTPUT_TOPOLOGY_POINT;
} else if (nir->info.tess.primitive_mode == GL_ISOLINES) {
} else if (nir->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES) {
prog_data->output_topology = BRW_TESS_OUTPUT_TOPOLOGY_LINE;
} else {
/* Hardware winding order is backwards from OpenGL */

View File

@@ -380,7 +380,7 @@ brw_compile_tcs(const struct brw_compiler *compiler,
brw_nir_apply_key(nir, compiler, &key->base, 8, is_scalar);
brw_nir_lower_vue_inputs(nir, &input_vue_map);
brw_nir_lower_tcs_outputs(nir, &vue_prog_data->vue_map,
key->tes_primitive_mode);
key->_tes_primitive_mode);
if (key->quads_workaround)
brw_nir_apply_tcs_quads_workaround(nir);

View File

@@ -983,10 +983,10 @@ merge_tess_info(struct shader_info *tes_info,
tcs_info->tess.spacing == tes_info->tess.spacing);
tes_info->tess.spacing |= tcs_info->tess.spacing;
assert(tcs_info->tess.primitive_mode == 0 ||
tes_info->tess.primitive_mode == 0 ||
tcs_info->tess.primitive_mode == tes_info->tess.primitive_mode);
tes_info->tess.primitive_mode |= tcs_info->tess.primitive_mode;
assert(tcs_info->tess._primitive_mode == 0 ||
tes_info->tess._primitive_mode == 0 ||
tcs_info->tess._primitive_mode == tes_info->tess._primitive_mode);
tes_info->tess._primitive_mode |= tcs_info->tess._primitive_mode;
tes_info->tess.ccw |= tcs_info->tess.ccw;
tes_info->tess.point_mode |= tcs_info->tess.point_mode;
}
@@ -1011,11 +1011,11 @@ anv_pipeline_link_tcs(const struct brw_compiler *compiler,
* this comes from the SPIR-V, which is part of the hash used for the
* pipeline cache. So it should be safe.
*/
tcs_stage->key.tcs.tes_primitive_mode =
tes_stage->nir->info.tess.primitive_mode;
tcs_stage->key.tcs._tes_primitive_mode =
tes_stage->nir->info.tess._primitive_mode;
tcs_stage->key.tcs.quads_workaround =
compiler->devinfo->ver < 9 &&
tes_stage->nir->info.tess.primitive_mode == 7 /* GL_QUADS */ &&
tes_stage->nir->info.tess._primitive_mode == TESS_PRIMITIVE_QUADS &&
tes_stage->nir->info.tess.spacing == TESS_SPACING_EQUAL;
}

View File

@@ -316,7 +316,7 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx)
if (tes->info.tess.point_mode) {
if (ctx->TransformFeedback.Mode != GL_POINTS)
mask = 0;
} else if (tes->info.tess.primitive_mode == GL_ISOLINES) {
} else if (tes->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES) {
if (ctx->TransformFeedback.Mode != GL_LINES)
mask = 0;
} else {
@@ -388,7 +388,7 @@ _mesa_update_valid_to_render_state(struct gl_context *ctx)
if (tes->info.tess.point_mode)
valid = geom_mode == GL_POINTS;
else if (tes->info.tess.primitive_mode == GL_ISOLINES)
else if (tes->info.tess._primitive_mode == TESS_PRIMITIVE_ISOLINES)
valid = geom_mode == GL_LINES;
else
/* the GL_QUADS mode generates triangles too */

View File

@@ -2531,11 +2531,7 @@ struct gl_shader_info
* Tessellation Evaluation shader state from layout qualifiers.
*/
struct {
/**
* GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
* in this shader.
*/
GLenum16 PrimitiveMode;
enum tess_primitive_mode _PrimitiveMode;
enum gl_tess_spacing Spacing;

View File

@@ -1007,8 +1007,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]->
Program->info.tess.primitive_mode;
const struct gl_linked_shader *tes =
shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL];
switch (tes->Program->info.tess._primitive_mode) {
case TESS_PRIMITIVE_TRIANGLES:
*params = GL_TRIANGLES;
break;
case TESS_PRIMITIVE_QUADS:
*params = GL_QUADS;
break;
case TESS_PRIMITIVE_ISOLINES:
*params = GL_ISOLINES;
break;
case TESS_PRIMITIVE_UNSPECIFIED:
*params = 0;
break;
}
}
return;
case GL_TESS_GEN_SPACING: