[Mesa-dev] [PATCH v2 47/73] ac/nir: move setting shader_info->fs.writes_memory to radv-specific code

Nicolai Hähnle nhaehnle at gmail.com
Wed Jul 5 10:48:31 UTC 2017


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

---
 src/amd/common/ac_nir_to_llvm.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 5d7f53e..301cb83 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -3396,23 +3396,20 @@ static LLVMValueRef visit_image_load(struct ac_nir_context *ctx,
 static void visit_image_store(struct ac_nir_context *ctx,
 			      nir_intrinsic_instr *instr)
 {
 	LLVMValueRef params[8];
 	char intrinsic_name[64];
 	const nir_variable *var = instr->variables[0]->var;
 	const struct glsl_type *type = glsl_without_array(var->type);
 	LLVMValueRef i1false = LLVMConstInt(ctx->ac.i1, 0, false);
 	LLVMValueRef i1true = LLVMConstInt(ctx->ac.i1, 1, false);
 
-	if (ctx->stage == MESA_SHADER_FRAGMENT)
-		ctx->nctx->shader_info->fs.writes_memory = true;
-
 	if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF) {
 		params[0] = to_float(&ctx->ac, get_src(ctx, instr->src[2])); /* data */
 		params[1] = get_sampler_desc(ctx, instr->variables[0], AC_DESC_BUFFER, true, true);
 		params[2] = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[0]),
 						    ctx->ac.i32_0, ""); /* vindex */
 		params[3] = ctx->ac.i32_0; /* voffset */
 		params[4] = i1false;  /* glc */
 		params[5] = i1false;  /* slc */
 		ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32", ctx->ac.voidt,
 				   params, 6, 0);
@@ -3459,23 +3456,20 @@ static LLVMValueRef visit_image_atomic(struct ac_nir_context *ctx,
 	int param_count = 0;
 	const nir_variable *var = instr->variables[0]->var;
 
 	const char *atomic_name;
 	char intrinsic_name[41];
 	const struct glsl_type *type = glsl_without_array(var->type);
 	LLVMValueRef i1false = LLVMConstInt(ctx->ac.i1, 0, false);
 	LLVMValueRef i1true = LLVMConstInt(ctx->ac.i1, 1, false);
 	MAYBE_UNUSED int length;
 
-	if (ctx->stage == MESA_SHADER_FRAGMENT)
-		ctx->nctx->shader_info->fs.writes_memory = true;
-
 	switch (instr->intrinsic) {
 	case nir_intrinsic_image_atomic_add:
 		atomic_name = "add";
 		break;
 	case nir_intrinsic_image_atomic_min:
 		atomic_name = "smin";
 		break;
 	case nir_intrinsic_image_atomic_max:
 		atomic_name = "smax";
 		break;
@@ -4135,20 +4129,23 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
 	struct radv_descriptor_set_layout *layout = ctx->options->layout->set[descriptor_set].layout;
 	struct radv_descriptor_set_binding_layout *binding = layout->binding + base_index;
 	unsigned offset = binding->offset;
 	unsigned stride = binding->size;
 	unsigned type_size;
 	LLVMBuilderRef builder = ctx->builder;
 	LLVMTypeRef type;
 
 	assert(base_index < layout->binding_count);
 
+	if (write && ctx->stage == MESA_SHADER_FRAGMENT)
+		ctx->shader_info->fs.writes_memory = true;
+
 	switch (desc_type) {
 	case AC_DESC_IMAGE:
 		type = ctx->v8i32;
 		type_size = 32;
 		break;
 	case AC_DESC_FMASK:
 		type = ctx->v8i32;
 		offset += 32;
 		type_size = 32;
 		break;
-- 
2.9.3



More information about the mesa-dev mailing list