Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
57 | pj | 1 | /* $Id: s_context.h,v 1.1 2003-02-28 11:49:41 pj Exp $ */ |
2 | |||
3 | /* |
||
4 | * Mesa 3-D graphics library |
||
5 | * Version: 4.1 |
||
6 | * |
||
7 | * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. |
||
8 | * |
||
9 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
10 | * copy of this software and associated documentation files (the "Software"), |
||
11 | * to deal in the Software without restriction, including without limitation |
||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
13 | * and/or sell copies of the Software, and to permit persons to whom the |
||
14 | * Software is furnished to do so, subject to the following conditions: |
||
15 | * |
||
16 | * The above copyright notice and this permission notice shall be included |
||
17 | * in all copies or substantial portions of the Software. |
||
18 | * |
||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
25 | * |
||
26 | * Authors: |
||
27 | * Keith Whitwell <keith@tungstengraphics.com> |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * \file swrast/s_context.h |
||
32 | * \brief fill in description |
||
33 | * \author Keith Whitwell <keith@tungstengraphics.com> |
||
34 | */ |
||
35 | |||
36 | #ifndef S_CONTEXT_H |
||
37 | #define S_CONTEXT_H |
||
38 | |||
39 | #include "mtypes.h" |
||
40 | #include "swrast.h" |
||
41 | |||
42 | /* |
||
43 | * For texture sampling: |
||
44 | */ |
||
45 | typedef void (*TextureSampleFunc)( GLcontext *ctx, GLuint texUnit, |
||
46 | const struct gl_texture_object *tObj, |
||
47 | GLuint n, GLfloat texcoords[][4], |
||
48 | const GLfloat lambda[], GLchan rgba[][4] ); |
||
49 | |||
50 | |||
51 | |||
52 | /* |
||
53 | * Blending function |
||
54 | */ |
||
55 | #ifdef USE_MMX_ASM |
||
56 | typedef void (_ASMAPIP blend_func)( GLcontext *ctx, GLuint n, |
||
57 | const GLubyte mask[], |
||
58 | GLchan src[][4], CONST GLchan dst[][4] ); |
||
59 | #else |
||
60 | typedef void (*blend_func)( GLcontext *ctx, GLuint n, const GLubyte mask[], |
||
61 | GLchan src[][4], CONST GLchan dst[][4] ); |
||
62 | #endif |
||
63 | |||
64 | typedef void (*swrast_point_func)( GLcontext *ctx, const SWvertex *); |
||
65 | |||
66 | typedef void (*swrast_line_func)( GLcontext *ctx, |
||
67 | const SWvertex *, const SWvertex *); |
||
68 | |||
69 | typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *, |
||
70 | const SWvertex *, const SWvertex *); |
||
71 | |||
72 | |||
73 | /** \defgroup Bitmasks |
||
74 | * Bitmasks to indicate which rasterization options are enabled |
||
75 | * (RasterMask) |
||
76 | */ |
||
77 | /*@{*/ |
||
78 | #define ALPHATEST_BIT 0x001 /**< Alpha-test pixels */ |
||
79 | #define BLEND_BIT 0x002 /**< Blend pixels */ |
||
80 | #define DEPTH_BIT 0x004 /**< Depth-test pixels */ |
||
81 | #define FOG_BIT 0x008 /**< Fog pixels */ |
||
82 | #define LOGIC_OP_BIT 0x010 /**< Apply logic op in software */ |
||
83 | #define CLIP_BIT 0x020 /**< Scissor or window clip pixels */ |
||
84 | #define STENCIL_BIT 0x040 /**< Stencil pixels */ |
||
85 | #define MASKING_BIT 0x080 /**< Do glColorMask or glIndexMask */ |
||
86 | #define ALPHABUF_BIT 0x100 /**< Using software alpha buffer */ |
||
87 | #define MULTI_DRAW_BIT 0x400 /**< Write to more than one color- */ |
||
88 | /**< buffer or no buffers. */ |
||
89 | #define OCCLUSION_BIT 0x800 /**< GL_HP_occlusion_test enabled */ |
||
90 | #define TEXTURE_BIT 0x1000 /**< Texturing really enabled */ |
||
91 | /*@}*/ |
||
92 | |||
93 | #define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \ |
||
94 | _NEW_SCISSOR| \ |
||
95 | _NEW_COLOR| \ |
||
96 | _NEW_DEPTH| \ |
||
97 | _NEW_FOG| \ |
||
98 | _NEW_STENCIL| \ |
||
99 | _NEW_TEXTURE| \ |
||
100 | _NEW_VIEWPORT| \ |
||
101 | _NEW_DEPTH) |
||
102 | |||
103 | |||
104 | /** |
||
105 | * \struct SWcontext |
||
106 | * \brief SWContext? |
||
107 | */ |
||
108 | typedef struct |
||
109 | { |
||
110 | /** Driver interface: |
||
111 | */ |
||
112 | struct swrast_device_driver Driver; |
||
113 | |||
114 | /** Configuration mechanisms to make software rasterizer match |
||
115 | * characteristics of the hardware rasterizer (if present): |
||
116 | */ |
||
117 | GLboolean AllowVertexFog; |
||
118 | GLboolean AllowPixelFog; |
||
119 | |||
120 | /** Derived values, invalidated on statechanges, updated from |
||
121 | * _swrast_validate_derived(): |
||
122 | */ |
||
123 | GLuint _RasterMask; |
||
124 | GLfloat _MinMagThresh[MAX_TEXTURE_UNITS]; |
||
125 | GLfloat _backface_sign; |
||
126 | GLboolean _PreferPixelFog; |
||
127 | GLboolean _AnyTextureCombine; |
||
128 | |||
129 | /* Accum buffer temporaries. |
||
130 | */ |
||
131 | GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */ |
||
132 | GLfloat _IntegerAccumScaler; /**< Implicit scale factor */ |
||
133 | |||
134 | |||
135 | /* Working values: |
||
136 | */ |
||
137 | GLuint StippleCounter; /**< Line stipple counter */ |
||
138 | GLuint NewState; |
||
139 | GLuint StateChanges; |
||
140 | GLenum Primitive; /* current primitive being drawn (ala glBegin) */ |
||
141 | GLuint CurrentBuffer; /* exactly one of FRONT_LEFT_BIT, BACK_LEFT_BIT, etc*/ |
||
142 | |||
143 | /** Mechanism to allow driver (like X11) to register further |
||
144 | * software rasterization routines. |
||
145 | */ |
||
146 | /*@{*/ |
||
147 | void (*choose_point)( GLcontext * ); |
||
148 | void (*choose_line)( GLcontext * ); |
||
149 | void (*choose_triangle)( GLcontext * ); |
||
150 | |||
151 | GLuint invalidate_point; |
||
152 | GLuint invalidate_line; |
||
153 | GLuint invalidate_triangle; |
||
154 | /*@}*/ |
||
155 | |||
156 | /** Function pointers for dispatch behind public entrypoints. */ |
||
157 | /*@{*/ |
||
158 | void (*InvalidateState)( GLcontext *ctx, GLuint new_state ); |
||
159 | |||
160 | swrast_point_func Point; |
||
161 | swrast_line_func Line; |
||
162 | swrast_tri_func Triangle; |
||
163 | /*@}*/ |
||
164 | |||
165 | /** |
||
166 | * Placeholders for when separate specular (or secondary color) is |
||
167 | * enabled but texturing is not. |
||
168 | */ |
||
169 | /*@{*/ |
||
170 | swrast_point_func SpecPoint; |
||
171 | swrast_line_func SpecLine; |
||
172 | swrast_tri_func SpecTriangle; |
||
173 | /*@}*/ |
||
174 | |||
175 | /** |
||
176 | * Typically, we'll allocate a sw_span structure as a local variable |
||
177 | * and set its 'array' pointer to point to this object. The reason is |
||
178 | * this object is big and causes problems when allocated on the stack |
||
179 | * on some systems. |
||
180 | */ |
||
181 | struct span_arrays *SpanArrays; |
||
182 | |||
183 | /** |
||
184 | * Used to buffer N GL_POINTS, instead of rendering one by one. |
||
185 | */ |
||
186 | struct sw_span PointSpan; |
||
187 | |||
188 | /** Internal hooks, kept uptodate by the same mechanism as above. |
||
189 | */ |
||
190 | blend_func BlendFunc; |
||
191 | TextureSampleFunc TextureSample[MAX_TEXTURE_UNITS]; |
||
192 | |||
193 | /** Buffer for saving the sampled texture colors. |
||
194 | * Needed for GL_ARB_texture_env_crossbar implementation. |
||
195 | */ |
||
196 | GLchan *TexelBuffer; |
||
197 | |||
198 | } SWcontext; |
||
199 | |||
200 | |||
201 | extern void |
||
202 | _swrast_validate_derived( GLcontext *ctx ); |
||
203 | |||
204 | |||
205 | #define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context) |
||
206 | |||
207 | #define RENDER_START(SWctx, GLctx) \ |
||
208 | do { \ |
||
209 | if ((SWctx)->Driver.SpanRenderStart) { \ |
||
210 | (*(SWctx)->Driver.SpanRenderStart)(GLctx); \ |
||
211 | } \ |
||
212 | } while (0) |
||
213 | |||
214 | #define RENDER_FINISH(SWctx, GLctx) \ |
||
215 | do { \ |
||
216 | if ((SWctx)->Driver.SpanRenderFinish) { \ |
||
217 | (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \ |
||
218 | } \ |
||
219 | } while (0) |
||
220 | |||
221 | |||
222 | |||
223 | /* |
||
224 | * XXX these macros are just bandages for now in order to make |
||
225 | * CHAN_BITS==32 compile cleanly. |
||
226 | * These should probably go elsewhere at some point. |
||
227 | */ |
||
228 | #if CHAN_TYPE == GL_FLOAT |
||
229 | #define ChanToFixed(X) (X) |
||
230 | #define FixedToChan(X) (X) |
||
231 | #else |
||
232 | #define ChanToFixed(X) IntToFixed(X) |
||
233 | #define FixedToChan(X) FixedToInt(X) |
||
234 | #endif |
||
235 | |||
236 | #endif |