mesa: get the translation from mesa 2d regs to tgsi working
authorZack Rusin <zackr@vmware.com>
Sat, 10 Jul 2010 06:02:35 +0000 (02:02 -0400)
committerZack Rusin <zackr@vmware.com>
Sat, 10 Jul 2010 06:02:35 +0000 (02:02 -0400)
first working version of arb_geometry_shader4

src/gallium/auxiliary/draw/draw_pt.c
src/mesa/slang/slang_emit.c
src/mesa/slang/slang_link.c
src/mesa/state_tracker/st_mesa_to_tgsi.c
src/mesa/state_tracker/st_program.c

index 6234272d6ce98a334b716111b9535b3e56df4a0e..32bd3d99cce7583776575a61dd81eeb76a1d9f9c 100644 (file)
@@ -102,7 +102,7 @@ draw_pt_arrays(struct draw_context *draw,
       opt |= PT_SHADE;
    }
 
-   if (draw->pt.middle.llvm && !draw->gs.geometry_shader) {
+   if (draw->pt.middle.llvm) {
       middle = draw->pt.middle.llvm;
    } else {
       if (opt == 0)
index 4a02ba6d4666077fd0104fed2454db515ad69a44..6cd9ce65a02884c2347957cd4f9fc18b2e3e7edb 100644 (file)
@@ -2320,7 +2320,13 @@ emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n)
    }
    else if (n->Store->File == PROGRAM_INPUT) {
       assert(n->Store->Index >= 0);
-      emitInfo->prog->InputsRead |= (1 << n->Store->Index);
+      /* geometry shaders have the input index in the second
+       * index */
+      if (emitInfo->prog->Target == MESA_GEOMETRY_PROGRAM &&
+          n->Store->Is2D) {
+         emitInfo->prog->InputsRead |= (1 << n->Store->Index2D);
+      } else
+         emitInfo->prog->InputsRead |= (1 << n->Store->Index);
    }
 
    if (n->Store->Index < 0) {
index bc2bd31fda5f18272a3990e8d2d5ada17ca06535..8d5a9e96ad96aea64dc966786742947d4762abd4 100644 (file)
@@ -761,9 +761,15 @@ _slang_update_inputs_outputs(struct gl_program *prog)
       const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode);
       for (j = 0; j < numSrc; j++) {
          if (inst->SrcReg[j].File == PROGRAM_INPUT) {
-            prog->InputsRead |= get_inputs_read_mask(prog->Target,
-                                                     inst->SrcReg[j].Index,
-                                                     inst->SrcReg[j].RelAddr);
+            if (prog->Target == MESA_GEOMETRY_PROGRAM &&
+                inst->SrcReg[j].HasIndex2D)
+               prog->InputsRead |= get_inputs_read_mask(prog->Target,
+                                                        inst->SrcReg[j].Index2D,
+                                                        inst->SrcReg[j].RelAddr2D);
+            else
+               prog->InputsRead |= get_inputs_read_mask(prog->Target,
+                                                        inst->SrcReg[j].Index,
+                                                        inst->SrcReg[j].RelAddr);
          }
          else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) {
             maxAddrReg = MAX2(maxAddrReg, (GLuint) (inst->SrcReg[j].Index + 1));
index 050b5d164d7c4787ffe0afa33b2f785d6b32720c..c870db2d699c8b927e81d40eabe9d75ca131b1f9 100644 (file)
@@ -176,7 +176,7 @@ dst_register( struct st_translate *t,
       else if (t->procType == TGSI_PROCESSOR_FRAGMENT)
          assert(index < FRAG_RESULT_MAX);
       else
-         assert(0 && "geom shaders not handled in dst_register() yet");
+         assert(index < GEOM_RESULT_MAX);
 
       assert(t->outputMapping[index] < Elements(t->outputs));
 
@@ -305,6 +305,15 @@ translate_src( struct st_translate *t,
 {
    struct ureg_src src = src_register( t, SrcReg->File, SrcReg->Index );
 
+   if (t->procType == TGSI_PROCESSOR_GEOMETRY && SrcReg->HasIndex2D) {
+      src = src_register( t, SrcReg->File, SrcReg->Index2D );
+      if (SrcReg->RelAddr2D)
+         src = ureg_src_dimension_indirect( src, ureg_src(t->address[0]),
+                                            SrcReg->Index);
+      else
+         src = ureg_src_dimension( src, SrcReg->Index);
+   }
+
    src = ureg_swizzle( src,
                        GET_SWZ( SrcReg->Swizzle, 0 ) & 0x3,
                        GET_SWZ( SrcReg->Swizzle, 1 ) & 0x3,
@@ -330,14 +339,6 @@ translate_src( struct st_translate *t,
       }
    }
 
-   if (SrcReg->HasIndex2D) {
-      if (SrcReg->RelAddr2D)
-         src = ureg_src_dimension_indirect( src, ureg_src(t->address[0]),
-                                            SrcReg->Index2D);
-      else
-         src = ureg_src_dimension( src, SrcReg->Index2D);
-   }
-
    return src;
 }
 
index 1d748965f801efcfdd6781fc22b929e16b549464..6f3ecdbce110227a35c6549630e7fc810d5e14fb 100644 (file)
@@ -492,6 +492,9 @@ st_translate_geometry_program(struct st_context *st,
    /* which vertex output goes to the first geometry input */
    vslot = 0;
 
+   memset(inputMapping, 0, sizeof(inputMapping));
+   memset(outputMapping, 0, sizeof(outputMapping));
+
    /*
     * Convert Mesa program inputs to TGSI input register semantics.
     */