fbSwapBuffers needs to return a status
[mesa.git] / src / mesa / drivers / dri / r300 / r300_cmdbuf.h
1 /*
2 Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
3
4 The Weather Channel (TM) funded Tungsten Graphics to develop the
5 initial release of the Radeon 8500 driver under the XFree86 license.
6 This notice must be preserved.
7
8 Permission is hereby granted, free of charge, to any person obtaining
9 a copy of this software and associated documentation files (the
10 "Software"), to deal in the Software without restriction, including
11 without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense, and/or sell copies of the Software, and to
13 permit persons to whom the Software is furnished to do so, subject to
14 the following conditions:
15
16 The above copyright notice and this permission notice (including the
17 next paragraph) shall be included in all copies or substantial
18 portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
24 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 **************************************************************************/
29
30 /*
31 * Authors:
32 * Nicolai Haehnle <prefect_@gmx.net>
33 */
34
35 #ifndef __R300_CMDBUF_H__
36 #define __R300_CMDBUF_H__
37
38 #include "r300_context.h"
39
40
41 extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller);
42 extern int r300FlushCmdBuf(r300ContextPtr r300, const char* caller);
43
44 extern void r300EmitState(r300ContextPtr r300);
45
46 extern void r300InitCmdBuf(r300ContextPtr r300);
47 extern void r300DestroyCmdBuf(r300ContextPtr r300);
48
49 extern void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset);
50
51
52 /**
53 * Make sure that enough space is available in the command buffer
54 * by flushing if necessary.
55 */
56 static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
57 int dwords, const char* caller)
58 {
59 assert(dwords < r300->cmdbuf.size);
60
61 if (r300->cmdbuf.count_used + dwords > r300->cmdbuf.size)
62 r300FlushCmdBuf(r300, caller);
63 }
64
65
66 /**
67 * Allocate the given number of dwords in the command buffer and return
68 * a pointer to the allocated area.
69 * When necessary, these functions cause a flush. r300AllocCmdBuf() also
70 * causes state reemission after a flush. This is necessary to ensure
71 * correct hardware state after an unlock.
72 */
73 static __inline__ uint32_t* r300RawAllocCmdBuf(r300ContextPtr r300,
74 int dwords, const char* caller)
75 {
76 uint32_t* ptr;
77
78 r300EnsureCmdBufSpace(r300, dwords, caller);
79
80 ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
81 r300->cmdbuf.count_used += dwords;
82 return ptr;
83 }
84
85 static __inline__ uint32_t* r300AllocCmdBuf(r300ContextPtr r300,
86 int dwords, const char* caller)
87 {
88 uint32_t* ptr;
89
90 r300EnsureCmdBufSpace(r300, dwords, caller);
91
92 if (!r300->cmdbuf.count_used) {
93 if (RADEON_DEBUG & DEBUG_IOCTL)
94 fprintf(stderr, "Reemit state after flush (from %s)\n",
95 caller);
96 r300EmitState(r300);
97 }
98
99 ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
100 r300->cmdbuf.count_used += dwords;
101 return ptr;
102 }
103
104 extern void r300EmitBlit(r300ContextPtr rmesa,
105 GLuint color_fmt,
106 GLuint src_pitch,
107 GLuint src_offset,
108 GLuint dst_pitch,
109 GLuint dst_offset,
110 GLint srcx, GLint srcy,
111 GLint dstx, GLint dsty, GLuint w, GLuint h);
112
113 extern void r300EmitWait(r300ContextPtr rmesa, GLuint flags);
114 extern void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start);
115 extern void r300EmitVertexShader(r300ContextPtr rmesa);
116 extern void r300EmitPixelShader(r300ContextPtr rmesa);
117
118 #endif /* __R300_CMDBUF_H__ */