amd/common: scan if gl_PrimitiveID is used before translating to LLVM
It makes more sense to move all scan stuff in the same place. Also, we don't really need to duplicate the uses_primid field for each stages. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
@@ -4209,14 +4209,10 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
|
|||||||
break;
|
break;
|
||||||
case nir_intrinsic_load_primitive_id:
|
case nir_intrinsic_load_primitive_id:
|
||||||
if (ctx->stage == MESA_SHADER_GEOMETRY) {
|
if (ctx->stage == MESA_SHADER_GEOMETRY) {
|
||||||
if (ctx->nctx)
|
|
||||||
ctx->nctx->shader_info->gs.uses_prim_id = true;
|
|
||||||
result = ctx->abi->gs_prim_id;
|
result = ctx->abi->gs_prim_id;
|
||||||
} else if (ctx->stage == MESA_SHADER_TESS_CTRL) {
|
} else if (ctx->stage == MESA_SHADER_TESS_CTRL) {
|
||||||
ctx->nctx->shader_info->tcs.uses_prim_id = true;
|
|
||||||
result = ctx->nctx->tcs_patch_id;
|
result = ctx->nctx->tcs_patch_id;
|
||||||
} else if (ctx->stage == MESA_SHADER_TESS_EVAL) {
|
} else if (ctx->stage == MESA_SHADER_TESS_EVAL) {
|
||||||
ctx->nctx->shader_info->tcs.uses_prim_id = true;
|
|
||||||
result = ctx->nctx->tes_patch_id;
|
result = ctx->nctx->tes_patch_id;
|
||||||
} else
|
} else
|
||||||
fprintf(stderr, "Unknown primitive id intrinsic: %d", ctx->stage);
|
fprintf(stderr, "Unknown primitive id intrinsic: %d", ctx->stage);
|
||||||
|
@@ -191,10 +191,8 @@ struct ac_shader_variant_info {
|
|||||||
unsigned invocations;
|
unsigned invocations;
|
||||||
unsigned gsvs_vertex_size;
|
unsigned gsvs_vertex_size;
|
||||||
unsigned max_gsvs_emit_size;
|
unsigned max_gsvs_emit_size;
|
||||||
bool uses_prim_id;
|
|
||||||
} gs;
|
} gs;
|
||||||
struct {
|
struct {
|
||||||
bool uses_prim_id;
|
|
||||||
unsigned tcs_vertices_out;
|
unsigned tcs_vertices_out;
|
||||||
/* Which outputs are actually written */
|
/* Which outputs are actually written */
|
||||||
uint64_t outputs_written;
|
uint64_t outputs_written;
|
||||||
@@ -210,7 +208,6 @@ struct ac_shader_variant_info {
|
|||||||
enum gl_tess_spacing spacing;
|
enum gl_tess_spacing spacing;
|
||||||
bool ccw;
|
bool ccw;
|
||||||
bool point_mode;
|
bool point_mode;
|
||||||
bool uses_prim_id;
|
|
||||||
} tes;
|
} tes;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -73,6 +73,9 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, struct ac_shader_info *info)
|
|||||||
case nir_intrinsic_load_invocation_id:
|
case nir_intrinsic_load_invocation_id:
|
||||||
info->uses_invocation_id = true;
|
info->uses_invocation_id = true;
|
||||||
break;
|
break;
|
||||||
|
case nir_intrinsic_load_primitive_id:
|
||||||
|
info->uses_prim_id = true;
|
||||||
|
break;
|
||||||
case nir_intrinsic_vulkan_resource_index:
|
case nir_intrinsic_vulkan_resource_index:
|
||||||
info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr));
|
info->desc_set_used_mask |= (1 << nir_intrinsic_desc_set(instr));
|
||||||
break;
|
break;
|
||||||
|
@@ -32,6 +32,7 @@ struct ac_shader_info {
|
|||||||
uint32_t desc_set_used_mask;
|
uint32_t desc_set_used_mask;
|
||||||
bool needs_multiview_view_index;
|
bool needs_multiview_view_index;
|
||||||
bool uses_invocation_id;
|
bool uses_invocation_id;
|
||||||
|
bool uses_prim_id;
|
||||||
struct {
|
struct {
|
||||||
bool has_vertex_buffers; /* needs vertex buffers and base/start */
|
bool has_vertex_buffers; /* needs vertex buffers and base/start */
|
||||||
bool needs_draw_id;
|
bool needs_draw_id;
|
||||||
|
@@ -2514,12 +2514,12 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
|
|||||||
if (pipeline->shaders[MESA_SHADER_FRAGMENT]->info.fs.prim_id_input)
|
if (pipeline->shaders[MESA_SHADER_FRAGMENT]->info.fs.prim_id_input)
|
||||||
pipeline->graphics.ia_switch_on_eoi = true;
|
pipeline->graphics.ia_switch_on_eoi = true;
|
||||||
if (radv_pipeline_has_gs(pipeline) &&
|
if (radv_pipeline_has_gs(pipeline) &&
|
||||||
pipeline->shaders[MESA_SHADER_GEOMETRY]->info.gs.uses_prim_id)
|
pipeline->shaders[MESA_SHADER_GEOMETRY]->info.info.uses_prim_id)
|
||||||
pipeline->graphics.ia_switch_on_eoi = true;
|
pipeline->graphics.ia_switch_on_eoi = true;
|
||||||
if (radv_pipeline_has_tess(pipeline)) {
|
if (radv_pipeline_has_tess(pipeline)) {
|
||||||
/* SWITCH_ON_EOI must be set if PrimID is used. */
|
/* SWITCH_ON_EOI must be set if PrimID is used. */
|
||||||
if (pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.tcs.uses_prim_id ||
|
if (pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.info.uses_prim_id ||
|
||||||
radv_get_tess_eval_shader(pipeline)->info.tes.uses_prim_id)
|
radv_get_tess_eval_shader(pipeline)->info.info.uses_prim_id)
|
||||||
pipeline->graphics.ia_switch_on_eoi = true;
|
pipeline->graphics.ia_switch_on_eoi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user