core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

s_span.c File Reference


Detailed Description

Span processing functions used by all rasterization functions.

This is where all the per-fragment tests are performed

Author:
Brian Paul

#include "main/glheader.h"
#include "main/colormac.h"
#include "main/context.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/image.h"
#include "s_atifragshader.h"
#include "s_alpha.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_fog.h"
#include "s_logic.h"
#include "s_masking.h"
#include "s_fragprog.h"
#include "s_span.h"
#include "s_stencil.h"
#include "s_texcombine.h"

Functions

void _swrast_span_default_attribs (GLcontext *ctx, SWspan *span)
 Set default fragment attributes for the span using the current raster values.
static INLINE void interpolate_active_attribs (GLcontext *ctx, SWspan *span, GLbitfield attrMask)
 Interpolate the active attributes (and'd with attrMask) to fill in span->array->attribs[].
static INLINE void interpolate_int_colors (GLcontext *ctx, SWspan *span)
 Interpolate primary colors to fill in the span->array->rgba8 (or rgb16) color array.
static INLINE void interpolate_float_colors (SWspan *span)
 Populate the FRAG_ATTRIB_COL0 array.
static INLINE void interpolate_indexes (GLcontext *ctx, SWspan *span)
void _swrast_span_interpolate_z (const GLcontext *ctx, SWspan *span)
 Fill in the span.zArray array from the span->z, zStep values.
GLfloat _swrast_compute_lambda (GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, GLfloat s, GLfloat t, GLfloat q, GLfloat invQ)
 Compute mipmap LOD from partial derivatives.
static void interpolate_texcoords (GLcontext *ctx, SWspan *span)
 Compute mipmap LOD from partial derivatives.
static INLINE void interpolate_wpos (GLcontext *ctx, SWspan *span)
 Fill in the arrays->attribs[FRAG_ATTRIB_WPOS] array.
static INLINE void stipple_polygon_span (GLcontext *ctx, SWspan *span)
 Apply the current polygon stipple pattern to a span of pixels.
static INLINE GLuint clip_span (GLcontext *ctx, SWspan *span)
 Clip a pixel span to the current buffer/window boundaries: DrawBuffer->_Xmin, _Xmax, _Ymin, _Ymax.
void _swrast_write_index_span (GLcontext *ctx, SWspan *span)
 Apply all the per-fragment opertions to a span of color index fragments and write them to the enabled color drawbuffers.
static INLINE void add_specular (GLcontext *ctx, SWspan *span)
 Add specular colors to primary colors.
static INLINE void apply_aa_coverage (SWspan *span)
 Apply antialiasing coverage value to alpha values.
static INLINE void clamp_colors (SWspan *span)
 Clamp span's float colors to [0,1].
static INLINE void convert_color_type (SWspan *span, GLenum newType, GLuint output)
 Convert the span's color arrays to the given type.
static INLINE void shade_texture_span (GLcontext *ctx, SWspan *span)
 Apply fragment shader, fragment program or normal texturing to span.
void _swrast_write_rgba_span (GLcontext *ctx, SWspan *span)
 Apply all the per-fragment operations to a span.
void _swrast_read_rgba_span (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLenum dstType, GLvoid *rgba)
 Read RGBA pixels from a renderbuffer.
void _swrast_read_index_span (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n, GLint x, GLint y, GLuint index[])
 Read CI pixels from a renderbuffer.
void _swrast_get_values (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, const GLint x[], const GLint y[], void *values, GLuint valueSize)
 Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid reading values outside the buffer bounds.
void _swrast_put_row (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, const GLvoid *values, GLuint valueSize)
 Wrapper for gl_renderbuffer::PutRow() which does clipping.
void _swrast_get_row (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count, GLint x, GLint y, GLvoid *values, GLuint valueSize)
 Wrapper for gl_renderbuffer::GetRow() which does clipping.
void * _swrast_get_dest_rgba (GLcontext *ctx, struct gl_renderbuffer *rb, SWspan *span)
 Get RGBA pixels from the given renderbuffer.


Function Documentation

GLfloat _swrast_compute_lambda ( GLfloat  dsdx,
GLfloat  dsdy,
GLfloat  dtdx,
GLfloat  dtdy,
GLfloat  dqdx,
GLfloat  dqdy,
GLfloat  texW,
GLfloat  texH,
GLfloat  s,
GLfloat  t,
GLfloat  q,
GLfloat  invQ 
)

Compute mipmap LOD from partial derivatives.

This the ideal solution, as given in the OpenGL spec.

void* _swrast_get_dest_rgba ( GLcontext ctx,
struct gl_renderbuffer rb,
SWspan span 
)

Get RGBA pixels from the given renderbuffer.

Put the pixel colors into the span's specular color arrays. The specular color arrays should no longer be needed by time this function is called. Used by blending, logicop and masking functions.

Returns:
pointer to the colors we read.

void _swrast_get_row ( GLcontext ctx,
struct gl_renderbuffer rb,
GLuint  count,
GLint  x,
GLint  y,
GLvoid *  values,
GLuint  valueSize 
)

Wrapper for gl_renderbuffer::GetRow() which does clipping.

Parameters:
valueSize size of each value (pixel) in bytes

void _swrast_get_values ( GLcontext ctx,
struct gl_renderbuffer rb,
GLuint  count,
const GLint  x[],
const GLint  y[],
void *  values,
GLuint  valueSize 
)

Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid reading values outside the buffer bounds.

We can use this for reading any format/type of renderbuffer.

Parameters:
valueSize is the size in bytes of each value (pixel) put into the values array.

void _swrast_put_row ( GLcontext ctx,
struct gl_renderbuffer rb,
GLuint  count,
GLint  x,
GLint  y,
const GLvoid *  values,
GLuint  valueSize 
)

Wrapper for gl_renderbuffer::PutRow() which does clipping.

Parameters:
valueSize size of each value (pixel) in bytes

void _swrast_read_index_span ( GLcontext ctx,
struct gl_renderbuffer rb,
GLuint  n,
GLint  x,
GLint  y,
GLuint  index[] 
)

Read CI pixels from a renderbuffer.

Clipping will be done to prevent reading ouside the buffer's boundaries.

void _swrast_read_rgba_span ( GLcontext ctx,
struct gl_renderbuffer rb,
GLuint  n,
GLint  x,
GLint  y,
GLenum  dstType,
GLvoid *  rgba 
)

Read RGBA pixels from a renderbuffer.

Clipping will be done to prevent reading ouside the buffer's boundaries.

Parameters:
dstType datatype for returned colors
rgba the returned colors

void _swrast_span_default_attribs ( GLcontext ctx,
SWspan span 
)

Set default fragment attributes for the span using the current raster values.

Used prior to glDraw/CopyPixels and glBitmap.

void _swrast_span_interpolate_z ( const GLcontext ctx,
SWspan span 
)

Fill in the span.zArray array from the span->z, zStep values.

void _swrast_write_index_span ( GLcontext ctx,
SWspan span 
)

Apply all the per-fragment opertions to a span of color index fragments and write them to the enabled color drawbuffers.

The 'span' parameter can be considered to be const. Note that span->interpMask and span->arrayMask may be changed but will be restored to their original values before returning.

void _swrast_write_rgba_span ( GLcontext ctx,
SWspan span 
)

Apply all the per-fragment operations to a span.

This now includes texturing (_swrast_write_texture_span() is history). This function may modify any of the array values in the span. span->interpMask and span->arrayMask may be changed but will be restored to their original values before returning.

static INLINE void add_specular ( GLcontext ctx,
SWspan span 
) [static]

Add specular colors to primary colors.

Only called during fixed-function operation. Result is float color array (FRAG_ATTRIB_COL0).

static INLINE void apply_aa_coverage ( SWspan span  )  [static]

Apply antialiasing coverage value to alpha values.

static INLINE void clamp_colors ( SWspan span  )  [static]

Clamp span's float colors to [0,1].

static INLINE GLuint clip_span ( GLcontext ctx,
SWspan span 
) [static]

Clip a pixel span to the current buffer/window boundaries: DrawBuffer->_Xmin, _Xmax, _Ymin, _Ymax.

This will accomplish window clipping and scissoring. Return: GL_TRUE some pixels still visible GL_FALSE nothing visible

static INLINE void convert_color_type ( SWspan span,
GLenum  newType,
GLuint  output 
) [static]

Convert the span's color arrays to the given type.

The only way 'output' can be greater than zero is when we have a fragment program that writes to gl_FragData[1] or higher.

Parameters:
output which fragment program color output is being processed

static INLINE void interpolate_active_attribs ( GLcontext ctx,
SWspan span,
GLbitfield  attrMask 
) [static]

Interpolate the active attributes (and'd with attrMask) to fill in span->array->attribs[].

Perspective correction will be done. The point/line/triangle function should have computed attrStart/Step values for FRAG_ATTRIB_WPOS[3]!

static INLINE void interpolate_float_colors ( SWspan span  )  [static]

Populate the FRAG_ATTRIB_COL0 array.

static INLINE void interpolate_indexes ( GLcontext ctx,
SWspan span 
) [static]

static INLINE void interpolate_int_colors ( GLcontext ctx,
SWspan span 
) [static]

Interpolate primary colors to fill in the span->array->rgba8 (or rgb16) color array.

static void interpolate_texcoords ( GLcontext ctx,
SWspan span 
) [static]

Compute mipmap LOD from partial derivatives.

This is a faster approximation than above function. Fill in the span.array->attrib[FRAG_ATTRIB_TEXn] arrays from the using the attrStart/Step values.

This function only used during fixed-function fragment processing.

Note: in the places where we divide by Q (or mult by invQ) we're really doing two things: perspective correction and texcoord projection. Remember, for texcoord (s,t,r,q) we need to index texels with (s/q, t/q, r/q).

static INLINE void interpolate_wpos ( GLcontext ctx,
SWspan span 
) [static]

Fill in the arrays->attribs[FRAG_ATTRIB_WPOS] array.

static INLINE void shade_texture_span ( GLcontext ctx,
SWspan span 
) [static]

Apply fragment shader, fragment program or normal texturing to span.

static INLINE void stipple_polygon_span ( GLcontext ctx,
SWspan span 
) [static]

Apply the current polygon stipple pattern to a span of pixels.


Generated on Sun Sep 27 06:48:05 2009 for Mesa Software Rasterization (swrast) by  doxygen 1.5.4