summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-06-08 18:38:06 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-07-05 12:33:51 +0200
commita5334f6e7b1be629e6eff02b07a7e3f560dd0ee0 (patch)
treebef3bcd6ed22d2befb0b5887a2feff9a5ea64c74
parent4205c8526870eae22314c9685bd90ba9e9bd8a3e (diff)
radeonsi/nir: load VS inputs
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c11
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_internal.h5
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_nir.c26
3 files changed, 40 insertions, 2 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index ae61d20359..7bf0303510 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -395,10 +395,9 @@ static LLVMValueRef extract_double_to_float(struct si_shader_context *ctx,
return LLVMBuildFPTrunc(builder, value, ctx->f32, "");
}
-static void declare_input_vs(
+void si_llvm_load_input_vs(
struct si_shader_context *ctx,
unsigned input_index,
- const struct tgsi_full_declaration *decl,
LLVMValueRef out[4])
{
struct gallivm_state *gallivm = &ctx->gallivm;
@@ -601,6 +600,14 @@ static void declare_input_vs(
}
}
+static void declare_input_vs(
+ struct si_shader_context *ctx,
+ unsigned input_index,
+ const struct tgsi_full_declaration *decl,
+ LLVMValueRef out[4])
+{
+ si_llvm_load_input_vs(ctx, input_index, out);
+}
static LLVMValueRef get_primitive_id(struct si_shader_context *ctx,
unsigned swizzle)
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h
index c8dcd5c88e..99d17c223f 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -313,6 +313,11 @@ LLVMTypeRef si_const_array(LLVMTypeRef elem_type, int num_elements);
void si_shader_context_init_alu(struct lp_build_tgsi_context *bld_base);
void si_shader_context_init_mem(struct si_shader_context *ctx);
+void si_llvm_load_input_vs(
+ struct si_shader_context *ctx,
+ unsigned input_index,
+ LLVMValueRef out[4]);
+
bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir);
#endif
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index cc7517bf9a..8b8baac77f 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -313,8 +313,34 @@ void si_nir_scan_shader(const struct nir_shader *nir,
}
}
+static void declare_nir_input_vs(struct si_shader_context *ctx,
+ struct nir_variable *variable, unsigned rel,
+ LLVMValueRef out[4])
+{
+ si_llvm_load_input_vs(ctx, variable->data.driver_location / 4 + rel, out);
+}
+
bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
{
+ nir_foreach_variable(variable, &nir->inputs) {
+ unsigned attrib_count = glsl_count_attribute_slots(variable->type,
+ nir->stage == MESA_SHADER_VERTEX);
+ unsigned input_idx = variable->data.driver_location;
+
+ for (unsigned i = 0; i < attrib_count; ++i) {
+ LLVMValueRef data[4];
+
+ declare_nir_input_vs(ctx, variable, i, data);
+
+ for (unsigned chan = 0; chan < 4; chan++) {
+ ctx->inputs[input_idx + chan] =
+ LLVMBuildBitCast(ctx->ac.builder, data[chan], ctx->ac.i32, "");
+ }
+ }
+ }
+
+ ctx->abi.inputs = &ctx->inputs[0];
+
ac_nir_translate(&ctx->ac, &ctx->abi, nir, NULL);
return true;