r600g: Use the actual Evergreen functions to query format support on Evergreen.
[mesa.git] / src / gallium / auxiliary / util / u_blitter.c
index 079dce76ad86f42c045afa85d93b19f6caf16f71..528f344a0f79dbdccd9397d4cbb03e49476d7a1e 100644 (file)
@@ -104,8 +104,6 @@ struct blitter_context_priv
    /* Destination surface dimensions. */
    unsigned dst_width;
    unsigned dst_height;
-
-   boolean running;
 };
 
 static void blitter_draw_rectangle(struct blitter_context *blitter,
@@ -269,11 +267,11 @@ void util_blitter_destroy(struct blitter_context *blitter)
 
 static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
 {
-   if (ctx->running) {
+   if (ctx->base.running) {
       _debug_printf("u_blitter: Caught recursion on save. "
                     "This is a driver bug.\n");
    }
-   ctx->running = TRUE;
+   ctx->base.running = TRUE;
 
    /* make sure these CSOs have been saved */
    assert(ctx->base.saved_blend_state != INVALID_PTR &&
@@ -349,11 +347,11 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
       ctx->base.saved_num_vertex_buffers = ~0;
    }
 
-   if (!ctx->running) {
+   if (!ctx->base.running) {
       _debug_printf("u_blitter: Caught recursion on restore. "
                     "This is a driver bug.\n");
    }
-   ctx->running = FALSE;
+   ctx->base.running = FALSE;
 }
 
 static void blitter_set_rectangle(struct blitter_context_priv *ctx,
@@ -641,7 +639,9 @@ static void blitter_draw_rectangle(struct blitter_context *blitter,
    }
 
    blitter_set_rectangle(ctx, x1, y1, x2, y2, depth);
-   util_draw_vertex_buffer(ctx->base.pipe, ctx->vbuf, 0,
+   ctx->base.pipe->redefine_user_buffer(ctx->base.pipe, ctx->vbuf,
+                                        0, ctx->vbuf->width0);
+   util_draw_vertex_buffer(ctx->base.pipe, NULL, ctx->vbuf, 0,
                            PIPE_PRIM_TRIANGLE_FAN, 4, 2);
 }
 
@@ -770,19 +770,22 @@ void util_blitter_copy_region(struct blitter_context *blitter,
 
    /* Check if we can sample from and render to the surfaces. */
    /* (assuming copying a stencil buffer is not possible) */
-    if ((!ignore_stencil && is_stencil) ||
+   if ((!ignore_stencil && is_stencil) ||
        !screen->is_format_supported(screen, dst->format, dst->target,
-                                    dst->nr_samples, bind, 0) ||
+                                    dst->nr_samples, bind) ||
        !screen->is_format_supported(screen, src->format, src->target,
-                                    src->nr_samples, PIPE_BIND_SAMPLER_VIEW, 0)) {
+                                    src->nr_samples, PIPE_BIND_SAMPLER_VIEW)) {
+      ctx->base.running = TRUE;
       util_resource_copy_region(pipe, dst, dstlevel, dstx, dsty, dstz,
                                 src, srclevel, srcbox);
+      ctx->base.running = FALSE;
       return;
    }
 
    /* Get surface. */
    memset(&surf_templ, 0, sizeof(surf_templ));
    u_surface_default_template(&surf_templ, dst, bind);
+   surf_templ.format = util_format_linear(dst->format);
    surf_templ.u.tex.level = dstlevel;
    surf_templ.u.tex.first_layer = dstz;
    surf_templ.u.tex.last_layer = dstz;
@@ -821,7 +824,7 @@ void util_blitter_copy_region(struct blitter_context *blitter,
    normalized = src->target != PIPE_TEXTURE_RECT;
 
    /* Initialize sampler view. */
-   u_sampler_view_default_template(&viewTempl, src, src->format);
+   u_sampler_view_default_template(&viewTempl, src, util_format_linear(src->format));
    view = pipe->create_sampler_view(pipe, src, &viewTempl);
 
    /* Set rasterizer state, shaders, and textures. */
@@ -867,7 +870,9 @@ void util_blitter_copy_region(struct blitter_context *blitter,
 
          /* Draw. */
          blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0);
-         util_draw_vertex_buffer(ctx->base.pipe, ctx->vbuf, 0,
+         ctx->base.pipe->redefine_user_buffer(ctx->base.pipe, ctx->vbuf,
+                                              0, ctx->vbuf->width0);
+         util_draw_vertex_buffer(ctx->base.pipe, NULL, ctx->vbuf, 0,
                                  PIPE_PRIM_TRIANGLE_FAN, 4, 2);
          break;