Fix some issues with depth renderbuffers. 3D rendering into FBOs seems OK now.

Misc clean-ups in other places.
This commit is contained in:
Brian Paul 2006-03-19 19:06:12 +00:00
parent c8dd839acb
commit af4d93f256
6 changed files with 36 additions and 45 deletions

View file

@ -279,7 +279,7 @@ void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
clear_color = intel->ClearColor;
clear_depth = 0;
if (flags & BUFFER_BIT_DEPTH) {
clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
clear_depth = (GLuint) (ctx->DrawBuffer->_DepthMax * ctx->Depth.Clear);
}
if (flags & BUFFER_BIT_STENCIL) {
clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;

View file

@ -60,42 +60,30 @@ GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst,
return GL_TRUE;
}
/**
* Return pointer to current color drawing region, or NULL.
*/
struct intel_region *intel_drawbuf_region( struct intel_context *intel )
{
switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) {
case BUFFER_BIT_FRONT_LEFT:
return intel->front_region;
case BUFFER_BIT_BACK_LEFT:
return intel->back_region;
default:
/* Not necessary to fallback - could handle either NONE or
* FRONT_AND_BACK cases below.
*/
return NULL;
}
struct intel_renderbuffer *irbColor =
intel_renderbuffer(intel->ctx.DrawBuffer->_ColorDrawBuffers[0][0]);
if (irbColor)
return irbColor->region;
else
return NULL;
}
/**
* Return pointer to current color reading region, or NULL.
*/
struct intel_region *intel_readbuf_region( struct intel_context *intel )
{
GLcontext *ctx = &intel->ctx;
/* This will have to change to support EXT_fbo's, but is correct
* for now:
*/
#if 0 /* XXX FBO */
switch (ctx->ReadBuffer->_ColorReadBufferIndex) {
case BUFFER_FRONT_LEFT:
return intel->front_region;
case BUFFER_BACK_LEFT:
return intel->back_region;
default:
assert(0);
struct intel_renderbuffer *irb
= intel_renderbuffer(intel->ctx.ReadBuffer->_ColorReadBuffer);
if (irb)
return irb->region;
else
return NULL;
}
#else
struct intel_renderbuffer *irb = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
return irb->region;
#endif
}
@ -232,6 +220,7 @@ void intelWindowMoved( struct intel_context *intel )
}
else if (intel->ctx.DrawBuffer->Name != 0) {
/* drawing to user-created FBO - do nothing */
/* Cliprects would be set from intelDrawBuffer() */
}
else {
/* drawing to a window */
@ -246,9 +235,11 @@ void intelWindowMoved( struct intel_context *intel )
/* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
intelSetFrontClipRects( intel );
}
}
/* this update Mesa's notion of window size */
_mesa_resize_framebuffer(ctx, ctx->DrawBuffer,
/* this update Mesa's notion of window size */
if (ctx->WinSysDrawBuffer) {
_mesa_resize_framebuffer(ctx, ctx->WinSysDrawBuffer,
intel->driDrawable->w, intel->driDrawable->h);
}

View file

@ -348,20 +348,14 @@ GLboolean intelInitContext( struct intel_context *intel,
intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
intel->hw_stipple = 1;
/* XXX FBO: this doesn't seem to be used anywhere */
switch(mesaVis->depthBits) {
case 0: /* what to do in this case? */
case 16:
intel->depth_scale = 1.0/0xffff;
intel->polygon_offset_scale = 1.0/0xffff;
intel->depth_clear_mask = ~0;
intel->ClearDepth = 0xffff;
break;
case 24:
intel->depth_scale = 1.0/0xffffff;
intel->polygon_offset_scale = 2.0/0xffffff; /* req'd to pass glean */
intel->depth_clear_mask = 0x00ffffff;
intel->stencil_clear_mask = 0xff000000;
intel->ClearDepth = 0x00ffffff;
break;
default:
assert(0);

View file

@ -183,7 +183,6 @@ struct intel_context
GLboolean locked;
GLuint ClearColor;
GLuint ClearDepth;
/* Offsets of fields within the current vertex:
*/
@ -195,10 +194,7 @@ struct intel_context
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
GLuint vertex_attr_count;
GLfloat depth_scale;
GLfloat polygon_offset_scale; /* dependent on depth_scale, bpp */
GLuint depth_clear_mask;
GLuint stencil_clear_mask;
GLboolean hw_stencil;
GLboolean hw_stipple;

View file

@ -172,11 +172,16 @@ intel_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
intelFlush(ctx);
/* free old region */
if (irb->region) {
/*LOCK_HARDWARE(intel);*/
intel_region_release(intel, &irb->region);
/*UNLOCK_HARDWARE(intel);*/
}
if (softwareBuffer) {
return _mesa_soft_renderbuffer_storage(ctx, rb, internalFormat,
width, height);
@ -187,7 +192,9 @@ intel_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
assert(width > 1);
assert(height > 1);
_mesa_debug(ctx, "Allocating %d x %d Intel RBO\n", width, height);
/*LOCK_HARDWARE(intel);*/
irb->region = intel_region_alloc(intel, cpp, width, height);
/*UNLOCK_HARDWARE(intel);*/
if (!irb->region)
return GL_FALSE; /* out of memory? */
}
@ -384,6 +391,8 @@ intel_bind_framebuffer(GLcontext *ctx, GLenum target,
intel->vtbl.set_draw_region(intel, colorRegion, depthRegion);
#else
ctx->Driver.DrawBuffer(ctx, 0); /* second param is ignored */
/* Integer depth range depends on depth buffer bits */
ctx->Driver.DepthRange(ctx, ctx->Viewport.Near, ctx->Viewport.Far);
#endif
}
else {

View file

@ -187,6 +187,7 @@ static void intelCalcViewport( GLcontext *ctx )
{
struct intel_context *intel = intel_context(ctx);
const GLfloat *v = ctx->Viewport._WindowMap.m;
const GLfloat depthScale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
GLfloat *m = intel->ViewportMatrix.m;
GLint h = 0;
@ -200,8 +201,8 @@ static void intelCalcViewport( GLcontext *ctx )
m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
m[MAT_SY] = - v[MAT_SY];
m[MAT_TY] = - v[MAT_TY] + h;
m[MAT_SZ] = v[MAT_SZ] * intel->depth_scale;
m[MAT_TZ] = v[MAT_TZ] * intel->depth_scale;
m[MAT_SZ] = v[MAT_SZ] * depthScale;
m[MAT_TZ] = v[MAT_TZ] * depthScale;
}
static void intelViewport( GLcontext *ctx,