Bug #2428: #ifdef GLX_DIRECT_RENDERING in DRI drivers is pointless.
[mesa.git] / src / mesa / drivers / dri / mga / mga_xmesa.h
1 /*
2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keith@tungstengraphics.com>
26 */
27 /* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h,v 1.12 2002/12/16 16:18:52 dawes Exp $ */
28
29 #ifndef _MGA_INIT_H_
30 #define _MGA_INIT_H_
31
32 #include <sys/time.h>
33 #include "dri_util.h"
34 #include "mga_drm.h"
35 #include "mtypes.h"
36 #include "mgaregs.h"
37 #include "xmlconfig.h"
38
39 typedef struct mga_screen_private_s {
40
41 int chipset;
42 int width;
43 int height;
44 int mem;
45
46 int cpp; /* for front and back buffers */
47 GLint agpMode;
48 unsigned int irq; /* IRQ number (0 means none) */
49 GLboolean linecomp_sane; /* GL_TRUE if line comp. programmed correctly
50 * by the DDX driver.
51 */
52
53 unsigned int mAccess;
54
55 unsigned int frontOffset;
56 unsigned int frontPitch;
57 unsigned int backOffset;
58 unsigned int backPitch;
59
60 unsigned int depthOffset;
61 unsigned int depthPitch;
62 int depthCpp;
63
64 unsigned int dmaOffset;
65
66 unsigned int textureOffset[MGA_NR_TEX_HEAPS];
67 unsigned int textureSize[MGA_NR_TEX_HEAPS];
68 int logTextureGranularity[MGA_NR_TEX_HEAPS];
69 char *texVirtual[MGA_NR_TEX_HEAPS];
70
71
72 __DRIscreenPrivate *sPriv;
73 drmBufMapPtr bufs;
74
75 drmRegion mmio;
76 drmRegion status;
77 drmRegion primary;
78 drmRegion buffers;
79 unsigned int sarea_priv_offset;
80
81 /* Configuration cache with default values for all contexts */
82 driOptionCache optionCache;
83 } mgaScreenPrivate;
84
85
86 #include "mgacontext.h"
87
88 extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
89 extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
90 extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit );
91
92 #define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch
93 #define GET_ENQUEUE_AGE( mmesa ) mmesa->sarea->last_enqueue
94
95
96
97 /* Lock the hardware and validate our state.
98 */
99 #define LOCK_HARDWARE( mmesa ) \
100 do { \
101 char __ret=0; \
102 DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
103 (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
104 if (__ret) \
105 mgaGetLock( mmesa, 0 ); \
106 } while (0)
107
108
109 /*
110 */
111 #define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \
112 LOCK_HARDWARE( mmesa ); \
113 UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \
114 } while (0)
115
116
117 /* Unlock the hardware using the global current context
118 */
119 #define UNLOCK_HARDWARE(mmesa) \
120 DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
121
122
123 /* Freshen our snapshot of the drawables
124 */
125 #define REFRESH_DRAWABLE_INFO( mmesa ) \
126 do { \
127 LOCK_HARDWARE( mmesa ); \
128 mmesa->lastX = mmesa->drawX; \
129 mmesa->lastY = mmesa->drawY; \
130 UNLOCK_HARDWARE( mmesa ); \
131 } while (0)
132
133
134 #define GET_DRAWABLE_LOCK( mmesa ) while(0)
135 #define RELEASE_DRAWABLE_LOCK( mmesa ) while(0)
136
137
138 /* The 2D driver macros are busted -- we can't use them here as they
139 * rely on the 2D driver data structures rather than taking an explicit
140 * base address.
141 */
142 #define MGA_BASE( reg ) ((unsigned long)(mmesa->mgaScreen->mmio.map))
143 #define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
144
145 #define MGA_DEREF( reg ) *(volatile u_int32_t *)MGA_ADDR( reg )
146 #define MGA_READ( reg ) MGA_DEREF( reg )
147 #define MGA_WRITE( reg, val ) do { MGA_DEREF( reg ) = val; } while (0)
148
149 #endif