[Mesa-dev] [PATCH 02/15] gallivm: Allow user to configure behavior of emit_fetch() -> aos

Tom Stellard tstellar at gmail.com
Fri Dec 9 14:15:54 PST 2011


In lp_bld_tgsi_aos.c, emit_fetch() the switch statement is
replaced by a call to to a function pointer, which has been added
as a field of struct lp_build_tgsi_aos_context.
---
 src/gallium/auxiliary/gallivm/lp_bld_tgsi.h     |    4 ++
 src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c |   40 +++++++++++++++--------
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index b5b1c6e..9118a68 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -43,6 +43,7 @@
 #include "tgsi/tgsi_scan.h"
 
 
+struct tgsi_full_src_register;
 struct tgsi_token;
 struct tgsi_shader_info;
 struct lp_build_mask_context;
@@ -246,6 +247,9 @@ struct lp_build_tgsi_aos_context
 
    struct tgsi_full_instruction *instructions;
    uint max_instructions;
+
+   LLVMValueRef (*emit_fetch_switch_file_fn)(struct lp_build_tgsi_aos_context *,
+                                         const struct tgsi_full_src_register *);
 };
 
 
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
index b968c22..3677e76 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_aos.c
@@ -98,28 +98,16 @@ swizzle_scalar_aos(struct lp_build_tgsi_aos_context *bld,
    return lp_build_swizzle_scalar_aos(&bld->base, a, chan);
 }
 
-
-/**
- * Register fetch.
- */
 static LLVMValueRef
-emit_fetch(
+emit_fetch_switch_file(
    struct lp_build_tgsi_aos_context *bld,
-   const struct tgsi_full_instruction *inst,
-   unsigned src_op)
+   const struct tgsi_full_src_register *reg)
 {
    LLVMBuilderRef builder = bld->base.gallivm->builder;
    struct lp_type type = bld->base.type;
-   const struct tgsi_full_src_register *reg = &inst->Src[src_op];
    LLVMValueRef res;
    unsigned chan;
 
-   assert(!reg->Register.Indirect);
-
-   /*
-    * Fetch the from the register file.
-    */
-
    switch (reg->Register.File) {
    case TGSI_FILE_CONSTANT:
       /*
@@ -201,6 +189,29 @@ emit_fetch(
       return bld->base.undef;
    }
 
+   return res;
+
+}
+
+/**
+ * Register fetch.
+ */
+static LLVMValueRef
+emit_fetch(
+   struct lp_build_tgsi_aos_context *bld,
+   const struct tgsi_full_instruction *inst,
+   unsigned src_op)
+{
+   LLVMValueRef res;
+   const struct tgsi_full_src_register *reg = &inst->Src[src_op];
+
+   assert(!reg->Register.Indirect);
+
+   /*
+    * Fetch the from the register file.
+    */
+   res = bld->emit_fetch_switch_file_fn(bld, reg);
+
    /*
     * Apply sign modifier.
     */
@@ -1025,6 +1036,7 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm,
    bld.consts_ptr = consts_ptr;
    bld.sampler = sampler;
    bld.indirect_files = info->indirect_files;
+   bld.emit_fetch_switch_file_fn = emit_fetch_switch_file;
    bld.instructions = (struct tgsi_full_instruction *)
                       MALLOC(LP_MAX_INSTRUCTIONS * sizeof(struct tgsi_full_instruction));
    bld.max_instructions = LP_MAX_INSTRUCTIONS;
-- 
1.7.6.4



More information about the mesa-dev mailing list