[965] Move to using shared texture management code.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_context.h
index 808512f7fd53ab37ba70933104dd51007b6e4a2a..583ef42166ed39f889729603010efd9ed57f1e8d 100644 (file)
@@ -35,6 +35,7 @@
 #include "texmem.h"
 
 #include "intel_screen.h"
+#include "intel_tex_obj.h"
 #include "i830_common.h"
 #include "tnl/t_vertex.h"
 
@@ -63,28 +64,9 @@ typedef void (*intel_point_func)(struct intel_context *, intelVertex *);
 extern void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode );
 #define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
 
-
-
-struct intel_texture_object
-{
-   struct gl_texture_object base; /* The "parent" object */
-
-   /* The mipmap tree must include at least these levels once
-    * validated:
-    */
-   GLuint firstLevel;
-   GLuint lastLevel;
-
-   GLuint dirty_images[6];
-   GLuint dirty;
-
-   /* On validation any active images held in main memory or in other
-    * regions will be copied to this region and the old storage freed.
-    */
-   struct intel_mipmap_tree *mt;
-};
-
-
+#define INTEL_WRITE_PART  0x1
+#define INTEL_WRITE_FULL  0x2
+#define INTEL_READ        0x4
 
 struct intel_context
 {
@@ -109,20 +91,6 @@ struct intel_context
       void (*emit_flush)( struct intel_context *intel,
                          GLuint unused );
 
-      void (*aub_commands)( struct intel_context *intel, 
-                           GLuint offset,
-                           const void *buf,
-                           GLuint sz );
-      void (*aub_dump_bmp)( struct intel_context *intel, GLuint buffer );
-      void (*aub_wrap)( struct intel_context *intel );
-      void (*aub_gtt_data)( struct intel_context *intel, 
-                           GLuint offset,
-                           const void *src,
-                           GLuint size,
-                           GLuint aubtype, 
-                           GLuint aubsubtype);
-
-
       void (*reduced_primitive_state)( struct intel_context *intel, GLenum rprim );
 
       GLboolean (*check_vertex_size)( struct intel_context *intel, GLuint expected );
@@ -165,21 +133,34 @@ struct intel_context
                             GLfloat s0, GLfloat s1,
                             GLfloat t0, GLfloat t1);
 
-
-
+      void (*debug_batch)(struct intel_context *intel);
    } vtbl;
 
    GLint refcount;   
    GLuint Fallback;
    GLuint NewGLState;
-   
-   GLuint last_swap_fence;
-   GLuint second_last_swap_fence;
-   
-   GLboolean aub_wrap;
+
+   dri_bufmgr *bufmgr;
+   unsigned int maxBatchSize;
+
+   struct intel_region *front_region;
+   struct intel_region *back_region;
+   struct intel_region *third_region;
+   struct intel_region *depth_region;
+
+   /**
+    * This value indicates that the kernel memory manager is being used
+    * instead of the fake client-side memory manager.
+    */
+   GLboolean ttm;
+
+   dri_fence *first_swap_fence;
+   dri_fence *last_swap_fence;
+
    GLuint stats_wm;
 
    struct intel_batchbuffer *batch;
+   unsigned batch_id;
 
    GLubyte clear_chan[4];
    GLuint ClearColor;
@@ -193,29 +174,17 @@ struct intel_context
    GLboolean hw_stencil;
    GLboolean hw_stipple;
    GLboolean depth_buffer_is_float;
-   GLboolean no_hw;
    GLboolean no_rast;
-   GLboolean thrashing;
    GLboolean locked;
    GLboolean strict_conformance;
    GLboolean need_flush;
 
-
-   
-   /* AGP memory buffer manager:
-    */
-   struct bufmgr *bm;
-
-
    /* State for intelvb.c and inteltris.c.
     */
    GLenum render_primitive;
    GLenum reduced_primitive;
 
-   struct intel_region *front_region;
-   struct intel_region *back_region;
    struct intel_region *draw_region;
-   struct intel_region *depth_region;
 
    /* These refer to the current draw (front vs. back) buffer:
     */
@@ -234,24 +203,20 @@ struct intel_context
    int driFd;
 
    __DRIdrawablePrivate *driDrawable;
+   __DRIdrawablePrivate *driReadDrawable;
    __DRIscreenPrivate *driScreen;
    intelScreenPrivate *intelScreen; 
    volatile drmI830Sarea *sarea; 
-   
-   FILE *aub_file;
 
    GLuint lastStamp;
 
+   GLboolean no_hw;
+
    /**
     * Configuration cache
     */
    driOptionCache optionCache;
 
-   /* VBI
-    */
-   GLuint vbl_seq;
-   GLuint vblank_flags;
-
    int64_t swap_ust;
    int64_t swap_missed_ust;
 
@@ -268,6 +233,8 @@ void UNLOCK_HARDWARE( struct intel_context *intel );
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
+#define ALIGN(value, alignment)  ((value + alignment - 1) & ~(alignment - 1))
+
 /* ================================================================
  * Color packing:
  */
@@ -321,32 +288,6 @@ static inline void * __memcpy(void * to, const void * from, size_t n)
 #endif
 
 
-/* The system memcpy (at least on ubuntu 5.10) has problems copying
- * to agp (writecombined) memory from a source which isn't 64-byte
- * aligned - there is a 4x performance falloff.
- *
- * The x86 __memcpy is immune to this but is slightly slower
- * (10%-ish) than the system memcpy.
- *
- * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
- * isn't much faster than x86_memcpy for agp copies.
- * 
- * TODO: switch dynamically.
- */
-static inline void *do_memcpy( void *dest, const void *src, size_t n )
-{
-   if ( (((unsigned long)src) & 63) ||
-       (((unsigned long)dest) & 63)) {
-      return  __memcpy(dest, src, n);  
-   }
-   else
-      return memcpy(dest, src, n);
-}
-
-
-
-
-
 /* ================================================================
  * Debugging:
  */
@@ -371,21 +312,16 @@ extern int INTEL_DEBUG;
 #define DEBUG_WM        0x10000
 #define DEBUG_URB       0x20000
 #define DEBUG_VS        0x40000
+#define DEBUG_BATCH    0x80000
+#define DEBUG_BUFMGR   0x100000
+#define DEBUG_BLIT     0x200000
+#define DEBUG_REGION   0x400000
+#define DEBUG_MIPTREE  0x800000
 
-
-#define PCI_CHIP_845_G                 0x2562
-#define PCI_CHIP_I830_M                        0x3577
-#define PCI_CHIP_I855_GM               0x3582
-#define PCI_CHIP_I865_G                        0x2572
-#define PCI_CHIP_I915_G                        0x2582
-#define PCI_CHIP_I915_GM               0x2592
-#define PCI_CHIP_I945_G                        0x2772
-#define PCI_CHIP_I965_G                        0x29A2
-#define PCI_CHIP_I965_Q                        0x2992
-#define PCI_CHIP_I965_G_1              0x2982
-#define PCI_CHIP_I946_GZ               0x2972
-#define PCI_CHIP_I965_GM                0x2A02
-
+#define DBG(...) do {                                          \
+       if (INTEL_DEBUG & FILE_DEBUG_FLAG)                      \
+               _mesa_printf(__VA_ARGS__);                      \
+} while(0)
 
 /* ================================================================
  * intel_context.c:
@@ -399,7 +335,6 @@ extern GLboolean intelInitContext( struct intel_context *intel,
 
 extern void intelGetLock(struct intel_context *intel, GLuint flags);
 
-extern void intelInitState( GLcontext *ctx );
 extern void intelFinish( GLcontext *ctx );
 extern void intelFlush( GLcontext *ctx );
 
@@ -463,7 +398,7 @@ extern void intelInitStateFuncs( struct dd_function_table *functions );
 #define BLENDFACT_INV_CONST_ALPHA      0x0f
 #define BLENDFACT_MASK                 0x0f
 
-
+extern int intel_translate_shadow_compare_func( GLenum func );
 extern int intel_translate_compare_func( GLenum func );
 extern int intel_translate_stencil_op( GLenum op );
 extern int intel_translate_blend_factor( GLenum factor );
@@ -514,15 +449,5 @@ static inline struct intel_context *intel_context( GLcontext *ctx )
    return (struct intel_context *)ctx;
 }
 
-static inline struct intel_texture_object *intel_texture_object( struct gl_texture_object *obj )
-{
-   return (struct intel_texture_object *)obj;
-}
-
-static inline struct intel_texture_image *intel_texture_image( struct gl_texture_image *img )
-{
-   return (struct intel_texture_image *)img;
-}
-
 #endif