summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
blob: 0aafb1e3773e334b65057801266c6ee61004a477 (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
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.h,v 1.4 2000/08/28 02:43:12 tsi Exp $ */

#ifndef MGA_IOCTL_H
#define MGA_IOCTL_H

#include "mgalib.h"
#include "mga_xmesa.h"

GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
		     GLint cx, GLint cy, GLint cw, GLint ch ); 


void mgaSwapBuffers( mgaContextPtr mmesa ); 



mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );


void mgaGetILoadBufferLocked( mgaContextPtr mmesa );


void mgaFireILoadLocked( mgaContextPtr mmesa, 
			 GLuint offset, GLuint length );

void mgaWaitAgeLocked( mgaContextPtr mmesa, int age );
void mgaWaitAge( mgaContextPtr mmesa, int age );
int mgaUpdateLock( mgaContextPtr mmesa, drmLockFlags flags );

void mgaFlushVertices( mgaContextPtr mmesa ); 
void mgaFlushVerticesLocked( mgaContextPtr mmesa );


void mgaFireEltsLocked( mgaContextPtr mmesa, 
			GLuint start, 
			GLuint end,
			GLuint discard );

void mgaGetEltBufLocked( mgaContextPtr mmesa );
void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer );

void mgaFlushEltsLocked( mgaContextPtr mmesa );
void mgaFlushElts( mgaContextPtr mmesa ) ;


/* upload texture
 */

void mgaDDFinish( GLcontext *ctx );

void mgaDDInitIoctlFuncs( GLcontext *ctx );
 
#define FLUSH_BATCH(mmesa) do {						\
        if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)  				\
              fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__);	\
	if (mmesa->vertex_dma_buffer) mgaFlushVertices(mmesa);		\
	else if (mmesa->next_elt != mmesa->first_elt) mgaFlushElts(mmesa);	        	\
} while (0)

extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa );

static __inline
mgaUI32 *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords )
{
   int bytes = dwords * 4;
   mgaUI32 *head;

   if (!mmesa->vertex_dma_buffer) {
      LOCK_HARDWARE( mmesa );

      if (mmesa->first_elt != mmesa->next_elt) 
	 mgaFlushEltsLocked(mmesa);

      mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
      UNLOCK_HARDWARE( mmesa );
   } else if (mmesa->vertex_dma_buffer->used + bytes > 
	      mmesa->vertex_dma_buffer->total) {
      LOCK_HARDWARE( mmesa );
      mgaFlushVerticesLocked( mmesa );
      mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
      UNLOCK_HARDWARE( mmesa );
   }

   head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + 
		      mmesa->vertex_dma_buffer->used);

   mmesa->vertex_dma_buffer->used += bytes;
   return head;
}


#endif