[Mesa-dev] [PATCH 72/92] ac/nir: extract shader_info->fs.can_discard from NIR shader info

Nicolai Hähnle nhaehnle at gmail.com
Mon Jun 26 14:10:51 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/amd/common/ac_nir_to_llvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index c35bda2..98b5f79 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3520,21 +3520,20 @@ static void emit_barrier(struct nir_to_llvm_context *ctx)
 		return;
 	}
 	ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.s.barrier",
 			   ctx->voidt, NULL, 0, AC_FUNC_ATTR_CONVERGENT);
 }
 
 static void emit_discard_if(struct nir_to_llvm_context *ctx,
 			    const nir_intrinsic_instr *instr)
 {
 	LLVMValueRef cond;
-	ctx->shader_info->fs.can_discard = true;
 
 	cond = LLVMBuildICmp(ctx->builder, LLVMIntNE,
 			     get_src(ctx->nir, instr->src[0]),
 			     ctx->i32zero, "");
 
 	cond = LLVMBuildSelect(ctx->builder, cond,
 			       LLVMConstReal(ctx->f32, -1.0f),
 			       ctx->f32zero, "");
 	ac_build_kill(&ctx->ac, cond);
 }
@@ -3977,21 +3976,20 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
 	case nir_intrinsic_image_atomic_or:
 	case nir_intrinsic_image_atomic_xor:
 	case nir_intrinsic_image_atomic_exchange:
 	case nir_intrinsic_image_atomic_comp_swap:
 		result = visit_image_atomic(ctx, instr);
 		break;
 	case nir_intrinsic_image_size:
 		result = visit_image_size(ctx, instr);
 		break;
 	case nir_intrinsic_discard:
-		ctx->nctx->shader_info->fs.can_discard = true;
 		ac_build_intrinsic(&ctx->ac, "llvm.AMDGPU.kilp",
 				   LLVMVoidTypeInContext(ctx->ac.context),
 				   NULL, 0, AC_FUNC_ATTR_LEGACY);
 		break;
 	case nir_intrinsic_discard_if:
 		emit_discard_if(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_memory_barrier:
 		emit_waitcnt(ctx->nctx, VM_CNT);
 		break;
@@ -6059,20 +6057,22 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
 		ctx.gs_next_vertex = ac_build_alloca(&ctx.ac, ctx.i32, "gs_next_vertex");
 
 		ctx.gs_max_out_vertices = nir->info.gs.vertices_out;
 	} else if (nir->stage == MESA_SHADER_TESS_EVAL) {
 		ctx.tes_primitive_mode = nir->info.tess.primitive_mode;
 	} else if (nir->stage == MESA_SHADER_VERTEX) {
 		if (shader_info->info.vs.needs_instance_id) {
 			ctx.shader_info->vs.vgpr_comp_cnt =
 				MAX2(3, ctx.shader_info->vs.vgpr_comp_cnt);
 		}
+	} else if (nir->stage == MESA_SHADER_FRAGMENT) {
+		shader_info->fs.can_discard = nir->info.fs.uses_discard;
 	}
 
 	ac_setup_rings(&ctx);
 
 	ctx.num_output_clips = nir->info.clip_distance_array_size;
 	ctx.num_output_culls = nir->info.cull_distance_array_size;
 
 	nir_foreach_variable(variable, &nir->inputs)
 		handle_shader_input_decl(&ctx, variable);
 
-- 
2.9.3



More information about the mesa-dev mailing list