Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1901 | serge | 1 | /* |
2 | * Mesa 3-D graphics library |
||
3 | * Version: 7.5 |
||
4 | * |
||
5 | * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. |
||
6 | * Copyright (C) 2009 VMware, Inc. All Rights Reserved. |
||
7 | * |
||
8 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
9 | * copy of this software and associated documentation files (the "Software"), |
||
10 | * to deal in the Software without restriction, including without limitation |
||
11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
12 | * and/or sell copies of the Software, and to permit persons to whom the |
||
13 | * Software is furnished to do so, subject to the following conditions: |
||
14 | * |
||
15 | * The above copyright notice and this permission notice shall be included |
||
16 | * in all copies or substantial portions of the Software. |
||
17 | * |
||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
||
19 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||
21 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
||
22 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
||
23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
24 | */ |
||
25 | |||
26 | |||
27 | #ifndef S_SPAN_H |
||
28 | #define S_SPAN_H |
||
29 | |||
30 | |||
31 | #include "swrast.h" |
||
32 | |||
33 | |||
34 | /** |
||
35 | * \defgroup SpanFlags |
||
36 | * Special bitflags to describe span data. |
||
37 | * |
||
38 | * In general, the point/line/triangle functions interpolate/emit the |
||
39 | * attributes specified by swrast->_ActiveAttribs (i.e. FRAT_BIT_* values). |
||
40 | * Some things don't fit into that, though, so we have these flags. |
||
41 | */ |
||
42 | /*@{*/ |
||
43 | #define SPAN_RGBA 0x01 /**< interpMask and arrayMask */ |
||
44 | #define SPAN_Z 0x02 /**< interpMask and arrayMask */ |
||
45 | #define SPAN_FLAT 0x04 /**< interpMask: flat shading? */ |
||
46 | #define SPAN_XY 0x08 /**< array.x[], y[] valid? */ |
||
47 | #define SPAN_MASK 0x10 /**< was array.mask[] filled in by caller? */ |
||
48 | #define SPAN_LAMBDA 0x20 /**< array.lambda[] valid? */ |
||
49 | #define SPAN_COVERAGE 0x40 /**< array.coverage[] valid? */ |
||
50 | /*@}*/ |
||
51 | |||
52 | |||
53 | /** |
||
54 | * \sw_span_arrays |
||
55 | * \brief Arrays of fragment values. |
||
56 | * |
||
57 | * These will either be computed from the span x/xStep values or |
||
58 | * filled in by glDraw/CopyPixels, etc. |
||
59 | * These arrays are separated out of sw_span to conserve memory. |
||
60 | */ |
||
61 | typedef struct sw_span_arrays |
||
62 | { |
||
63 | /** Per-fragment attributes (indexed by FRAG_ATTRIB_* tokens) */ |
||
64 | /* XXX someday look at transposing first two indexes for better memory |
||
65 | * access pattern. |
||
66 | */ |
||
67 | GLfloat attribs[FRAG_ATTRIB_MAX][MAX_WIDTH][4]; |
||
68 | |||
69 | /** This mask indicates which fragments are alive or culled */ |
||
70 | GLubyte mask[MAX_WIDTH]; |
||
71 | |||
72 | GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */ |
||
73 | |||
74 | /** Attribute arrays that don't fit into attribs[] array above */ |
||
75 | /*@{*/ |
||
76 | GLubyte rgba8[MAX_WIDTH][4]; |
||
77 | GLushort rgba16[MAX_WIDTH][4]; |
||
78 | GLchan (*rgba)[4]; /** either == rgba8 or rgba16 */ |
||
79 | GLint x[MAX_WIDTH]; /**< fragment X coords */ |
||
80 | GLint y[MAX_WIDTH]; /**< fragment Y coords */ |
||
81 | GLuint z[MAX_WIDTH]; /**< fragment Z coords */ |
||
82 | GLuint index[MAX_WIDTH]; /**< Color indexes */ |
||
83 | GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */ |
||
84 | GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ |
||
85 | /*@}*/ |
||
86 | } SWspanarrays; |
||
87 | |||
88 | |||
89 | /** |
||
90 | * The SWspan structure describes the colors, Z, fogcoord, texcoords, |
||
91 | * etc for either a horizontal run or an array of independent pixels. |
||
92 | * We can either specify a base/step to indicate interpolated values, or |
||
93 | * fill in explicit arrays of values. The interpMask and arrayMask bitfields |
||
94 | * indicate which attributes are active interpolants or arrays, respectively. |
||
95 | * |
||
96 | * It would be interesting to experiment with multiprocessor rasterization |
||
97 | * with this structure. The triangle rasterizer could simply emit a |
||
98 | * stream of these structures which would be consumed by one or more |
||
99 | * span-processing threads which could run in parallel. |
||
100 | */ |
||
101 | typedef struct sw_span |
||
102 | { |
||
103 | /** Coord of first fragment in horizontal span/run */ |
||
104 | GLint x, y; |
||
105 | |||
106 | /** Number of fragments in the span */ |
||
107 | GLuint end; |
||
108 | |||
109 | /** for clipping left edge of spans */ |
||
110 | GLuint leftClip; |
||
111 | |||
112 | /** This flag indicates that mask[] array is effectively filled with ones */ |
||
113 | GLboolean writeAll; |
||
114 | |||
115 | /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */ |
||
116 | GLenum primitive; |
||
117 | |||
118 | /** 0 = front-facing span, 1 = back-facing span (for two-sided stencil) */ |
||
119 | GLuint facing; |
||
120 | |||
121 | /** |
||
122 | * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates |
||
123 | * which of the attrStart/StepX/StepY variables are relevant. |
||
124 | */ |
||
125 | GLbitfield interpMask; |
||
126 | |||
127 | /** Fragment attribute interpolants */ |
||
128 | GLfloat attrStart[FRAG_ATTRIB_MAX][4]; /**< initial value */ |
||
129 | GLfloat attrStepX[FRAG_ATTRIB_MAX][4]; /**< dvalue/dx */ |
||
130 | GLfloat attrStepY[FRAG_ATTRIB_MAX][4]; /**< dvalue/dy */ |
||
131 | |||
132 | /* XXX the rest of these will go away eventually... */ |
||
133 | |||
134 | /* For horizontal spans, step is the partial derivative wrt X. |
||
135 | * For lines, step is the delta from one fragment to the next. |
||
136 | */ |
||
137 | GLfixed red, redStep; |
||
138 | GLfixed green, greenStep; |
||
139 | GLfixed blue, blueStep; |
||
140 | GLfixed alpha, alphaStep; |
||
141 | GLfixed index, indexStep; |
||
142 | GLfixed z, zStep; /**< XXX z should probably be GLuint */ |
||
143 | GLfixed intTex[2], intTexStep[2]; /**< (s,t) for unit[0] only */ |
||
144 | |||
145 | /** |
||
146 | * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates |
||
147 | * which of the fragment arrays in the span_arrays struct are relevant. |
||
148 | */ |
||
149 | GLbitfield arrayMask; |
||
150 | |||
151 | GLbitfield arrayAttribs; |
||
152 | |||
153 | /** |
||
154 | * We store the arrays of fragment values in a separate struct so |
||
155 | * that we can allocate sw_span structs on the stack without using |
||
156 | * a lot of memory. The span_arrays struct is about 1.4MB while the |
||
157 | * sw_span struct is only about 512 bytes. |
||
158 | */ |
||
159 | SWspanarrays *array; |
||
160 | } SWspan; |
||
161 | |||
162 | |||
163 | |||
164 | #define INIT_SPAN(S, PRIMITIVE) \ |
||
165 | do { \ |
||
166 | (S).primitive = (PRIMITIVE); \ |
||
167 | (S).interpMask = 0x0; \ |
||
168 | (S).arrayMask = 0x0; \ |
||
169 | (S).arrayAttribs = 0x0; \ |
||
170 | (S).end = 0; \ |
||
171 | (S).leftClip = 0; \ |
||
172 | (S).facing = 0; \ |
||
173 | (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ |
||
174 | } while (0) |
||
175 | |||
176 | |||
177 | |||
178 | extern void |
||
179 | _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span); |
||
180 | |||
181 | extern void |
||
182 | _swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span ); |
||
183 | |||
184 | extern GLfloat |
||
185 | _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, |
||
186 | GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, |
||
187 | GLfloat s, GLfloat t, GLfloat q, GLfloat invQ); |
||
188 | |||
189 | |||
190 | extern void |
||
191 | _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span); |
||
192 | |||
193 | |||
194 | extern void |
||
195 | _swrast_read_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, |
||
196 | GLuint n, GLint x, GLint y, GLenum type, GLvoid *rgba); |
||
197 | |||
198 | extern void |
||
199 | _swrast_get_values(struct gl_context *ctx, struct gl_renderbuffer *rb, |
||
200 | GLuint count, const GLint x[], const GLint y[], |
||
201 | void *values, GLuint valueSize); |
||
202 | |||
203 | extern void |
||
204 | _swrast_put_row(struct gl_context *ctx, struct gl_renderbuffer *rb, |
||
205 | GLuint count, GLint x, GLint y, |
||
206 | const GLvoid *values, GLuint valueSize); |
||
207 | |||
208 | extern void |
||
209 | _swrast_get_row(struct gl_context *ctx, struct gl_renderbuffer *rb, |
||
210 | GLuint count, GLint x, GLint y, |
||
211 | GLvoid *values, GLuint valueSize); |
||
212 | |||
213 | |||
214 | extern void * |
||
215 | _swrast_get_dest_rgba(struct gl_context *ctx, struct gl_renderbuffer *rb, |
||
216 | SWspan *span); |
||
217 | |||
218 | #endif>>>>>>>>>>>>>>>>>>> |