2 #ifndef COMMON_CONTEXT_H
3 #define COMMON_CONTEXT_H
4 /* This union is used to avoid warnings/miscompilation
5 with float to uint32_t casts due to strict-aliasing */
6 typedef union { GLfloat f
; uint32_t ui32
; } float_ui32_type
;
9 typedef struct radeon_context radeonContextRec
;
10 typedef struct radeon_context
*radeonContextPtr
;
13 #include "math/m_vector.h"
15 #include "tnl/t_context.h"
25 /* Rasterizing fallbacks */
26 /* See correponding strings in r200_swtcl.c */
27 #define RADEON_FALLBACK_TEXTURE 0x0001
28 #define RADEON_FALLBACK_DRAW_BUFFER 0x0002
29 #define RADEON_FALLBACK_STENCIL 0x0004
30 #define RADEON_FALLBACK_RENDER_MODE 0x0008
31 #define RADEON_FALLBACK_BLEND_EQ 0x0010
32 #define RADEON_FALLBACK_BLEND_FUNC 0x0020
33 #define RADEON_FALLBACK_DISABLE 0x0040
34 #define RADEON_FALLBACK_BORDER_MODE 0x0080
36 #define R200_FALLBACK_TEXTURE 0x01
37 #define R200_FALLBACK_DRAW_BUFFER 0x02
38 #define R200_FALLBACK_STENCIL 0x04
39 #define R200_FALLBACK_RENDER_MODE 0x08
40 #define R200_FALLBACK_DISABLE 0x10
41 #define R200_FALLBACK_BORDER_MODE 0x20
43 /* The blit width for texture uploads
45 #define BLIT_WIDTH_BYTES 1024
47 /* Use the templated vertex format:
50 #define TAG(x) radeon##x
51 #include "tnl_dd/t_dd_vertex.h"
54 struct radeon_colorbuffer_state
{
57 struct radeon_renderbuffer
*rrb
;
60 struct radeon_depthbuffer_state
{
63 struct radeon_renderbuffer
*rrb
;
66 struct radeon_scissor_state
{
70 GLuint numClipRects
; /* Cliprects active */
71 GLuint numAllocedClipRects
; /* Cliprects available */
72 drm_clip_rect_t
*pClipRects
;
75 struct radeon_stencilbuffer_state
{
77 GLuint clear
; /* rb3d_stencilrefmask value */
80 struct radeon_stipple_state
{
84 struct radeon_state_atom
{
85 struct radeon_state_atom
*next
, *prev
;
86 const char *name
; /* for debug */
87 int cmd_size
; /* size in bytes */
90 GLuint
*cmd
; /* one or more cmd's */
91 GLuint
*lastcmd
; /* one or more cmd's */
92 GLboolean dirty
; /* dirty-mark in emit_state_list */
93 int (*check
) (GLcontext
*, struct radeon_state_atom
*atom
); /* is this state active? */
94 void (*emit
) (GLcontext
*, struct radeon_state_atom
*atom
);
97 typedef struct radeon_tex_obj radeonTexObj
, *radeonTexObjPtr
;
99 /* Texture object in locally shared texture space.
101 #ifndef RADEON_COMMON_FOR_R300
102 struct radeon_tex_obj
{
103 driTextureObject base
;
105 GLuint bufAddr
; /* Offset to start of locally
106 shared texture block */
108 GLuint dirty_state
; /* Flags (1 per texunit) for
109 whether or not this texobj
110 has dirty hardware state
111 (pp_*) that needs to be
115 drm_radeon_tex_image_t image
[6][RADEON_MAX_TEXTURE_LEVELS
];
116 /* Six, for the cube faces */
118 GLboolean image_override
; /* Image overridden by GLX_EXT_tfp */
120 GLuint pp_txfilter
; /* hardware register values */
122 GLuint pp_txformat_x
;
123 GLuint pp_txoffset
; /* Image location in texmem.
124 All cube faces follow. */
125 GLuint pp_txsize
; /* npot only */
126 GLuint pp_txpitch
; /* npot only */
127 GLuint pp_border_color
;
128 GLuint pp_cubic_faces
; /* cube face 1,2,3,4 log2 sizes */
130 GLboolean border_fallback
;
132 GLuint tile_bits
; /* hw texture tile bits used on this texture */
136 /* Need refcounting on dma buffers:
138 struct radeon_dma_buffer
{
139 int refcount
; /* the number of retained regions in buf */
143 /* A retained region, eg vertices for indexed vertices.
145 struct radeon_dma_region
{
146 struct radeon_dma_buffer
*buf
;
147 char *address
; /* == buf->address */
148 int start
, end
, ptr
; /* offsets from start of buf */
156 /* Active dma region. Allocations for vertices and retained
157 * regions come from here. Also used for emitting random vertices,
158 * these may be flushed by calling flush_current();
160 struct radeon_dma_region current
;
162 void (*flush
)( GLcontext
*ctx
);
164 char *buf0_address
; /* start of buf[0], for index calcs */
165 GLuint nr_released_bufs
; /* flush after so many buffers released */
168 struct radeon_ioctl
{
169 GLuint vertex_offset
;
173 #define RADEON_MAX_PRIMS 64
181 static INLINE GLuint
radeonPackColor(GLuint cpp
,
182 GLubyte r
, GLubyte g
,
183 GLubyte b
, GLubyte a
)
187 return PACK_COLOR_565(r
, g
, b
);
189 return PACK_COLOR_8888(a
, r
, g
, b
);
195 #define MAX_CMD_BUF_SZ (16*1024)
197 struct radeon_store
{
200 char cmd_buf
[MAX_CMD_BUF_SZ
];
205 struct radeon_dri_mirror
{
206 __DRIcontextPrivate
*context
; /* DRI context */
207 __DRIscreenPrivate
*screen
; /* DRI screen */
210 * DRI drawable bound to this context for drawing.
212 __DRIdrawablePrivate
*drawable
;
215 * DRI drawable bound to this context for reading.
217 __DRIdrawablePrivate
*readable
;
219 drm_context_t hwContext
;
220 drm_hw_lock_t
*hwLock
;
225 #define DEBUG_TEXTURE 0x001
226 #define DEBUG_STATE 0x002
227 #define DEBUG_IOCTL 0x004
228 #define DEBUG_PRIMS 0x008
229 #define DEBUG_VERTS 0x010
230 #define DEBUG_FALLBACKS 0x020
231 #define DEBUG_VFMT 0x040
232 #define DEBUG_CODEGEN 0x080
233 #define DEBUG_VERBOSE 0x100
234 #define DEBUG_DRI 0x200
235 #define DEBUG_DMA 0x400
236 #define DEBUG_SANITY 0x800
237 #define DEBUG_SYNC 0x1000
238 #define DEBUG_PIXEL 0x2000
239 #define DEBUG_MEMORY 0x4000
243 typedef void (*radeon_tri_func
) (radeonContextPtr
,
245 radeonVertex
*, radeonVertex
*);
247 typedef void (*radeon_line_func
) (radeonContextPtr
,
248 radeonVertex
*, radeonVertex
*);
250 typedef void (*radeon_point_func
) (radeonContextPtr
, radeonVertex
*);
252 struct radeon_state
{
253 struct radeon_colorbuffer_state color
;
254 struct radeon_depthbuffer_state depth
;
255 struct radeon_scissor_state scissor
;
256 struct radeon_stencilbuffer_state stencil
;
259 struct radeon_context
{
261 radeonScreenPtr radeonScreen
; /* Screen private DRI data */
263 /* Texture object bookkeeping
266 driTexHeap
* texture_heaps
[ RADEON_NR_TEX_HEAPS
];
267 driTextureObject swapped
;
269 float initialMaxAnisotropy
;
271 /* Rasterization and vertex state:
276 DECLARE_RENDERINPUTS(tnl_index_bitset
); /* index of bits for last tnl_install_attrs */
281 /* Drawable, cliprect and scissor information */
282 GLuint numClipRects
; /* Cliprects for the draw buffer */
283 drm_clip_rect_t
*pClipRects
;
284 unsigned int lastStamp
;
285 GLboolean lost_context
;
286 drm_radeon_sarea_t
*sarea
; /* Private SAREA data */
288 /* Mirrors of some DRI state */
289 struct radeon_dri_mirror dri
;
295 drm_radeon_irq_wait_t iw
;
299 int64_t swap_missed_ust
;
302 GLuint swap_missed_count
;
304 /* Derived state - for r300 only */
305 struct radeon_state state
;
307 /* Configuration cache
309 driOptionCache optionCache
;
312 void (*get_lock
)(radeonContextPtr radeon
);
313 void (*update_viewport_offset
)(GLcontext
*ctx
);
314 void (*flush
)(GLcontext
*ctx
);
315 void (*set_all_dirty
)(GLcontext
*ctx
);
316 void (*update_draw_buffer
)(GLcontext
*ctx
);
320 #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
322 /* ================================================================
328 extern int RADEON_DEBUG
;
330 #define RADEON_DEBUG 0