summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2007-07-19 17:42:14 +0200
committerRoland Scheidegger <[email protected]>2007-07-19 17:42:14 +0200
commit79ddb7f9a27421089efea090de6c41d2d630bb8f (patch)
tree6794b0de6f625edf669a1b1b465a7d8da5cca5f0
parentda21eff86be088852457cdcb725aed5337c4519d (diff)
more cleanups (looks pretty reasonable now)
remove some already ifdefed out, no longer functional and used code. Don't do our own scissor clipping in the pixeldraw/copy paths, as meas already does that for us...
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_buffers.c144
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_buffers.h6
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_context.c12
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_fbo.c120
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_pixel_copy.c77
-rw-r--r--src/mesa/drivers/dri/i915tex/intel_pixel_draw.c44
6 files changed, 45 insertions, 358 deletions
diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c
index 0ecf3aa1d4d..ee3266e09bd 100644
--- a/src/mesa/drivers/dri/i915tex/intel_buffers.c
+++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c
@@ -396,150 +396,6 @@ intelClearWithTris(struct intel_context *intel, GLbitfield mask)
}
-#if 0
-/* Xorg seems to handle that nowadays, and this code here no longer works with priv
- buffers */
-/**
- * Copy the window contents named by dPriv to the rotated (or reflected)
- * color buffer.
- * srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source.
- */
-void
-intelRotateWindow(struct intel_context *intel,
- __DRIdrawablePrivate * dPriv, GLuint srcBuf)
-{
-
- intelScreenPrivate *screen = intel->intelScreen;
- drm_clip_rect_t fullRect;
- struct intel_framebuffer *intel_fb;
- struct intel_region *src;
- const drm_clip_rect_t *clipRects;
- int numClipRects;
- int i;
- GLenum format, type;
-
- int origNumClipRects;
- drm_clip_rect_t *origRects;
-
- /*
- * set up hardware state
- */
- intelFlush(&intel->ctx);
-
- LOCK_HARDWARE(intel);
-
- if (!intel->numClipRects) {
- UNLOCK_HARDWARE(intel);
- return;
- }
-
- intel->vtbl.install_meta_state(intel);
-
- intel->vtbl.meta_no_depth_write(intel);
- intel->vtbl.meta_no_stencil_write(intel);
- intel->vtbl.meta_color_mask(intel, GL_FALSE);
-
-
- /* save current drawing origin and cliprects (restored at end) */
- origNumClipRects = intel->numClipRects;
- origRects = intel->pClipRects;
-
- /*
- * set drawing origin, cliprects for full-screen access to rotated screen
- */
- fullRect.x1 = 0;
- fullRect.y1 = 0;
- fullRect.x2 = screen->rotatedWidth;
- fullRect.y2 = screen->rotatedHeight;
- intel->numClipRects = 1;
- intel->pClipRects = &fullRect;
-
- intel->vtbl.meta_draw_region(intel, screen->rotated_region, NULL); /* ? */
-
- intel_fb = dPriv->driverPrivate;
-
- if ((srcBuf == BUFFER_BIT_BACK_LEFT && !intel_fb->pf_active)) {
- src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
- clipRects = dPriv->pBackClipRects;
- numClipRects = dPriv->numBackClipRects;
- }
- else {
- src = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
- clipRects = dPriv->pClipRects;
- numClipRects = dPriv->numClipRects;
- }
-
- if (src->cpp == 4) {
- format = GL_BGRA;
- type = GL_UNSIGNED_BYTE;
- }
- else {
- format = GL_BGR;
- type = GL_UNSIGNED_SHORT_5_6_5_REV;
- }
-
- /* set the whole screen up as a texture to avoid alignment issues */
- intel->vtbl.meta_tex_rect_source(intel,
- src->buffer,
- screen->width,
- screen->height, src->pitch, format, type);
-
- intel->vtbl.meta_texture_blend_replace(intel);
-
- /*
- * loop over the source window's cliprects
- */
- for (i = 0; i < numClipRects; i++) {
- int srcX0 = clipRects[i].x1;
- int srcY0 = clipRects[i].y1;
- int srcX1 = clipRects[i].x2;
- int srcY1 = clipRects[i].y2;
- GLfloat verts[4][2], tex[4][2];
- int j;
-
- /* build vertices for four corners of clip rect */
- verts[0][0] = srcX0;
- verts[0][1] = srcY0;
- verts[1][0] = srcX1;
- verts[1][1] = srcY0;
- verts[2][0] = srcX1;
- verts[2][1] = srcY1;
- verts[3][0] = srcX0;
- verts[3][1] = srcY1;
-
- /* .. and texcoords */
- tex[0][0] = srcX0;
- tex[0][1] = srcY0;
- tex[1][0] = srcX1;
- tex[1][1] = srcY0;
- tex[2][0] = srcX1;
- tex[2][1] = srcY1;
- tex[3][0] = srcX0;
- tex[3][1] = srcY1;
-
- /* transform coords to rotated screen coords */
-
- for (j = 0; j < 4; j++) {
- matrix23TransformCoordf(&screen->rotMatrix,
- &verts[j][0], &verts[j][1]);
- }
-
- /* draw polygon to map source image to dest region */
- intel_meta_draw_poly(intel, 4, verts, 0, 0, tex);
-
- } /* cliprect loop */
-
- intel->vtbl.leave_meta_state(intel);
- intel_batchbuffer_flush(intel->batch);
-
- /* restore original drawing origin and cliprects */
- intel->numClipRects = origNumClipRects;
- intel->pClipRects = origRects;
-
- UNLOCK_HARDWARE(intel);
-}
-#endif
-
/**
* Called by ctx->Driver.Clear.
*/
diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.h b/src/mesa/drivers/dri/i915tex/intel_buffers.h
index 3c7a9cf139c..13d1a15ffbf 100644
--- a/src/mesa/drivers/dri/i915tex/intel_buffers.h
+++ b/src/mesa/drivers/dri/i915tex/intel_buffers.h
@@ -52,10 +52,4 @@ extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb);
extern void intelInitBufferFuncs(struct dd_function_table *functions);
-#if 0
-extern void
-intelRotateWindow(struct intel_context *intel,
- __DRIdrawablePrivate * dPriv, GLuint srcBuf);
-#endif
-
#endif /* INTEL_BUFFERS_H */
diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c
index 5acfd923b99..769287ba6a8 100644
--- a/src/mesa/drivers/dri/i915tex/intel_context.c
+++ b/src/mesa/drivers/dri/i915tex/intel_context.c
@@ -296,17 +296,7 @@ intelCheckFrontUpdate(GLcontext * ctx)
if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] ==
BUFFER_BIT_FRONT_LEFT) {
__DRIdrawablePrivate *dPriv = intel->driDrawable;
-#if 0
- intelScreenPrivate *screen = intel->intelScreen;
- if (screen->current_rotation != 0) {
- intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
- }
- else {
- intelCopyBuffer(dPriv, NULL);
- }
-#else
intelCopyBuffer(dPriv, NULL);
-#endif
}
}
@@ -570,6 +560,8 @@ GLboolean
intelUnbindContext(__DRIcontextPrivate * driContextPriv)
{
struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate;
+ /* XXX UnbindContext is called AFTER the new context is made current.
+ Hopefully shouldn't be a problem ? */
FLUSH_VERTICES((&intel->ctx), 0);
intelFlush(&intel->ctx);
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/i915tex/intel_fbo.c b/src/mesa/drivers/dri/i915tex/intel_fbo.c
index b0c243ebe02..399a280c47c 100644
--- a/src/mesa/drivers/dri/i915tex/intel_fbo.c
+++ b/src/mesa/drivers/dri/i915tex/intel_fbo.c
@@ -299,25 +299,6 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
-#if 0
-/**
- * Called for each hardware renderbuffer when a _window_ is resized.
- * Just update fields.
- * Not used for user-created renderbuffers!
- */
-static GLboolean
-intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
- GLenum internalFormat, GLuint width, GLuint height)
-{
- ASSERT(rb->Name == 0);
- rb->Width = width;
- rb->Height = height;
- rb->_ActualFormat = internalFormat;
-
- return GL_TRUE;
-}
-#endif
-
static void
intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
GLuint width, GLuint height)
@@ -353,107 +334,6 @@ intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
-#if 0
-/**
- * Create a new intel_renderbuffer which corresponds to an on-screen window,
- * not a user-created renderbuffer.
- * \param width the screen width
- * \param height the screen height
- */
-struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat, GLsizei width, GLsizei height,
- int offset, int pitch, int cpp, void *map)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- struct intel_renderbuffer *irb;
- const GLuint name = 0;
-
- irb = CALLOC_STRUCT(intel_renderbuffer);
- if (!irb) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
- return NULL;
- }
-
- _mesa_init_renderbuffer(&irb->Base, name);
- irb->Base.ClassID = INTEL_RB_CLASS;
-
- switch (intFormat) {
- case GL_RGB5:
- irb->Base._ActualFormat = GL_RGB5;
- irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 5;
- irb->Base.GreenBits = 6;
- irb->Base.BlueBits = 5;
- irb->Base.DataType = GL_UNSIGNED_BYTE;
- cpp = 2;
- break;
- case GL_RGBA8:
- irb->Base._ActualFormat = GL_RGBA8;
- irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 8;
- irb->Base.GreenBits = 8;
- irb->Base.BlueBits = 8;
- irb->Base.AlphaBits = 8;
- irb->Base.DataType = GL_UNSIGNED_BYTE;
- cpp = 4;
- break;
- case GL_STENCIL_INDEX8_EXT:
- irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT;
- irb->Base._BaseFormat = GL_STENCIL_INDEX;
- irb->Base.StencilBits = 8;
- irb->Base.DataType = GL_UNSIGNED_BYTE;
- cpp = 1;
- break;
- case GL_DEPTH_COMPONENT16:
- irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
- irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 16;
- irb->Base.DataType = GL_UNSIGNED_SHORT;
- cpp = 2;
- break;
- case GL_DEPTH_COMPONENT24:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 24;
- irb->Base.DataType = GL_UNSIGNED_INT;
- cpp = 4;
- break;
- case GL_DEPTH24_STENCIL8_EXT:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
- irb->Base.DepthBits = 24;
- irb->Base.StencilBits = 8;
- irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
- cpp = 4;
- break;
- default:
- _mesa_problem(NULL,
- "Unexpected intFormat in intel_create_renderbuffer");
- return NULL;
- }
-
- irb->Base.InternalFormat = intFormat;
-
- /* intel-specific methods */
- irb->Base.Delete = intel_delete_renderbuffer;
- irb->Base.AllocStorage = intel_alloc_window_storage;
- irb->Base.GetPointer = intel_get_pointer;
- /* This sets the Get/PutRow/Value functions */
- intel_set_span_functions(&irb->Base);
-
- irb->pfMap = map;
- irb->pfPitch = pitch / cpp; /* in pixels */
-
-#if 00
- irb->region = intel_region_create_static(intel,
- DRM_MM_TT,
- offset, map, cpp, width, height);
-#endif
-
- return irb;
-}
-#endif
struct intel_renderbuffer *
intel_new_renderbuffer_fb(GLuint intFormat)
diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c
index 58c415215e7..2ecacc3c090 100644
--- a/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i915tex/intel_pixel_copy.c
@@ -234,6 +234,8 @@ do_blit_copypixels(GLcontext * ctx,
GLint dstx, GLint dsty, GLenum type)
{
struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_framebuffer *fbread = ctx->ReadBuffer;
struct intel_renderbuffer *irbread;
struct intel_renderbuffer *irbdraw;
struct intel_region *dst;
@@ -249,16 +251,16 @@ do_blit_copypixels(GLcontext * ctx,
intelFlush(&intel->ctx);
if (type == GL_COLOR) {
- irbread = intel_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
+ irbread = intel_renderbuffer(fbread->_ColorReadBuffer);
+ irbdraw = intel_renderbuffer(fb->_ColorDrawBuffers[0][0]);
if (!irbread || !irbread->region || !irbdraw || !irbdraw->region)
return GL_FALSE;
}
else if (type == GL_DEPTH) {
/* Don't think this is really possible execpt at 16bpp, when we have no stencil.
*/
- irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped);
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
+ irbread = intel_renderbuffer(fbread->_DepthBuffer->Wrapped);
+ irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
if (!irbread || !irbread->region || !irbdraw || !irbdraw->region
|| !(irbread->region->cpp == 2))
return GL_FALSE;
@@ -266,8 +268,8 @@ do_blit_copypixels(GLcontext * ctx,
else if (type == GL_DEPTH_STENCIL_EXT) {
/* Does it matter whether it is stencil/depth or depth/stencil?
*/
- irbread = intel_renderbuffer(ctx->ReadBuffer->_DepthBuffer->Wrapped);
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
+ irbread = intel_renderbuffer(fbread->_DepthBuffer->Wrapped);
+ irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
if (!irbread || !irbread->region || !irbdraw || !irbdraw->region)
return GL_FALSE;
}
@@ -281,61 +283,38 @@ do_blit_copypixels(GLcontext * ctx,
dst = irbdraw->region;
{
- GLint delta_x = 0;
- GLint delta_y = 0;
+ GLint dx = dstx - srcx;
+ GLint dy = dsty - srcy;
- /* Do scissoring in GL coordinates:
+ /* Clip against dest, including scissor, in GL coordinates:
*/
- if (ctx->Scissor.Enabled)
- {
- GLint x = ctx->Scissor.X;
- GLint y = ctx->Scissor.Y;
- GLuint w = ctx->Scissor.Width;
- GLuint h = ctx->Scissor.Height;
- GLint dx = dstx - srcx;
- GLint dy = dsty - srcy;
-
- if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
- goto out;
- srcx = dstx - dx;
- srcy = dsty - dy;
- }
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax - 1, fb->_Ymax - 1,
+ &dstx, &dsty, &width, &height))
+ goto out;
+
+ srcx = dstx - dx;
+ srcy = dsty - dy;
/* Convert from GL to hardware coordinates:
*/
- dsty = irbdraw->Base.Height - dsty - height;
- srcy = irbread->Base.Height - srcy - height;
+ dsty = fb->Height - dsty - height;
+ srcy = fbread->Height - srcy - height;
/* Clip against the source region:
*/
- {
- delta_x = srcx - dstx;
- delta_y = srcy - dsty;
+ dx = srcx - dstx;
+ dy = srcy - dsty;
- if (!_mesa_clip_to_region(0, 0, irbread->Base.Width - 1,
- irbread->Base.Height - 1,
- &srcx, &srcy, &width, &height))
- goto out;
+ if (!_mesa_clip_to_region(0, 0, irbread->Base.Width - 1,
+ irbread->Base.Height - 1,
+ &srcx, &srcy, &width, &height))
+ goto out;
- dstx = srcx - delta_x;
- dsty = srcy - delta_y;
- }
+ dstx = srcx - dx;
+ dsty = srcy - dy;
- /* Clip against the dest region:
- */
- {
- delta_x = dstx - srcx;
- delta_y = dsty - srcy;
-
- if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1,
- irbdraw->Base.Height - 1,
- &dstx, &dsty, &width, &height))
- goto out;
-
- srcx = dstx - delta_x;
- srcy = dsty - delta_y;
- }
{
diff --git a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
index 4d6b4af5898..4139117206e 100644
--- a/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/i915tex/intel_pixel_draw.c
@@ -219,33 +219,33 @@ do_blit_drawpixels(GLcontext * ctx,
const GLvoid * pixels)
{
struct intel_context *intel = intel_context(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
struct intel_renderbuffer *irbdraw;
struct intel_region *dest;
struct intel_buffer_object *src = intel_buffer_object(unpack->BufferObj);
GLuint src_offset;
GLuint rowLength;
- GLuint height_orig = height;
struct _DriFenceObject *fence = NULL;
if (INTEL_DEBUG & DEBUG_PIXEL)
_mesa_printf("%s\n", __FUNCTION__);
if (type == GL_COLOR) {
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
+ irbdraw = intel_renderbuffer(fb->_ColorDrawBuffers[0][0]);
if (!irbdraw || !irbdraw->region)
return GL_FALSE;
}
else if (type == GL_DEPTH) {
/* Don't think this is really possible execpt at 16bpp, when we have no stencil.
*/
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
+ irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
if (!irbdraw || !irbdraw->region || !(irbdraw->region->cpp == 2))
return GL_FALSE;
}
else if (type == GL_DEPTH_STENCIL_EXT) {
/* Does it matter whether it is stencil/depth or depth/stencil?
*/
- irbdraw = intel_renderbuffer(ctx->DrawBuffer->_DepthBuffer->Wrapped);
+ irbdraw = intel_renderbuffer(fb->_DepthBuffer->Wrapped);
if (!irbdraw || !irbdraw->region)
return GL_FALSE;
}
@@ -331,40 +331,26 @@ do_blit_drawpixels(GLcontext * ctx,
GLuint srcy = 0;
GLint dx = dstx;
GLint dy = dsty;
+ GLuint height_orig = height;
- /* Do scissoring in GL coordinates:
+ /* Do scissoring and clipping in GL coordinates, no need to clip against
+ * pbo src region (note fbo fields include scissor already):
*/
- if (ctx->Scissor.Enabled)
- {
- GLint x = ctx->Scissor.X;
- GLint y = ctx->Scissor.Y;
- GLuint w = ctx->Scissor.Width;
- GLuint h = ctx->Scissor.Height;
- height_orig = height;
-
-
- if (!_mesa_clip_to_region(x, y, x+w-1, y+h-1, &dstx, &dsty, &width, &height))
- goto out;
-
- }
+ height_orig = height;
+ if (!_mesa_clip_to_region(fb->_Xmin, fb->_Ymin,
+ fb->_Xmax - 1, fb->_Ymax - 1,
+ &dstx, &dsty, &width, &height))
+ goto out;
- /* no need to clip against pbo src region, but clip against dest */
- {
- if (!_mesa_clip_to_region(0, 0, irbdraw->Base.Width - 1,
- irbdraw->Base.Height - 1,
- &dstx, &dsty, &width, &height))
- goto out;
-
- srcx = dstx - dx;
- srcy = dsty - dy;
- }
+ srcx = dstx - dx;
+ srcy = dsty - dy;
struct _DriBufferObject *src_buffer =
intel_bufferobj_buffer(intel, src, INTEL_READ);
/* Convert from GL to hardware coordinates:
*/
- dsty = irbdraw->Base.Height - dsty - height;
+ dsty = fb->Height - dsty - height;
srcy = height_orig - srcy - height;
{