ReactOS  0.4.12-dev-375-g61fed54
s_context.h
Go to the documentation of this file.
1 /*
2  * Mesa 3-D graphics library
3  * Version: 6.5.3
4  *
5  * Copyright (C) 1999-2007 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 
25 
43 #ifndef S_CONTEXT_H
44 #define S_CONTEXT_H
45 
46 #include "main/compiler.h"
47 #include "main/mtypes.h"
48 #include "swrast.h"
49 #include "s_span.h"
50 
51 
52 typedef void (*texture_sample_func)(struct gl_context *ctx,
53  const struct gl_texture_object *tObj,
54  GLuint n, const GLfloat texcoords[][4],
55  const GLfloat lambda[], GLfloat rgba[][4]);
56 
57 typedef void (_ASMAPIP blend_func)( struct gl_context *ctx, GLuint n,
58  const GLubyte mask[],
59  GLvoid *src, const GLvoid *dst,
61 
62 typedef void (*swrast_point_func)( struct gl_context *ctx, const SWvertex *);
63 
64 typedef void (*swrast_line_func)( struct gl_context *ctx,
65  const SWvertex *, const SWvertex *);
66 
67 typedef void (*swrast_tri_func)( struct gl_context *ctx, const SWvertex *,
68  const SWvertex *, const SWvertex *);
69 
70 
72  struct gl_texture_object *texObj,
74 
75 
82 #define ALPHATEST_BIT 0x001
83 #define BLEND_BIT 0x002
84 #define DEPTH_BIT 0x004
85 #define FOG_BIT 0x008
86 #define LOGIC_OP_BIT 0x010
87 #define CLIP_BIT 0x020
88 #define STENCIL_BIT 0x040
89 #define MASKING_BIT 0x080
90 #define MULTI_DRAW_BIT 0x400
92 #define TEXTURE_BIT 0x1000
93 #define CLAMPING_BIT 0x8000
95 
96 #define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \
97  _NEW_SCISSOR| \
98  _NEW_COLOR| \
99  _NEW_DEPTH| \
100  _NEW_FOG| \
101  _NEW_STENCIL| \
102  _NEW_TEXTURE| \
103  _NEW_VIEWPORT| \
104  _NEW_DEPTH)
105 
106 
107 struct swrast_texture_image;
108 
109 
113 typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage,
114  GLint col, GLint row, GLint img,
115  GLfloat *texelOut);
116 
117 
124 {
126 
131 
140 
142 };
143 
144 
146 static inline struct swrast_texture_image *
148 {
149  return (struct swrast_texture_image *) img;
150 }
151 
153 static inline const struct swrast_texture_image *
155 {
156  return (const struct swrast_texture_image *) img;
157 }
158 
159 
165 {
167 
176 };
177 
178 
180 static inline struct swrast_renderbuffer *
182 {
183  return (struct swrast_renderbuffer *) img;
184 }
185 
186 
187 
192 typedef struct
193 {
197 
203 
210  GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */
214 
216  GLuint _ActiveAttribs[FRAG_ATTRIB_MAX];
222  GLenum _InterpMode[FRAG_ATTRIB_MAX]; /* GL_FLAT or GL_SMOOTH (for now) */
223 
224  /* Working values:
225  */
229  GLenum Primitive; /* current primitive being drawn (ala glBegin) */
230 
231  void (*InvalidateState)( struct gl_context *ctx, GLbitfield new_state );
232 
248  void (*choose_point)( struct gl_context * );
249  void (*choose_line)( struct gl_context * );
250  void (*choose_triangle)( struct gl_context * );
285 
288  blend_func BlendFunc;
290 
295 
297 
298 } SWcontext;
299 
300 
301 extern void
302 _swrast_validate_derived( struct gl_context *ctx );
303 
304 extern void
306 
307 
309 static inline SWcontext *
311 {
312  return (SWcontext *) ctx->swrast_context;
313 }
314 
316 static inline const SWcontext *
318 {
319  return (const SWcontext *) ctx->swrast_context;
320 }
321 
322 
328 static inline void
330 {
332  if (swrast->Driver.SpanRenderStart)
333  swrast->Driver.SpanRenderStart(ctx);
334 }
335 
336 
338 static inline void
340 {
342  if (swrast->Driver.SpanRenderFinish)
343  swrast->Driver.SpanRenderFinish(ctx);
344 }
345 
346 
347 extern void
349 
350 extern void
352 
353 extern void
354 _swrast_map_textures(struct gl_context *ctx);
355 
356 extern void
358 
359 extern void
360 _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj);
361 
362 extern void
363 _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj);
364 
365 
366 extern void
368 
369 extern void
371 
372 
376 #define RGBA_PIXEL_SIZE(TYPE) \
377  ((TYPE == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) : \
378  ((TYPE == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort) \
379  : 4 * sizeof(GLfloat)))
380 
381 
382 
383 /*
384  * Fixed point arithmetic macros
385  */
386 #ifndef FIXED_FRAC_BITS
387 #define FIXED_FRAC_BITS 11
388 #endif
389 
390 #define FIXED_SHIFT FIXED_FRAC_BITS
391 #define FIXED_ONE (1 << FIXED_SHIFT)
392 #define FIXED_HALF (1 << (FIXED_SHIFT-1))
393 #define FIXED_FRAC_MASK (FIXED_ONE - 1)
394 #define FIXED_INT_MASK (~FIXED_FRAC_MASK)
395 #define FIXED_EPSILON 1
396 #define FIXED_SCALE ((float) FIXED_ONE)
397 #define FIXED_DBL_SCALE ((double) FIXED_ONE)
398 #define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
399 #define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
400 #define IntToFixed(I) ((I) << FIXED_SHIFT)
401 #define FixedToInt(X) ((X) >> FIXED_SHIFT)
402 #define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
403 #define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
404 #define FixedFloor(X) ((X) & FIXED_INT_MASK)
405 #define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
406 #define PosFloatToFixed(X) FloatToFixed(X)
407 #define SignedFloatToFixed(X) FloatToFixed(X)
408 
409 
410 
411 /*
412  * XXX these macros are just bandages for now in order to make
413  * CHAN_BITS==32 compile cleanly.
414  * These should probably go elsewhere at some point.
415  */
416 #if CHAN_TYPE == GL_FLOAT
417 #define ChanToFixed(X) (X)
418 #define FixedToChan(X) (X)
419 #else
420 #define ChanToFixed(X) IntToFixed(X)
421 #define FixedToChan(X) FixedToInt(X)
422 #endif
423 
424 
429 #define ATTRIB_LOOP_BEGIN \
430  { \
431  GLuint a; \
432  for (a = 0; a < swrast->_NumActiveAttribs; a++) { \
433  const GLuint attr = swrast->_ActiveAttribs[a];
434 
435 #define ATTRIB_LOOP_END } }
436 
437 
441 static inline GLubyte *
443 {
444  struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
445  const GLint bpp = _mesa_get_format_bytes(rb->Format);
446  const GLint rowStride = srb->RowStride;
447  assert(x >= 0);
448  assert(y >= 0);
449  /* NOTE: using <= only because of s_tritemp.h which gets a pixel
450  * address but doesn't necessarily access it.
451  */
452  assert(x <= (GLint) rb->Width);
453  assert(y <= (GLint) rb->Height);
454  assert(srb->Map);
455  return (GLubyte *) srb->Map + y * rowStride + x * bpp;
456 }
457 
458 
459 
460 #endif
GLint level
Definition: gl.h:1546
static struct swrast_texture_image * swrast_texture_image(struct gl_texture_image *img)
Definition: s_context.h:147
GLbitfield InvalidateTriangleMask
Definition: s_context.h:240
Public interface to the software rasterization functions.
SWspan PointSpan
Definition: s_context.h:284
Arrays of fragment values.
Definition: s_span.h:68
static const SWcontext * CONST_SWRAST_CONTEXT(const struct gl_context *ctx)
Definition: s_context.h:317
GLboolean AllowVertexFog
Definition: s_context.h:201
void(* swrast_line_func)(struct gl_context *ctx, const SWvertex *, const SWvertex *)
Definition: s_context.h:64
#define assert(x)
Definition: debug.h:53
void _swrast_update_texture_samplers(struct gl_context *ctx)
Definition: s_context.c:346
GLboolean _FogEnabled
Definition: s_context.h:212
GLfloat _BackfaceSign
Definition: s_context.h:208
gl_format Format
Definition: mtypes.h:1351
void _swrast_map_renderbuffers(struct gl_context *ctx)
void _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
Definition: s_texture.c:244
GLbitfield NewState
Definition: s_context.h:227
WORD face[3]
Definition: mesh.c:4747
static SWcontext * SWRAST_CONTEXT(struct gl_context *ctx)
Definition: s_context.h:310
GLuint StateChanges
Definition: s_context.h:228
GLint _mesa_get_format_bytes(gl_format format)
Definition: formats.c:786
Data-structure to handle vertices in the software rasterizer.
Definition: swrast.h:72
swrast_tri_func Triangle
Definition: s_context.h:259
GLfloat * TexelBuffer
Definition: s_context.h:294
GLboolean _PreferPixelFog
Definition: s_context.h:210
INT INT y
Definition: msvc.h:62
GLuint StippleCounter
Definition: s_context.h:226
unsigned int GLbitfield
Definition: gl.h:152
GLuint n
Definition: s_context.h:57
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
GLboolean AllowPixelFog
Definition: s_context.h:202
FetchTexelFunc FetchTexel
Definition: s_context.h:141
GLenum GLint GLuint mask
Definition: glext.h:6028
static struct swrast_renderbuffer * swrast_renderbuffer(struct gl_renderbuffer *img)
Definition: s_context.h:181
unsigned char GLboolean
Definition: gl.h:151
#define _ASMAPIP
Definition: compiler.h:275
void(* validate_texture_image_func)(struct gl_context *ctx, struct gl_texture_object *texObj, GLuint face, GLuint level)
Definition: s_context.h:71
void _swrast_unmap_textures(struct gl_context *ctx)
Definition: s_texture.c:282
texture_sample_func TextureSample
Definition: s_context.h:289
void _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
Definition: s_texture.c:223
void _swrast_map_textures(struct gl_context *ctx)
Definition: s_texture.c:268
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
float GLfloat
Definition: gl.h:161
void _swrast_span_render_start(struct gl_context *ctx)
Definition: s_context.c:665
GLboolean _IsPowerOfTwo
Definition: s_context.h:127
swrast_point_func Point
Definition: s_context.h:257
GLubyte * Buffer
Definition: s_context.h:168
void(* swrast_point_func)(struct gl_context *ctx, const SWvertex *)
Definition: s_context.h:62
static GLubyte * _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y)
Definition: s_context.h:442
GLuint const GLubyte GLvoid const GLvoid GLenum chanType
Definition: s_context.h:57
GLbitfield InvalidateLineMask
Definition: s_context.h:239
GLint GLvoid * img
Definition: gl.h:1956
struct gl_renderbuffer Base
Definition: s_context.h:166
void swrast
Definition: s_aatritemp.h:63
GLuint * ImageOffsets
Definition: s_context.h:134
GLboolean _TextureCombinePrimary
Definition: s_context.h:211
GLuint _NumActiveAttribs
Definition: s_context.h:220
static const struct swrast_texture_image * swrast_texture_image_const(const struct gl_texture_image *img)
Definition: s_context.h:154
SWspanarrays * SpanArrays
Definition: s_context.h:278
static void swrast_render_finish(struct gl_context *ctx)
Definition: s_context.h:339
void(* texture_sample_func)(struct gl_context *ctx, const struct gl_texture_object *tObj, GLuint n, const GLfloat texcoords[][4], const GLfloat lambda[], GLfloat rgba[][4])
Definition: s_context.h:52
validate_texture_image_func ValidateTextureImage
Definition: s_context.h:296
GLuint Width
Definition: mtypes.h:1345
unsigned char GLubyte
Definition: gl.h:157
GLuint Height
Definition: mtypes.h:1345
SWspanarrays * ZoomedArrays
Definition: s_context.h:279
struct gl_texture_image Base
Definition: s_context.h:125
unsigned int GLuint
Definition: gl.h:159
INT x
Definition: msvc.h:62
swrast_line_func SpecLine
Definition: s_context.h:268
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
GLfloat _BackfaceCullSign
Definition: s_context.h:209
GLenum Primitive
Definition: s_context.h:229
void * swrast_context
Definition: mtypes.h:1920
GLbitfield _RasterMask
Definition: s_context.h:207
swrast_point_func SpecPoint
Definition: s_context.h:267
GLbitfield InvalidatePointMask
Definition: s_context.h:238
static void swrast_render_start(struct gl_context *ctx)
Definition: s_context.h:329
swrast_tri_func SpecTriangle
Definition: s_context.h:269
void _swrast_span_render_finish(struct gl_context *ctx)
Definition: s_context.c:674
void _swrast_unmap_renderbuffers(struct gl_context *ctx)
void(* swrast_tri_func)(struct gl_context *ctx, const SWvertex *, const SWvertex *, const SWvertex *)
Definition: s_context.h:67
DWORD bpp
Definition: surface.c:181
Per-context state that's private to the software rasterizer module.
Definition: s_context.h:192
GLbitfield64 _ActiveAttribMask
Definition: s_context.h:218
swrast_line_func Line
Definition: s_context.h:258
GLuint64 GLbitfield64
Definition: mtypes.h:54
GLboolean _DeferredTexture
Definition: s_context.h:213
void(* FetchTexelFunc)(const struct swrast_texture_image *texImage, GLint col, GLint row, GLint img, GLfloat *texelOut)
Definition: s_context.h:113
typedef void(_ASMAPIP blend_func)(struct gl_context *ctx
blend_func BlendFunc
Definition: s_context.h:288
void _swrast_validate_derived(struct gl_context *ctx)
Definition: s_context.c:411
const GLint const GLsizei GLint
Definition: dispatch.h:5271
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:76