assert(shader->key.as_ngg && !shader->key.as_es);
- return sel->info.stage != MESA_SHADER_GEOMETRY && !sel->info.writes_edgeflag;
+ return sel->info.stage != MESA_SHADER_GEOMETRY &&
+ !gfx10_ngg_writes_user_edgeflags(shader);
}
void gfx10_ngg_build_sendmsg_gs_alloc_req(struct si_shader_context *ctx)
/* This is only used with NGG culling, which returns the NGG
* passthrough prim export encoding.
*/
- if (ctx->shader->selector->info.writes_edgeflag) {
+ if (gfx10_ngg_writes_user_edgeflags(ctx->shader)) {
unsigned all_bits_no_edgeflags = ~SI_NGG_PRIM_EDGE_FLAG_BITS;
LLVMValueRef edgeflags = LLVMConstInt(ctx->ac.i32, all_bits_no_edgeflags, 0);
prim.isnull = ctx->ac.i1false;
- if (ctx->stage == MESA_SHADER_VERTEX &&
- !ctx->shader->selector->info.base.vs.blit_sgprs_amd)
+ if (gfx10_edgeflags_have_effect(ctx->shader))
prim.edgeflags = ac_pack_edgeflags_for_export(&ctx->ac, &ctx->args);
else
prim.edgeflags = ctx->ac.i32_0;
for (unsigned i = 0; i < prim.num_vertices; ++i)
prim.index[i] = si_unpack_param(ctx, ctx->args.gs_vtx_offset[i / 2], (i & 1) * 16, 16);
- if (ctx->shader->selector->info.writes_edgeflag) {
+ if (gfx10_ngg_writes_user_edgeflags(ctx->shader)) {
LLVMValueRef edgeflags = ctx->ac.i32_0;
for (unsigned i = 0; i < prim.num_vertices; ++i) {
* used for padding to reduce LDS bank conflicts. */
if (shader->selector->so.num_outputs)
lds_vertex_size = 4 * shader->selector->info.num_outputs + 1;
- if (shader->selector->info.writes_edgeflag)
+ if (gfx10_ngg_writes_user_edgeflags(shader))
lds_vertex_size = MAX2(lds_vertex_size, 1);
/* LDS size for passing data from GS to ES.
prim.num_vertices = num_vertices;
prim.isnull = ctx->ac.i1false;
- if (ctx->stage == MESA_SHADER_VERTEX)
+ if (gfx10_edgeflags_have_effect(shader))
prim.edgeflags = ac_pack_edgeflags_for_export(&ctx->ac, &ctx->args);
else
prim.edgeflags = ctx->ac.i32_0;
}
/* These two also use LDS. */
- if (sel->info.writes_edgeflag ||
+ if (gfx10_ngg_writes_user_edgeflags(shader) ||
(ctx->stage == MESA_SHADER_VERTEX && shader->key.mono.u.vs_export_prim_id))
ac_build_s_barrier(&ctx->ac);
LLVMValueRef vertex_ptr = NULL;
- if (sel->so.num_outputs || sel->info.writes_edgeflag)
+ if (sel->so.num_outputs || gfx10_ngg_writes_user_edgeflags(ctx->shader))
vertex_ptr = ngg_nogs_vertex_ptr(ctx, get_thread_id_in_tg(ctx));
for (unsigned i = 0; i < info->num_outputs; i++) {
}
/* Store the edgeflag at the end (if streamout is enabled) */
- if (info->output_semantic[i] == VARYING_SLOT_EDGE && sel->info.writes_edgeflag) {
+ if (info->output_semantic[i] == VARYING_SLOT_EDGE && gfx10_ngg_writes_user_edgeflags(ctx->shader)) {
LLVMValueRef edgeflag = LLVMBuildLoad(builder, addrs[4 * i], "");
/* The output is a float, but the hw expects a 1-bit integer. */
edgeflag = LLVMBuildFPToUI(ctx->ac.builder, edgeflag, ctx->ac.i32, "");
}
bool unterminated_es_if_block =
- !sel->so.num_outputs && !sel->info.writes_edgeflag &&
+ !sel->so.num_outputs && !gfx10_ngg_writes_user_edgeflags(ctx->shader) &&
!ctx->screen->use_ngg_streamout && /* no query buffer */
(ctx->stage != MESA_SHADER_VERTEX || !ctx->shader->key.mono.u.vs_export_prim_id);
LLVMValueRef user_edgeflags[3] = {};
- if (sel->info.writes_edgeflag) {
+ if (gfx10_ngg_writes_user_edgeflags(ctx->shader)) {
assert(!unterminated_es_if_block);
/* Streamout already inserted the barrier, so don't insert it again. */
assert(!unterminated_es_if_block);
/* Streamout and edge flags use LDS. Make it idle, so that we can reuse it. */
- if (sel->so.num_outputs || sel->info.writes_edgeflag)
+ if (sel->so.num_outputs || gfx10_ngg_writes_user_edgeflags(ctx->shader))
ac_build_s_barrier(&ctx->ac);
ac_build_ifcc(&ctx->ac, is_gs_thread, 5400);
* for the GL_LINE polygon mode to skip rendering lines on inner edges.
*/
if (gs_info->uses_invocationid ||
- (gs_stage == MESA_SHADER_VERTEX && !gfx10_is_ngg_passthrough(shader)))
+ (gfx10_edgeflags_have_effect(shader) && !gfx10_is_ngg_passthrough(shader)))
gs_vgpr_comp_cnt = 3; /* VGPR3 contains InvocationID, edge flags. */
else if ((gs_stage == MESA_SHADER_GEOMETRY && gs_info->uses_primid) ||
(gs_stage == MESA_SHADER_VERTEX && shader->key.mono.u.vs_export_prim_id))
S_028B90_CNT(gs_num_invocations) | S_028B90_ENABLE(gs_num_invocations > 1) |
S_028B90_EN_MAX_VERT_OUT_PER_GS_INSTANCE(shader->ngg.max_vert_out_per_gs_instance);
- /* Always output hw-generated edge flags and pass them via the prim
+ /* Output hw-generated edge flags if needed and pass them via the prim
* export to prevent drawing lines on internal edges of decomposed
- * primitives (such as quads) with polygon mode = lines. Only VS needs
- * this.
+ * primitives (such as quads) with polygon mode = lines.
*/
shader->ctx_reg.ngg.pa_cl_ngg_cntl =
- S_028838_INDEX_BUF_EDGE_FLAG_ENA(gs_stage == MESA_SHADER_VERTEX) |
+ S_028838_INDEX_BUF_EDGE_FLAG_ENA(gfx10_edgeflags_have_effect(shader)) |
/* Reuse for NGG. */
S_028838_VERTEX_REUSE_DEPTH(sscreen->info.chip_class >= GFX10_3 ? 30 : 0);
shader->pa_cl_vs_out_cntl = si_get_vs_out_cntl(shader->selector, shader, true);