summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h
blob: 030864f4261c0c6536823a9fe387e60ff5a9eb10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* $XFree86$ */
/**************************************************************************

Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
                     VA Linux Systems Inc., Fremont, California.

All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
on the rights to use, copy, modify, merge, publish, distribute, sub
license, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

**************************************************************************/

/*
 * Authors:
 *   Kevin E. Martin <martin@valinux.com>
 *   Gareth Hughes <gareth@valinux.com>
 *
 */

#ifndef __RADEON_IOCTL_H__
#define __RADEON_IOCTL_H__

#ifdef GLX_DIRECT_RENDERING

#include "radeon_dri.h"
#include "radeon_lock.h"

#include "xf86drm.h"
#include "xf86drmRadeon.h"

#define RADEON_BUFFER_MAX_DWORDS	(RADEON_BUFFER_SIZE / sizeof(CARD32))


extern drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa );
extern void radeonEmitPrim( radeonContextPtr rmesa );
extern void radeonFlushPrims( radeonContextPtr rmesa );
extern void radeonFlushPrimsLocked( radeonContextPtr rmesa );
extern void radeonFlushPrimsGetBuffer( radeonContextPtr rmesa );
extern void radeonFireBlitLocked( radeonContextPtr rmesa,
				  drmBufPtr buffer,
				  GLint offset, GLint pitch, GLint format,
				  GLint x, GLint y,
				  GLint width, GLint height );
extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable );
extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
extern void radeonPerformanceCounters( radeonContextPtr rmesa );
extern void radeonPerformanceBoxesLocked( radeonContextPtr rmesa );
extern void radeonInitIoctlFuncs( GLcontext *ctx );
extern void radeonReleaseRetainedBuffer( radeonContextPtr rmesa );


/* ================================================================
 * Helper macros:
 */

/* Can accomodate several state changes and primitive changes without
 * actually firing the buffer.
 */
#define RADEON_STATECHANGE( rmesa, flag )				\
do {									\
   if ( 0 ) radeonPrintDirty( __FUNCTION__, flag );			\
   if ( rmesa->dma.low != rmesa->dma.last )				\
      radeonEmitPrim( rmesa );						\
   rmesa->state.hw.dirty |= flag;					\
} while (0)


/* Fire the buffered vertices no matter what.
 */
#define RADEON_FIREVERTICES( rmesa )					\
do {									\
   if ( rmesa->store.primnr || rmesa->dma.low != rmesa->dma.last ) {	\
      if ( 0 )								\
	 fprintf( stderr, "RADEON_FIREVERTICES in "__FUNCTION__"\n" );	\
      radeonFlushPrims( rmesa );					\
   }									\
} while (0)


static __inline void *radeonAllocDmaLow( radeonContextPtr rmesa,
					 int bytes, const char *where )
{
   if ( rmesa->dma.low + bytes > rmesa->dma.high ) {
      if (0) fprintf( stderr, "%s flush for %d (%d/%d/%d)\n",
		      where, bytes, rmesa->dma.last,
		      rmesa->dma.low, rmesa->dma.high );
      radeonFlushPrimsGetBuffer( rmesa );
   }

   {
      GLubyte *head = rmesa->dma.address + rmesa->dma.low;
      if (0) fprintf( stderr, "%s: alloc %d (%d/%d/%d)\n",
		      where, bytes, rmesa->dma.last,
		      rmesa->dma.low, rmesa->dma.high );
      rmesa->dma.low += bytes;
      return head;
   }
}

static __inline void *radeonAllocDmaHigh( radeonContextPtr rmesa, int bytes )
{
   if ( rmesa->dma.low + bytes > rmesa->dma.high )
      radeonFlushPrimsGetBuffer( rmesa );

   rmesa->dma.high -= bytes;
   return (void *)(rmesa->dma.address + rmesa->dma.high);
}



#endif
#endif /* __RADEON_IOCTL_H__ */