gallium: implement blit in driver wrappers
authorMarek Olšák <maraeo@gmail.com>
Wed, 12 Sep 2012 22:12:22 +0000 (00:12 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 30 Sep 2012 16:57:56 +0000 (18:57 +0200)
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/galahad/glhd_context.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/noop/noop_pipe.c
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/drivers/trace/tr_dump_state.h

index 601081b0dc160e130781b735fa3cb72b86c1fa54..e20986fca6e372c0b01a2e9f602a5ab9a43d2a80 100644 (file)
@@ -721,6 +721,31 @@ galahad_context_resource_copy_region(struct pipe_context *_pipe,
                               src_box);
 }
 
+static void
+galahad_context_blit(struct pipe_context *_pipe,
+                     const struct pipe_blit_info *info)
+{
+   struct galahad_context *glhd_pipe = galahad_context(_pipe);
+   struct pipe_context *pipe = glhd_pipe->pipe;
+
+   if (info->dst.box.width < 0 ||
+       info->dst.box.height < 0)
+      glhd_error("Destination dimensions are negative");
+
+   if (info->filter != PIPE_TEX_FILTER_NEAREST &&
+       info->src.resource->target != PIPE_TEXTURE_3D &&
+       info->dst.box.depth != info->src.box.depth)
+      glhd_error("Filtering in z-direction on non-3D texture");
+
+   if (util_format_is_depth_or_stencil(info->dst.format) !=
+       util_format_is_depth_or_stencil(info->src.format))
+      glhd_error("Invalid format conversion: %s <- %s\n",
+                 util_format_name(info->dst.format),
+                 util_format_name(info->src.format));
+
+   pipe->blit(pipe, info);
+}
+
 static void
 galahad_context_clear(struct pipe_context *_pipe,
                unsigned buffers,
@@ -1054,6 +1079,7 @@ galahad_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    //GLHD_PIPE_INIT(stream_output_target_destroy);
    //GLHD_PIPE_INIT(set_stream_output_targets);
    GLHD_PIPE_INIT(resource_copy_region);
+   GLHD_PIPE_INIT(blit);
    //GLHD_PIPE_INIT(resource_resolve);
    GLHD_PIPE_INIT(clear);
    GLHD_PIPE_INIT(clear_render_target);
index f5c6a5cc4fa1386f11eda4dec41f97ff488142b3..cf0a3f9aa409e632dc3c7f2deb4397a4e86d363a 100644 (file)
@@ -632,6 +632,20 @@ identity_resource_copy_region(struct pipe_context *_pipe,
                               src_box);
 }
 
+static void
+identity_blit(struct pipe_context *_pipe,
+              const struct pipe_blit_info *info)
+{
+   struct identity_context *id_pipe = identity_context(_pipe);
+   struct pipe_context *pipe = id_pipe->pipe;
+   struct pipe_blit_info blit = *info;
+
+   blit.src.resource = identity_resource(blit.src.resource)->resource;
+   blit.dst.resource = identity_resource(blit.dst.resource)->resource;
+
+   pipe->blit(pipe, &blit);
+}
+
 static void
 identity_clear(struct pipe_context *_pipe,
                unsigned buffers,
@@ -937,6 +951,7 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
    id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region;
    id_pipe->base.transfer_inline_write = identity_context_transfer_inline_write;
+   id_pipe->base.blit = identity_blit;
 
    id_pipe->pipe = pipe;
 
index 8e777332be634a0103c2bfbc950b9ff8a765f8b0..6411418c3fe69bc2916fa0c0e2cd010a59350b99 100644 (file)
@@ -241,6 +241,12 @@ static void noop_resource_copy_region(struct pipe_context *ctx,
 }
 
 
+static void noop_blit(struct pipe_context *ctx,
+                      const struct pipe_blit_info *info)
+{
+}
+
+
 /*
  * context
  */
@@ -268,6 +274,7 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen, void
        ctx->clear_render_target = noop_clear_render_target;
        ctx->clear_depth_stencil = noop_clear_depth_stencil;
        ctx->resource_copy_region = noop_resource_copy_region;
+       ctx->blit = noop_blit;
        ctx->create_query = noop_create_query;
        ctx->destroy_query = noop_destroy_query;
        ctx->begin_query = noop_begin_query;
index f50a7426ed5c7c2b929718b770211fde24eb813b..affdfca228fd573bd4519b2395557b00cdfa3d6a 100644 (file)
@@ -1226,6 +1226,28 @@ trace_context_resource_copy_region(struct pipe_context *_pipe,
 }
 
 
+static INLINE void
+trace_context_blit(struct pipe_context *_pipe,
+                   const struct pipe_blit_info *_info)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+   struct pipe_blit_info info = *_info;
+
+   info.dst.resource = trace_resource_unwrap(tr_ctx, info.dst.resource);
+   info.src.resource = trace_resource_unwrap(tr_ctx, info.src.resource);
+
+   trace_dump_call_begin("pipe_context", "blit");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(blit_info, _info);
+
+   pipe->blit(pipe, &info);
+
+   trace_dump_call_end();
+}
+
+
 static INLINE void
 trace_context_clear(struct pipe_context *_pipe,
                     unsigned buffers,
@@ -1637,6 +1659,7 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(stream_output_target_destroy);
    TR_CTX_INIT(set_stream_output_targets);
    TR_CTX_INIT(resource_copy_region);
+   TR_CTX_INIT(blit);
    TR_CTX_INIT(clear);
    TR_CTX_INIT(clear_render_target);
    TR_CTX_INIT(clear_depth_stencil);
index 2e8df54cebaa9532b8eda83f64d56191041baf92..3df6f1220d135445b3c278cbd2337b43b8ac892f 100644 (file)
@@ -96,12 +96,12 @@ void trace_dump_box(const struct pipe_box *box)
 
    trace_dump_struct_begin("pipe_box");
 
-   trace_dump_member(uint, box, x);
-   trace_dump_member(uint, box, y);
-   trace_dump_member(uint, box, z);
-   trace_dump_member(uint, box, width);
-   trace_dump_member(uint, box, height);
-   trace_dump_member(uint, box, depth);
+   trace_dump_member(int, box, x);
+   trace_dump_member(int, box, y);
+   trace_dump_member(int, box, z);
+   trace_dump_member(int, box, width);
+   trace_dump_member(int, box, height);
+   trace_dump_member(int, box, depth);
 
    trace_dump_struct_end();
 }
@@ -693,3 +693,60 @@ void trace_dump_draw_info(const struct pipe_draw_info *state)
 
    trace_dump_struct_end();
 }
+
+void trace_dump_blit_info(const struct pipe_blit_info *info)
+{
+   char mask[7];
+
+   if (!trace_dumping_enabled_locked())
+      return;
+
+   if (!info) {
+      trace_dump_null();
+      return;
+   }
+
+   trace_dump_struct_begin("pipe_blit_info");
+
+   trace_dump_member_begin("dst");
+   trace_dump_struct_begin("dst");
+   trace_dump_member(resource_ptr, &info->dst, resource);
+   trace_dump_member(uint, &info->dst, level);
+   trace_dump_member(format, &info->dst, format);
+   trace_dump_member_begin("box");
+   trace_dump_box(&info->dst.box);
+   trace_dump_member_end();
+   trace_dump_struct_end();
+   trace_dump_member_end();
+
+   trace_dump_member_begin("src");
+   trace_dump_struct_begin("src");
+   trace_dump_member(resource_ptr, &info->src, resource);
+   trace_dump_member(uint, &info->src, level);
+   trace_dump_member(format, &info->src, format);
+   trace_dump_member_begin("box");
+   trace_dump_box(&info->src.box);
+   trace_dump_member_end();
+   trace_dump_struct_end();
+   trace_dump_member_end();
+
+   mask[0] = (info->mask & PIPE_MASK_R) ? 'R' : '-';
+   mask[1] = (info->mask & PIPE_MASK_G) ? 'G' : '-';
+   mask[2] = (info->mask & PIPE_MASK_B) ? 'B' : '-';
+   mask[3] = (info->mask & PIPE_MASK_A) ? 'A' : '-';
+   mask[4] = (info->mask & PIPE_MASK_Z) ? 'Z' : '-';
+   mask[5] = (info->mask & PIPE_MASK_S) ? 'S' : '-';
+   mask[6] = 0;
+
+   trace_dump_member_begin("mask");
+   trace_dump_string(mask);
+   trace_dump_member_end();
+   trace_dump_member(uint, info, filter);
+
+   trace_dump_member(bool, info, scissor_enable);
+   trace_dump_member_begin("scissor");
+   trace_dump_scissor_state(&info->scissor);
+   trace_dump_member_end();
+
+   trace_dump_struct_end();
+}
index a6e7ccdb864f9fd3d4c6d75aa2961610e9abe563..e17246b21b1340013b5fe28403315ada13cbae59 100644 (file)
@@ -81,5 +81,7 @@ void trace_dump_vertex_element(const struct pipe_vertex_element *state);
 
 void trace_dump_draw_info(const struct pipe_draw_info *state);
 
+void trace_dump_blit_info(const struct pipe_blit_info *);
+
 
 #endif /* TR_STATE_H */