Exemple #1
0
static void r128RunPipeline( GLcontext *ctx )
{
   r128ContextPtr rmesa = R128_CONTEXT(ctx);

   if (rmesa->new_state || rmesa->NewGLState & _NEW_TEXTURE)
      r128DDUpdateHWState( ctx );

   if (!rmesa->Fallback && rmesa->NewGLState) {
      if (rmesa->NewGLState & _R128_NEW_RENDER_STATE)
	 r128ChooseRenderState( ctx );

      rmesa->NewGLState = 0;
   }

   _tnl_run_pipeline( ctx );
}
Exemple #2
0
static void r128Clear( GLcontext *ctx, GLbitfield mask )
{
    r128ContextPtr rmesa = R128_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
    drm_r128_clear_t clear;
    GLuint flags = 0;
    GLint i;
    GLint ret;
    GLuint depthmask = 0;
    GLint cx, cy, cw, ch;

    if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
        fprintf( stderr, "%s:\n", __FUNCTION__ );
    }

    FLUSH_BATCH( rmesa );

    /* The only state change we care about here is the RGBA colormask
     * We'll just update that state, if needed.  If we do more then
     * there's some strange side-effects that the conformance tests find.
     */
    if ( rmesa->new_state & R128_NEW_MASKS) {
        const GLuint save_state = rmesa->new_state;
        rmesa->new_state = R128_NEW_MASKS;
        r128DDUpdateHWState( ctx );
        rmesa->new_state = save_state & ~R128_NEW_MASKS;
    }

    if ( mask & BUFFER_BIT_FRONT_LEFT ) {
        flags |= R128_FRONT;
        mask &= ~BUFFER_BIT_FRONT_LEFT;
    }

    if ( mask & BUFFER_BIT_BACK_LEFT ) {
        flags |= R128_BACK;
        mask &= ~BUFFER_BIT_BACK_LEFT;
    }

    if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
        flags |= R128_DEPTH;
        /* if we're at 16 bits, extra plane mask won't hurt */
        depthmask |= 0x00ffffff;
        mask &= ~BUFFER_BIT_DEPTH;
    }

    if ( mask & BUFFER_BIT_STENCIL &&
            (ctx->Visual.stencilBits > 0 && ctx->Visual.depthBits == 24) ) {
        flags |= R128_DEPTH;
        depthmask |= ctx->Stencil.WriteMask[0] << 24;
        mask &= ~BUFFER_BIT_STENCIL;
    }

    if ( flags ) {

        LOCK_HARDWARE( rmesa );

        /* compute region after locking: */
        cx = ctx->DrawBuffer->_Xmin;
        cy = ctx->DrawBuffer->_Ymin;
        cw = ctx->DrawBuffer->_Xmax - cx;
        ch = ctx->DrawBuffer->_Ymax - cy;

        /* Flip top to bottom */
        cx += dPriv->x;
        cy  = dPriv->y + dPriv->h - cy - ch;

        /* FIXME: Do we actually need this?
         */
        if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) {
            r128EmitHwStateLocked( rmesa );
        }

        for ( i = 0 ; i < rmesa->numClipRects ; ) {
            GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects );
            drm_clip_rect_t *box = rmesa->pClipRects;
            drm_clip_rect_t *b = rmesa->sarea->boxes;
            GLint n = 0;

            if (cw != dPriv->w || ch != dPriv->h) {
                /* clear subregion */
                for ( ; i < nr ; i++ ) {
                    GLint x = box[i].x1;
                    GLint y = box[i].y1;
                    GLint w = box[i].x2 - x;
                    GLint h = box[i].y2 - y;

                    if ( x < cx ) w -= cx - x, x = cx;
                    if ( y < cy ) h -= cy - y, y = cy;
                    if ( x + w > cx + cw ) w = cx + cw - x;
                    if ( y + h > cy + ch ) h = cy + ch - y;
                    if ( w <= 0 ) continue;
                    if ( h <= 0 ) continue;

                    b->x1 = x;
                    b->y1 = y;
                    b->x2 = x + w;
                    b->y2 = y + h;
                    b++;
                    n++;
                }
            } else {
                /* clear whole window */
                for ( ; i < nr ; i++ ) {
                    *b++ = box[i];
                    n++;
                }
            }

            rmesa->sarea->nbox = n;

            if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) {
                fprintf( stderr,
                         "DRM_R128_CLEAR: flag 0x%x color %x depth %x nbox %d\n",
                         flags,
                         (GLuint)rmesa->ClearColor,
                         (GLuint)rmesa->ClearDepth,
                         rmesa->sarea->nbox );
            }

            clear.flags = flags;
            clear.clear_color = rmesa->ClearColor;
            clear.clear_depth = rmesa->ClearDepth;
            clear.color_mask = rmesa->setup.plane_3d_mask_c;
            clear.depth_mask = depthmask;

            ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR,
                                   &clear, sizeof(clear) );

            if ( ret ) {
                UNLOCK_HARDWARE( rmesa );
                fprintf( stderr, "DRM_R128_CLEAR: return = %d\n", ret );
                exit( 1 );
            }
        }

        UNLOCK_HARDWARE( rmesa );

        rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
    }

    if ( mask )
        _swrast_Clear( ctx, mask );
}