changes in hardware depth buffer support
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: context.c,v 1.26 1999/12/04 21:23:17 brianp Exp $ */
|
/* $Id: context.c,v 1.27 1999/12/10 19:09:21 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -1277,10 +1277,11 @@ GLcontext *gl_create_context( GLvisual *visual,
|
|||||||
|
|
||||||
/* Fill in some driver defaults now.
|
/* Fill in some driver defaults now.
|
||||||
*/
|
*/
|
||||||
|
#if 0
|
||||||
ctx->Driver.AllocDepthBuffer = gl_alloc_depth_buffer;
|
ctx->Driver.AllocDepthBuffer = gl_alloc_depth_buffer;
|
||||||
ctx->Driver.ReadDepthSpanFloat = gl_read_depth_span_float;
|
ctx->Driver.ReadDepthSpanFloat = gl_read_depth_span_float;
|
||||||
ctx->Driver.ReadDepthSpanInt = gl_read_depth_span_int;
|
ctx->Driver.ReadDepthSpanInt = gl_read_depth_span_int;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PROFILE
|
#ifdef PROFILE
|
||||||
init_timings( ctx );
|
init_timings( ctx );
|
||||||
@@ -1427,18 +1428,47 @@ void gl_destroy_context( GLcontext *ctx )
|
|||||||
* encapsulates the depth, stencil and accum buffers and related
|
* encapsulates the depth, stencil and accum buffers and related
|
||||||
* parameters.
|
* parameters.
|
||||||
* Input: visual - a GLvisual pointer
|
* Input: visual - a GLvisual pointer
|
||||||
|
* softwareDepth - create/use a software depth buffer?
|
||||||
|
* softwareStencil - create/use a software stencil buffer?
|
||||||
|
* softwareAccum - create/use a software accum buffer?
|
||||||
|
* softwareAlpha - create/use a software alpha buffer?
|
||||||
|
|
||||||
* Return: pointer to new GLframebuffer struct or NULL if error.
|
* Return: pointer to new GLframebuffer struct or NULL if error.
|
||||||
*/
|
*/
|
||||||
GLframebuffer *gl_create_framebuffer( GLvisual *visual )
|
GLframebuffer *gl_create_framebuffer( GLvisual *visual,
|
||||||
|
GLboolean softwareDepth,
|
||||||
|
GLboolean softwareStencil,
|
||||||
|
GLboolean softwareAccum,
|
||||||
|
GLboolean softwareAlpha )
|
||||||
{
|
{
|
||||||
GLframebuffer *buffer;
|
GLframebuffer *buffer;
|
||||||
|
|
||||||
buffer = (GLframebuffer *) CALLOC( sizeof(GLframebuffer) );
|
buffer = CALLOC_STRUCT(gl_frame_buffer);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sanity checks */
|
||||||
|
if (softwareDepth ) {
|
||||||
|
assert(visual->DepthBits > 0);
|
||||||
|
}
|
||||||
|
if (softwareStencil) {
|
||||||
|
assert(visual->StencilBits > 0);
|
||||||
|
}
|
||||||
|
if (softwareAccum) {
|
||||||
|
assert(visual->RGBAflag);
|
||||||
|
assert(visual->AccumBits > 0);
|
||||||
|
}
|
||||||
|
if (softwareAlpha) {
|
||||||
|
assert(visual->RGBAflag);
|
||||||
|
assert(visual->AlphaBits > 0);
|
||||||
|
}
|
||||||
|
|
||||||
buffer->Visual = visual;
|
buffer->Visual = visual;
|
||||||
|
buffer->UseSoftwareDepthBuffer = softwareDepth;
|
||||||
|
buffer->UseSoftwareStencilBuffer = softwareStencil;
|
||||||
|
buffer->UseSoftwareAccumBuffer = softwareAccum;
|
||||||
|
buffer->UseSoftwareAlphaBuffers = softwareAlpha;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -1694,15 +1724,15 @@ _mesa_ResizeBuffersMESA( void )
|
|||||||
ctx->DrawBuffer->Height = buf_height;
|
ctx->DrawBuffer->Height = buf_height;
|
||||||
|
|
||||||
/* Reallocate other buffers if needed. */
|
/* Reallocate other buffers if needed. */
|
||||||
if (ctx->Visual->DepthBits>0) {
|
if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
|
||||||
/* reallocate depth buffer */
|
/* reallocate depth buffer */
|
||||||
(*ctx->Driver.AllocDepthBuffer)( ctx );
|
gl_alloc_depth_buffer( ctx );
|
||||||
}
|
}
|
||||||
if (ctx->Visual->StencilBits>0) {
|
if (ctx->DrawBuffer->UseSoftwareStencilBuffer) {
|
||||||
/* reallocate stencil buffer */
|
/* reallocate stencil buffer */
|
||||||
gl_alloc_stencil_buffer( ctx );
|
gl_alloc_stencil_buffer( ctx );
|
||||||
}
|
}
|
||||||
if (ctx->Visual->AccumBits>0) {
|
if (ctx->DrawBuffer->UseSoftwareAccumBuffer) {
|
||||||
/* reallocate accum buffer */
|
/* reallocate accum buffer */
|
||||||
gl_alloc_accum_buffer( ctx );
|
gl_alloc_accum_buffer( ctx );
|
||||||
}
|
}
|
||||||
@@ -2197,31 +2227,6 @@ void gl_update_state( GLcontext *ctx )
|
|||||||
ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
|
ctx->DrawBuffer->Ymax = ctx->Scissor.Y + ctx->Scissor.Height - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The driver isn't managing the depth buffer.
|
|
||||||
*/
|
|
||||||
if (ctx->Driver.AllocDepthBuffer == gl_alloc_depth_buffer)
|
|
||||||
{
|
|
||||||
if (ctx->Depth.Mask) {
|
|
||||||
switch (ctx->Depth.Func) {
|
|
||||||
case GL_LESS:
|
|
||||||
ctx->Driver.DepthTestSpan = gl_depth_test_span_less;
|
|
||||||
ctx->Driver.DepthTestPixels = gl_depth_test_pixels_less;
|
|
||||||
break;
|
|
||||||
case GL_GREATER:
|
|
||||||
ctx->Driver.DepthTestSpan = gl_depth_test_span_greater;
|
|
||||||
ctx->Driver.DepthTestPixels = gl_depth_test_pixels_greater;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
|
|
||||||
ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ctx->Driver.DepthTestSpan = gl_depth_test_span_generic;
|
|
||||||
ctx->Driver.DepthTestPixels = gl_depth_test_pixels_generic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->NewState & NEW_LIGHTING) {
|
if (ctx->NewState & NEW_LIGHTING) {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: context.h,v 1.4 1999/11/24 18:48:31 brianp Exp $ */
|
/* $Id: context.h,v 1.5 1999/12/10 19:09:22 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -97,7 +97,11 @@ extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
|
|||||||
* It bundles up the depth buffer, stencil buffer and accum buffers into a
|
* It bundles up the depth buffer, stencil buffer and accum buffers into a
|
||||||
* single entity.
|
* single entity.
|
||||||
*/
|
*/
|
||||||
extern GLframebuffer *gl_create_framebuffer( GLvisual *visual );
|
extern GLframebuffer *gl_create_framebuffer( GLvisual *visual,
|
||||||
|
GLboolean softwareDepth,
|
||||||
|
GLboolean softwareStencil,
|
||||||
|
GLboolean softwareAccum,
|
||||||
|
GLboolean softwareAlpha );
|
||||||
|
|
||||||
extern void gl_destroy_framebuffer( GLframebuffer *buffer );
|
extern void gl_destroy_framebuffer( GLframebuffer *buffer );
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: dd.h,v 1.7 1999/12/10 16:14:40 brianp Exp $ */
|
/* $Id: dd.h,v 1.8 1999/12/10 19:09:22 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -393,33 +393,32 @@ struct dd_function_table {
|
|||||||
*** Either ALL or NONE of these functions must be implemented!
|
*** Either ALL or NONE of these functions must be implemented!
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void (*AllocDepthBuffer)( GLcontext *ctx );
|
void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
/*
|
const GLdepth depth[], const GLubyte mask[] );
|
||||||
* Called when the depth buffer must be allocated or possibly resized.
|
/* Write a horizontal span of values into the depth buffer. Only write
|
||||||
|
* depth[i] value if mask[i] is nonzero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GLuint (*DepthTestSpan)( GLcontext *ctx,
|
void (*ReadDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
GLuint n, GLint x, GLint y, const GLdepth z[],
|
GLdepth depth[] );
|
||||||
GLubyte mask[] );
|
/* Read a horizontal span of values from the depth buffer.
|
||||||
void (*DepthTestPixels)( GLcontext *ctx,
|
|
||||||
GLuint n, const GLint x[], const GLint y[],
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
/*
|
|
||||||
* Apply the depth buffer test to an span/array of pixels and return
|
|
||||||
* an updated pixel mask. This function is not used when accelerated
|
|
||||||
* point, line, polygon functions are used.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void (*ReadDepthSpanFloat)( GLcontext *ctx,
|
|
||||||
GLuint n, GLint x, GLint y, GLfloat depth[]);
|
void (*WriteDepthPixels)( GLcontext *ctx, GLuint n,
|
||||||
void (*ReadDepthSpanInt)( GLcontext *ctx,
|
const GLint x[], const GLint y[],
|
||||||
GLuint n, GLint x, GLint y, GLdepth depth[] );
|
const GLdepth depth[], const GLubyte mask[] );
|
||||||
/*
|
/* Write an array of randomly positioned depth values into the
|
||||||
* Return depth values as integers for glReadPixels.
|
* depth buffer. Only write depth[i] value if mask[i] is nonzero.
|
||||||
* Floats should be returned in the range [0,1].
|
|
||||||
* Ints (GLdepth) values should be in the range [0,MAXDEPTH].
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void (*ReadDepthPixels)( GLcontext *ctx, GLuint n,
|
||||||
|
const GLint x[], const GLint y[],
|
||||||
|
GLdepth depth[] );
|
||||||
|
/* Read an array of randomly positioned depth values from the depth buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** For supporting hardware stencil buffers:
|
*** For supporting hardware stencil buffers:
|
||||||
@@ -427,8 +426,7 @@ struct dd_function_table {
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
void (*WriteStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
const GLstencil stencil[],
|
const GLstencil stencil[], const GLubyte mask[] );
|
||||||
const GLubyte mask[] );
|
|
||||||
/* Write a horizontal span of stencil values into the stencil buffer.
|
/* Write a horizontal span of stencil values into the stencil buffer.
|
||||||
* If mask is NULL, write all stencil values.
|
* If mask is NULL, write all stencil values.
|
||||||
* Else, only write stencil[i] if mask[i] is non-zero.
|
* Else, only write stencil[i] if mask[i] is non-zero.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: depth.h,v 1.4 1999/11/24 18:48:31 brianp Exp $ */
|
/* $Id: depth.h,v 1.5 1999/12/10 19:09:22 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -33,63 +33,13 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the address of the Z-buffer value for window coordinate (x,y):
|
* Immediate-mode API entrpoints
|
||||||
*/
|
*/
|
||||||
#define Z_ADDRESS( CTX, X, Y ) \
|
|
||||||
((CTX)->DrawBuffer->Depth + (CTX)->DrawBuffer->Width * (Y) + (X))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern GLuint
|
|
||||||
gl_depth_test_span_generic( GLcontext* ctx, GLuint n, GLint x, GLint y,
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
extern GLuint
|
|
||||||
gl_depth_test_span_less( GLcontext* ctx, GLuint n, GLint x, GLint y,
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
extern GLuint
|
|
||||||
gl_depth_test_span_greater( GLcontext* ctx, GLuint n, GLint x, GLint y,
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
|
||||||
gl_depth_test_pixels_generic( GLcontext* ctx,
|
|
||||||
GLuint n, const GLint x[], const GLint y[],
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
extern void
|
|
||||||
gl_depth_test_pixels_less( GLcontext* ctx,
|
|
||||||
GLuint n, const GLint x[], const GLint y[],
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
extern void
|
|
||||||
gl_depth_test_pixels_greater( GLcontext* ctx,
|
|
||||||
GLuint n, const GLint x[], const GLint y[],
|
|
||||||
const GLdepth z[], GLubyte mask[] );
|
|
||||||
|
|
||||||
|
|
||||||
extern void gl_read_depth_span_float( GLcontext* ctx,
|
|
||||||
GLuint n, GLint x, GLint y,
|
|
||||||
GLfloat depth[] );
|
|
||||||
|
|
||||||
|
|
||||||
extern void gl_read_depth_span_int( GLcontext* ctx, GLuint n, GLint x, GLint y,
|
|
||||||
GLdepth depth[] );
|
|
||||||
|
|
||||||
|
|
||||||
extern void gl_alloc_depth_buffer( GLcontext* ctx );
|
|
||||||
|
|
||||||
|
|
||||||
extern void gl_clear_depth_buffer( GLcontext* ctx );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_ClearDepth( GLclampd depth );
|
_mesa_ClearDepth( GLclampd depth );
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
_mesa_DepthFunc( GLenum func );
|
_mesa_DepthFunc( GLenum func );
|
||||||
|
|
||||||
@@ -98,4 +48,39 @@ extern void
|
|||||||
_mesa_DepthMask( GLboolean flag );
|
_mesa_DepthMask( GLboolean flag );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the address of the Z-buffer value for window coordinate (x,y):
|
||||||
|
*/
|
||||||
|
#define Z_ADDRESS( CTX, X, Y ) \
|
||||||
|
((CTX)->DrawBuffer->Depth + (CTX)->DrawBuffer->Width * (Y) + (X))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern GLuint
|
||||||
|
gl_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
|
const GLdepth z[], GLubyte mask[] );
|
||||||
|
|
||||||
|
extern void
|
||||||
|
gl_depth_test_pixels( GLcontext *ctx,
|
||||||
|
GLuint n, const GLint x[], const GLint y[],
|
||||||
|
const GLdepth z[], GLubyte mask[] );
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
gl_read_depth_span_float( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
||||||
|
GLfloat depth[] );
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
gl_alloc_depth_buffer( GLcontext* ctx );
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
gl_clear_depth_buffer( GLcontext* ctx );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: stencil.c,v 1.12 1999/12/10 16:15:04 brianp Exp $ */
|
/* $Id: stencil.c,v 1.13 1999/12/10 19:09:22 brianp Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mesa 3-D graphics library
|
* Mesa 3-D graphics library
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
#else
|
#else
|
||||||
#include "glheader.h"
|
#include "glheader.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
|
#include "depth.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "pb.h"
|
#include "pb.h"
|
||||||
#include "stencil.h"
|
#include "stencil.h"
|
||||||
@@ -579,8 +580,7 @@ stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
|
|||||||
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
||||||
|
|
||||||
/* apply the depth test */
|
/* apply the depth test */
|
||||||
if (ctx->Driver.DepthTestSpan)
|
gl_depth_test_span(ctx, n, x, y, z, mask);
|
||||||
(*ctx->Driver.DepthTestSpan)( ctx, n, x, y, z, mask );
|
|
||||||
|
|
||||||
/* Set the stencil pass/fail flags according to result of depth testing.
|
/* Set the stencil pass/fail flags according to result of depth testing.
|
||||||
* if oldmask[i] == 0 then
|
* if oldmask[i] == 0 then
|
||||||
@@ -1059,8 +1059,7 @@ gl_stencil_and_depth_test_pixels( GLcontext *ctx,
|
|||||||
|
|
||||||
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
||||||
|
|
||||||
if (ctx->Driver.DepthTestPixels)
|
gl_depth_test_pixels(ctx, n, x, y, z, mask);
|
||||||
(*ctx->Driver.DepthTestPixels)( ctx, n, x, y, z, mask );
|
|
||||||
|
|
||||||
for (i=0;i<n;i++) {
|
for (i=0;i<n;i++) {
|
||||||
ASSERT(mask[i] == 0 || mask[i] == 1);
|
ASSERT(mask[i] == 0 || mask[i] == 1);
|
||||||
@@ -1100,8 +1099,7 @@ gl_stencil_and_depth_test_pixels( GLcontext *ctx,
|
|||||||
|
|
||||||
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
MEMCPY(oldmask, mask, n * sizeof(GLubyte));
|
||||||
|
|
||||||
if (ctx->Driver.DepthTestPixels)
|
gl_depth_test_pixels(ctx, n, x, y, z, mask);
|
||||||
(*ctx->Driver.DepthTestPixels)( ctx, n, x, y, z, mask );
|
|
||||||
|
|
||||||
for (i=0;i<n;i++) {
|
for (i=0;i<n;i++) {
|
||||||
ASSERT(mask[i] == 0 || mask[i] == 1);
|
ASSERT(mask[i] == 0 || mask[i] == 1);
|
||||||
|
Reference in New Issue
Block a user