From 8643d41622f0f175d7062d0c469537e2d5a5ec35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Thu, 8 Jun 2017 18:38:06 +0200 Subject: [PATCH] radeonsi/nir: load VS inputs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák --- src/gallium/drivers/radeonsi/si_shader.c | 11 ++++++-- .../drivers/radeonsi/si_shader_internal.h | 5 ++++ src/gallium/drivers/radeonsi/si_shader_nir.c | 26 +++++++++++++++++++ 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 0d25773cc3d..44ba6ad5d91 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -409,10 +409,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; @@ -615,6 +614,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 31b4c30ee90..a86fd022177 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -314,6 +314,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 00bcf963bea..ef0dd9dbf96 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; -- 2.30.2