[Mesa-dev] [PATCH 9/9] gallium : st_glsl_to_tgsi handles UBO

vlj vljn at ovi.com
Sun Oct 16 15:37:22 PDT 2011


---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 3fbb0cd..63975a4 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -90,7 +90,7 @@ static int swizzle_for_size(int size);
  */
 class st_src_reg {
 public:
-   st_src_reg(gl_register_file file, int index, const glsl_type *type)
+   st_src_reg(gl_register_file file, int index, const glsl_type *type,int ubo = -1)
    {
       this->file = file;
       this->index = index;
@@ -101,6 +101,7 @@ public:
       this->negate = 0;
       this->type = type ? type->base_type : GLSL_TYPE_ERROR;
       this->reladdr = NULL;
+      this->ubo = ubo;
    }
 
    st_src_reg(gl_register_file file, int index, int type)
@@ -111,6 +112,7 @@ public:
       this->swizzle = SWIZZLE_XYZW;
       this->negate = 0;
       this->reladdr = NULL;
+      this->ubo = -1;
    }
 
    st_src_reg()
@@ -121,6 +123,7 @@ public:
       this->swizzle = 0;
       this->negate = 0;
       this->reladdr = NULL;
+      this->ubo = -1;
    }
 
    explicit st_src_reg(st_dst_reg reg);
@@ -132,6 +135,7 @@ public:
    int type; /** GLSL_TYPE_* from GLSL IR (enum glsl_base_type) */
    /** Register index should be offset by the integer in this reg. */
    st_src_reg *reladdr;
+   int ubo;
 };
 
 class st_dst_reg {
@@ -1867,7 +1871,11 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
       }
    }
 
-   this->result = st_src_reg(entry->file, entry->index, var->type);
+   if(entry->var->UBO)
+      this->result = st_src_reg(entry->file, entry->var->UBO->IndexInUBO, var->type, entry->var->UBO->UBO->Index);
+   else
+      this->result = st_src_reg(entry->file, entry->index, var->type);
+
    if (!native_integers)
       this->result.type = GLSL_TYPE_FLOAT;
 }
@@ -4179,7 +4187,15 @@ translate_dst(struct st_translate *t,
 static struct ureg_src
 translate_src(struct st_translate *t, const st_src_reg *src_reg)
 {
-   struct ureg_src src = src_register(t, src_reg->file, src_reg->index);
+   struct ureg_src src;
+   if(src_reg->ubo < 0)
+      src = src_register(t, src_reg->file, src_reg->index);
+   else {
+      printf("Emitting ureg for index %d, dimension %d \n",src_reg->index,src_reg->ubo);
+      src = ureg_src_register(TGSI_FILE_CONSTANT,src_reg->index);
+      src.Dimension = true;
+      src.DimensionIndex = src_reg->ubo;
+   }
 
    src = ureg_swizzle(src,
                       GET_SWZ(src_reg->swizzle, 0) & 0x3,
-- 
1.7.6.4



More information about the mesa-dev mailing list