Merge branch 'master' into i915-unification
[mesa.git] / src / mesa / drivers / dri / r200 / r200_ioctl.h
index 5025c1d2304c8cb5eca629ab39b081f902dbce81..5ed1555f6a324a11378216ec974a66b75929ff43 100644 (file)
@@ -1,6 +1,4 @@
-/* $XFree86$ */
-/**************************************************************************
-
+/*
 Copyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
 
 The Weather Channel (TM) funded Tungsten Graphics to develop the
@@ -37,14 +35,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef __R200_IOCTL_H__
 #define __R200_IOCTL_H__
 
-#ifdef GLX_DIRECT_RENDERING
-
 #include "simple_list.h"
 #include "radeon_dri.h"
 #include "r200_lock.h"
 
 #include "xf86drm.h"
-#include "radeon_common.h"
+#include "drm.h"
+#include "radeon_drm.h"
 
 extern void r200EmitState( r200ContextPtr rmesa );
 extern void r200EmitVertexAOS( r200ContextPtr rmesa,
@@ -88,33 +85,31 @@ extern void r200AllocDmaRegion( r200ContextPtr rmesa,
                                  int bytes, 
                                  int alignment );
 
-extern void r200AllocDmaRegionVerts( r200ContextPtr rmesa,
-                                      struct r200_dma_region *region,
-                                      int numverts,
-                                      int vertsize, 
-                                      int alignment );
-
 extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
                                    struct r200_dma_region *region,
                                    const char *caller );
 
-extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable );
+extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable,
+                           const drm_clip_rect_t      *rect);
 extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
 extern void r200Flush( GLcontext *ctx );
 extern void r200Finish( GLcontext *ctx );
 extern void r200WaitForIdleLocked( r200ContextPtr rmesa );
 extern void r200WaitForVBlank( r200ContextPtr rmesa );
-extern void r200InitIoctlFuncs( GLcontext *ctx );
+extern void r200InitIoctlFuncs( struct dd_function_table *functions );
 
-extern void *r200AllocateMemoryNV( GLsizei size, GLfloat readfreq,
+extern void *r200AllocateMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLsizei size, GLfloat readfreq,
                                   GLfloat writefreq, GLfloat priority );
-extern void r200FreeMemoryNV( GLvoid *pointer );
-extern GLuint r200GetAGPOffset( const GLvoid *pointer );
-extern GLboolean r200IsAgpMemory( r200ContextPtr rmesa, const GLvoid *pointer,
-                                 GLint size );
+extern void r200FreeMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLvoid *pointer );
+extern GLuint r200GetMemoryOffsetMESA( __DRInativeDisplay *dpy, int scrn, const GLvoid *pointer );
 
-extern GLuint r200AgpOffsetFromVirtual( r200ContextPtr rmesa, 
-                                       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 );
 
 /* ================================================================
  * Helper macros:
@@ -134,7 +129,8 @@ do {                                                \
 #define R200_STATECHANGE( rmesa, ATOM )                        \
 do {                                                           \
    R200_NEWPRIM( rmesa );                                      \
-   move_to_head( &(rmesa->hw.dirty), &(rmesa->hw.ATOM));       \
+   rmesa->hw.ATOM.dirty = GL_TRUE;                             \
+   rmesa->hw.is_dirty = GL_TRUE;                               \
 } while (0)
 
 #define R200_DB_STATE( ATOM )                          \
@@ -148,7 +144,8 @@ static __inline int R200_DB_STATECHANGE(
    if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
       int *tmp;
       R200_NEWPRIM( rmesa );
-      move_to_head( &(rmesa->hw.dirty), atom );
+      atom->dirty = GL_TRUE;
+      rmesa->hw.is_dirty = GL_TRUE;
       tmp = atom->cmd; 
       atom->cmd = atom->lastcmd;
       atom->lastcmd = tmp;
@@ -168,6 +165,31 @@ do {                                                       \
    }                                                   \
 } 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 ELTS_BUFSZ(nr) (12 + nr * 2)
+#define VBUF_BUFSZ     (3 * sizeof(int))
+
+/* Ensure that a minimum amount of space is available in the command buffer.
+ * This is used to ensure atomicity of state updates with the rendering requests
+ * that rely on them.
+ *
+ * An alternative would be to implement a "soft lock" such that when the buffer
+ * wraps at an inopportune time, we grab the lock, flush the current buffer,
+ * and hang on to the lock until the critical section is finished and we flush
+ * the buffer again and unlock.
+ */
+static __inline void r200EnsureCmdBufSpace( r200ContextPtr rmesa, int bytes )
+{
+   if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
+      r200FlushCmdBuf( rmesa, __FUNCTION__ );
+   assert( bytes <= R200_CMD_BUF_SZ );
+}
+
 /* Alloc space in the command buffer
  */
 static __inline char *r200AllocCmdBuf( r200ContextPtr rmesa,
@@ -184,8 +206,4 @@ static __inline char *r200AllocCmdBuf( r200ContextPtr rmesa,
    return head;
 }
 
-
-
-
-#endif
 #endif /* __R200_IOCTL_H__ */