r300: move some more function to generic
authorDave Airlie <airlied@linux.ie>
Thu, 15 Jan 2009 06:50:58 +0000 (16:50 +1000)
committerDave Airlie <airlied@linux.ie>
Thu, 15 Jan 2009 06:56:50 +0000 (16:56 +1000)
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_emit.c
src/mesa/drivers/dri/r300/r300_emit.h
src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_render.c
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/radeon/common_cmdbuf.h
src/mesa/drivers/dri/radeon/common_context.h

index f4b4848cee286be32fbc2de3e1a40774fcc24eef..30314d454ffcaa74ad4409f7a35d205ff08a6119 100644 (file)
@@ -327,7 +327,7 @@ static void emit_cb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
 static void emit_zb_offset(GLcontext *ctx, struct radeon_state_atom * atom)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       BATCH_LOCALS(r300);
+       BATCH_LOCALS(&r300->radeon);
        struct radeon_renderbuffer *rrb;
        uint32_t zbpitch;
 
index 1a430169f5ffe52b6edc755bcd3f940b56c82847..8449d00d37a6291eafcedf55a9051b8571551616 100644 (file)
@@ -75,50 +75,7 @@ typedef struct r300_context *r300ContextPtr;
 #include "r300_vertprog.h"
 #include "r500_fragprog.h"
 
-/**
- * This function takes a float and packs it into a uint32_t
- */
-static INLINE uint32_t r300PackFloat32(float fl)
-{
-       union {
-               float fl;
-               uint32_t u;
-       } u;
-
-       u.fl = fl;
-       return u.u;
-}
-
-/* This is probably wrong for some values, I need to test this
- * some more.  Range checking would be a good idea also..
- *
- * But it works for most things.  I'll fix it later if someone
- * else with a better clue doesn't
- */
-static INLINE uint32_t r300PackFloat24(float f)
-{
-       float mantissa;
-       int exponent;
-       uint32_t float24 = 0;
-
-       if (f == 0.0)
-               return 0;
-
-       mantissa = frexpf(f, &exponent);
 
-       /* Handle -ve */
-       if (mantissa < 0) {
-               float24 |= (1 << 23);
-               mantissa = mantissa * -1.0;
-       }
-       /* Handle exponent, bias of 63 */
-       exponent += 62;
-       float24 |= (exponent << 16);
-       /* Kill 7 LSB of mantissa */
-       float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
-
-       return float24;
-}
 
 /************ DMA BUFFERS **************/
 
@@ -869,4 +826,7 @@ extern int r300VertexProgUpdateParams(GLcontext * ctx,
 #define RADEON_D_PLAYBACK_RAW 2
 #define RADEON_D_T 3
 
+#define r300PackFloat32 radeonPackFloat32
+#define r300PackFloat24 radeonPackFloat24
+
 #endif                         /* __R300_CONTEXT_H__ */
index a984f552bdf3920e8de0750a39e7389559556cd6..bf33c18979d7c3eb63bfa57889f5bdd7fe31059f 100644 (file)
@@ -493,7 +493,7 @@ void r300ReleaseArrays(GLcontext * ctx)
 
 void r300EmitCacheFlush(r300ContextPtr rmesa)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
 
        BEGIN_BATCH(4);
        OUT_BATCH_REGVAL(R300_RB3D_DSTCACHE_CTLSTAT,
index db43cc3beed47d774ff313d5b34461789b7c68d3..1e7a639c000f2b809ee93f846c344a8105165040 100644 (file)
@@ -138,28 +138,13 @@ static INLINE uint32_t cmdpacify(struct radeon_screen *rscrn)
        return cmd.u;
 }
 
-
-/** Single register write to command buffer; requires 2 dwords. */
-#define OUT_BATCH_REGVAL(reg, val) \
-       OUT_BATCH(cmdpacket0(b_l_r300->radeon.radeonScreen, (reg), 1)); \
-       OUT_BATCH((val))
-
-/** Continuous register range write to command buffer; requires 1 dword,
- * expects count dwords afterwards for register contents. */
-#define OUT_BATCH_REGSEQ(reg, count) \
-       OUT_BATCH(cmdpacket0(b_l_r300->radeon.radeonScreen, (reg), (count)));
-
-/** Write a 32 bit float to the ring; requires 1 dword. */
-#define OUT_BATCH_FLOAT32(f) \
-       OUT_BATCH(r300PackFloat32((f)));
-
 /**
  * Write the header of a packet3 to the command buffer.
  * Outputs 2 dwords and expects (num_extra+1) additional dwords afterwards.
  */
 #define OUT_BATCH_PACKET3(packet, num_extra) do {\
-    if (!b_l_r300->radeon.radeonScreen->kernel_mm) { \
-       OUT_BATCH(cmdpacket3(b_l_r300->radeon.radeonScreen,\
+    if (!b_l_rmesa->radeonScreen->kernel_mm) { \
+       OUT_BATCH(cmdpacket3(b_l_rmesa->radeonScreen,\
                   R300_CMD_PACKET3_RAW)); \
     }\
        OUT_BATCH(CP_PACKET3((packet), (num_extra))); \
@@ -170,7 +155,7 @@ static INLINE uint32_t cmdpacify(struct radeon_screen *rscrn)
  */
 void static INLINE end_3d(r300ContextPtr rmesa)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
 
     if (!rmesa->radeon.radeonScreen->kernel_mm) {
        BEGIN_BATCH(1);
@@ -181,7 +166,7 @@ void static INLINE end_3d(r300ContextPtr rmesa)
 
 void static INLINE cp_delay(r300ContextPtr rmesa, unsigned short count)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
 
     if (!rmesa->radeon.radeonScreen->kernel_mm) {
        BEGIN_BATCH(1);
@@ -192,42 +177,42 @@ void static INLINE cp_delay(r300ContextPtr rmesa, unsigned short count)
 
 void static INLINE cp_wait(r300ContextPtr rmesa, unsigned char flags)
 {
-       BATCH_LOCALS(rmesa);
-    uint32_t wait_until;
-
-    if (!rmesa->radeon.radeonScreen->kernel_mm) {
-       BEGIN_BATCH_NO_AUTOSTATE(1);
-       OUT_BATCH(cmdwait(rmesa->radeon.radeonScreen, flags));
-           END_BATCH();
-    } else {
-        switch(flags) {
-        case R300_WAIT_2D:
-            wait_until = (1 << 14);
-            break;
-        case R300_WAIT_3D:
-            wait_until = (1 << 15);
-            break;
-        case R300_NEW_WAIT_2D_3D:
-            wait_until = (1 << 14) | (1 << 15);
-            break;
-        case R300_NEW_WAIT_2D_2D_CLEAN:
-            wait_until = (1 << 14) | (1 << 16) | (1 << 18);
-            break;
-        case R300_NEW_WAIT_3D_3D_CLEAN:
-            wait_until = (1 << 15) | (1 << 17) | (1 << 18);
-            break;
-        case R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN:
-            wait_until  = (1 << 14) | (1 << 16) | (1 << 18);
-            wait_until |= (1 << 15) | (1 << 17) | (1 << 18);
-            break;
-        default:
-            return;
-        }
-       BEGIN_BATCH_NO_AUTOSTATE(2);
-        OUT_BATCH(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
-        OUT_BATCH(wait_until);
-           END_BATCH();
-    }
+       BATCH_LOCALS(&rmesa->radeon);
+       uint32_t wait_until;
+
+       if (!rmesa->radeon.radeonScreen->kernel_mm) {
+               BEGIN_BATCH_NO_AUTOSTATE(1);
+               OUT_BATCH(cmdwait(rmesa->radeon.radeonScreen, flags));
+               END_BATCH();
+       } else {
+               switch(flags) {
+               case R300_WAIT_2D:
+                       wait_until = (1 << 14);
+                       break;
+               case R300_WAIT_3D:
+                       wait_until = (1 << 15);
+                       break;
+               case R300_NEW_WAIT_2D_3D:
+                       wait_until = (1 << 14) | (1 << 15);
+                       break;
+               case R300_NEW_WAIT_2D_2D_CLEAN:
+                       wait_until = (1 << 14) | (1 << 16) | (1 << 18);
+                       break;
+               case R300_NEW_WAIT_3D_3D_CLEAN:
+                       wait_until = (1 << 15) | (1 << 17) | (1 << 18);
+                       break;
+               case R300_NEW_WAIT_2D_2D_CLEAN_3D_3D_CLEAN:
+                       wait_until  = (1 << 14) | (1 << 16) | (1 << 18);
+                       wait_until |= (1 << 15) | (1 << 17) | (1 << 18);
+                       break;
+               default:
+                       return;
+               }
+               BEGIN_BATCH_NO_AUTOSTATE(2);
+               OUT_BATCH(CP_PACKET0(RADEON_WAIT_UNTIL, 0));
+               OUT_BATCH(wait_until);
+               END_BATCH();
+       }
 }
 
 extern int r300EmitArrays(GLcontext * ctx);
index 63989636c2fc0f0abc56a690ad26ca0a6bcc4f06..02c4b1cb4081c8c9c32dda70b1222f578b6836d6 100644 (file)
@@ -70,7 +70,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags,
                            struct radeon_renderbuffer *rrb,
                 struct radeon_renderbuffer *rrbd)
 {
-       BATCH_LOCALS(r300);
+       BATCH_LOCALS(&r300->radeon);
        GLcontext *ctx = r300->radeon.glCtx;
        __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
        GLuint cbpitch = 0;
@@ -205,7 +205,7 @@ static void r300ClearBuffer(r300ContextPtr r300, int flags,
 static void r300EmitClearState(GLcontext * ctx)
 {
        r300ContextPtr r300 = R300_CONTEXT(ctx);
-       BATCH_LOCALS(r300);
+       BATCH_LOCALS(&r300->radeon);
        __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
        int i;
        int has_tcl = 1;
index cb6652fabeffb0dcec9ecba8fdd55b2080032de1..c81393e747645eb397313d97b6bb0a1756b5e4a5 100644 (file)
@@ -189,44 +189,44 @@ static void r300EmitElts(GLcontext * ctx, void *elts, unsigned long n_elts)
 
 static void r300FireEB(r300ContextPtr rmesa, int vertex_count, int type)
 {
-       BATCH_LOCALS(rmesa);
-
-    if (vertex_count > 0) {
-       BEGIN_BATCH(8);
-       OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0);
-       OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
-                  ((vertex_count + 0) << 16) |
-                  type |
-                  R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
-
-    if (!rmesa->radeon.radeonScreen->kernel_mm) {
-       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
-           OUT_BATCH(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
-       OUT_BATCH_RELOC(rmesa->state.elt_dma_offset,
-                        rmesa->state.elt_dma_bo,
-                        rmesa->state.elt_dma_offset,
-                        RADEON_GEM_DOMAIN_GTT, 0, 0);
-        OUT_BATCH(vertex_count);
-    } else {
-       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
-           OUT_BATCH(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
-        OUT_BATCH(rmesa->state.elt_dma_offset);
-        OUT_BATCH(vertex_count);
-        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
-                              rmesa->state.elt_dma_bo,
-                              RADEON_GEM_DOMAIN_GTT, 0, 0);
-    }
-       END_BATCH();
-    }
+       BATCH_LOCALS(&rmesa->radeon);
+
+       if (vertex_count > 0) {
+               BEGIN_BATCH(8);
+               OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_INDX_2, 0);
+               OUT_BATCH(R300_VAP_VF_CNTL__PRIM_WALK_INDICES |
+                         ((vertex_count + 0) << 16) |
+                         type |
+                         R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
+               
+               if (!rmesa->radeon.radeonScreen->kernel_mm) {
+                       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
+                       OUT_BATCH(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
+                       OUT_BATCH_RELOC(rmesa->state.elt_dma_offset,
+                                       rmesa->state.elt_dma_bo,
+                                       rmesa->state.elt_dma_offset,
+                                       RADEON_GEM_DOMAIN_GTT, 0, 0);
+                       OUT_BATCH(vertex_count);
+               } else {
+                       OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
+                       OUT_BATCH(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
+                       OUT_BATCH(rmesa->state.elt_dma_offset);
+                       OUT_BATCH(vertex_count);
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->state.elt_dma_bo,
+                                             RADEON_GEM_DOMAIN_GTT, 0, 0);
+               }
+               END_BATCH();
+       }
 }
 
 static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
 {
-       BATCH_LOCALS(rmesa);
-    uint32_t voffset;
+       BATCH_LOCALS(&rmesa->radeon);
+       uint32_t voffset;
        int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
        int i;
-
+       
        if (RADEON_DEBUG & DEBUG_VERTS)
                fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __FUNCTION__, nr,
                        offset);
@@ -236,91 +236,91 @@ static void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
        OUT_BATCH(nr);
 
     
-    if (!rmesa->radeon.radeonScreen->kernel_mm) {
-       for (i = 0; i + 1 < nr; i += 2) {
-               OUT_BATCH((rmesa->state.aos[i].components << 0) |
-                         (rmesa->state.aos[i].stride << 8) |
-                         (rmesa->state.aos[i + 1].components << 16) |
-                         (rmesa->state.aos[i + 1].stride << 24));
-
-        voffset =  rmesa->state.aos[i + 0].offset +
-                   offset * 4 * rmesa->state.aos[i + 0].stride;
-               OUT_BATCH_RELOC(voffset,
-                        rmesa->state.aos[i].bo,
-                        voffset,
-                        RADEON_GEM_DOMAIN_GTT,
-                        0, 0);
-        voffset =  rmesa->state.aos[i + 1].offset +
-                   offset * 4 * rmesa->state.aos[i + 1].stride;
-               OUT_BATCH_RELOC(voffset,
-                        rmesa->state.aos[i+1].bo,
-                        voffset,
-                        RADEON_GEM_DOMAIN_GTT,
-                        0, 0);
-       }
-
-       if (nr & 1) {
-               OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
-                         (rmesa->state.aos[nr - 1].stride << 8));
-        voffset =  rmesa->state.aos[nr - 1].offset +
-                   offset * 4 * rmesa->state.aos[nr - 1].stride;
-               OUT_BATCH_RELOC(voffset,
-                        rmesa->state.aos[nr - 1].bo,
-                                   voffset,
+       if (!rmesa->radeon.radeonScreen->kernel_mm) {
+               for (i = 0; i + 1 < nr; i += 2) {
+                       OUT_BATCH((rmesa->state.aos[i].components << 0) |
+                                 (rmesa->state.aos[i].stride << 8) |
+                                 (rmesa->state.aos[i + 1].components << 16) |
+                                 (rmesa->state.aos[i + 1].stride << 24));
+                       
+                       voffset =  rmesa->state.aos[i + 0].offset +
+                               offset * 4 * rmesa->state.aos[i + 0].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->state.aos[i].bo,
+                                       voffset,
                         RADEON_GEM_DOMAIN_GTT,
-                        0, 0);
-       }
-    } else {
-       for (i = 0; i + 1 < nr; i += 2) {
-               OUT_BATCH((rmesa->state.aos[i].components << 0) |
-                         (rmesa->state.aos[i].stride << 8) |
-                         (rmesa->state.aos[i + 1].components << 16) |
-                         (rmesa->state.aos[i + 1].stride << 24));
-
-        voffset =  rmesa->state.aos[i + 0].offset +
-                   offset * 4 * rmesa->state.aos[i + 0].stride;
-               OUT_BATCH(voffset);
-        voffset =  rmesa->state.aos[i + 1].offset +
-                   offset * 4 * rmesa->state.aos[i + 1].stride;
-               OUT_BATCH(voffset);
-       }
-
-       if (nr & 1) {
-               OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
+                                       0, 0);
+                       voffset =  rmesa->state.aos[i + 1].offset +
+                               offset * 4 * rmesa->state.aos[i + 1].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->state.aos[i+1].bo,
+                                       voffset,
+                                       RADEON_GEM_DOMAIN_GTT,
+                                       0, 0);
+               }
+               
+               if (nr & 1) {
+                       OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
+                                 (rmesa->state.aos[nr - 1].stride << 8));
+                       voffset =  rmesa->state.aos[nr - 1].offset +
+                               offset * 4 * rmesa->state.aos[nr - 1].stride;
+                       OUT_BATCH_RELOC(voffset,
+                                       rmesa->state.aos[nr - 1].bo,
+                                       voffset,
+                                       RADEON_GEM_DOMAIN_GTT,
+                                       0, 0);
+               }
+       } else {
+               for (i = 0; i + 1 < nr; i += 2) {
+                       OUT_BATCH((rmesa->state.aos[i].components << 0) |
+                                 (rmesa->state.aos[i].stride << 8) |
+                                 (rmesa->state.aos[i + 1].components << 16) |
+                                 (rmesa->state.aos[i + 1].stride << 24));
+                       
+                       voffset =  rmesa->state.aos[i + 0].offset +
+                               offset * 4 * rmesa->state.aos[i + 0].stride;
+                       OUT_BATCH(voffset);
+                       voffset =  rmesa->state.aos[i + 1].offset +
+                               offset * 4 * rmesa->state.aos[i + 1].stride;
+                       OUT_BATCH(voffset);
+               }
+               
+               if (nr & 1) {
+                       OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
                          (rmesa->state.aos[nr - 1].stride << 8));
-        voffset =  rmesa->state.aos[nr - 1].offset +
-                   offset * 4 * rmesa->state.aos[nr - 1].stride;
-               OUT_BATCH(voffset);
-       }
-       for (i = 0; i + 1 < nr; i += 2) {
-        voffset =  rmesa->state.aos[i + 0].offset +
-                   offset * 4 * rmesa->state.aos[i + 0].stride;
-        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
-                              rmesa->state.aos[i+0].bo,
-                              RADEON_GEM_DOMAIN_GTT,
-                              0, 0);
-        voffset =  rmesa->state.aos[i + 1].offset +
-                   offset * 4 * rmesa->state.aos[i + 1].stride;
-        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
-                              rmesa->state.aos[i+1].bo,
-                              RADEON_GEM_DOMAIN_GTT,
-                              0, 0);
-       }
-       if (nr & 1) {
-        voffset =  rmesa->state.aos[nr - 1].offset +
-                   offset * 4 * rmesa->state.aos[nr - 1].stride;
-        radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
-                              rmesa->state.aos[nr-1].bo,
-                              RADEON_GEM_DOMAIN_GTT,
-                              0, 0);
+                       voffset =  rmesa->state.aos[nr - 1].offset +
+                               offset * 4 * rmesa->state.aos[nr - 1].stride;
+                       OUT_BATCH(voffset);
+               }
+               for (i = 0; i + 1 < nr; i += 2) {
+                       voffset =  rmesa->state.aos[i + 0].offset +
+                               offset * 4 * rmesa->state.aos[i + 0].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->state.aos[i+0].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+                       voffset =  rmesa->state.aos[i + 1].offset +
+                               offset * 4 * rmesa->state.aos[i + 1].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->state.aos[i+1].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+               }
+               if (nr & 1) {
+                       voffset =  rmesa->state.aos[nr - 1].offset +
+                               offset * 4 * rmesa->state.aos[nr - 1].stride;
+                       radeon_cs_write_reloc(rmesa->radeon.cmdbuf.cs,
+                                             rmesa->state.aos[nr-1].bo,
+                                             RADEON_GEM_DOMAIN_GTT,
+                                             0, 0);
+               }
        }
-    }
        END_BATCH();
 }
 
 static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
 
        BEGIN_BATCH(3);
        OUT_BATCH_PACKET3(R300_PACKET3_3D_DRAW_VBUF_2, 0);
@@ -331,7 +331,7 @@ static void r300FireAOS(r300ContextPtr rmesa, int vertex_count, int type)
 static void r300RunRenderPrimitive(r300ContextPtr rmesa, GLcontext * ctx,
                                   int start, int end, int prim)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
        TNLcontext *tnl = TNL_CONTEXT(ctx);
        struct vertex_buffer *vb = &tnl->vb;
index 0108f7cf6af4b91e1d2e5265c7ac15737bc8f232..03fc2107dbad9846199d9a4926aa1745ef430905 100644 (file)
@@ -636,7 +636,7 @@ void r300DestroySwtcl(GLcontext *ctx)
 
 void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, struct radeon_bo *bo, GLuint offset)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
 
        if (RADEON_DEBUG & DEBUG_VERTS)
                fprintf(stderr, "%s:  vertex_size %d, offset 0x%x \n",
@@ -652,7 +652,7 @@ void r300EmitVertexAOS(r300ContextPtr rmesa, GLuint vertex_size, struct radeon_b
 
 void r300EmitVbufPrim(r300ContextPtr rmesa, GLuint primitive, GLuint vertex_nr)
 {
-       BATCH_LOCALS(rmesa);
+       BATCH_LOCALS(&rmesa->radeon);
        int type, num_verts;
 
        type = r300PrimitiveType(rmesa, primitive);
index 018049b452302a82b5e430eba0c0941056fc467a..fbcbf72b2bfdd82b42730aa5c7d330ed369243f9 100644 (file)
@@ -31,7 +31,7 @@ void rcommonBeginBatch(radeonContextPtr rmesa,
 /**
  * Same as BEGIN_BATCH, but do not cause automatic state emits.
  */
-#define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_r300, n, 0, __FILE__, __FUNCTION__, __LINE__)
+#define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_rmesa, n, 0, __FILE__, __FUNCTION__, __LINE__)
 
 /**
  * Write one dword to the command buffer.
@@ -89,5 +89,17 @@ void rcommonBeginBatch(radeonContextPtr rmesa,
        } while(0)
 
 
+/** Single register write to command buffer; requires 2 dwords. */
+#define OUT_BATCH_REGVAL(reg, val) \
+       OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), 1)); \
+       OUT_BATCH((val))
 
+/** Continuous register range write to command buffer; requires 1 dword,
+ * expects count dwords afterwards for register contents. */
+#define OUT_BATCH_REGSEQ(reg, count) \
+       OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), (count)));
+
+/** Write a 32 bit float to the ring; requires 1 dword. */
+#define OUT_BATCH_FLOAT32(f) \
+       OUT_BATCH(radeonPackFloat32((f)));
 #endif
index 2748c51a59cfd4b8ddc7891a4ecda704e3e51dab..d6e15bc3b86006b7fd4bb0b3f2cb7855264de3fe 100644 (file)
@@ -343,6 +343,51 @@ struct radeon_context {
 
 #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
 
+/**
+ * This function takes a float and packs it into a uint32_t
+ */
+static INLINE uint32_t radeonPackFloat32(float fl)
+{
+       union {
+               float fl;
+               uint32_t u;
+       } u;
+
+       u.fl = fl;
+       return u.u;
+}
+
+/* This is probably wrong for some values, I need to test this
+ * some more.  Range checking would be a good idea also..
+ *
+ * But it works for most things.  I'll fix it later if someone
+ * else with a better clue doesn't
+ */
+static INLINE uint32_t radeonPackFloat24(float f)
+{
+       float mantissa;
+       int exponent;
+       uint32_t float24 = 0;
+
+       if (f == 0.0)
+               return 0;
+
+       mantissa = frexpf(f, &exponent);
+
+       /* Handle -ve */
+       if (mantissa < 0) {
+               float24 |= (1 << 23);
+               mantissa = mantissa * -1.0;
+       }
+       /* Handle exponent, bias of 63 */
+       exponent += 62;
+       float24 |= (exponent << 16);
+       /* Kill 7 LSB of mantissa */
+       float24 |= (radeonPackFloat32(mantissa) & 0x7FFFFF) >> 7;
+
+       return float24;
+}
+
 /* ================================================================
  * Debugging:
  */