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

s_stencil.c File Reference

#include "main/glheader.h"
#include "main/context.h"
#include "main/imports.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_stencil.h"
#include "s_span.h"

Defines

#define STENCIL_ADDRESS(X, Y)   (stencilStart + (Y) * stride + (X))

Functions

static void apply_stencil_op (const GLcontext *ctx, GLenum oper, GLuint face, GLuint n, GLstencil stencil[], const GLubyte mask[])
 Apply the given stencil operator to the array of stencil values.
static GLboolean do_stencil_test (GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[], GLubyte mask[])
 Apply stencil test to an array of stencil values (before depth buffering).
static INLINE void compute_pass_fail_masks (GLuint n, const GLubyte origMask[], const GLubyte newMask[], GLubyte passMask[], GLubyte failMask[])
 Compute the zpass/zfail masks by comparing the pre- and post-depth test masks.
static GLboolean stencil_and_ztest_span (GLcontext *ctx, SWspan *span, GLuint face)
 Apply stencil and depth testing to the span of pixels.
static void apply_stencil_op_to_pixels (GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLenum oper, GLuint face, const GLubyte mask[])
 Apply the given stencil operator for each pixel in the array whose mask flag is set.
static GLboolean stencil_test_pixels (GLcontext *ctx, GLuint face, GLuint n, const GLint x[], const GLint y[], GLubyte mask[])
 Apply stencil test to an array of pixels before depth buffering.
static GLboolean stencil_and_ztest_pixels (GLcontext *ctx, SWspan *span, GLuint face)
 Apply stencil and depth testing to an array of pixels.
GLboolean _swrast_stencil_and_ztest_span (GLcontext *ctx, SWspan *span)
 /return GL_TRUE = one or more fragments passed, GL_FALSE = all fragments failed.
void _swrast_read_stencil_span (GLcontext *ctx, struct gl_renderbuffer *rb, GLint n, GLint x, GLint y, GLstencil stencil[])
 Return a span of stencil values from the stencil buffer.
void _swrast_write_stencil_span (GLcontext *ctx, GLint n, GLint x, GLint y, const GLstencil stencil[])
 Write a span of stencil values to the stencil buffer.
void _swrast_clear_stencil_buffer (GLcontext *ctx, struct gl_renderbuffer *rb)
 Clear the stencil buffer.


Define Documentation

#define STENCIL_ADDRESS ( X,
 )     (stencilStart + (Y) * stride + (X))


Function Documentation

void _swrast_clear_stencil_buffer ( GLcontext ctx,
struct gl_renderbuffer rb 
)

Clear the stencil buffer.

void _swrast_read_stencil_span ( GLcontext ctx,
struct gl_renderbuffer rb,
GLint  n,
GLint  x,
GLint  y,
GLstencil  stencil[] 
)

Return a span of stencil values from the stencil buffer.

Used for glRead/CopyPixels Input: n - how many pixels x,y - location of first pixel Output: stencil - the array of stencil values

GLboolean _swrast_stencil_and_ztest_span ( GLcontext ctx,
SWspan span 
)

/return GL_TRUE = one or more fragments passed, GL_FALSE = all fragments failed.

void _swrast_write_stencil_span ( GLcontext ctx,
GLint  n,
GLint  x,
GLint  y,
const GLstencil  stencil[] 
)

Write a span of stencil values to the stencil buffer.

This function applies the stencil write mask when needed. Used for glDraw/CopyPixels Input: n - how many pixels x, y - location of first pixel stencil - the array of stencil values

static void apply_stencil_op ( const GLcontext ctx,
GLenum  oper,
GLuint  face,
GLuint  n,
GLstencil  stencil[],
const GLubyte  mask[] 
) [static]

Apply the given stencil operator to the array of stencil values.

Don't touch stencil[i] if mask[i] is zero. Input: n - size of stencil array oper - the stencil buffer operator face - 0 or 1 for front or back face operation stencil - array of stencil values mask - array [n] of flag: 1=apply operator, 0=don't apply operator Output: stencil - modified values

static void apply_stencil_op_to_pixels ( GLcontext ctx,
GLuint  n,
const GLint  x[],
const GLint  y[],
GLenum  oper,
GLuint  face,
const GLubyte  mask[] 
) [static]

Apply the given stencil operator for each pixel in the array whose mask flag is set.

Note:
This is for software stencil buffers only. Input: n - number of pixels in the span x, y - array of [n] pixels operator - the stencil buffer operator mask - array [n] of flag: 1=apply operator, 0=don't apply operator

static INLINE void compute_pass_fail_masks ( GLuint  n,
const GLubyte  origMask[],
const GLubyte  newMask[],
GLubyte  passMask[],
GLubyte  failMask[] 
) [static]

Compute the zpass/zfail masks by comparing the pre- and post-depth test masks.

static GLboolean do_stencil_test ( GLcontext ctx,
GLuint  face,
GLuint  n,
GLstencil  stencil[],
GLubyte  mask[] 
) [static]

Apply stencil test to an array of stencil values (before depth buffering).

Input: face - 0 or 1 for front or back-face polygons n - number of pixels in the array stencil - array of [n] stencil values mask - array [n] of flag: 0=skip the pixel, 1=stencil the pixel Output: mask - pixels which fail the stencil test will have their mask flag set to 0. stencil - updated stencil values (where the test passed) Return: GL_FALSE = all pixels failed, GL_TRUE = zero or more pixels passed.

static GLboolean stencil_and_ztest_pixels ( GLcontext ctx,
SWspan span,
GLuint  face 
) [static]

Apply stencil and depth testing to an array of pixels.

This is used both for software and hardware stencil buffers.

The comments in this function are a bit sparse but the code is almost identical to stencil_and_ztest_span(), which is well commented.

Input: n - number of pixels in the array x, y - array of [n] pixel positions z - array [n] of z values mask - array [n] of flags (1=test this pixel, 0=skip the pixel) Output: mask - array [n] of flags (1=stencil and depth test passed) Return: GL_FALSE - all fragments failed the testing GL_TRUE - one or more fragments passed the testing

static GLboolean stencil_and_ztest_span ( GLcontext ctx,
SWspan span,
GLuint  face 
) [static]

Apply stencil and depth testing to the span of pixels.

Both software and hardware stencil buffers are acceptable. Input: n - number of pixels in the span x, y - location of leftmost pixel in span z - array [n] of z values mask - array [n] of flags (1=test this pixel, 0=skip the pixel) Output: mask - array [n] of flags (1=stencil and depth test passed) Return: GL_FALSE - all fragments failed the testing GL_TRUE - one or more fragments passed the testing

static GLboolean stencil_test_pixels ( GLcontext ctx,
GLuint  face,
GLuint  n,
const GLint  x[],
const GLint  y[],
GLubyte  mask[] 
) [static]

Apply stencil test to an array of pixels before depth buffering.

Note:
Used for software stencil buffer only. Input: n - number of pixels in the span x, y - array of [n] pixels to stencil mask - array [n] of flag: 0=skip the pixel, 1=stencil the pixel Output: mask - pixels which fail the stencil test will have their mask flag set to 0.
Returns:
GL_FALSE = all pixels failed, GL_TRUE = zero or more pixels passed.


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