vl: Get rid of pipe_video_surface.
authorYounes Manton <younes.m@gmail.com>
Fri, 12 Mar 2010 17:09:44 +0000 (12:09 -0500)
committerYounes Manton <younes.m@gmail.com>
Fri, 12 Mar 2010 17:09:44 +0000 (12:09 -0500)
13 files changed:
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/drivers/identity/id_objects.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/drivers/softpipe/sp_video_context.h
src/gallium/include/pipe/p_video_context.h
src/gallium/include/pipe/p_video_state.h
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h

index f24edfcf194c157e35b503df87343d2a8b515626..532f346a17a2cccf4b1c5c71aa51ad7a41889aad 100644 (file)
@@ -34,7 +34,6 @@
 #include "vl_types.h"
 
 struct pipe_context;
-struct pipe_video_surface;
 struct pipe_macroblock;
 
 /* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
index 2b1a60c1bf135a8943c90f601ced350190222fe0..c65c6bf0056bcc857121db44580932f04df1c771 100644 (file)
@@ -180,42 +180,3 @@ identity_transfer_destroy(struct identity_transfer *id_transfer)
    screen->tex_transfer_destroy(id_transfer->transfer);
    FREE(id_transfer);
 }
-
-struct pipe_video_surface *
-identity_video_surface_create(struct identity_screen *id_screen,
-                              struct pipe_video_surface *video_surface)
-{
-   struct identity_video_surface *id_video_surface;
-
-   if (!video_surface) {
-      goto error;
-   }
-
-   assert(video_surface->screen == id_screen->screen);
-
-   id_video_surface = CALLOC_STRUCT(identity_video_surface);
-   if (!id_video_surface) {
-      goto error;
-   }
-
-   memcpy(&id_video_surface->base,
-          video_surface,
-          sizeof(struct pipe_video_surface));
-
-   pipe_reference_init(&id_video_surface->base.reference, 1);
-   id_video_surface->base.screen = &id_screen->base;
-   id_video_surface->video_surface = video_surface;
-
-   return &id_video_surface->base;
-
-error:
-   pipe_video_surface_reference(&video_surface, NULL);
-   return NULL;
-}
-
-void
-identity_video_surface_destroy(struct identity_video_surface *id_video_surface)
-{
-   pipe_video_surface_reference(&id_video_surface->video_surface, NULL);
-   FREE(id_video_surface);
-}
index 77cc7190798c75810cecfa076b8987ec6c95c7b4..e89cb2e78c43250bb50f4852c01f43cd7c51f917 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
-#include "pipe/p_video_state.h"
 
 #include "id_screen.h"
 
@@ -68,14 +67,6 @@ struct identity_transfer
 };
 
 
-struct identity_video_surface
-{
-   struct pipe_video_surface base;
-
-   struct pipe_video_surface *video_surface;
-};
-
-
 static INLINE struct identity_buffer *
 identity_buffer(struct pipe_buffer *_buffer)
 {
@@ -112,16 +103,6 @@ identity_transfer(struct pipe_transfer *_transfer)
    return (struct identity_transfer *)_transfer;
 }
 
-static INLINE struct identity_video_surface *
-identity_video_surface(struct pipe_video_surface *_video_surface)
-{
-   if (!_video_surface) {
-      return NULL;
-   }
-   (void)identity_screen(_video_surface->screen);
-   return (struct identity_video_surface *)_video_surface;
-}
-
 static INLINE struct pipe_buffer *
 identity_buffer_unwrap(struct pipe_buffer *_buffer)
 {
@@ -183,12 +164,5 @@ identity_transfer_create(struct identity_texture *id_texture,
 void
 identity_transfer_destroy(struct identity_transfer *id_transfer);
 
-struct pipe_video_surface *
-identity_video_surface_create(struct identity_screen *id_screen,
-                              struct pipe_video_surface *video_surface);
-
-void
-identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
-
 
 #endif /* ID_OBJECTS_H */
index b85492114a3714a68266fd3c4c7a435fef11f19d..480ea802d048dc20bc60ca2c9f2773428c120514 100644 (file)
@@ -394,33 +394,6 @@ identity_screen_buffer_destroy(struct pipe_buffer *_buffer)
    identity_buffer_destroy(identity_buffer(_buffer));
 }
 
-static struct pipe_video_surface *
-identity_screen_video_surface_create(struct pipe_screen *_screen,
-                                     enum pipe_video_chroma_format chroma_format,
-                                     unsigned width,
-                                     unsigned height)
-{
-   struct identity_screen *id_screen = identity_screen(_screen);
-   struct pipe_screen *screen = id_screen->screen;
-   struct pipe_video_surface *result;
-
-   result = screen->video_surface_create(screen,
-                                         chroma_format,
-                                         width,
-                                         height);
-
-   if (result) {
-      return identity_video_surface_create(id_screen, result);
-   }
-   return NULL;
-}
-
-static void
-identity_screen_video_surface_destroy(struct pipe_video_surface *_vsfc)
-{
-   identity_video_surface_destroy(identity_video_surface(_vsfc));
-}
-
 static void
 identity_screen_flush_frontbuffer(struct pipe_screen *_screen,
                                   struct pipe_surface *_surface,
@@ -515,12 +488,6 @@ identity_screen_create(struct pipe_screen *screen)
    if (screen->buffer_unmap)
       id_screen->base.buffer_unmap = identity_screen_buffer_unmap;
    id_screen->base.buffer_destroy = identity_screen_buffer_destroy;
-   if (screen->video_surface_create) {
-      id_screen->base.video_surface_create = identity_screen_video_surface_create;
-   }
-   if (screen->video_surface_destroy) {
-      id_screen->base.video_surface_destroy = identity_screen_video_surface_destroy;
-   }
    id_screen->base.flush_frontbuffer = identity_screen_flush_frontbuffer;
    id_screen->base.fence_reference = identity_screen_fence_reference;
    id_screen->base.fence_signalled = identity_screen_fence_signalled;
index ceb4e338f1a5b4c893387975d5c8cf21ed14ecd0..9298023bbe26fdbf1f6db7cd591f247f50551d16 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include "util/u_memory.h"
+#include "util/u_inlines.h"
 
 #include "draw/draw_context.h"
 #include "draw/draw_context.h"
index 32d261b5ffc326b2aad180fbe4497b6c430566b8..d80a71aca50cf10f07b61bc2b2b4902757260047 100644 (file)
@@ -402,58 +402,6 @@ softpipe_transfer_unmap(struct pipe_screen *screen,
 }
 
 
-static struct pipe_video_surface*
-softpipe_video_surface_create(struct pipe_screen *screen,
-                              enum pipe_video_chroma_format chroma_format,
-                              unsigned width, unsigned height)
-{
-   struct softpipe_video_surface *sp_vsfc;
-   struct pipe_texture template;
-
-   assert(screen);
-   assert(width && height);
-
-   sp_vsfc = CALLOC_STRUCT(softpipe_video_surface);
-   if (!sp_vsfc)
-      return NULL;
-
-   pipe_reference_init(&sp_vsfc->base.reference, 1);
-   sp_vsfc->base.screen = screen;
-   sp_vsfc->base.chroma_format = chroma_format;
-   /*sp_vsfc->base.surface_format = PIPE_VIDEO_SURFACE_FORMAT_VUYA;*/
-   sp_vsfc->base.width = width;
-   sp_vsfc->base.height = height;
-
-   memset(&template, 0, sizeof(struct pipe_texture));
-   template.target = PIPE_TEXTURE_2D;
-   template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
-   template.last_level = 0;
-   /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */
-   template.width0 = util_next_power_of_two(width);
-   template.height0 = util_next_power_of_two(height);
-   template.depth0 = 1;
-   template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
-
-   sp_vsfc->tex = screen->texture_create(screen, &template);
-   if (!sp_vsfc->tex) {
-      FREE(sp_vsfc);
-      return NULL;
-   }
-
-   return &sp_vsfc->base;
-}
-
-
-static void
-softpipe_video_surface_destroy(struct pipe_video_surface *vsfc)
-{
-   struct softpipe_video_surface *sp_vsfc = softpipe_video_surface(vsfc);
-
-   pipe_texture_reference(&sp_vsfc->tex, NULL);
-   FREE(sp_vsfc);
-}
-
-
 void
 softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
 {
@@ -468,9 +416,6 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
    screen->tex_transfer_destroy = softpipe_tex_transfer_destroy;
    screen->transfer_map = softpipe_transfer_map;
    screen->transfer_unmap = softpipe_transfer_unmap;
-
-   screen->video_surface_create = softpipe_video_surface_create;
-   screen->video_surface_destroy = softpipe_video_surface_destroy;
 }
 
 
index 2ef64e1e7c31bec2a582a30379023cf1f37047a8..2537ab6a40d62ac1368528c8b559c5a681367ba5 100644 (file)
@@ -30,7 +30,6 @@
 
 
 #include "pipe/p_state.h"
-#include "pipe/p_video_state.h"
 
 
 struct pipe_context;
@@ -63,15 +62,6 @@ struct softpipe_transfer
    unsigned long offset;
 };
 
-struct softpipe_video_surface
-{
-   struct pipe_video_surface base;
-
-   /* The data is held here:
-    */
-   struct pipe_texture *tex;
-};
-
 
 /** cast wrappers */
 static INLINE struct softpipe_texture *
@@ -86,12 +76,6 @@ softpipe_transfer(struct pipe_transfer *pt)
    return (struct softpipe_transfer *) pt;
 }
 
-static INLINE struct softpipe_video_surface *
-softpipe_video_surface(struct pipe_video_surface *pvs)
-{
-   return (struct softpipe_video_surface *) pvs;
-}
-
 
 extern void
 softpipe_init_screen_texture_funcs(struct pipe_screen *screen);
index e575e238bd7f8bad049e39505269532c8f5298ea..2be093f505d8b8c07f2a06ef80dcb3dee64de57c 100644 (file)
@@ -51,7 +51,7 @@ sp_mpeg12_destroy(struct pipe_video_context *vpipe)
    ctx->pipe->delete_rasterizer_state(ctx->pipe, ctx->rast);
    ctx->pipe->delete_depth_stencil_alpha_state(ctx->pipe, ctx->dsa);
 
-   pipe_video_surface_reference(&ctx->decode_target, NULL);
+   pipe_surface_reference(&ctx->decode_target, NULL);
    vl_compositor_cleanup(&ctx->compositor);
    vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
    ctx->pipe->destroy(ctx->pipe);
@@ -61,8 +61,8 @@ sp_mpeg12_destroy(struct pipe_video_context *vpipe)
 
 static void
 sp_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe,
-                             struct pipe_video_surface *past,
-                             struct pipe_video_surface *future,
+                             struct pipe_surface *past,
+                             struct pipe_surface *future,
                              unsigned num_macroblocks,
                              struct pipe_macroblock *macroblocks,
                              struct pipe_fence_handle **fence)
@@ -77,9 +77,9 @@ sp_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe,
    assert(ctx->decode_target);
 
    vl_mpeg12_mc_renderer_render_macroblocks(&ctx->mc_renderer,
-                                            softpipe_video_surface(ctx->decode_target)->tex,
-                                            past ? softpipe_video_surface(past)->tex : NULL,
-                                            future ? softpipe_video_surface(future)->tex : NULL,
+                                            ctx->decode_target->texture,
+                                            past ? past->texture : NULL,
+                                            future ? future->texture : NULL,
                                             num_macroblocks, mpeg12_macroblocks, fence);
 }
 
@@ -122,12 +122,12 @@ sp_mpeg12_surface_copy(struct pipe_video_context *vpipe,
 
 static void
 sp_mpeg12_render_picture(struct pipe_video_context     *vpipe,
-                         struct pipe_video_surface     *src_surface,
+                         struct pipe_surface           *src_surface,
                          enum pipe_mpeg12_picture_type picture_type,
                          /*unsigned                    num_past_surfaces,
-                         struct pipe_video_surface     *past_surfaces,
+                         struct pipe_surface           *past_surfaces,
                          unsigned                      num_future_surfaces,
-                         struct pipe_video_surface     *future_surfaces,*/
+                         struct pipe_surface           *future_surfaces,*/
                          struct pipe_video_rect        *src_area,
                          struct pipe_surface           *dst_surface,
                          struct pipe_video_rect        *dst_area,
@@ -141,7 +141,7 @@ sp_mpeg12_render_picture(struct pipe_video_context     *vpipe,
    assert(dst_surface);
    assert(dst_area);
 
-   vl_compositor_render(&ctx->compositor, softpipe_video_surface(src_surface)->tex,
+   vl_compositor_render(&ctx->compositor, src_surface->texture,
                         picture_type, src_area, dst_surface->texture, dst_area, fence);
 }
 
@@ -177,14 +177,14 @@ sp_mpeg12_set_picture_layers(struct pipe_video_context *vpipe,
 
 static void
 sp_mpeg12_set_decode_target(struct pipe_video_context *vpipe,
-                            struct pipe_video_surface *dt)
+                            struct pipe_surface *dt)
 {
    struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
 
    assert(vpipe);
    assert(dt);
 
-   pipe_video_surface_reference(&ctx->decode_target, dt);
+   pipe_surface_reference(&ctx->decode_target, dt);
 }
 
 static void
index 40743ac423c6fffa1a49a554217c65d06ace5014..bc5daa05ac6145d9a036f6009d99c10628513376 100644 (file)
 
 struct pipe_screen;
 struct pipe_context;
-struct pipe_video_surface;
 
 struct sp_mpeg12_context
 {
    struct pipe_video_context base;
    struct pipe_context *pipe;
-   struct pipe_video_surface *decode_target;
+   struct pipe_surface *decode_target;
    struct vl_mpeg12_mc_renderer mc_renderer;
    struct vl_compositor compositor;
 
index b3346b219f83cd098a9571828164d7529e663307..83d214cc53dcfa48abaaed8b51059259f8a52c61 100644 (file)
@@ -37,7 +37,6 @@ extern "C" {
 struct pipe_screen;
 struct pipe_buffer;
 struct pipe_surface;
-struct pipe_video_surface;
 struct pipe_macroblock;
 struct pipe_picture_desc;
 struct pipe_fence_handle;
@@ -66,28 +65,22 @@ struct pipe_video_context
                             struct pipe_buffer **bitstream_buf);
 
    void (*decode_macroblocks)(struct pipe_video_context *vpipe,
-                              struct pipe_video_surface *past,
-                              struct pipe_video_surface *future,
+                              struct pipe_surface *past,
+                              struct pipe_surface *future,
                               unsigned num_macroblocks,
                               struct pipe_macroblock *macroblocks,
                               struct pipe_fence_handle **fence);
 
    void (*render_picture)(struct pipe_video_context     *vpipe,
-                          /*struct pipe_surface         *backround,
-                          struct pipe_video_rect        *backround_area,*/
-                          struct pipe_video_surface     *src_surface,
+                          struct pipe_surface           *src_surface,
                           enum pipe_mpeg12_picture_type picture_type,
                           /*unsigned                    num_past_surfaces,
-                          struct pipe_video_surface     *past_surfaces,
+                          struct pipe_surface           *past_surfaces,
                           unsigned                      num_future_surfaces,
-                          struct pipe_video_surface     *future_surfaces,*/
+                          struct pipe_surface           *future_surfaces,*/
                           struct pipe_video_rect        *src_area,
                           struct pipe_surface           *dst_surface,
                           struct pipe_video_rect        *dst_area,
-                          /*unsigned                      num_layers,
-                          struct pipe_texture           *layers,
-                          struct pipe_video_rect        *layer_src_areas,
-                          struct pipe_video_rect        *layer_dst_areas,*/
                           struct pipe_fence_handle      **fence);
 
    void (*surface_fill)(struct pipe_video_context *vpipe,
@@ -123,7 +116,7 @@ struct pipe_video_context
                             const struct pipe_picture_desc *desc);
 
    void (*set_decode_target)(struct pipe_video_context *vpipe,
-                             struct pipe_video_surface *dt);
+                             struct pipe_surface *dt);
 
    void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
 
index 96bab56741a53d95ac8a0756c53ecfe0da831fb5..79ce174701b0be47c74442cd48f1e7a587805ead 100644 (file)
 extern "C" {
 #endif
 
-struct pipe_video_surface
-{
-   struct pipe_reference reference;
-   struct pipe_screen *screen;
-   enum pipe_video_chroma_format chroma_format;
-   /*enum pipe_video_surface_format surface_format;*/
-   unsigned width;
-   unsigned height;
-};
-
-static INLINE void
-pipe_video_surface_reference(struct pipe_video_surface **ptr, struct pipe_video_surface *surf)
-{
-   struct pipe_video_surface *old_surf = *ptr;
-
-   if (pipe_reference(&(*ptr)->reference, &surf->reference))
-      old_surf->screen->video_surface_destroy(old_surf);
-   *ptr = surf;
-}
-
 struct pipe_video_rect
 {
    unsigned x, y, w, h;
index db630c9e790f422524226c090db37399dfb1296f..a2d71b5c14eb418fad5fe43a63b966cddbe38fcf 100644 (file)
@@ -33,6 +33,7 @@
 #include <pipe/p_state.h>
 #include <util/u_inlines.h>
 #include <util/u_memory.h>
+#include <util/u_math.h>
 #include "xvmc_private.h"
 
 static enum pipe_mpeg12_macroblock_type TypeToPipe(int xvmc_mb_type)
@@ -190,7 +191,9 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
    XvMCContextPrivate *context_priv;
    struct pipe_video_context *vpipe;
    XvMCSurfacePrivate *surface_priv;
-   struct pipe_video_surface *vsfc;
+   struct pipe_texture template;
+   struct pipe_texture *vsfc_tex;
+   struct pipe_surface *vsfc;
 
    XVMC_MSG(XVMC_TRACE, "[XvMC] Creating surface %p.\n", surface);
 
@@ -208,9 +211,25 @@ Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surfac
    if (!surface_priv)
       return BadAlloc;
 
-   assert(vpipe->screen->video_surface_create);
-   vsfc = vpipe->screen->video_surface_create(vpipe->screen, vpipe->chroma_format,
-                                              vpipe->width, vpipe->height);
+   memset(&template, 0, sizeof(struct pipe_texture));
+   template.target = PIPE_TEXTURE_2D;
+   /* XXX: Let the pipe_video_context choose whatever format it likes to render to */
+   template.format = PIPE_FORMAT_AYUV;
+   template.last_level = 0;
+   /* XXX: vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true, clean this up */
+   template.width0 = util_next_power_of_two(context->width);
+   template.height0 = util_next_power_of_two(context->height);
+   template.depth0 = 1;
+   template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   vsfc_tex = vpipe->screen->texture_create(vpipe->screen, &template);
+   if (!vsfc_tex) {
+      FREE(surface_priv);
+      return BadAlloc;
+   }
+
+   vsfc = vpipe->screen->get_tex_surface(vpipe->screen, vsfc_tex, 0, 0, 0,
+                                         PIPE_BUFFER_USAGE_GPU_READ_WRITE);
+   pipe_texture_reference(&vsfc_tex, NULL);
    if (!vsfc) {
       FREE(surface_priv);
       return BadAlloc;
@@ -390,7 +409,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->texture, &src_rects, &dst_rects, 1);
+      vpipe->set_picture_layers(vpipe, &subpicture_priv->sfc, &src_rects, &dst_rects, 1);
 
       surface_priv->subpicture = NULL;
       subpicture_priv->surface = NULL;
@@ -443,7 +462,7 @@ Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
       return XvMCBadSurface;
 
    surface_priv = surface->privData;
-   pipe_video_surface_reference(&surface_priv->pipe_vsfc, NULL);
+   pipe_surface_reference(&surface_priv->pipe_vsfc, NULL);
    FREE(surface_priv);
    surface->privData = NULL;
 
index df2a0dcc6f320dd3234c987f43c378896ed0b1a7..82f6fcad71260b5821c218316798877711e412f3 100644 (file)
@@ -47,7 +47,7 @@ typedef struct
 
 typedef struct
 {
-   struct pipe_video_surface *pipe_vsfc;
+   struct pipe_surface *pipe_vsfc;
    struct pipe_fence_handle *render_fence;
    struct pipe_fence_handle *disp_fence;