summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-05-19 17:43:51 +0200
committerNicolai Hähnle <[email protected]>2017-07-31 14:55:33 +0200
commit9df23db13d706a28190325b64e6c3f61eedc6206 (patch)
treeb971be901cc4e17b227ccbdbd27d4572f727bde5
parentd77526ee3094293b62d08f6c04f28801d7868354 (diff)
radeonsi: translate NIR to LLVM
Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/amd/common/ac_nir_to_llvm.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c13
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_internal.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_shader_nir.c9
4 files changed, 22 insertions, 4 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.h b/src/amd/common/ac_nir_to_llvm.h
index 791c694c78a..0cb48a86469 100644
--- a/src/amd/common/ac_nir_to_llvm.h
+++ b/src/amd/common/ac_nir_to_llvm.h
@@ -30,7 +30,7 @@
#include "amd_family.h"
#include "../vulkan/radv_descriptor_set.h"
#include "ac_shader_info.h"
-#include "shader_enums.h"
+#include "compiler/shader_enums.h"
struct ac_shader_binary;
struct ac_shader_config;
struct nir_shader;
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index ac58d87784a..cd1be493157 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5652,9 +5652,16 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
ctx->postponed_kill = lp_build_alloca(&ctx->gallivm, ctx->f32, "");
}
- if (!lp_build_tgsi_llvm(bld_base, sel->tokens)) {
- fprintf(stderr, "Failed to translate shader from TGSI to LLVM\n");
- return false;
+ if (sel->tokens) {
+ if (!lp_build_tgsi_llvm(bld_base, sel->tokens)) {
+ fprintf(stderr, "Failed to translate shader from TGSI to LLVM\n");
+ return false;
+ }
+ } else {
+ if (!si_nir_build_llvm(ctx, sel->nir)) {
+ fprintf(stderr, "Failed to translate shader from NIR to LLVM\n");
+ return false;
+ }
}
si_llvm_build_ret(ctx, ctx->return_value);
diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h
index 9b5e0b4e535..ae93f78d2fb 100644
--- a/src/gallium/drivers/radeonsi/si_shader_internal.h
+++ b/src/gallium/drivers/radeonsi/si_shader_internal.h
@@ -307,4 +307,6 @@ 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);
+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 9cf032aebaf..00bcf963bea 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -22,6 +22,9 @@
*/
#include "si_shader.h"
+#include "si_shader_internal.h"
+
+#include "ac_nir_to_llvm.h"
#include "tgsi/tgsi_from_mesa.h"
@@ -310,3 +313,9 @@ void si_nir_scan_shader(const struct nir_shader *nir,
}
}
+bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
+{
+ ac_nir_translate(&ctx->ac, &ctx->abi, nir, NULL);
+
+ return true;
+}