radeon: Simplify cliprects computation now that there's just 1.
authorEric Anholt <eric@anholt.net>
Fri, 14 Oct 2011 20:52:31 +0000 (13:52 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 28 Oct 2011 18:31:11 +0000 (11:31 -0700)
This can probably be reduced even further by moving this logic to the
scissor state update or just removing the logic entirely, but I don't
trust myself in radeon quite that much.

src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/drivers/dri/radeon/radeon_common.h
src/mesa/drivers/dri/radeon/radeon_common_context.h

index 64a7c3f33ff6a04a27cbb318847e9c05f0ae7d4a..c7ba2afc473842236ff9cf3702b6117f956e270d 100644 (file)
@@ -90,24 +90,18 @@ static GLboolean intersect_rect(drm_clip_rect_t * out,
 
 void radeonRecalcScissorRects(radeonContextPtr radeon)
 {
-       drm_clip_rect_t *out;
-       int i;
-
-       /* Grow cliprect store?
-        */
-       if (radeon->state.scissor.numAllocedClipRects < radeon->numClipRects) {
-               while (radeon->state.scissor.numAllocedClipRects <
-                      radeon->numClipRects) {
-                       radeon->state.scissor.numAllocedClipRects += 1; /* zero case */
-                       radeon->state.scissor.numAllocedClipRects *= 2;
-               }
+       struct gl_context *ctx = radeon->glCtx;
+       drm_clip_rect_t bounds;
 
-               if (radeon->state.scissor.pClipRects)
-                       FREE(radeon->state.scissor.pClipRects);
+       bounds.x1 = 0;
+       bounds.y1 = 0;
+       bounds.x2 = ctx->DrawBuffer->Width;
+       bounds.x2 = ctx->DrawBuffer->Height;
 
+       if (!radeon->state.scissor.numAllocedClipRects) {
+               radeon->state.scissor.numAllocedClipRects = 1;
                radeon->state.scissor.pClipRects =
-                       MALLOC(radeon->state.scissor.numAllocedClipRects *
-                              sizeof(drm_clip_rect_t));
+                       MALLOC(sizeof(drm_clip_rect_t));
 
                if (radeon->state.scissor.pClipRects == NULL) {
                        radeon->state.scissor.numAllocedClipRects = 0;
@@ -115,54 +109,17 @@ void radeonRecalcScissorRects(radeonContextPtr radeon)
                }
        }
 
-       out = radeon->state.scissor.pClipRects;
        radeon->state.scissor.numClipRects = 0;
-
-       for (i = 0; i < radeon->numClipRects; i++) {
-               if (intersect_rect(out,
-                                  &radeon->pClipRects[i],
-                                  &radeon->state.scissor.rect)) {
-                       radeon->state.scissor.numClipRects++;
-                       out++;
-               }
+       if (intersect_rect(radeon->state.scissor.pClipRects,
+                          &bounds,
+                          &radeon->state.scissor.rect)) {
+               radeon->state.scissor.numClipRects = 1;
        }
 
        if (radeon->vtbl.update_scissor)
           radeon->vtbl.update_scissor(radeon->glCtx);
 }
 
-void radeon_get_cliprects(radeonContextPtr radeon,
-                         struct drm_clip_rect **cliprects,
-                         unsigned int *num_cliprects,
-                         int *x_off, int *y_off)
-{
-       __DRIdrawable *dPriv = radeon_get_drawable(radeon);
-       struct radeon_framebuffer *rfb = dPriv->driverPrivate;
-
-       if (radeon->constant_cliprect) {
-               radeon->fboRect.x1 = 0;
-               radeon->fboRect.y1 = 0;
-               radeon->fboRect.x2 = radeon->glCtx->DrawBuffer->Width;
-               radeon->fboRect.y2 = radeon->glCtx->DrawBuffer->Height;
-
-               *cliprects = &radeon->fboRect;
-               *num_cliprects = 1;
-               *x_off = 0;
-               *y_off = 0;
-       } else if (radeon->front_cliprects ||
-                  rfb->pf_active || dPriv->numBackClipRects == 0) {
-               *cliprects = dPriv->pClipRects;
-               *num_cliprects = dPriv->numClipRects;
-               *x_off = dPriv->x;
-               *y_off = dPriv->y;
-       } else {
-               *num_cliprects = dPriv->numBackClipRects;
-               *cliprects = dPriv->pBackClipRects;
-               *x_off = dPriv->backX;
-               *y_off = dPriv->backY;
-       }
-}
-
 /**
  * Update cliprects and scissors.
  */
@@ -176,10 +133,6 @@ void radeonSetCliprects(radeonContextPtr radeon)
 
        struct radeon_framebuffer *const draw_rfb = drawable->driverPrivate;
        struct radeon_framebuffer *const read_rfb = readable->driverPrivate;
-       int x_off, y_off;
-
-       radeon_get_cliprects(radeon, &radeon->pClipRects,
-                            &radeon->numClipRects, &x_off, &y_off);
 
        if ((draw_rfb->base.Width != drawable->w) ||
            (draw_rfb->base.Height != drawable->h)) {
@@ -766,8 +719,7 @@ int rcommonFlushCmdBufLocked(radeonContextPtr rmesa, const char *caller)
        rmesa->cmdbuf.flushing = 1;
 
        if (RADEON_DEBUG & RADEON_IOCTL) {
-               fprintf(stderr, "%s from %s - %i cliprects\n",
-                       __FUNCTION__, caller, rmesa->numClipRects);
+               fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
        }
 
        radeonEmitQueryEnd(rmesa->glCtx);
index 344250efcef3ae91829444ff3252a0094df9e5c7..67925cb9a10b2d1f677628e38242a6c29537fbaa 100644 (file)
@@ -25,10 +25,6 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb);
 void radeonDrawBuffer( struct gl_context *ctx, GLenum mode );
 void radeonReadBuffer( struct gl_context *ctx, GLenum mode );
 void radeon_viewport(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height);
-void radeon_get_cliprects(radeonContextPtr radeon,
-                         struct drm_clip_rect **cliprects,
-                         unsigned int *num_cliprects,
-                         int *x_off, int *y_off);
 void radeon_fbo_init(struct radeon_context *radeon);
 void
 radeon_renderbuffer_set_bo(struct radeon_renderbuffer *rb,
index ef39913b24ad02d216d631cb0495dc829f03a3e8..2b478e1ee0cd814ad34e025efc1d484150c76cf8 100644 (file)
@@ -457,9 +457,7 @@ struct radeon_context {
    GLuint NewGLState;
    DECLARE_RENDERINPUTS(tnl_index_bitset);     /* index of bits for last tnl_install_attrs */
 
-   /* Drawable, cliprect and scissor information */
-   GLuint numClipRects;        /* Cliprects for the draw buffer */
-   drm_clip_rect_t *pClipRects;
+   /* Drawable information */
    unsigned int lastStamp;
    drm_radeon_sarea_t *sarea;  /* Private SAREA data */