All elements of pre-DRI_NEW_INTERFACE_ONLY are removed. This allows
[mesa.git] / src / mesa / drivers / dri / mga / mgacontext.h
index 7188f6d9552130aab6cf662190dbfd74c0c91938..1d8c5da6dae5b3869b233ffe20fd08f4ab787c04 100644 (file)
 #ifndef MGALIB_INC
 #define MGALIB_INC
 
-#include <inttypes.h>
+#include <stdint.h>
+#include "drm.h"
+#include "mga_drm.h"
 #include "dri_util.h"
 #include "mtypes.h"
-#include "colormac.h"
 #include "xf86drm.h"
 #include "mm.h"
-#include "mga_sarea.h"
+#include "colormac.h"
 #include "texmem.h"
 #include "macros.h"
+#include "xmlconfig.h"
 
 #define MGA_SET_FIELD(reg,mask,val)  reg = ((reg) & (mask)) | ((val) & ~(mask))
 #define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
 #define MGA_FALLBACK_TEXTURE        0x1
 #define MGA_FALLBACK_DRAW_BUFFER    0x2
 #define MGA_FALLBACK_READ_BUFFER    0x4
-#define MGA_FALLBACK_LOGICOP        0x8
+#define MGA_FALLBACK_BLEND          0x8
 #define MGA_FALLBACK_RENDERMODE     0x10
 #define MGA_FALLBACK_STENCIL        0x20
 #define MGA_FALLBACK_DEPTH          0x40
 #define MGA_FALLBACK_BORDER_MODE    0x80
+#define MGA_FALLBACK_DISABLE        0x100
 
 
 /* Use the templated vertex formats:
@@ -79,10 +82,14 @@ typedef void (*mga_point_func)( mgaContextPtr, mgaVertex * );
 
 
 
-/* Reasons why the GL_BLEND fallback mightn't work:
+/* Texture environment color
  */
-#define MGA_BLEND_ENV_COLOR 0x1
-#define MGA_BLEND_MULTITEX  0x2
+#define RGB_ZERO(c)   (((c) & 0xffffff) == 0x000000)
+#define RGB_ONE(c)    (((c) & 0xffffff) == 0xffffff)
+#define ALPHA_ZERO(c) (((c) >> 24) == 0x00)
+#define ALPHA_ONE(c)  (((c) >> 24) == 0xff)
+#define RGBA_EQUAL(c) ((c) == PACK_COLOR_8888( (c) & 0xff, (c) & 0xff, \
+                                               (c) & 0xff, (c) & 0xff ))
 
 struct mga_texture_object_s;
 struct mga_screen_private_s;
@@ -142,13 +149,17 @@ typedef struct mga_texture_object_s
    int                texelBytes;
    GLuint             age;
 
-   mga_texture_regs_t setup;
+   drm_mga_texture_regs_t setup;
 
    /* If one texture dimension wraps with GL_CLAMP and the other with
     * GL_CLAMP_TO_EDGE, we have to fallback to software.  We would also have
     * to fallback for GL_CLAMP_TO_BORDER.
     */
    GLboolean          border_fallback;
+   /* Depending on multitxturing and environment color
+    * GL_BLEND may have to be a software fallback.
+    */
+   GLboolean texenv_fallback;
 } mgaTextureObject_t;
 
 struct mga_hw_state {
@@ -190,22 +201,17 @@ struct mga_context_t {
     */
    GLuint tmu_source[2];
    
-   GLboolean default32BitTextures;
+   int texture_depth;
 
    /* Manage fallbacks
     */
    GLuint Fallback;  
 
-
-   /* Temporaries for translating away float colors:
-    */
-   struct gl_client_array UbyteColor;
-   struct gl_client_array UbyteSecondaryColor;
-
-   /* Support for limited GL_BLEND fallback
+   /* Texture environment color.
     */
-   unsigned int blend_flags;
-   unsigned int envcolor;
+   unsigned int envcolor[2];
+   GLboolean fcol_used;
+   GLboolean force_dualtex;
 
    /* Rasterization state 
     */
@@ -234,7 +240,7 @@ struct mga_context_t {
    GLuint        NewGLState; 
    GLuint        dirty;
 
-   mga_context_regs_t setup;
+   drm_mga_context_regs_t setup;
 
    GLuint        ClearColor;
    GLuint        ClearDepth;
@@ -257,12 +263,14 @@ struct mga_context_t {
    GLuint vbl_seq;
    GLuint vblank_flags;
 
-   uint64_t swap_ust;
-   uint64_t swap_missed_ust;
+   int64_t swap_ust;
+   int64_t swap_missed_ust;
 
    GLuint swap_count;
    GLuint swap_missed_count;
 
+   uint32_t last_frame_fence;
+
    PFNGLXGETUSTPROC get_ust;
 
    /* Drawable, cliprect and scissor information
@@ -274,12 +282,12 @@ struct mga_context_t {
    int drawX, drawY;           /* origin of drawable in draw buffer */
    int lastX, lastY;           /* detect DSTORG bug */
    GLuint numClipRects;                /* cliprects for the draw buffer */
-   XF86DRIClipRectPtr pClipRects;
-   XF86DRIClipRectRec draw_rect;
-   XF86DRIClipRectRec scissor_rect;
+   drm_clip_rect_t *pClipRects;
+   drm_clip_rect_t draw_rect;
+   drm_clip_rect_t scissor_rect;
    int scissor;
 
-   XF86DRIClipRectRec tmp_boxes[2][MGA_NR_SAREA_CLIPRECTS];
+   drm_clip_rect_t tmp_boxes[2][MGA_NR_SAREA_CLIPRECTS];
 
 
    /* Texture aging and DMA based aging.
@@ -291,14 +299,26 @@ struct mga_context_t {
 
    /* Mirrors of some DRI state.
     */
-   GLframebuffer *glBuffer;
-   drmContext hHWContext;
-   drmLock *driHwLock;
+   drm_context_t hHWContext;
+   drm_hw_lock_t *driHwLock;
    int driFd;
    __DRIdrawablePrivate *driDrawable;
+   __DRIdrawablePrivate *driReadable;
+
+   /**
+    * Drawable used by Mesa for software fallbacks for reading and
+    * writing.  It is set by Mesa's \c SetBuffer callback, and will always be
+    * either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
+    */
+   __DRIdrawablePrivate *mesa_drawable;
+
    __DRIscreenPrivate *driScreen;
    struct mga_screen_private_s *mgaScreen;
-   MGASAREAPrivPtr sarea;
+   drm_mga_sarea_t *sarea;
+
+   /* Configuration cache
+    */
+   driOptionCache optionCache;
 };
 
 #define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx))