summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian König <[email protected]>2011-03-25 23:38:50 +0100
committerChristian König <[email protected]>2011-03-25 23:38:50 +0100
commit4a0b80f00dbc77d333027afd195daae7ef1e651c (patch)
treeceb0a277b084225f453e59b914058bad60a31b98
parenta17788ac490744b631fc7dd47e94af3296895701 (diff)
[g3dvl] rework supicture handling
This gets ia44 and ai44 at least partial working
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c34
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h14
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_context.c138
-rw-r--r--src/gallium/include/pipe/p_video_context.h49
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/subpicture.c76
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/surface.c2
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/xvmc_private.h4
7 files changed, 178 insertions, 139 deletions
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index c54e5476f3a..cef8b6992ab 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -364,6 +364,7 @@ void vl_compositor_cleanup(struct vl_compositor *compositor)
cleanup_pipe_state(compositor);
}
+#if 0
void vl_compositor_set_background(struct vl_compositor *compositor,
struct pipe_surface *bg, struct pipe_video_rect *bg_src_rect)
{
@@ -378,9 +379,10 @@ void vl_compositor_set_background(struct vl_compositor *compositor,
compositor->dirty_bg = true;
}
}
+#endif
void vl_compositor_set_layers(struct vl_compositor *compositor,
- struct pipe_surface *layers[],
+ struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
struct pipe_video_rect *dst_rects[],
unsigned num_layers)
@@ -399,11 +401,9 @@ void vl_compositor_set_layers(struct vl_compositor *compositor,
!u_video_rects_equal(&compositor->layer_src_rects[i], src_rects[i]) ||
!u_video_rects_equal(&compositor->layer_dst_rects[i], dst_rects[i]))
{
- pipe_surface_reference(&compositor->layers[i], layers[i]);
- /*if (!u_video_rects_equal(&compositor->layer_src_rects[i], src_rects[i]))*/
- compositor->layer_src_rects[i] = *src_rects[i];
- /*if (!u_video_rects_equal(&compositor->layer_dst_rects[i], dst_rects[i]))*/
- compositor->layer_dst_rects[i] = *dst_rects[i];
+ pipe_sampler_view_reference(&compositor->layers[i], layers[i]);
+ compositor->layer_src_rects[i] = *src_rects[i];
+ compositor->layer_dst_rects[i] = *dst_rects[i];
compositor->dirty_layers |= 1 << i;
}
@@ -412,7 +412,7 @@ void vl_compositor_set_layers(struct vl_compositor *compositor,
}
for (; i < VL_COMPOSITOR_MAX_LAYERS; ++i)
- pipe_surface_reference(&compositor->layers[i], NULL);
+ pipe_sampler_view_reference(&compositor->layers[i], NULL);
}
static void gen_rect_verts(unsigned pos,
@@ -460,10 +460,10 @@ static void gen_rect_verts(unsigned pos,
}
static unsigned gen_data(struct vl_compositor *c,
- struct pipe_surface *src_surface,
+ struct pipe_sampler_view *src_surface,
struct pipe_video_rect *src_rect,
struct pipe_video_rect *dst_rect,
- struct pipe_surface **textures,
+ struct pipe_sampler_view **textures,
void **frag_shaders)
{
void *vb;
@@ -485,7 +485,7 @@ static unsigned gen_data(struct vl_compositor *c,
return 0;
if (c->dirty_bg) {
- struct vertex2f bg_inv_size = {1.0f / c->bg->width, 1.0f / c->bg->height};
+ struct vertex2f bg_inv_size = {1.0f / c->bg->texture->width0, 1.0f / c->bg->texture->height0};
gen_rect_verts(num_rects, &c->bg_src_rect, &bg_inv_size, NULL, NULL, vb);
textures[num_rects] = c->bg;
/* XXX: Hack */
@@ -495,7 +495,7 @@ static unsigned gen_data(struct vl_compositor *c,
}
{
- struct vertex2f src_inv_size = { 1.0f / src_surface->width, 1.0f / src_surface->height};
+ struct vertex2f src_inv_size = { 1.0f / src_surface->texture->width0, 1.0f / src_surface->texture->height0};
gen_rect_verts(num_rects, src_rect, &src_inv_size, dst_rect, &c->fb_inv_size, vb);
textures[num_rects] = src_surface;
/* XXX: Hack, sort of */
@@ -507,7 +507,7 @@ static unsigned gen_data(struct vl_compositor *c,
assert(i < VL_COMPOSITOR_MAX_LAYERS);
if (c->dirty_layers & (1 << i)) {
- struct vertex2f layer_inv_size = {1.0f / c->layers[i]->width, 1.0f / c->layers[i]->height};
+ struct vertex2f layer_inv_size = {1.0f / c->layers[i]->texture->width0, 1.0f / c->layers[i]->texture->height0};
gen_rect_verts(num_rects, &c->layer_src_rects[i], &layer_inv_size,
&c->layer_dst_rects[i], &c->fb_inv_size, vb);
textures[num_rects] = c->layers[i];
@@ -524,12 +524,12 @@ static unsigned gen_data(struct vl_compositor *c,
}
static void draw_layers(struct vl_compositor *c,
- struct pipe_surface *src_surface,
+ struct pipe_sampler_view *src_surface,
struct pipe_video_rect *src_rect,
struct pipe_video_rect *dst_rect)
{
unsigned num_rects;
- struct pipe_surface *src_surfaces[VL_COMPOSITOR_MAX_LAYERS + 2];
+ struct pipe_sampler_view *src_surfaces[VL_COMPOSITOR_MAX_LAYERS + 2];
void *frag_shaders[VL_COMPOSITOR_MAX_LAYERS + 2];
unsigned i;
@@ -569,12 +569,8 @@ static void draw_layers(struct vl_compositor *c,
}
void vl_compositor_render(struct vl_compositor *compositor,
- struct pipe_surface *src_surface,
+ struct pipe_sampler_view *src_surface,
enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_surface *future_surfaces,*/
struct pipe_video_rect *src_area,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
index 820c9ef6ddb..c2de98de0ef 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ b/src/gallium/auxiliary/vl/vl_compositor.h
@@ -57,10 +57,10 @@ struct vl_compositor
void *vertex_elems_state;
struct pipe_resource *fs_const_buf;
- struct pipe_surface *bg;
+ struct pipe_sampler_view *bg;
struct pipe_video_rect bg_src_rect;
bool dirty_bg;
- struct pipe_surface *layers[VL_COMPOSITOR_MAX_LAYERS];
+ struct pipe_sampler_view *layers[VL_COMPOSITOR_MAX_LAYERS];
struct pipe_video_rect layer_src_rects[VL_COMPOSITOR_MAX_LAYERS];
struct pipe_video_rect layer_dst_rects[VL_COMPOSITOR_MAX_LAYERS];
unsigned dirty_layers;
@@ -72,22 +72,20 @@ bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *p
void vl_compositor_cleanup(struct vl_compositor *compositor);
+#if 0
void vl_compositor_set_background(struct vl_compositor *compositor,
struct pipe_surface *bg, struct pipe_video_rect *bg_src_rect);
+#endif
void vl_compositor_set_layers(struct vl_compositor *compositor,
- struct pipe_surface *layers[],
+ struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
struct pipe_video_rect *dst_rects[],
unsigned num_layers);
void vl_compositor_render(struct vl_compositor *compositor,
- struct pipe_surface *src_surface,
+ struct pipe_sampler_view *src_surface,
enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_surface *future_surfaces,*/
struct pipe_video_rect *src_area,
struct pipe_surface *dst_surface,
struct pipe_video_rect *dst_area,
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_context.c b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
index 39429df68b7..185380ed216 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_context.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_context.c
@@ -242,13 +242,25 @@ vl_mpeg12_get_param(struct pipe_video_context *vpipe, int param)
static struct pipe_surface *
vl_mpeg12_create_surface(struct pipe_video_context *vpipe,
struct pipe_resource *resource,
- const struct pipe_surface *templat)
+ const struct pipe_surface *templ)
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
assert(ctx);
- return ctx->pipe->create_surface(ctx->pipe, resource, templat);
+ return ctx->pipe->create_surface(ctx->pipe, resource, templ);
+}
+
+static struct pipe_sampler_view *
+vl_mpeg12_create_sampler_view(struct pipe_video_context *vpipe,
+ struct pipe_resource *resource,
+ const struct pipe_sampler_view *templ)
+{
+ struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
+
+ assert(ctx);
+
+ return ctx->pipe->create_sampler_view(ctx->pipe, resource, templ);
}
static struct pipe_video_buffer *
@@ -353,24 +365,6 @@ vl_mpeg12_is_format_supported(struct pipe_video_context *vpipe,
0, usage);
}
-static void
-vl_mpeg12_clear_render_target(struct pipe_video_context *vpipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- const float *rgba,
- unsigned width, unsigned height)
-{
- struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(dst);
-
- if (ctx->pipe->clear_render_target)
- ctx->pipe->clear_render_target(ctx->pipe, dst, rgba, dstx, dsty, width, height);
- else
- util_clear_render_target(ctx->pipe, dst, rgba, dstx, dsty, width, height);
-}
-
#if 0
static void
vl_mpeg12_resource_copy_region(struct pipe_video_context *vpipe,
@@ -401,7 +395,6 @@ vl_mpeg12_resource_copy_region(struct pipe_video_context *vpipe,
dstx, dsty, dstz,
src, 0, &box);
}
-#endif
static struct pipe_transfer*
vl_mpeg12_get_transfer(struct pipe_video_context *vpipe,
@@ -469,26 +462,77 @@ vl_mpeg12_transfer_unmap(struct pipe_video_context *vpipe,
ctx->pipe->transfer_unmap(ctx->pipe, transfer);
}
+#endif
+
static void
-vl_mpeg12_transfer_inline_write(struct pipe_video_context *vpipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage, /* a combination of PIPE_TRANSFER_x */
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned slice_stride)
+vl_mpeg12_clear_sampler(struct pipe_video_context *vpipe,
+ struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box,
+ const float *rgba)
{
struct vl_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
+ struct pipe_transfer *transfer;
+ union util_color uc;
+ void *map;
+ unsigned i;
assert(vpipe);
- assert(resource);
- assert(box);
- assert(data);
- assert(ctx->pipe->transfer_inline_write);
+ assert(dst);
+ assert(dst_box);
+ assert(rgba);
- ctx->pipe->transfer_inline_write(ctx->pipe, resource, level, usage,
- box, data, stride, slice_stride);
+ 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 void
+vl_mpeg12_upload_sampler(struct pipe_video_context *vpipe,
+ 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_mpeg12_context *ctx = (struct vl_mpeg12_context*)vpipe;
+ struct pipe_transfer *transfer;
+ void *map;
+
+ assert(vpipe);
+ 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
@@ -509,11 +553,12 @@ vl_mpeg12_render_picture(struct pipe_video_context *vpipe,
assert(dst_surface);
assert(dst_area);
- vl_compositor_render(&ctx->compositor, buf->surface,
+ vl_compositor_render(&ctx->compositor, buf->sampler_view,
picture_type, src_area,
dst_surface, dst_area, fence);
}
+#if 0
static void
vl_mpeg12_set_picture_background(struct pipe_video_context *vpipe,
struct pipe_surface *bg,
@@ -527,10 +572,11 @@ vl_mpeg12_set_picture_background(struct pipe_video_context *vpipe,
vl_compositor_set_background(&ctx->compositor, bg, bg_src_rect);
}
+#endif
static void
vl_mpeg12_set_picture_layers(struct pipe_video_context *vpipe,
- struct pipe_surface *layers[],
+ struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
struct pipe_video_rect *dst_rects[],
unsigned num_layers)
@@ -709,18 +755,18 @@ vl_create_mpeg12_context(struct pipe_context *pipe,
ctx->base.get_param = vl_mpeg12_get_param;
ctx->base.is_format_supported = vl_mpeg12_is_format_supported;
ctx->base.create_surface = vl_mpeg12_create_surface;
+ ctx->base.create_sampler_view = vl_mpeg12_create_sampler_view;
ctx->base.create_buffer = vl_mpeg12_create_buffer;
ctx->base.render_picture = vl_mpeg12_render_picture;
- ctx->base.clear_render_target = vl_mpeg12_clear_render_target;
+ ctx->base.clear_sampler = vl_mpeg12_clear_sampler;
//ctx->base.resource_copy_region = vl_mpeg12_resource_copy_region;
- ctx->base.get_transfer = vl_mpeg12_get_transfer;
- ctx->base.transfer_destroy = vl_mpeg12_transfer_destroy;
- ctx->base.transfer_map = vl_mpeg12_transfer_map;
- ctx->base.transfer_flush_region = vl_mpeg12_transfer_flush_region;
- ctx->base.transfer_unmap = vl_mpeg12_transfer_unmap;
- if (pipe->transfer_inline_write)
- ctx->base.transfer_inline_write = vl_mpeg12_transfer_inline_write;
- ctx->base.set_picture_background = vl_mpeg12_set_picture_background;
+ //ctx->base.get_transfer = vl_mpeg12_get_transfer;
+ //ctx->base.transfer_destroy = vl_mpeg12_transfer_destroy;
+ //ctx->base.transfer_map = vl_mpeg12_transfer_map;
+ //ctx->base.transfer_flush_region = vl_mpeg12_transfer_flush_region;
+ //ctx->base.transfer_unmap = vl_mpeg12_transfer_unmap;
+ ctx->base.upload_sampler = vl_mpeg12_upload_sampler;
+ //ctx->base.set_picture_background = vl_mpeg12_set_picture_background;
ctx->base.set_picture_layers = vl_mpeg12_set_picture_layers;
ctx->base.set_csc_matrix = vl_mpeg12_set_csc_matrix;
diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h
index aa903ddc125..be40c36366a 100644
--- a/src/gallium/include/pipe/p_video_context.h
+++ b/src/gallium/include/pipe/p_video_context.h
@@ -72,14 +72,27 @@ struct pipe_video_context
enum pipe_format format,
unsigned usage);
+ /**
+ * destroy context, all buffers must be freed before calling this
+ */
void (*destroy)(struct pipe_video_context *vpipe);
+ /**
+ * create a surface of a texture
+ */
struct pipe_surface *(*create_surface)(struct pipe_video_context *vpipe,
struct pipe_resource *resource,
- const struct pipe_surface *templat);
+ const struct pipe_surface *templ);
/**
- * Creates a buffer for as decoding target
+ * create a sampler view of a texture, for subpictures for example
+ */
+ struct pipe_sampler_view *(*create_sampler_view)(struct pipe_video_context *vpipe,
+ struct pipe_resource *resource,
+ const struct pipe_sampler_view *templ);
+
+ /**
+ * Creates a buffer as decoding target
*/
struct pipe_video_buffer *(*create_buffer)(struct pipe_video_context *vpipe);
@@ -102,12 +115,6 @@ struct pipe_video_context
struct pipe_video_rect *dst_area,
struct pipe_fence_handle **fence);
- void (*clear_render_target)(struct pipe_video_context *vpipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- const float *rgba,
- unsigned width, unsigned height);
-
#if 0
void (*resource_copy_region)(struct pipe_video_context *vpipe,
struct pipe_resource *dst,
@@ -115,7 +122,6 @@ struct pipe_video_context
struct pipe_resource *src,
unsigned srcx, unsigned srcy, unsigned srcz,
unsigned width, unsigned height);
-#endif
struct pipe_transfer *(*get_transfer)(struct pipe_video_context *vpipe,
struct pipe_resource *resource,
@@ -135,15 +141,18 @@ struct pipe_video_context
void (*transfer_unmap)(struct pipe_video_context *vpipe,
struct pipe_transfer *transfer);
+#endif
- void (*transfer_inline_write)(struct pipe_video_context *vpipe,
- struct pipe_resource *resource,
- unsigned level,
- unsigned usage, /* a combination of PIPE_TRANSFER_x */
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned slice_stride);
+ void (*upload_sampler)(struct pipe_video_context *vpipe,
+ struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box,
+ const void *src, unsigned src_stride,
+ unsigned src_x, unsigned src_y);
+
+ void (*clear_sampler)(struct pipe_video_context *vpipe,
+ struct pipe_sampler_view *dst,
+ const struct pipe_box *dst_box,
+ const float *rgba);
/*@}*/
@@ -151,18 +160,22 @@ struct pipe_video_context
* Parameter-like states (or properties)
*/
/*@{*/
+#if 0
void (*set_picture_background)(struct pipe_video_context *vpipe,
struct pipe_surface *bg,
struct pipe_video_rect *bg_src_rect);
+#endif
void (*set_picture_layers)(struct pipe_video_context *vpipe,
- struct pipe_surface *layers[],
+ struct pipe_sampler_view *layers[],
struct pipe_video_rect *src_rects[],
struct pipe_video_rect *dst_rects[],
unsigned num_layers);
+#if 0
void (*set_picture_desc)(struct pipe_video_context *vpipe,
const struct pipe_picture_desc *desc);
+#endif
void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
index 548be8bed60..7123e3b0634 100644
--- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c
+++ b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
@@ -35,6 +35,7 @@
#include <pipe/p_state.h>
#include <util/u_memory.h>
#include <util/u_math.h>
+#include <util/u_format.h>
#include "xvmc_private.h"
#define FOURCC_RGB 0x0000003
@@ -139,9 +140,8 @@ Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *
XvMCContextPrivate *context_priv;
XvMCSubpicturePrivate *subpicture_priv;
struct pipe_video_context *vpipe;
- struct pipe_resource template;
- struct pipe_resource *tex;
- struct pipe_surface surf_template;
+ struct pipe_resource tex_templ, *tex;
+ struct pipe_sampler_view sampler_templ;
Status ret;
XVMC_MSG(XVMC_TRACE, "[XvMC] Creating subpicture %p.\n", subpicture);
@@ -169,44 +169,42 @@ Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *
if (!subpicture_priv)
return BadAlloc;
- memset(&template, 0, sizeof(struct pipe_resource));
- template.target = PIPE_TEXTURE_2D;
- template.format = XvIDToPipe(xvimage_id);
- template.last_level = 0;
+ memset(&tex_templ, 0, sizeof(tex_templ));
+ tex_templ.target = PIPE_TEXTURE_2D;
+ tex_templ.format = XvIDToPipe(xvimage_id);
+ tex_templ.last_level = 0;
if (vpipe->get_param(vpipe, PIPE_CAP_NPOT_TEXTURES)) {
- template.width0 = width;
- template.height0 = height;
+ tex_templ.width0 = width;
+ tex_templ.height0 = height;
}
else {
- template.width0 = util_next_power_of_two(width);
- template.height0 = util_next_power_of_two(height);
+ tex_templ.width0 = util_next_power_of_two(width);
+ tex_templ.height0 = util_next_power_of_two(height);
}
- template.depth0 = 1;
- template.array_size = 1;
- template.usage = PIPE_USAGE_DYNAMIC;
- template.bind = PIPE_BIND_SAMPLER_VIEW;
- template.flags = 0;
+ tex_templ.depth0 = 1;
+ tex_templ.array_size = 1;
+ tex_templ.usage = PIPE_USAGE_DYNAMIC;
+ tex_templ.bind = PIPE_BIND_SAMPLER_VIEW;
+ tex_templ.flags = 0;
- subpicture_priv->context = context;
- tex = vpipe->screen->resource_create(vpipe->screen, &template);
+ tex = vpipe->screen->resource_create(vpipe->screen, &tex_templ);
- memset(&surf_template, 0, sizeof(surf_template));
- surf_template.format = tex->format;
- surf_template.usage = PIPE_BIND_SAMPLER_VIEW;
- subpicture_priv->sfc = vpipe->create_surface(vpipe, tex, &surf_template);
+ memset(&sampler_templ, 0, sizeof(sampler_templ));
+ subpicture_priv->sampler = vpipe->create_sampler_view(vpipe, tex, &sampler_templ);
pipe_resource_reference(&tex, NULL);
- if (!subpicture_priv->sfc) {
+ if (!subpicture_priv->sampler) {
FREE(subpicture_priv);
return BadAlloc;
}
+ subpicture_priv->context = context;
subpicture->subpicture_id = XAllocID(dpy);
subpicture->context_id = context->context_id;
subpicture->xvimage_id = xvimage_id;
subpicture->width = width;
subpicture->height = height;
subpicture->num_palette_entries = 0;
- subpicture->entry_bytes = PipeToComponentOrder(template.format, subpicture->component_order);
+ subpicture->entry_bytes = PipeToComponentOrder(tex_templ.format, subpicture->component_order);
subpicture->privData = subpicture_priv;
SyncHandle();
@@ -222,7 +220,6 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
- unsigned int tmp_color;
float color_f[4];
assert(dpy);
@@ -238,9 +235,9 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
/* TODO: Assert clear rect is within bounds? Or clip? */
- context_priv->vctx->vpipe->clear_render_target(context_priv->vctx->vpipe,
- subpicture_priv->sfc, x, y,
- color_f, width, height);
+ //context_priv->vctx->vpipe->clear_render_target(context_priv->vctx->vpipe,
+ // subpicture_priv->sampler, x, y,
+ // color_f, width, height);
return Success;
}
@@ -253,7 +250,7 @@ Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
struct pipe_video_context *vpipe;
- struct pipe_transfer *xfer;
+
unsigned char *src, *dst, *dst_line;
unsigned x, y;
struct pipe_box dst_box = {dstx, dsty, 0, width, height, 1};
@@ -279,19 +276,10 @@ Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage
vpipe = context_priv->vctx->vpipe;
/* TODO: Assert rects are within bounds? Or clip? */
+ vpipe->upload_sampler(vpipe, subpicture_priv->sampler, &dst_box,
+ image->data, width*3, srcx, srcy);
- xfer = vpipe->get_transfer(vpipe, subpicture_priv->sfc->texture,
- 0, PIPE_TRANSFER_WRITE, &dst_box);
- if (!xfer)
- return BadAlloc;
-
- src = image->data;
- dst = vpipe->transfer_map(vpipe, xfer);
- if (!dst) {
- vpipe->transfer_destroy(vpipe, xfer);
- return BadAlloc;
- }
-
+#if 0
switch (image->id) {
case FOURCC_RGB:
assert(subpicture_priv->sfc->format == XvIDToPipe(image->id));
@@ -308,9 +296,7 @@ Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage
default:
XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", image->id);
}
-
- vpipe->transfer_unmap(vpipe, xfer);
- vpipe->transfer_destroy(vpipe, xfer);
+#endif
XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p composited.\n", subpicture);
@@ -330,7 +316,7 @@ Status XvMCDestroySubpicture(Display *dpy, XvMCSubpicture *subpicture)
return XvMCBadSubpicture;
subpicture_priv = subpicture->privData;
- pipe_surface_reference(&subpicture_priv->sfc, NULL);
+ pipe_sampler_view_reference(&subpicture_priv->sampler, NULL);
FREE(subpicture_priv);
XVMC_MSG(XVMC_TRACE, "[XvMC] Subpicture %p destroyed.\n", subpicture);
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index 03301238883..6fb19124867 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -449,7 +449,7 @@ Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
XVMC_MSG(XVMC_TRACE, "[XvMC] Surface %p has subpicture %p.\n", surface, surface_priv->subpicture);
assert(subpicture_priv->surface == surface);
- vpipe->set_picture_layers(vpipe, &subpicture_priv->sfc, src_rects, dst_rects, 1);
+ vpipe->set_picture_layers(vpipe, &subpicture_priv->sampler, src_rects, dst_rects, 1);
surface_priv->subpicture = NULL;
subpicture_priv->surface = NULL;
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
index 26be1f7b846..68dfb0d355f 100644
--- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
+++ b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
@@ -36,7 +36,7 @@
#define BLOCK_SIZE_BYTES (BLOCK_SIZE_SAMPLES * 2)
struct vl_context;
-struct pipe_surface;
+struct pipe_sampler_view;
struct pipe_fence_handle;
typedef struct
@@ -72,7 +72,7 @@ typedef struct
typedef struct
{
- struct pipe_surface *sfc;
+ struct pipe_sampler_view *sampler;
/* The surface this subpicture is currently associated with, if any. */
XvMCSurface *surface;