[Mesa-dev] [PATCH 5/5] draw: better llvm names for shaders for debugging.

sroland at vmware.com sroland at vmware.com
Mon May 12 19:02:41 PDT 2014


From: Roland Scheidegger <sroland at vmware.com>

All shaders had the same name.
We could probably use some identifier per shader too, but for now only use
the variant number.
---
 src/gallium/auxiliary/draw/draw_llvm.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index b9f8bb9..0f38762 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -581,6 +581,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
       return NULL;
 
    variant->llvm = llvm;
+   variant->shader = shader;
 
    variant->gallivm = gallivm_create();
 
@@ -603,7 +604,6 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
    variant->jit_func_elts = (draw_jit_vert_func_elts)
          gallivm_jit_function(variant->gallivm, variant->function_elts);
 
-   variant->shader = shader;
    variant->list_item_global.base = variant;
    variant->list_item_local.base = variant;
    /*variant->no = */shader->variants_created++;
@@ -1522,6 +1522,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
    LLVMValueRef context_ptr;
    LLVMBasicBlockRef block;
    LLVMBuilderRef builder;
+   char func_name[64];
    struct lp_type vs_type;
    LLVMValueRef end, start;
    LLVMValueRef count, fetch_elts, fetch_elt_max, fetch_count;
@@ -1558,6 +1559,9 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
 
    memset(&system_values, 0, sizeof(system_values));
 
+   util_snprintf(func_name, sizeof(func_name), "draw_llvm_vs_variant%u%s",
+                 variant->shader->variants_cached, elts ? "_elts" : "");
+
    i = 0;
    arg_types[i++] = get_context_ptr_type(variant);       /* context */
    arg_types[i++] = get_vertex_header_ptr_type(variant); /* vertex_header */
@@ -1575,9 +1579,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant,
 
    func_type = LLVMFunctionType(int32_type, arg_types, num_arg_types, 0);
 
-   variant_func = LLVMAddFunction(gallivm->module,
-                                  elts ? "draw_llvm_shader_elts" : "draw_llvm_shader",
-                                  func_type);
+   variant_func = LLVMAddFunction(gallivm->module, func_name, func_type);
 
    if (elts)
       variant->function_elts = variant_func;
@@ -2098,6 +2100,7 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
    struct lp_build_sampler_soa *sampler = 0;
    struct lp_build_context bld;
    struct lp_bld_tgsi_system_values system_values;
+   char func_name[64];
    struct lp_type gs_type;
    unsigned i;
    struct draw_gs_llvm_iface gs_iface;
@@ -2110,6 +2113,9 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
 
    memset(&system_values, 0, sizeof(system_values));
 
+   util_snprintf(func_name, sizeof(func_name), "draw_llvm_gs_variant%u",
+                 variant->shader->variants_cached);
+
    assert(variant->vertex_header_ptr_type);
 
    arg_types[0] = get_gs_context_ptr_type(variant);    /* context */
@@ -2122,8 +2128,8 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
 
    func_type = LLVMFunctionType(int32_type, arg_types, Elements(arg_types), 0);
 
-   variant_func = LLVMAddFunction(gallivm->module, "draw_geometry_shader",
-                                  func_type);
+   variant_func = LLVMAddFunction(gallivm->module, func_name, func_type);
+
    variant->function = variant_func;
 
    LLVMSetFunctionCallConv(variant_func, LLVMCCallConv);
-- 
1.9.1


More information about the mesa-dev mailing list