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;
}
}
+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)
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
}
}
+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;