From 4b2fcb2bcb7a93cf3dc8cd164f4e87b5c538f7f6 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Sun, 13 Jun 2010 17:36:34 -0400 Subject: [PATCH] vl: Add transfer funcs to pipe_video_context and softpipe. --- .../drivers/softpipe/sp_video_context.c | 95 +++++++++++++++++++ src/gallium/include/pipe/p_video_context.h | 28 ++++++ 2 files changed, 123 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index 9d3a1ab5f5b..44df00e0b78 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -161,6 +161,94 @@ sp_mpeg12_surface_copy(struct pipe_video_context *vpipe, util_surface_copy(ctx->pipe, FALSE, dst, dstx, dsty, src, srcx, srcy, width, height); } +static struct pipe_transfer* +sp_mpeg12_get_transfer(struct pipe_video_context *vpipe, + struct pipe_resource *resource, + struct pipe_subresource subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *box) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(resource); + assert(box); + + return ctx->pipe->get_transfer(ctx->pipe, resource, subresource, usage, box); +} + +static void +sp_mpeg12_transfer_destroy(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(transfer); + + ctx->pipe->transfer_destroy(ctx->pipe, transfer); +} + +static void* +sp_mpeg12_transfer_map(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(transfer); + + return ctx->pipe->transfer_map(ctx->pipe, transfer); +} + +static void +sp_mpeg12_transfer_flush_region(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer, + const struct pipe_box *box) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(transfer); + assert(box); + + ctx->pipe->transfer_flush_region(ctx->pipe, transfer, box); +} + +static void +sp_mpeg12_transfer_unmap(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(transfer); + + ctx->pipe->transfer_unmap(ctx->pipe, transfer); +} + +static void +sp_mpeg12_transfer_inline_write(struct pipe_video_context *vpipe, + struct pipe_resource *resource, + struct pipe_subresource subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned slice_stride) +{ + struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe; + + assert(vpipe); + assert(resource); + assert(box); + assert(data); + assert(ctx->pipe->transfer_inline_write); + + ctx->pipe->transfer_inline_write(ctx->pipe, resource, subresource, usage, + box, data, stride, slice_stride); +} + static void sp_mpeg12_render_picture(struct pipe_video_context *vpipe, struct pipe_surface *src_surface, @@ -346,6 +434,13 @@ sp_mpeg12_create(struct pipe_context *pipe, enum pipe_video_profile profile, ctx->base.render_picture = sp_mpeg12_render_picture; ctx->base.surface_fill = sp_mpeg12_surface_fill; ctx->base.surface_copy = sp_mpeg12_surface_copy; + ctx->base.get_transfer = sp_mpeg12_get_transfer; + ctx->base.transfer_destroy = sp_mpeg12_transfer_destroy; + ctx->base.transfer_map = sp_mpeg12_transfer_map; + ctx->base.transfer_flush_region = sp_mpeg12_transfer_flush_region; + ctx->base.transfer_unmap = sp_mpeg12_transfer_unmap; + if (pipe->transfer_inline_write) + ctx->base.transfer_inline_write = sp_mpeg12_transfer_inline_write; ctx->base.set_picture_background = sp_mpeg12_set_picture_background; ctx->base.set_picture_layers = sp_mpeg12_set_picture_layers; ctx->base.set_decode_target = sp_mpeg12_set_decode_target; diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h index d90b667de6c..294dc464c36 100644 --- a/src/gallium/include/pipe/p_video_context.h +++ b/src/gallium/include/pipe/p_video_context.h @@ -114,6 +114,34 @@ struct pipe_video_context unsigned srcx, unsigned srcy, unsigned width, unsigned height); + struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe, + struct pipe_resource *resource, + struct pipe_subresource subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *box); + + void (*transfer_destroy)(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer); + + void* (*transfer_map)(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer); + + void (*transfer_flush_region)(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer, + const struct pipe_box *box); + + void (*transfer_unmap)(struct pipe_video_context *vpipe, + struct pipe_transfer *transfer); + + void (*transfer_inline_write)(struct pipe_video_context *vpipe, + struct pipe_resource *resource, + struct pipe_subresource subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *box, + const void *data, + unsigned stride, + unsigned slice_stride); + /*@}*/ /** -- 2.30.2