First attempt at using private back/z buffers.

Allocate and use private back and z/stencil buffers.
This is still very broken.
This commit is contained in:
Roland Scheidegger 2007-07-10 18:07:38 +02:00
parent 5657fc5b4c
commit d348a48ac3
6 changed files with 89 additions and 9 deletions

View file

@ -88,6 +88,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
const int nbox = dPriv->numClipRects;
const drm_clip_rect_t *pbox = dPriv->pClipRects;
const int pitch = frontRegion->pitch;
const int srcpitch = backRegion->pitch;
const int cpp = frontRegion->cpp;
int BR13, CMD;
int i;
@ -96,9 +97,12 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
ASSERT(intel_fb->Base.Name == 0); /* Not a user-created FBO */
ASSERT(frontRegion);
ASSERT(backRegion);
ASSERT(frontRegion->pitch == backRegion->pitch);
// ASSERT(frontRegion->pitch == backRegion->pitch);
ASSERT(frontRegion->cpp == backRegion->cpp);
DBG("copy buffer, front pitch %d back pitch %d\n",
frontRegion->pitch, backRegion->pitch);
if (cpp == 2) {
BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24);
CMD = XY_SRC_COPY_BLT_CMD;
@ -142,7 +146,7 @@ intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
OUT_RELOC(frontRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
OUT_BATCH((pbox->y1 << 16) | pbox->x1);
OUT_BATCH(BR13 & 0xffff);
OUT_BATCH((srcpitch * cpp) & 0xffff);
OUT_RELOC(backRegion->buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);

View file

@ -569,6 +569,13 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
__DRIdrawablePrivate * driReadPriv)
{
#if 0
if (driDrawPriv) {
fprintf(stderr, "x %d, y %d, width %d, height %d\n",
driDrawPriv->x, driDrawPriv->y, driDrawPriv->w, driDrawPriv->h);
}
#endif
if (driContextPriv) {
struct intel_context *intel =
(struct intel_context *) driContextPriv->driverPrivate;
@ -576,6 +583,9 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
(struct intel_framebuffer *) driDrawPriv->driverPrivate;
GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
/* this is a hack so we have a valid context when the region allocation
is done. Need a per-screen context? */
intel->intelScreen->dummyctxptr = intel;
/* XXX FBO temporary fix-ups! */
/* if the renderbuffers don't have regions, init them from the context */
@ -613,6 +623,7 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
}
_mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
intel->intelScreen->dummyctxptr = &intel->ctx;
/* The drawbuffer won't always be updated by _mesa_make_current:
*/

View file

@ -353,7 +353,7 @@ __memcpy(void *to, const void *from, size_t n)
/* ================================================================
* Debugging:
*/
#define DO_DEBUG 0
#define DO_DEBUG 1
#if DO_DEBUG
extern int INTEL_DEBUG;
#else

View file

@ -257,7 +257,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
break;
default:
_mesa_problem(ctx,
"Unexpected format in intel_alloc_renderbuffer_storage");
"Unexpected format (%x) in intel_alloc_renderbuffer_storage", internalFormat);
return GL_FALSE;
}
@ -453,6 +453,29 @@ intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height,
return irb;
}
struct gl_renderbuffer *
intel_new_renderbuffer_fb(GLcontext * ctx, GLuint intFormat)
{
struct intel_renderbuffer *irb;
irb = CALLOC_STRUCT(intel_renderbuffer);
if (!irb) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
return NULL;
}
_mesa_init_renderbuffer(&irb->Base, 0);
irb->Base.ClassID = INTEL_RB_CLASS;
irb->Base.InternalFormat = intFormat;
/* intel-specific methods */
irb->Base.Delete = intel_delete_renderbuffer;
irb->Base.AllocStorage = intel_alloc_renderbuffer_storage;
irb->Base.GetPointer = intel_get_pointer;
/* span routines set in alloc_storage function */
return &irb->Base;
}
/**
* Create a new renderbuffer object.

View file

@ -156,7 +156,7 @@ intel_recreate_static(intelScreenPrivate *intelScreen,
}
return region;
}
/* Create intel_region structs to describe the static front,back,depth
* buffers created by the xserver.
@ -192,7 +192,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen)
intelScreen->rotated.pitch /
intelScreen->cpp, intelScreen->height);
#if 0
intelScreen->back_region =
intel_recreate_static(intelScreen,
intelScreen->back_region,
@ -226,6 +226,7 @@ intel_recreate_static_regions(intelScreenPrivate *intelScreen)
intelScreen->cpp,
intelScreen->depth.pitch / intelScreen->cpp,
intelScreen->height);
#endif
}
/**
@ -382,7 +383,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
intelScreen->rotatedWidth = sarea->virtualX;
intelScreen->rotatedHeight = sarea->virtualY;
if (0)
if (1)
intelPrintSAREA(sarea);
}
@ -614,6 +615,7 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
&intel_fb->color_rb[0]->Base);
}
#if 0
if (mesaVis->doubleBufferMode) {
intel_fb->color_rb[1]
= intel_create_renderbuffer(rgbFormat,
@ -640,7 +642,6 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
_mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
}
}
if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
/* combined depth/stencil buffer */
struct intel_renderbuffer *depthStencilRb
@ -670,6 +671,39 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
}
#else
if (mesaVis->doubleBufferMode) {
intel_fb->color_rb[1]
= intel_new_renderbuffer_fb(NULL, rgbFormat);
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
&intel_fb->color_rb[1]->Base);
if (screen->third.handle) {
struct gl_renderbuffer *tmp_rb = NULL;
intel_fb->color_rb[2]
= intel_new_renderbuffer_fb(NULL, rgbFormat);
_mesa_reference_renderbuffer(&tmp_rb, &intel_fb->color_rb[2]->Base);
}
}
if (mesaVis->depthBits == 24 && mesaVis->stencilBits == 8) {
/* combined depth/stencil buffer */
struct intel_renderbuffer *depthStencilRb
= intel_new_renderbuffer_fb(NULL, GL_DEPTH24_STENCIL8_EXT);
/* note: bind RB to two attachment points */
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
&depthStencilRb->Base);
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
&depthStencilRb->Base);
}
else if (mesaVis->depthBits == 16) {
/* just 16-bit depth buffer, no hw stencil */
struct intel_renderbuffer *depthRb
= intel_new_renderbuffer_fb(NULL, GL_DEPTH_COMPONENT16);
_mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
}
#endif
/* now add any/all software-based renderbuffers we may need */
_mesa_add_soft_renderbuffers(&intel_fb->Base,
GL_FALSE, /* never sw color */
@ -939,11 +973,18 @@ struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
* context at screen creation. For now just use the current context.
*/
GET_CURRENT_CONTEXT(ctx);
/* GET_CURRENT_CONTEXT(ctx);
if (ctx == NULL) {
_mesa_problem(NULL, "No current context in intelScreenContext\n");
return NULL;
}
return intel_context(ctx);
*/
if (intelScreen->dummyctxptr == NULL) {
_mesa_problem(NULL, "No current context in intelScreenContext\n");
return NULL;
}
return intelScreen->dummyctxptr;
}

View file

@ -96,6 +96,7 @@ typedef struct
struct _DriBufferPool *staticPool;
unsigned int maxBatchSize;
GLboolean havePools;
struct intel_context *dummyctxptr;
} intelScreenPrivate;