gallium: add some #if FEATURE_x tests
[mesa.git] / src / mesa / state_tracker / st_cb_blit.c
index dfa79c975c11e8e7f7c745c2ec88fdfcaa642815..799ef3f3be857d2f33dfb25c7b9e347cfe36aaf7 100644 (file)
@@ -52,7 +52,7 @@
 void
 st_init_blit(struct st_context *st)
 {
-   st->blit = util_create_blit(st->pipe);
+   st->blit = util_create_blit(st->pipe, st->cso_context);
 }
 
 
@@ -71,7 +71,6 @@ st_BlitFramebuffer(GLcontext *ctx,
                    GLbitfield mask, GLenum filter)
 {
    struct st_context *st = ctx->st;
-   struct pipe_context *pipe = st->pipe;
 
    const uint pFilter = ((filter == GL_NEAREST)
                          ? PIPE_TEX_MIPFILTER_NEAREST
@@ -85,11 +84,14 @@ st_BlitFramebuffer(GLcontext *ctx,
       struct pipe_surface *srcSurf = srcRb->surface;
       struct pipe_surface *dstSurf = dstRb->surface;
 
-      srcY0 = srcRb->Base.Height - srcY0;
-      srcY1 = srcRb->Base.Height - srcY1;
+      if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
+         /* invert Y */
+         srcY0 = srcRb->Base.Height - srcY0;
+         srcY1 = srcRb->Base.Height - srcY1;
 
-      dstY0 = dstRb->Base.Height - dstY0;
-      dstY1 = dstRb->Base.Height - dstY1;
+         dstY0 = dstRb->Base.Height - dstY0;
+         dstY1 = dstRb->Base.Height - dstY1;
+      }
 
       util_blit_pixels(st->blit,
                        srcSurf, srcX0, srcY0, srcX1, srcY1,
@@ -97,23 +99,6 @@ st_BlitFramebuffer(GLcontext *ctx,
                        0.0, pFilter);
 
    }
-
-#if 0
-   /* XXX is this sufficient? */
-   st_invalidate_state(ctx, _NEW_COLOR | _NEW_TEXTURE);
-#else
-   /* need to "unset" cso state because we went behind the back of the cso
-    * tracker.  Without unset, the _set_ calls would be no-ops.
-    */
-   cso_unset_blend(st->cso_context);
-   cso_unset_depth_stencil_alpha(st->cso_context);
-   cso_unset_rasterizer(st->cso_context);
-   cso_set_blend(st->cso_context, &st->state.blend);
-   cso_set_depth_stencil_alpha(st->cso_context, &st->state.depth_stencil);
-   cso_set_rasterizer(st->cso_context, &st->state.rasterizer);
-   pipe->bind_fs_state(pipe, st->fp->driver_shader);
-   pipe->bind_vs_state(pipe, st->vp->driver_shader);
-#endif
 }
 
 
@@ -121,5 +106,7 @@ st_BlitFramebuffer(GLcontext *ctx,
 void
 st_init_blit_functions(struct dd_function_table *functions)
 {
+#if FEATURE_EXT_framebuffer_blit
    functions->BlitFramebuffer = st_BlitFramebuffer;
+#endif
 }