Committing in .
[mesa.git] / src / mesa / swrast / s_context.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 3.5
4 *
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keithw@valinux.com>
26 */
27
28 #ifndef S_CONTEXT_H
29 #define S_CONTEXT_H
30
31 #include "mtypes.h"
32 #include "swrast.h"
33
34 /*
35 * For texture sampling:
36 */
37 typedef void (*TextureSampleFunc)( GLcontext *ctx, GLuint texUnit,
38 const struct gl_texture_object *tObj,
39 GLuint n,
40 const GLfloat s[], const GLfloat t[],
41 const GLfloat u[], const GLfloat lambda[],
42 GLchan rgba[][4] );
43
44
45
46 /*
47 * Blending function
48 */
49 #ifdef USE_MMX_ASM
50 typedef void (_ASMAPIP blend_func)( GLcontext *ctx, GLuint n,
51 const GLubyte mask[],
52 GLchan src[][4], CONST GLchan dst[][4] );
53 #else
54 typedef void (*blend_func)( GLcontext *ctx, GLuint n, const GLubyte mask[],
55 GLchan src[][4], CONST GLchan dst[][4] );
56 #endif
57
58 typedef void (*swrast_point_func)( GLcontext *ctx, const SWvertex *);
59
60 typedef void (*swrast_line_func)( GLcontext *ctx,
61 const SWvertex *, const SWvertex *);
62
63 typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
64 const SWvertex *, const SWvertex *);
65
66 typedef void (*swrast_quad_func)( GLcontext *ctx,
67 const SWvertex *, const SWvertex *,
68 const SWvertex *, const SWvertex *);
69
70
71
72 /*
73 * Bitmasks to indicate which rasterization options are enabled (RasterMask)
74 */
75 #define ALPHATEST_BIT 0x001 /* Alpha-test pixels */
76 #define BLEND_BIT 0x002 /* Blend pixels */
77 #define DEPTH_BIT 0x004 /* Depth-test pixels */
78 #define FOG_BIT 0x008 /* Fog pixels */
79 #define LOGIC_OP_BIT 0x010 /* Apply logic op in software */
80 #define SCISSOR_BIT 0x020 /* Scissor pixels */
81 #define STENCIL_BIT 0x040 /* Stencil pixels */
82 #define MASKING_BIT 0x080 /* Do glColorMask or glIndexMask */
83 #define ALPHABUF_BIT 0x100 /* Using software alpha buffer */
84 #define WINCLIP_BIT 0x200 /* Clip pixels/primitives to window */
85 #define MULTI_DRAW_BIT 0x400 /* Write to more than one color- */
86 /* buffer or no buffers. */
87 #define OCCLUSION_BIT 0x800 /* GL_HP_occlusion_test enabled */
88 #define TEXTURE_BIT 0x1000 /* Texturing really enabled */
89
90
91 #define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \
92 _NEW_SCISSOR| \
93 _NEW_COLOR| \
94 _NEW_DEPTH| \
95 _NEW_FOG| \
96 _NEW_STENCIL| \
97 _NEW_TEXTURE| \
98 _NEW_VIEWPORT| \
99 _NEW_DEPTH)
100
101
102
103 typedef struct
104 {
105 /* Configuration mechanisms to make software rasterizer match
106 * characteristics of the hardware rasterizer (if present):
107 */
108 GLboolean AllowVertexFog;
109 GLboolean AllowPixelFog;
110
111 /* Derived values, invalidated on statechanges, updated from
112 * _swrast_validate_derived():
113 */
114 GLuint _RasterMask;
115 GLboolean _MultiTextureEnabled;
116 GLuint _MinMagThresh[MAX_TEXTURE_UNITS];
117 GLfloat _backface_sign;
118 GLboolean _PreferPixelFog;
119
120 /* Accum buffer temporaries.
121 */
122 GLboolean _IntegerAccumMode; /* Storing unscaled integers? */
123 GLfloat _IntegerAccumScaler; /* Implicit scale factor */
124
125
126 /* Working values:
127 */
128 struct pixel_buffer* PB;
129 GLuint StippleCounter; /* Line stipple counter */
130 GLuint NewState;
131 GLuint StateChanges;
132
133 /* Mechanism to allow driver (like X11) to register further
134 * software rasterization routines.
135 */
136 void (*choose_point)( GLcontext * );
137 void (*choose_line)( GLcontext * );
138 void (*choose_triangle)( GLcontext * );
139 void (*choose_quad)( GLcontext * );
140
141 GLuint invalidate_point;
142 GLuint invalidate_line;
143 GLuint invalidate_triangle;
144 GLuint invalidate_quad;
145
146
147 /* Function pointers for dispatch behind public entrypoints.
148 */
149 void (*InvalidateState)( GLcontext *ctx, GLuint new_state );
150
151 swrast_point_func Point;
152 swrast_line_func Line;
153 swrast_tri_func Triangle;
154 swrast_quad_func Quad;
155
156 /* Internal hooks, kept uptodate by the same mechanism as above.
157 */
158 blend_func BlendFunc;
159 TextureSampleFunc TextureSample[MAX_TEXTURE_UNITS];
160
161 } SWcontext;
162
163
164 void
165 _swrast_validate_derived( GLcontext *ctx );
166
167
168 #define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context)
169
170
171
172 #endif