i965: Implement "Static Vertex Count" geometry shader optimization.
[mesa.git] / src / mesa / drivers / dri / r200 / r200_ioctl.h
index 316acef4593208d7f320566cc55050df33a0d54b..25a9dd376829ecdc8f620fd108776d167a2c4a10 100644 (file)
@@ -29,25 +29,22 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /*
  * Authors:
- *   Keith Whitwell <keith@tungstengraphics.com>
+ *   Keith Whitwell <keithw@vmware.com>
  */
 
 #ifndef __R200_IOCTL_H__
 #define __R200_IOCTL_H__
 
-#include "main/simple_list.h"
-#include "radeon_dri.h"
-#include "r200_lock.h"
+#include "util/simple_list.h"
 
-#include "radeon_cs_legacy.h"
+#include "radeon_bo_gem.h"
+#include "radeon_cs_gem.h"
 
 #include "xf86drm.h"
 #include "drm.h"
 #include "radeon_drm.h"
 
-#include "common_cmdbuf.h"
-
-extern void r200EmitState( r200ContextPtr rmesa );
+extern void r200EmitMaxVtxIndex(r200ContextPtr rmesa, int count);
 extern void r200EmitVertexAOS( r200ContextPtr rmesa,
                               GLuint vertex_size,
                               struct radeon_bo *bo,
@@ -57,7 +54,7 @@ extern void r200EmitVbufPrim( r200ContextPtr rmesa,
                                GLuint primitive,
                                GLuint vertex_nr );
 
-extern void r200FlushElts(GLcontext *ctx);
+extern void r200FlushElts(struct gl_context *ctx);
 
 extern GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
                                           GLuint primitive,
@@ -65,21 +62,8 @@ extern GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
 
 extern void r200EmitAOS(r200ContextPtr rmesa, GLuint nr, GLuint offset);
 
-extern void r200Flush( GLcontext *ctx );
-extern void r200Finish( GLcontext *ctx );
 extern void r200InitIoctlFuncs( struct dd_function_table *functions );
 
-extern void *r200AllocateMemoryMESA( __DRIscreen *screen, GLsizei size, GLfloat readfreq,
-                                  GLfloat writefreq, GLfloat priority );
-extern void r200FreeMemoryMESA( __DRIscreen *screen, GLvoid *pointer );
-extern GLuint r200GetMemoryOffsetMESA( __DRIscreen *screen, const GLvoid *pointer );
-
-extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
-                                  GLint size );
-
-extern GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa, 
-                                        const GLvoid *pointer );
-
 void r200SetUpAtomList( r200ContextPtr rmesa );
 
 /* ================================================================
@@ -91,24 +75,34 @@ void r200SetUpAtomList( r200ContextPtr rmesa );
 #define R200_NEWPRIM( rmesa )                  \
 do {                                           \
    if ( rmesa->radeon.dma.flush )                      \
-      rmesa->radeon.dma.flush( rmesa->radeon.glCtx );  \
+      rmesa->radeon.dma.flush( &rmesa->radeon.glCtx ); \
 } while (0)
 
-/* Can accomodate several state changes and primitive changes without
+/* Can accommodate several state changes and primitive changes without
  * actually firing the buffer.
  */
 #define R200_STATECHANGE( rmesa, ATOM )                        \
 do {                                                           \
    R200_NEWPRIM( rmesa );                                      \
    rmesa->hw.ATOM.dirty = GL_TRUE;                             \
-   rmesa->hw.is_dirty = GL_TRUE;                               \
+   rmesa->radeon.hw.is_dirty = GL_TRUE;                                \
 } while (0)
 
+#define R200_SET_STATE( rmesa, ATOM, index, newvalue )         \
+  do { \
+    uint32_t __index = (index); \
+    uint32_t __dword = (newvalue); \
+    if (__dword != (rmesa)->hw.ATOM.cmd[__index]) { \
+      R200_STATECHANGE( (rmesa), ATOM ); \
+      (rmesa)->hw.ATOM.cmd[__index] = __dword; \
+    } \
+  } while(0)
+
 #define R200_DB_STATE( ATOM )                          \
    memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
           rmesa->hw.ATOM.cmd_size * 4)
 
-static INLINE int R200_DB_STATECHANGE( 
+static inline int R200_DB_STATECHANGE( 
    r200ContextPtr rmesa,
    struct radeon_state_atom *atom )
 {
@@ -116,7 +110,7 @@ static INLINE int R200_DB_STATECHANGE(
       GLuint *tmp;
       R200_NEWPRIM( rmesa );
       atom->dirty = GL_TRUE;
-      rmesa->hw.is_dirty = GL_TRUE;
+      rmesa->radeon.hw.is_dirty = GL_TRUE;
       tmp = atom->cmd; 
       atom->cmd = atom->lastcmd;
       atom->lastcmd = tmp;
@@ -127,23 +121,16 @@ static INLINE int R200_DB_STATECHANGE(
 }
 
 
-/* Fire the buffered vertices no matter what.
- */
-#define R200_FIREVERTICES( rmesa )                     \
-do {                                                   \
-   if ( rmesa->radeon.cmdbuf.cs->cdw || rmesa->radeon.dma.flush ) {    \
-      r200Flush( rmesa->radeon.glCtx );                        \
-   }                                                   \
-} while (0)
-
 /* Command lengths.  Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
  * are available, you will also be adding an rmesa->state.max_state_size because
  * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
  */
-#define AOS_BUFSZ(nr)  ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
-#define VERT_AOS_BUFSZ (5 * sizeof(int))
+#define AOS_BUFSZ(nr)  ((3 + ((nr / 2) * 3) + ((nr & 1) * 2) + nr*2))
+#define VERT_AOS_BUFSZ (5)
 #define ELTS_BUFSZ(nr) (12 + nr * 2)
-#define VBUF_BUFSZ     (3 * sizeof(int))
+#define VBUF_BUFSZ     (3)
+#define SCISSOR_BUFSZ  (8)
+#define INDEX_BUFSZ    (8+2)
 
 static inline uint32_t cmdpacket3(int cmd_type)
 {
@@ -157,23 +144,13 @@ static inline uint32_t cmdpacket3(int cmd_type)
 }
 
 #define OUT_BATCH_PACKET3(packet, num_extra) do {            \
-    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
-      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3));                                     \
-      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
-    } else {                                                 \
-      OUT_BATCH(CP_PACKET2);                                 \
-      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
-    }                                                        \
+    OUT_BATCH(CP_PACKET2);                                   \
+    OUT_BATCH(CP_PACKET3((packet), (num_extra)));            \
   } while(0)
 
 #define OUT_BATCH_PACKET3_CLIP(packet, num_extra) do {       \
-    if (!b_l_rmesa->radeonScreen->kernel_mm) {               \
-      OUT_BATCH(cmdpacket3(RADEON_CMD_PACKET3_CLIP));        \
-      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
-    } else {                                                 \
-      OUT_BATCH(CP_PACKET2);                                 \
-      OUT_BATCH(CP_PACKET3((packet), (num_extra)));          \
-    }                                                        \
+    OUT_BATCH(CP_PACKET2);                                   \
+    OUT_BATCH(CP_PACKET3((packet), (num_extra)));            \
   } while(0)