FREE(ctx);
}
-static struct pipe_sampler_view *
-vl_context_create_sampler_view(struct pipe_video_context *context,
- struct pipe_resource *resource,
- const struct pipe_sampler_view *templ)
-{
- struct vl_context *ctx = (struct vl_context*)context;
-
- assert(ctx);
-
- return ctx->pipe->create_sampler_view(ctx->pipe, resource, templ);
-}
-
-static void
-vl_context_upload_sampler(struct pipe_video_context *context,
- struct pipe_sampler_view *dst,
- const struct pipe_box *dst_box,
- const void *src, unsigned src_stride,
- unsigned src_x, unsigned src_y)
-{
- struct vl_context *ctx = (struct vl_context*)context;
- struct pipe_transfer *transfer;
- void *map;
-
- assert(context);
- assert(dst);
- assert(dst_box);
- assert(src);
-
- transfer = ctx->pipe->get_transfer(ctx->pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
- if (!transfer)
- return;
-
- map = ctx->pipe->transfer_map(ctx->pipe, transfer);
- if (!transfer)
- goto error_map;
-
- util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
- dst_box->width, dst_box->height,
- src, src_stride, src_x, src_y);
-
- ctx->pipe->transfer_unmap(ctx->pipe, transfer);
-
-error_map:
- ctx->pipe->transfer_destroy(ctx->pipe, transfer);
-}
-
-static void
-vl_context_clear_sampler(struct pipe_video_context *context,
- struct pipe_sampler_view *dst,
- const struct pipe_box *dst_box,
- const float *rgba)
-{
- struct vl_context *ctx = (struct vl_context*)context;
- struct pipe_transfer *transfer;
- union util_color uc;
- void *map;
- unsigned i;
-
- assert(context);
- assert(dst);
- assert(dst_box);
- assert(rgba);
-
- transfer = ctx->pipe->get_transfer(ctx->pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
- if (!transfer)
- return;
-
- map = ctx->pipe->transfer_map(ctx->pipe, transfer);
- if (!transfer)
- goto error_map;
-
- for ( i = 0; i < 4; ++i)
- uc.f[i] = rgba[i];
-
- util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
- dst_box->width, dst_box->height, &uc);
-
- ctx->pipe->transfer_unmap(ctx->pipe, transfer);
-
-error_map:
- ctx->pipe->transfer_destroy(ctx->pipe, transfer);
-}
-
static struct pipe_video_decoder *
vl_context_create_decoder(struct pipe_video_context *context,
enum pipe_video_profile profile,
ctx->base.screen = pipe->screen;
ctx->base.destroy = vl_context_destroy;
- ctx->base.create_sampler_view = vl_context_create_sampler_view;
- ctx->base.clear_sampler = vl_context_clear_sampler;
- ctx->base.upload_sampler = vl_context_upload_sampler;
ctx->base.create_decoder = vl_context_create_decoder;
ctx->base.create_buffer = vl_context_create_buffer;
ctx->base.create_compositor = vl_context_create_compositor;
#include <util/u_memory.h>
#include <util/u_debug.h>
+#include <util/u_rect.h>
#include "vdpau_private.h"
uint32_t const *source_pitches)
{
enum pipe_format pformat = FormatToPipe(source_ycbcr_format);
+ struct pipe_context *pipe;
struct pipe_video_context *context;
struct pipe_sampler_view **sampler_views;
unsigned i;
if (!p_surf)
return VDP_STATUS_INVALID_HANDLE;
+ pipe = p_surf->device->context->pipe;
context = p_surf->device->context->vpipe;
- if (!context)
+ if (!pipe && !context)
return VDP_STATUS_INVALID_HANDLE;
if (p_surf->video_buffer == NULL || pformat != p_surf->video_buffer->buffer_format) {
for (i = 0; i < 3; ++i) { //TODO put nr of planes into util format
struct pipe_sampler_view *sv = sampler_views[i ? i ^ 3 : 0];
struct pipe_box dst_box = { 0, 0, 0, sv->texture->width0, sv->texture->height0, 1 };
- context->upload_sampler(context, sv, &dst_box, source_data[i], source_pitches[i], 0, 0);
+
+ struct pipe_transfer *transfer;
+ void *map;
+
+ transfer = pipe->get_transfer(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
+ if (!transfer)
+ return VDP_STATUS_RESOURCES;
+
+ map = pipe->transfer_map(pipe, transfer);
+ if (map) {
+ util_copy_rect(map, sv->texture->format, transfer->stride, 0, 0,
+ dst_box.width, dst_box.height,
+ source_data[i], source_pitches[i], 0, 0);
+
+ pipe->transfer_unmap(pipe, transfer);
+ }
+
+ pipe->transfer_destroy(pipe, transfer);
}
return VDP_STATUS_OK;
#include <util/u_math.h>
#include <util/u_format.h>
#include <util/u_sampler.h>
+#include <util/u_rect.h>
#include <vl_winsys.h>
return i < num_subpics ? Success : BadMatch;
}
+static void
+upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box, const void *src, unsigned src_stride,
+ unsigned src_x, unsigned src_y)
+{
+ struct pipe_transfer *transfer;
+ void *map;
+
+ transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box);
+ if (!transfer)
+ return;
+
+ map = pipe->transfer_map(pipe, transfer);
+ if (map) {
+ util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0,
+ dst_box->width, dst_box->height,
+ src, src_stride, src_x, src_y);
+
+ pipe->transfer_unmap(pipe, transfer);
+ }
+
+ pipe->transfer_destroy(pipe, transfer);
+}
+
PUBLIC
Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture,
unsigned short width, unsigned short height, int xvimage_id)
{
XvMCContextPrivate *context_priv;
XvMCSubpicturePrivate *subpicture_priv;
+ struct pipe_context *pipe;
struct pipe_video_context *vpipe;
struct pipe_resource tex_templ, *tex;
struct pipe_sampler_view sampler_templ;
return XvMCBadContext;
context_priv = context->privData;
+ pipe = context_priv->vctx->pipe;
vpipe = context_priv->vctx->vpipe;
if (!subpicture)
u_sampler_view_default_template(&sampler_templ, tex, tex->format);
XvIDToSwizzle(xvimage_id, &sampler_templ);
- subpicture_priv->sampler = vpipe->create_sampler_view(vpipe, tex, &sampler_templ);
+ subpicture_priv->sampler = pipe->create_sampler_view(pipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
if (!subpicture_priv->sampler) {
FREE(subpicture_priv);
memset(&sampler_templ, 0, sizeof(sampler_templ));
u_sampler_view_default_template(&sampler_templ, tex, tex->format);
sampler_templ.swizzle_a = PIPE_SWIZZLE_ONE;
- subpicture_priv->palette = vpipe->create_sampler_view(vpipe, tex, &sampler_templ);
+ subpicture_priv->palette = pipe->create_sampler_view(pipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
if (!subpicture_priv->sampler) {
FREE(subpicture_priv);
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
+ struct pipe_context *pipe;
+ struct pipe_sampler_view *dst;
struct pipe_box dst_box = {x, y, 0, width, height, 1};
- float color_f[4];
+ struct pipe_transfer *transfer;
+ union util_color uc;
+ void *map;
assert(dpy);
/* Convert color to float */
util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM,
- color_f, 1, &color, 4,
+ uc.f, 1, &color, 4,
0, 0, 1, 1);
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
+ pipe = context_priv->vctx->pipe;
+ dst = subpicture_priv->sampler;
+
/* TODO: Assert clear rect is within bounds? Or clip? */
- context_priv->vctx->vpipe->clear_sampler(context_priv->vctx->vpipe,
- subpicture_priv->sampler, &dst_box,
- color_f);
+ transfer = pipe->get_transfer(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, &dst_box);
+ if (!transfer)
+ return XvMCBadSubpicture;
+
+ map = pipe->transfer_map(pipe, transfer);
+ if (map) {
+ util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0,
+ dst_box.width, dst_box.height, &uc);
+
+ pipe->transfer_unmap(pipe, transfer);
+ }
+
+ pipe->transfer_destroy(pipe, transfer);
return Success;
}
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
- struct pipe_video_context *vpipe;
+ struct pipe_context *pipe;
struct pipe_box dst_box = {dstx, dsty, 0, width, height, 1};
unsigned src_stride;
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
- vpipe = context_priv->vctx->vpipe;
+ pipe = context_priv->vctx->pipe;
/* clipping should be done by upload_sampler and regardles what the documentation
says image->pitches[0] doesn't seems to be in bytes, so don't use it */
src_stride = image->width * util_format_get_blocksize(subpicture_priv->sampler->texture->format);
- vpipe->upload_sampler(vpipe, subpicture_priv->sampler, &dst_box,
- image->data, src_stride, srcx, srcy);
+ upload_sampler(pipe, subpicture_priv->sampler, &dst_box, image->data, src_stride, srcx, srcy);
XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p composited.\n", subpicture);
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
- struct pipe_video_context *vpipe;
+ struct pipe_context *pipe;
struct pipe_box dst_box = {0, 0, 0, 0, 1, 1};
assert(dpy);
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
- vpipe = context_priv->vctx->vpipe;
+ pipe = context_priv->vctx->pipe;
dst_box.width = subpicture->num_palette_entries;
- vpipe->upload_sampler(vpipe, subpicture_priv->palette, &dst_box, palette, 0, 0, 0);
+ upload_sampler(pipe, subpicture_priv->palette, &dst_box, palette, 0, 0, 0);
XVMC_MSG(XVMC_TRACE, "[XvMC] Palette of Subpicture %p set.\n", subpicture);