Module: Mesa
Branch: master
Commit: a1a3792b180e453d26bfd09853eee88460dfc466
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1a3792b180e453d26bfd09853eee88460dfc466

Author: Vincent Lejeune <v...@ovi.com>
Date:   Sun Sep 23 15:20:34 2012 +0200

r600g: tgsi-to-llvm path is taken after declarations have been parsed

Reviewed-by: Tom Stellard <thomas.stell...@amd.com>

---

 src/gallium/drivers/r600/r600_shader.c |   58 +++++++++++++++++--------------
 1 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 29616f9..20bf79d 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -1250,7 +1250,6 @@ static int r600_shader_from_tgsi(struct r600_screen 
*rscreen,
                ctx.file_offset[TGSI_FILE_INPUT] = evergreen_gpr_count(&ctx);
        }
 
-       /* LLVM backend setup */
 #ifdef R600_USE_LLVM
        if (use_llvm && ctx.info.indirect_files) {
                fprintf(stderr, "Warning: R600 LLVM backend does not support "
@@ -1258,34 +1257,13 @@ static int r600_shader_from_tgsi(struct r600_screen 
*rscreen,
                                "backend.\n");
                use_llvm = 0;
        }
-       if (use_llvm) {
-               struct radeon_llvm_context radeon_llvm_ctx;
-               LLVMModuleRef mod;
-               unsigned dump = 0;
-               memset(&radeon_llvm_ctx, 0, sizeof(radeon_llvm_ctx));
-               radeon_llvm_ctx.reserved_reg_count = 
ctx.file_offset[TGSI_FILE_INPUT];
-               mod = r600_tgsi_llvm(&radeon_llvm_ctx, tokens);
-               if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE)) {
-                       dump = 1;
-               }
-               if (r600_llvm_compile(mod, &inst_bytes, &inst_byte_count,
-                                                       rscreen->family, dump)) 
{
-                       FREE(inst_bytes);
-                       radeon_llvm_dispose(&radeon_llvm_ctx);
-                       use_llvm = 0;
-                       fprintf(stderr, "R600 LLVM backend failed to compile "
-                               "shader.  Falling back to TGSI\n");
-               } else {
-                       ctx.file_offset[TGSI_FILE_OUTPUT] =
-                                       ctx.file_offset[TGSI_FILE_INPUT];
-               }
-               radeon_llvm_dispose(&radeon_llvm_ctx);
-       }
 #endif
-       /* End of LLVM backend setup */
 
-       if (!use_llvm) {
+       if (use_llvm) {
                ctx.file_offset[TGSI_FILE_OUTPUT] =
+                       ctx.file_offset[TGSI_FILE_INPUT];
+       } else {
+          ctx.file_offset[TGSI_FILE_OUTPUT] =
                        ctx.file_offset[TGSI_FILE_INPUT] +
                        ctx.info.file_max[TGSI_FILE_INPUT] + 1;
        }
@@ -1346,6 +1324,34 @@ static int r600_shader_from_tgsi(struct r600_screen 
*rscreen,
                }
        }
 
+/* LLVM backend setup */
+#ifdef R600_USE_LLVM
+       if (use_llvm) {
+               struct radeon_llvm_context radeon_llvm_ctx;
+               LLVMModuleRef mod;
+               unsigned dump = 0;
+               memset(&radeon_llvm_ctx, 0, sizeof(radeon_llvm_ctx));
+               radeon_llvm_ctx.reserved_reg_count = 
ctx.file_offset[TGSI_FILE_INPUT];
+               mod = r600_tgsi_llvm(&radeon_llvm_ctx, tokens);
+               if (debug_get_bool_option("R600_DUMP_SHADERS", FALSE)) {
+                       dump = 1;
+               }
+               if (r600_llvm_compile(mod, &inst_bytes, &inst_byte_count,
+                                                       rscreen->family, dump)) 
{
+                       FREE(inst_bytes);
+                       radeon_llvm_dispose(&radeon_llvm_ctx);
+                       use_llvm = 0;
+                       fprintf(stderr, "R600 LLVM backend failed to compile "
+                               "shader.  Falling back to TGSI\n");
+               } else {
+                       ctx.file_offset[TGSI_FILE_OUTPUT] =
+                                       ctx.file_offset[TGSI_FILE_INPUT];
+               }
+               radeon_llvm_dispose(&radeon_llvm_ctx);
+       }
+#endif
+/* End of LLVM backend setup */
+
        if (shader->fs_write_all && rscreen->chip_class >= EVERGREEN)
                shader->nr_ps_max_color_exports = 8;
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to