[Mesa-dev] [PATCH v2 32/73] ac/nir: pass ac_nir_context to visit_{load, store}_var and get_deref_offset helper

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


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

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

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 5463e44..d13d67e 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2483,39 +2483,39 @@ static LLVMValueRef visit_load_ubo_buffer(struct nir_to_llvm_context *ctx,
 						AC_FUNC_ATTR_LEGACY);
 	}
 
 
 	ret = ac_build_gather_values(&ctx->ac, results, instr->num_components);
 	return LLVMBuildBitCast(ctx->builder, ret,
 	                        get_def_type(ctx->nir, &instr->dest.ssa), "");
 }
 
 static void
-radv_get_deref_offset(struct nir_to_llvm_context *ctx, nir_deref_var *deref,
-		      bool vs_in, unsigned *vertex_index_out,
-		      LLVMValueRef *vertex_index_ref,
-		      unsigned *const_out, LLVMValueRef *indir_out)
+get_deref_offset(struct ac_nir_context *ctx, nir_deref_var *deref,
+		 bool vs_in, unsigned *vertex_index_out,
+		 LLVMValueRef *vertex_index_ref,
+		 unsigned *const_out, LLVMValueRef *indir_out)
 {
 	unsigned const_offset = 0;
 	nir_deref *tail = &deref->deref;
 	LLVMValueRef offset = NULL;
 
 	if (vertex_index_out != NULL || vertex_index_ref != NULL) {
 		tail = tail->child;
 		nir_deref_array *deref_array = nir_deref_as_array(tail);
 		if (vertex_index_out)
 			*vertex_index_out = deref_array->base_offset;
 
 		if (vertex_index_ref) {
-			LLVMValueRef vtx = LLVMConstInt(ctx->i32, deref_array->base_offset, false);
+			LLVMValueRef vtx = LLVMConstInt(ctx->ac.i32, deref_array->base_offset, false);
 			if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
-				vtx = LLVMBuildAdd(ctx->builder, vtx, get_src(ctx->nir, deref_array->indirect), "");
+				vtx = LLVMBuildAdd(ctx->ac.builder, vtx, get_src(ctx, deref_array->indirect), "");
 			}
 			*vertex_index_ref = vtx;
 		}
 	}
 
 	if (deref->var->data.compact) {
 		assert(tail->child->deref_type == nir_deref_type_array);
 		assert(glsl_type_is_scalar(glsl_without_array(deref->var->type)));
 		nir_deref_array *deref_array = nir_deref_as_array(tail->child);
 		/* We always lower indirect dereferences for "compact" array vars. */
@@ -2532,43 +2532,43 @@ radv_get_deref_offset(struct nir_to_llvm_context *ctx, nir_deref_var *deref,
 		if (tail->deref_type == nir_deref_type_array) {
 			nir_deref_array *deref_array = nir_deref_as_array(tail);
 			LLVMValueRef index, stride, local_offset;
 			unsigned size = glsl_count_attribute_slots(tail->type, vs_in);
 
 			const_offset += size * deref_array->base_offset;
 			if (deref_array->deref_array_type == nir_deref_array_type_direct)
 				continue;
 
 			assert(deref_array->deref_array_type == nir_deref_array_type_indirect);
-			index = get_src(ctx->nir, deref_array->indirect);
-			stride = LLVMConstInt(ctx->i32, size, 0);
-			local_offset = LLVMBuildMul(ctx->builder, stride, index, "");
+			index = get_src(ctx, deref_array->indirect);
+			stride = LLVMConstInt(ctx->ac.i32, size, 0);
+			local_offset = LLVMBuildMul(ctx->ac.builder, stride, index, "");
 
 			if (offset)
-				offset = LLVMBuildAdd(ctx->builder, offset, local_offset, "");
+				offset = LLVMBuildAdd(ctx->ac.builder, offset, local_offset, "");
 			else
 				offset = local_offset;
 		} else if (tail->deref_type == nir_deref_type_struct) {
 			nir_deref_struct *deref_struct = nir_deref_as_struct(tail);
 
 			for (unsigned i = 0; i < deref_struct->index; i++) {
 				const struct glsl_type *ft = glsl_get_struct_field(parent_type, i);
 				const_offset += glsl_count_attribute_slots(ft, vs_in);
 			}
 		} else
 			unreachable("unsupported deref type");
 
 	}
 out:
 	if (const_offset && offset)
-		offset = LLVMBuildAdd(ctx->builder, offset,
-				      LLVMConstInt(ctx->i32, const_offset, 0),
+		offset = LLVMBuildAdd(ctx->ac.builder, offset,
+				      LLVMConstInt(ctx->ac.i32, const_offset, 0),
 				      "");
 
 	*const_out = const_offset;
 	*indir_out = offset;
 }
 
 static LLVMValueRef
 lds_load(struct nir_to_llvm_context *ctx,
 	 LLVMValueRef dw_addr)
 {
@@ -2720,23 +2720,23 @@ load_tcs_input(struct nir_to_llvm_context *ctx,
 {
 	LLVMValueRef dw_addr, stride;
 	unsigned const_index;
 	LLVMValueRef vertex_index;
 	LLVMValueRef indir_index;
 	unsigned param;
 	LLVMValueRef value[4], result;
 	const bool per_vertex = nir_is_per_vertex_io(instr->variables[0]->var, ctx->stage);
 	const bool is_compact = instr->variables[0]->var->data.compact;
 	param = shader_io_get_unique_index(instr->variables[0]->var->data.location);
-	radv_get_deref_offset(ctx, instr->variables[0],
-			      false, NULL, per_vertex ? &vertex_index : NULL,
-			      &const_index, &indir_index);
+	get_deref_offset(ctx->nir, instr->variables[0],
+			 false, NULL, per_vertex ? &vertex_index : NULL,
+			 &const_index, &indir_index);
 
 	stride = unpack_param(ctx, ctx->tcs_in_layout, 13, 8);
 	dw_addr = get_tcs_in_current_patch_offset(ctx);
 	dw_addr = get_dw_address(ctx, dw_addr, param, const_index, is_compact, vertex_index, stride,
 				 indir_index);
 
 	for (unsigned i = 0; i < instr->num_components; i++) {
 		value[i] = lds_load(ctx, dw_addr);
 		dw_addr = LLVMBuildAdd(ctx->builder, dw_addr,
 				       ctx->i32one, "");
@@ -2752,23 +2752,23 @@ load_tcs_output(struct nir_to_llvm_context *ctx,
 {
 	LLVMValueRef dw_addr, stride;
 	LLVMValueRef value[4], result;
 	LLVMValueRef vertex_index = NULL;
 	LLVMValueRef indir_index = NULL;
 	unsigned const_index = 0;
 	unsigned param;
 	const bool per_vertex = nir_is_per_vertex_io(instr->variables[0]->var, ctx->stage);
 	const bool is_compact = instr->variables[0]->var->data.compact;
 	param = shader_io_get_unique_index(instr->variables[0]->var->data.location);
-	radv_get_deref_offset(ctx, instr->variables[0],
-			      false, NULL, per_vertex ? &vertex_index : NULL,
-			      &const_index, &indir_index);
+	get_deref_offset(ctx->nir, instr->variables[0],
+			 false, NULL, per_vertex ? &vertex_index : NULL,
+			 &const_index, &indir_index);
 
 	if (!instr->variables[0]->var->data.patch) {
 		stride = unpack_param(ctx, ctx->tcs_out_layout, 13, 8);
 		dw_addr = get_tcs_out_current_patch_offset(ctx);
 	} else {
 		dw_addr = get_tcs_out_current_patch_data_offset(ctx);
 	}
 
 	dw_addr = get_dw_address(ctx, dw_addr, param, const_index, is_compact, vertex_index, stride,
 				 indir_index);
@@ -2791,23 +2791,23 @@ store_tcs_output(struct nir_to_llvm_context *ctx,
 {
 	LLVMValueRef stride, dw_addr;
 	LLVMValueRef buf_addr = NULL;
 	LLVMValueRef vertex_index = NULL;
 	LLVMValueRef indir_index = NULL;
 	unsigned const_index = 0;
 	unsigned param;
 	const bool per_vertex = nir_is_per_vertex_io(instr->variables[0]->var, ctx->stage);
 	const bool is_compact = instr->variables[0]->var->data.compact;
 
-	radv_get_deref_offset(ctx, instr->variables[0],
-			      false, NULL, per_vertex ? &vertex_index : NULL,
-			      &const_index, &indir_index);
+	get_deref_offset(ctx->nir, instr->variables[0],
+			 false, NULL, per_vertex ? &vertex_index : NULL,
+			 &const_index, &indir_index);
 
 	param = shader_io_get_unique_index(instr->variables[0]->var->data.location);
 	if (instr->variables[0]->var->data.location == VARYING_SLOT_CLIP_DIST0 &&
 	    is_compact && const_index > 3) {
 		const_index -= 3;
 		param++;
 	}
 
 	if (!instr->variables[0]->var->data.patch) {
 		stride = unpack_param(ctx, ctx->tcs_out_layout, 13, 8);
@@ -2858,23 +2858,23 @@ load_tes_input(struct nir_to_llvm_context *ctx,
 {
 	LLVMValueRef buf_addr;
 	LLVMValueRef result;
 	LLVMValueRef vertex_index = NULL;
 	LLVMValueRef indir_index = NULL;
 	unsigned const_index = 0;
 	unsigned param;
 	const bool per_vertex = nir_is_per_vertex_io(instr->variables[0]->var, ctx->stage);
 	const bool is_compact = instr->variables[0]->var->data.compact;
 
-	radv_get_deref_offset(ctx, instr->variables[0],
-			      false, NULL, per_vertex ? &vertex_index : NULL,
-			      &const_index, &indir_index);
+	get_deref_offset(ctx->nir, instr->variables[0],
+			 false, NULL, per_vertex ? &vertex_index : NULL,
+			 &const_index, &indir_index);
 	param = shader_io_get_unique_index(instr->variables[0]->var->data.location);
 	if (instr->variables[0]->var->data.location == VARYING_SLOT_CLIP_DIST0 &&
 	    is_compact && const_index > 3) {
 		const_index -= 3;
 		param++;
 	}
 	buf_addr = get_tcs_tes_buffer_address_params(ctx, param, const_index,
 						     is_compact, vertex_index, indir_index);
 
 	result = ac_build_buffer_load(&ctx->ac, ctx->hs_ring_tess_offchip, instr->num_components, NULL,
@@ -2887,23 +2887,23 @@ load_tes_input(struct nir_to_llvm_context *ctx,
 static LLVMValueRef
 load_gs_input(struct nir_to_llvm_context *ctx,
 	      nir_intrinsic_instr *instr)
 {
 	LLVMValueRef indir_index, vtx_offset;
 	unsigned const_index;
 	LLVMValueRef args[9];
 	unsigned param, vtx_offset_param;
 	LLVMValueRef value[4], result;
 	unsigned vertex_index;
-	radv_get_deref_offset(ctx, instr->variables[0],
-			      false, &vertex_index, NULL,
-			      &const_index, &indir_index);
+	get_deref_offset(ctx->nir, instr->variables[0],
+			 false, &vertex_index, NULL,
+			 &const_index, &indir_index);
 	vtx_offset_param = vertex_index;
 	assert(vtx_offset_param < 6);
 	vtx_offset = LLVMBuildMul(ctx->builder, ctx->gs_vtx_offset[vtx_offset_param],
 				  LLVMConstInt(ctx->i32, 4, false), "");
 
 	param = shader_io_get_unique_index(instr->variables[0]->var->data.location);
 	for (unsigned i = 0; i < instr->num_components; i++) {
 
 		args[0] = ctx->esgs_ring;
 		args[1] = vtx_offset;
@@ -2918,237 +2918,237 @@ load_gs_input(struct nir_to_llvm_context *ctx,
 		value[i] = ac_build_intrinsic(&ctx->ac, "llvm.SI.buffer.load.dword.i32.i32",
 					      ctx->i32, args, 9,
 					      AC_FUNC_ATTR_READONLY |
 					      AC_FUNC_ATTR_LEGACY);
 	}
 	result = ac_build_gather_values(&ctx->ac, value, instr->num_components);
 
 	return result;
 }
 
-static LLVMValueRef visit_load_var(struct nir_to_llvm_context *ctx,
+static LLVMValueRef visit_load_var(struct ac_nir_context *ctx,
 				   nir_intrinsic_instr *instr)
 {
 	LLVMValueRef values[8];
 	int idx = instr->variables[0]->var->data.driver_location;
 	int ve = instr->dest.ssa.num_components;
 	LLVMValueRef indir_index;
 	LLVMValueRef ret;
 	unsigned const_index;
 	bool vs_in = ctx->stage == MESA_SHADER_VERTEX &&
 	             instr->variables[0]->var->data.mode == nir_var_shader_in;
-	radv_get_deref_offset(ctx, instr->variables[0], vs_in, NULL, NULL,
+	get_deref_offset(ctx, instr->variables[0], vs_in, NULL, NULL,
 				      &const_index, &indir_index);
 
 	if (instr->dest.ssa.bit_size == 64)
 		ve *= 2;
 
 	switch (instr->variables[0]->var->data.mode) {
 	case nir_var_shader_in:
 		if (ctx->stage == MESA_SHADER_TESS_CTRL)
-			return load_tcs_input(ctx, instr);
+			return load_tcs_input(ctx->nctx, instr);
 		if (ctx->stage == MESA_SHADER_TESS_EVAL)
-			return load_tes_input(ctx, instr);
+			return load_tes_input(ctx->nctx, instr);
 		if (ctx->stage == MESA_SHADER_GEOMETRY) {
-			return load_gs_input(ctx, instr);
+			return load_gs_input(ctx->nctx, instr);
 		}
 		for (unsigned chan = 0; chan < ve; chan++) {
 			if (indir_index) {
 				unsigned count = glsl_count_attribute_slots(
 						instr->variables[0]->var->type,
 						ctx->stage == MESA_SHADER_VERTEX);
 				count -= chan / 4;
 				LLVMValueRef tmp_vec = ac_build_gather_values_extended(
-						&ctx->ac, ctx->inputs + idx + chan, count,
+						&ctx->ac, ctx->abi->inputs + idx + chan, count,
 						4, false);
 
-				values[chan] = LLVMBuildExtractElement(ctx->builder,
+				values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
 								       tmp_vec,
 								       indir_index, "");
 			} else
-				values[chan] = ctx->inputs[idx + chan + const_index * 4];
+				values[chan] = ctx->abi->inputs[idx + chan + const_index * 4];
 		}
 		break;
 	case nir_var_local:
 		for (unsigned chan = 0; chan < ve; chan++) {
 			if (indir_index) {
 				unsigned count = glsl_count_attribute_slots(
 					instr->variables[0]->var->type, false);
 				count -= chan / 4;
 				LLVMValueRef tmp_vec = ac_build_gather_values_extended(
-						&ctx->ac, ctx->nir->locals + idx + chan, count,
+						&ctx->ac, ctx->locals + idx + chan, count,
 						4, true);
 
-				values[chan] = LLVMBuildExtractElement(ctx->builder,
+				values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
 								       tmp_vec,
 								       indir_index, "");
 			} else {
-				values[chan] = LLVMBuildLoad(ctx->builder, ctx->nir->locals[idx + chan + const_index * 4], "");
+				values[chan] = LLVMBuildLoad(ctx->ac.builder, ctx->locals[idx + chan + const_index * 4], "");
 			}
 		}
 		break;
 	case nir_var_shader_out:
 		if (ctx->stage == MESA_SHADER_TESS_CTRL)
-			return load_tcs_output(ctx, instr);
+			return load_tcs_output(ctx->nctx, instr);
 		for (unsigned chan = 0; chan < ve; chan++) {
 			if (indir_index) {
 				unsigned count = glsl_count_attribute_slots(
 						instr->variables[0]->var->type, false);
 				count -= chan / 4;
 				LLVMValueRef tmp_vec = ac_build_gather_values_extended(
-						&ctx->ac, ctx->nir->outputs + idx + chan, count,
+						&ctx->ac, ctx->outputs + idx + chan, count,
 						4, true);
 
-				values[chan] = LLVMBuildExtractElement(ctx->builder,
+				values[chan] = LLVMBuildExtractElement(ctx->ac.builder,
 								       tmp_vec,
 								       indir_index, "");
 			} else {
-			values[chan] = LLVMBuildLoad(ctx->builder,
-						     ctx->nir->outputs[idx + chan + const_index * 4],
+				values[chan] = LLVMBuildLoad(ctx->ac.builder,
+						     ctx->outputs[idx + chan + const_index * 4],
 						     "");
 			}
 		}
 		break;
 	case nir_var_shared: {
-		LLVMValueRef ptr = get_shared_memory_ptr(ctx, idx, ctx->i32);
+		LLVMValueRef ptr = get_shared_memory_ptr(ctx->nctx, idx, ctx->ac.i32);
 		LLVMValueRef derived_ptr;
 
 		if (indir_index)
-			indir_index = LLVMBuildMul(ctx->builder, indir_index, LLVMConstInt(ctx->i32, 4, false), "");
+			indir_index = LLVMBuildMul(ctx->ac.builder, indir_index, LLVMConstInt(ctx->ac.i32, 4, false), "");
 
 		for (unsigned chan = 0; chan < ve; chan++) {
-			LLVMValueRef index = LLVMConstInt(ctx->i32, chan, false);
+			LLVMValueRef index = LLVMConstInt(ctx->ac.i32, chan, false);
 			if (indir_index)
-				index = LLVMBuildAdd(ctx->builder, index, indir_index, "");
-			derived_ptr = LLVMBuildGEP(ctx->builder, ptr, &index, 1, "");
+				index = LLVMBuildAdd(ctx->ac.builder, index, indir_index, "");
+			derived_ptr = LLVMBuildGEP(ctx->ac.builder, ptr, &index, 1, "");
 
-			values[chan] = LLVMBuildLoad(ctx->builder, derived_ptr, "");
+			values[chan] = LLVMBuildLoad(ctx->ac.builder, derived_ptr, "");
 		}
 		break;
 	}
 	default:
 		unreachable("unhandle variable mode");
 	}
 	ret = ac_build_gather_values(&ctx->ac, values, ve);
-	return LLVMBuildBitCast(ctx->builder, ret, get_def_type(ctx->nir, &instr->dest.ssa), "");
+	return LLVMBuildBitCast(ctx->ac.builder, ret, get_def_type(ctx, &instr->dest.ssa), "");
 }
 
 static void
-visit_store_var(struct nir_to_llvm_context *ctx,
-				   nir_intrinsic_instr *instr)
+visit_store_var(struct ac_nir_context *ctx,
+		nir_intrinsic_instr *instr)
 {
 	LLVMValueRef temp_ptr, value;
 	int idx = instr->variables[0]->var->data.driver_location;
-	LLVMValueRef src = to_float(&ctx->ac, get_src(ctx->nir, instr->src[0]));
+	LLVMValueRef src = to_float(&ctx->ac, get_src(ctx, instr->src[0]));
 	int writemask = instr->const_index[0];
 	LLVMValueRef indir_index;
 	unsigned const_index;
-	radv_get_deref_offset(ctx, instr->variables[0], false,
-	                      NULL, NULL, &const_index, &indir_index);
+	get_deref_offset(ctx, instr->variables[0], false,
+		         NULL, NULL, &const_index, &indir_index);
 
 	if (get_elem_bits(&ctx->ac, LLVMTypeOf(src)) == 64) {
 		int old_writemask = writemask;
 
-		src = LLVMBuildBitCast(ctx->builder, src,
-		                       LLVMVectorType(ctx->f32, get_llvm_num_components(src) * 2),
+		src = LLVMBuildBitCast(ctx->ac.builder, src,
+		                       LLVMVectorType(ctx->ac.f32, get_llvm_num_components(src) * 2),
 		                       "");
 
 		writemask = 0;
 		for (unsigned chan = 0; chan < 4; chan++) {
 			if (old_writemask & (1 << chan))
 				writemask |= 3u << (2 * chan);
 		}
 	}
 
 	switch (instr->variables[0]->var->data.mode) {
 	case nir_var_shader_out:
 
 		if (ctx->stage == MESA_SHADER_TESS_CTRL) {
-			store_tcs_output(ctx, instr, src, writemask);
+			store_tcs_output(ctx->nctx, instr, src, writemask);
 			return;
 		}
 
 		for (unsigned chan = 0; chan < 8; chan++) {
 			int stride = 4;
 			if (!(writemask & (1 << chan)))
 				continue;
 
 			value = llvm_extract_elem(&ctx->ac, src, chan);
 
 			if (instr->variables[0]->var->data.compact)
 				stride = 1;
 			if (indir_index) {
 				unsigned count = glsl_count_attribute_slots(
 						instr->variables[0]->var->type, false);
 				count -= chan / 4;
 				LLVMValueRef tmp_vec = ac_build_gather_values_extended(
-						&ctx->ac, ctx->nir->outputs + idx + chan, count,
+						&ctx->ac, ctx->outputs + idx + chan, count,
 						stride, true);
 
 				if (get_llvm_num_components(tmp_vec) > 1) {
-					tmp_vec = LLVMBuildInsertElement(ctx->builder, tmp_vec,
+					tmp_vec = LLVMBuildInsertElement(ctx->ac.builder, tmp_vec,
 									 value, indir_index, "");
 				} else
 					tmp_vec = value;
-				build_store_values_extended(&ctx->ac, ctx->nir->outputs + idx + chan,
+				build_store_values_extended(&ctx->ac, ctx->outputs + idx + chan,
 							    count, stride, tmp_vec);
 
 			} else {
-				temp_ptr = ctx->nir->outputs[idx + chan + const_index * stride];
+				temp_ptr = ctx->outputs[idx + chan + const_index * stride];
 
-				LLVMBuildStore(ctx->builder, value, temp_ptr);
+				LLVMBuildStore(ctx->ac.builder, value, temp_ptr);
 			}
 		}
 		break;
 	case nir_var_local:
 		for (unsigned chan = 0; chan < 8; chan++) {
 			if (!(writemask & (1 << chan)))
 				continue;
 
 			value = llvm_extract_elem(&ctx->ac, src, chan);
 			if (indir_index) {
 				unsigned count = glsl_count_attribute_slots(
 					instr->variables[0]->var->type, false);
 				count -= chan / 4;
 				LLVMValueRef tmp_vec = ac_build_gather_values_extended(
-					&ctx->ac, ctx->nir->locals + idx + chan, count,
+					&ctx->ac, ctx->locals + idx + chan, count,
 					4, true);
 
-				tmp_vec = LLVMBuildInsertElement(ctx->builder, tmp_vec,
+				tmp_vec = LLVMBuildInsertElement(ctx->ac.builder, tmp_vec,
 								 value, indir_index, "");
-				build_store_values_extended(&ctx->ac, ctx->nir->locals + idx + chan,
+				build_store_values_extended(&ctx->ac, ctx->locals + idx + chan,
 							    count, 4, tmp_vec);
 			} else {
-				temp_ptr = ctx->nir->locals[idx + chan + const_index * 4];
+				temp_ptr = ctx->locals[idx + chan + const_index * 4];
 
-				LLVMBuildStore(ctx->builder, value, temp_ptr);
+				LLVMBuildStore(ctx->ac.builder, value, temp_ptr);
 			}
 		}
 		break;
 	case nir_var_shared: {
-		LLVMValueRef ptr = get_shared_memory_ptr(ctx, idx, ctx->i32);
+		LLVMValueRef ptr = get_shared_memory_ptr(ctx->nctx, idx, ctx->ac.i32);
 
 		if (indir_index)
-			indir_index = LLVMBuildMul(ctx->builder, indir_index, LLVMConstInt(ctx->i32, 4, false), "");
+			indir_index = LLVMBuildMul(ctx->ac.builder, indir_index, LLVMConstInt(ctx->ac.i32, 4, false), "");
 
 		for (unsigned chan = 0; chan < 8; chan++) {
 			if (!(writemask & (1 << chan)))
 				continue;
-			LLVMValueRef index = LLVMConstInt(ctx->i32, chan, false);
+			LLVMValueRef index = LLVMConstInt(ctx->ac.i32, chan, false);
 			LLVMValueRef derived_ptr;
 
 			if (indir_index)
-				index = LLVMBuildAdd(ctx->builder, index, indir_index, "");
+				index = LLVMBuildAdd(ctx->ac.builder, index, indir_index, "");
 
 			value = llvm_extract_elem(&ctx->ac, src, chan);
-			derived_ptr = LLVMBuildGEP(ctx->builder, ptr, &index, 1, "");
-			LLVMBuildStore(ctx->builder,
+			derived_ptr = LLVMBuildGEP(ctx->ac.builder, ptr, &index, 1, "");
+			LLVMBuildStore(ctx->ac.builder,
 			               to_integer(&ctx->ac, value), derived_ptr);
 		}
 		break;
 	}
 	default:
 		break;
 	}
 }
 
 static int image_type_to_components_count(enum glsl_sampler_dim dim, bool array)
@@ -4027,24 +4027,24 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
 	case nir_intrinsic_ssbo_atomic_comp_swap:
 		result = visit_atomic_ssbo(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_load_ubo:
 		result = visit_load_ubo_buffer(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_get_buffer_size:
 		result = visit_get_buffer_size(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_load_var:
-		result = visit_load_var(ctx->nctx, instr);
+		result = visit_load_var(ctx, instr);
 		break;
 	case nir_intrinsic_store_var:
-		visit_store_var(ctx->nctx, instr);
+		visit_store_var(ctx, instr);
 		break;
 	case nir_intrinsic_image_load:
 		result = visit_image_load(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_image_store:
 		visit_image_store(ctx->nctx, instr);
 		break;
 	case nir_intrinsic_image_atomic_add:
 	case nir_intrinsic_image_atomic_min:
 	case nir_intrinsic_image_atomic_max:
-- 
2.9.3



More information about the mesa-dev mailing list