i965: very crude and hacky way of handling immediates
authorZack Rusin <zack@tungstengraphics.com>
Thu, 20 Dec 2007 17:54:23 +0000 (12:54 -0500)
committerZack Rusin <zack@tungstengraphics.com>
Thu, 20 Dec 2007 17:54:23 +0000 (12:54 -0500)
src/mesa/pipe/i965simple/brw_context.h
src/mesa/pipe/i965simple/brw_curbe.c
src/mesa/pipe/i965simple/brw_vs_emit.c

index 59e3d24a1d192de2421b43fb98a2a264ba0353a2..139f13ad4eefcaf63feb5125b4f59eb39526c783 100644 (file)
@@ -327,6 +327,9 @@ struct brw_vs_prog_data {
 
    unsigned max_const;
 
+   float    imm_buf[PIPE_MAX_CONSTANT][4];
+   unsigned num_imm;
+
    /* Used for calculating urb partitions:
     */
    unsigned urb_entry_size;
index 785affa2d86bd85009144f9975d576d29b9bddf0..603116c8634ddd77a2824ac40f0f76285e4fae9a 100644 (file)
@@ -252,13 +252,23 @@ static void upload_constant_buffer(struct brw_context *brw)
       /*unsigned nr = vp->max_const;*/
       const struct pipe_constant_buffer *cbuffer = brw->attribs.Constants[0];
       struct pipe_winsys *ws = brw->pipe.winsys;
-      /* map the vertex constant buffer and copy to curbe: */
-      ws->buffer_map(ws, cbuffer->buffer, 0);
-      ws->buffer_get_subdata(ws, cbuffer->buffer,
-                             0, 
-                            cbuffer->size,
-                             &buf[offset]);
-      ws->buffer_unmap(ws, cbuffer->buffer);
+      if (cbuffer->size) {
+         /* map the vertex constant buffer and copy to curbe: */
+         ws->buffer_map(ws, cbuffer->buffer, 0);
+         ws->buffer_get_subdata(ws, cbuffer->buffer,
+                                0,
+                                cbuffer->size,
+                                &buf[offset]);
+         ws->buffer_unmap(ws, cbuffer->buffer);
+         offset += cbuffer->size;
+      }
+      /*immediates*/
+#if 0
+      if (brw->vs.prog_data->num_imm) {
+         memcpy(&buf[offset], brw->vs.prog_data->imm_buf,
+                brw->vs.prog_data->num_imm * 4 * sizeof(float));
+      }
+#endif
    }
 
    if (1) {
index d70df158f9fc34e099a6b465736c80877eb1dbf3..f3507f60f7a9c873d439624806aa1dfc060c577c 100644 (file)
@@ -627,9 +627,12 @@ static struct brw_reg get_reg( struct brw_vs_compile *c,
    case TGSI_FILE_TEMPORARY:
    case TGSI_FILE_INPUT:
    case TGSI_FILE_OUTPUT:
-   case TGSI_FILE_CONSTANT:
       assert(c->regs[file][index].nr != 0);
       return c->regs[file][index];
+   case TGSI_FILE_CONSTANT:
+   case TGSI_FILE_IMMEDIATE:
+      assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0);
+      return c->regs[TGSI_FILE_CONSTANT][index];
    case TGSI_FILE_ADDRESS:
       assert(index == 0);
       return c->regs[file][index];
@@ -1298,6 +1301,14 @@ void brw_vs_emit(struct brw_vs_compile *c)
       }
          break;
       case TGSI_TOKEN_TYPE_IMMEDIATE: {
+         int i;
+         struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
+         /*assert(imm->Immediate.Size == 4);*/
+         c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
+         c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
+         c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;
+         c->prog_data.imm_buf[c->prog_data.num_imm][3] = imm->u.ImmediateFloat32[3].Float;
+         c->prog_data.num_imm++;
       }
          break;
       case TGSI_TOKEN_TYPE_INSTRUCTION: {
@@ -1306,7 +1317,7 @@ void brw_vs_emit(struct brw_vs_compile *c)
             /* first instruction (declerations finished).
              * now that we know what vars are being used allocate
              * registers for them.*/
-            c->prog_data.max_const = prog_info.num_consts;
+            c->prog_data.max_const = prog_info.num_consts + c->prog_data.num_imm;
             brw_vs_alloc_regs(c, &prog_info);
 
            brw_set_access_mode(p, BRW_ALIGN_1);