summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl
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 /src/gallium/auxiliary/vl
parenta17788ac490744b631fc7dd47e94af3296895701 (diff)
[g3dvl] rework supicture handling
This gets ia44 and ai44 at least partial working
Diffstat (limited to 'src/gallium/auxiliary/vl')
-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
3 files changed, 113 insertions, 73 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;