r600g,radeonsi: consolidate create_surface and surface_destroy
[mesa.git] / src / gallium / drivers / radeonsi / si_blit.c
index 250caab64e138f852af7afaa21ac429e678d674b..9975b4417f23a6b4f638016acee67372f8190559 100644 (file)
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
-#include "util/u_surface.h"
+
+#include "si_pipe.h"
 #include "util/u_blitter.h"
 #include "util/u_format.h"
-#include "si_pipe.h"
-#include "si_state.h"
 
 enum si_blitter_op /* bitmask */
 {
@@ -58,6 +57,7 @@ static void si_blitter_begin(struct pipe_context *ctx, enum si_blitter_op op)
        util_blitter_save_stencil_ref(sctx->blitter, &sctx->stencil_ref);
        util_blitter_save_rasterizer(sctx->blitter, sctx->queued.named.rasterizer);
        util_blitter_save_fragment_shader(sctx->blitter, sctx->ps_shader);
+       util_blitter_save_geometry_shader(sctx->blitter, sctx->gs_shader);
        util_blitter_save_vertex_shader(sctx->blitter, sctx->vs_shader);
        util_blitter_save_vertex_elements(sctx->blitter, sctx->vertex_elements);
        if (sctx->queued.named.viewport) {
@@ -483,9 +483,11 @@ static void si_resource_copy_region(struct pipe_context *ctx,
                                    const struct pipe_box *src_box)
 {
        struct si_context *sctx = (struct si_context *)ctx;
+       struct r600_texture *rdst = (struct r600_texture*)dst;
+       struct pipe_surface *dst_view, dst_templ;
+       struct pipe_sampler_view src_templ, *src_view;
        struct texture_orig_info orig_info[2];
-       struct pipe_box sbox;
-       const struct pipe_box *psbox = src_box;
+       struct pipe_box sbox, dstbox;
        boolean restore_orig[2];
 
        /* Fallback for buffers. */
@@ -513,7 +515,7 @@ static void si_resource_copy_region(struct pipe_context *ctx,
                sbox.width = util_format_get_nblocksx(orig_info[0].format, src_box->width);
                sbox.height = util_format_get_nblocksy(orig_info[0].format, src_box->height);
                sbox.depth = src_box->depth;
-               psbox=&sbox;
+               src_box = &sbox;
 
                si_compressed_to_blittable(dst, dst_level, &orig_info[1]);
                restore_orig[1] = TRUE;
@@ -563,11 +565,29 @@ static void si_resource_copy_region(struct pipe_context *ctx,
                restore_orig[1] = TRUE;
        }
 
+       /* Initialize the surface. */
+       util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
+       dst_view = r600_create_surface_custom(ctx, dst, &dst_templ,
+                                             rdst->surface.level[dst_level].npix_x,
+                                             rdst->surface.level[dst_level].npix_y);
+
+       /* Initialize the sampler view. */
+       util_blitter_default_src_texture(&src_templ, src, src_level);
+       src_view = ctx->create_sampler_view(ctx, src, &src_templ);
+
+       u_box_3d(dstx, dsty, dstz, abs(src_box->width), abs(src_box->height),
+                abs(src_box->depth), &dstbox);
+
+       /* Copy. */
        si_blitter_begin(ctx, SI_COPY);
-       util_blitter_copy_texture(sctx->blitter, dst, dst_level, dstx, dsty, dstz,
-                                 src, src_level, psbox);
+       util_blitter_blit_generic(sctx->blitter, dst_view, &dstbox,
+                                 src_view, src_box, src->width0, src->height0,
+                                 PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL);
        si_blitter_end(ctx);
 
+       pipe_surface_reference(&dst_view, NULL);
+       pipe_sampler_view_reference(&src_view, NULL);
+
        if (restore_orig[0])
                si_reset_blittable_to_orig(src, src_level, &orig_info[0]);