vl: Use pipe_surface instead of pipe_texture in interfaces.
authorYounes Manton <younes.m@gmail.com>
Fri, 12 Mar 2010 17:37:19 +0000 (12:37 -0500)
committerYounes Manton <younes.m@gmail.com>
Fri, 12 Mar 2010 17:38:33 +0000 (12:38 -0500)
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/include/pipe/p_video_context.h

index bafe232877e20eeeba1a3b6d0f0d8b2188dc4329..b11f45fe5f5d85d1c661251ebf46102a70b5cea7 100644 (file)
@@ -293,14 +293,14 @@ void vl_compositor_cleanup(struct vl_compositor *compositor)
 }
 
 void vl_compositor_set_background(struct vl_compositor *compositor,
-                                 struct pipe_texture *bg, struct pipe_video_rect *bg_src_rect)
+                                 struct pipe_surface *bg, struct pipe_video_rect *bg_src_rect)
 {
    assert(compositor);
    assert((bg && bg_src_rect) || (!bg && !bg_src_rect));
 
    if (compositor->bg != bg ||
        !u_video_rects_equal(&compositor->bg_src_rect, bg_src_rect)) {
-      pipe_texture_reference(&compositor->bg, bg);
+      pipe_surface_reference(&compositor->bg, bg);
       /*if (!u_video_rects_equal(&compositor->bg_src_rect, bg_src_rect))*/
          compositor->bg_src_rect = *bg_src_rect;
       compositor->dirty_bg = true;
@@ -308,7 +308,7 @@ void vl_compositor_set_background(struct vl_compositor *compositor,
 }
 
 void vl_compositor_set_layers(struct vl_compositor *compositor,
-                              struct pipe_texture *layers[],
+                              struct pipe_surface *layers[],
                               struct pipe_video_rect *src_rects[],
                               struct pipe_video_rect *dst_rects[],
                               unsigned num_layers)
@@ -327,7 +327,7 @@ 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_texture_reference(&compositor->layers[i], layers[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]))*/
@@ -337,7 +337,7 @@ void vl_compositor_set_layers(struct vl_compositor *compositor,
    }
 
    for (; i < VL_COMPOSITOR_MAX_LAYERS; ++i)
-      pipe_texture_reference(&compositor->layers[i], NULL);
+      pipe_surface_reference(&compositor->layers[i], NULL);
 }
 
 static void gen_rect_verts(unsigned pos,
@@ -385,10 +385,10 @@ static void gen_rect_verts(unsigned pos,
 }
 
 static unsigned gen_data(struct vl_compositor *c,
-                         struct pipe_texture *src_surface,
+                         struct pipe_surface *src_surface,
                          struct pipe_video_rect *src_rect,
                          struct pipe_video_rect *dst_rect,
-                         struct pipe_texture **textures)
+                         struct pipe_surface **textures)
 {
    void *vb;
    unsigned num_rects = 0;
@@ -407,7 +407,7 @@ static unsigned gen_data(struct vl_compositor *c,
       return 0;
 
    if (c->dirty_bg) {
-      struct vertex2f bg_inv_size = {1.0f / c->bg->width0, 1.0f / c->bg->height0};
+      struct vertex2f bg_inv_size = {1.0f / c->bg->width, 1.0f / c->bg->height};
       gen_rect_verts(num_rects, &c->bg_src_rect, &bg_inv_size, NULL, NULL, vb);
       textures[num_rects] = c->bg;
       ++num_rects;
@@ -415,7 +415,7 @@ static unsigned gen_data(struct vl_compositor *c,
    }
 
    {
-      struct vertex2f src_inv_size = { 1.0f / src_surface->width0, 1.0f / src_surface->height0};
+      struct vertex2f src_inv_size = { 1.0f / src_surface->width, 1.0f / src_surface->height};
       gen_rect_verts(num_rects, src_rect, &src_inv_size, dst_rect, &c->fb_inv_size, vb);
       textures[num_rects] = src_surface;
       ++num_rects;
@@ -425,7 +425,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]->width0, 1.0f / c->layers[i]->height0};
+         struct vertex2f layer_inv_size = {1.0f / c->layers[i]->width, 1.0f / c->layers[i]->height};
          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];
@@ -440,12 +440,12 @@ static unsigned gen_data(struct vl_compositor *c,
 }
 
 static void draw_layers(struct vl_compositor *c,
-                        struct pipe_texture *src_surface,
+                        struct pipe_surface *src_surface,
                         struct pipe_video_rect *src_rect,
                         struct pipe_video_rect *dst_rect)
 {
    unsigned num_rects;
-   struct pipe_texture *textures[VL_COMPOSITOR_MAX_LAYERS + 2];
+   struct pipe_surface *src_surfaces[VL_COMPOSITOR_MAX_LAYERS + 2];
    unsigned i;
 
    assert(c);
@@ -453,23 +453,23 @@ static void draw_layers(struct vl_compositor *c,
    assert(src_rect);
    assert(dst_rect);
 
-   num_rects = gen_data(c, src_surface, src_rect, dst_rect, textures);
+   num_rects = gen_data(c, src_surface, src_rect, dst_rect, src_surfaces);
 
    for (i = 0; i < num_rects; ++i) {
-      c->pipe->set_fragment_sampler_textures(c->pipe, 1, &textures[i]);
+      c->pipe->set_fragment_sampler_textures(c->pipe, 1, &src_surfaces[i]->texture);
       c->pipe->draw_arrays(c->pipe, PIPE_PRIM_TRIANGLES, i * 6, 6);
    }
 }
 
 void vl_compositor_render(struct vl_compositor          *compositor,
-                          struct pipe_texture           *src_surface,
+                          struct pipe_surface           *src_surface,
                           enum pipe_mpeg12_picture_type picture_type,
                           /*unsigned                    num_past_surfaces,
-                          struct pipe_texture           *past_surfaces,
+                          struct pipe_surface           *past_surfaces,
                           unsigned                      num_future_surfaces,
-                          struct pipe_texture           *future_surfaces,*/
+                          struct pipe_surface           *future_surfaces,*/
                           struct pipe_video_rect        *src_area,
-                          struct pipe_texture           *dst_surface,
+                          struct pipe_surface           *dst_surface,
                           struct pipe_video_rect        *dst_area,
                           struct pipe_fence_handle      **fence)
 {
@@ -480,21 +480,16 @@ void vl_compositor_render(struct vl_compositor          *compositor,
    assert(dst_area);
    assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
 
-   if (compositor->fb_state.width != dst_surface->width0) {
-      compositor->fb_inv_size.x = 1.0f / dst_surface->width0;
-      compositor->fb_state.width = dst_surface->width0;
+   if (compositor->fb_state.width != dst_surface->width) {
+      compositor->fb_inv_size.x = 1.0f / dst_surface->width;
+      compositor->fb_state.width = dst_surface->width;
    }
-   if (compositor->fb_state.height != dst_surface->height0) {
-      compositor->fb_inv_size.y = 1.0f / dst_surface->height0;
-      compositor->fb_state.height = dst_surface->height0;
+   if (compositor->fb_state.height != dst_surface->height) {
+      compositor->fb_inv_size.y = 1.0f / dst_surface->height;
+      compositor->fb_state.height = dst_surface->height;
    }
 
-   compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
-   (
-      compositor->pipe->screen,
-      dst_surface,
-      0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ_WRITE
-   );
+   compositor->fb_state.cbufs[0] = dst_surface;
 
    compositor->viewport.scale[0] = compositor->fb_state.width;
    compositor->viewport.scale[1] = compositor->fb_state.height;
@@ -518,8 +513,6 @@ void vl_compositor_render(struct vl_compositor          *compositor,
 
    assert(!compositor->dirty_bg && !compositor->dirty_layers);
    compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
-
-   pipe_surface_reference(&compositor->fb_state.cbufs[0], NULL);
 }
 
 void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat)
index a75223c773fc5ed6267f47004b7d8e0c46eb6fdc..3b1e809b868302fbe0e5157cbd8c22398a15cf89 100644 (file)
@@ -34,7 +34,6 @@
 #include "vl_types.h"
 
 struct pipe_context;
-struct pipe_texture;
 
 #define VL_COMPOSITOR_MAX_LAYERS 16
 
@@ -52,10 +51,10 @@ struct vl_compositor
    struct pipe_vertex_element vertex_elems[2];
    struct pipe_buffer *fs_const_buf;
 
-   struct pipe_texture *bg;
+   struct pipe_surface *bg;
    struct pipe_video_rect bg_src_rect;
    bool dirty_bg;
-   struct pipe_texture *layers[VL_COMPOSITOR_MAX_LAYERS];
+   struct pipe_surface *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;
@@ -66,23 +65,23 @@ bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *p
 void vl_compositor_cleanup(struct vl_compositor *compositor);
 
 void vl_compositor_set_background(struct vl_compositor *compositor,
-                                  struct pipe_texture *bg, struct pipe_video_rect *bg_src_rect);
+                                  struct pipe_surface *bg, struct pipe_video_rect *bg_src_rect);
 
 void vl_compositor_set_layers(struct vl_compositor *compositor,
-                              struct pipe_texture *layers[],
+                              struct pipe_surface *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_texture           *src_surface,
+                          struct pipe_surface           *src_surface,
                           enum pipe_mpeg12_picture_type picture_type,
                           /*unsigned                    num_past_surfaces,
-                          struct pipe_texture           *past_surfaces,
+                          struct pipe_surface           *past_surfaces,
                           unsigned                      num_future_surfaces,
-                          struct pipe_texture           *future_surfaces,*/
+                          struct pipe_surface           *future_surfaces,*/
                           struct pipe_video_rect        *src_area,
-                          struct pipe_texture           *dst_surface,
+                          struct pipe_surface           *dst_surface,
                           struct pipe_video_rect        *dst_area,
                           struct pipe_fence_handle      **fence);
 
index eca3452a5b4b309fd05b9fb5d4e4108e4bf24d16..2e611fca96bfae9d54071c9ed8a9e7e4419e305c 100644 (file)
@@ -997,11 +997,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
 
    gen_macroblock_stream(r, num_macroblocks);
 
-   r->fb_state.cbufs[0] = r->pipe->screen->get_tex_surface
-   (
-      r->pipe->screen, r->surface,
-      0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE
-   );
+   r->fb_state.cbufs[0] = r->surface;
 
    r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
    r->pipe->set_viewport_state(r->pipe, &r->viewport);
@@ -1012,8 +1008,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
       PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
    );
 
-   vs_consts->denorm.x = r->surface->width0;
-   vs_consts->denorm.y = r->surface->height0;
+   vs_consts->denorm.x = r->surface->width;
+   vs_consts->denorm.y = r->surface->height;
 
    pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf);
 
@@ -1036,7 +1032,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] > 0) {
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
-      r->textures.individual.ref[0] = r->past;
+      r->textures.individual.ref[0] = r->past->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
@@ -1050,7 +1046,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (false /*num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] > 0 */ ) {
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
-      r->textures.individual.ref[0] = r->past;
+      r->textures.individual.ref[0] = r->past->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
@@ -1064,7 +1060,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] > 0) {
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
-      r->textures.individual.ref[0] = r->future;
+      r->textures.individual.ref[0] = r->future->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
@@ -1078,7 +1074,7 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (false /*num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] > 0 */ ) {
       r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems);
-      r->textures.individual.ref[0] = r->future;
+      r->textures.individual.ref[0] = r->future->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
@@ -1092,8 +1088,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] > 0) {
       r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
-      r->textures.individual.ref[0] = r->past;
-      r->textures.individual.ref[1] = r->future;
+      r->textures.individual.ref[0] = r->past->texture;
+      r->textures.individual.ref[1] = r->future->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->b_vs[0]);
@@ -1107,8 +1103,8 @@ flush(struct vl_mpeg12_mc_renderer *r)
    if (false /*num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] > 0 */ ) {
       r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
       r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems);
-      r->textures.individual.ref[0] = r->past;
-      r->textures.individual.ref[1] = r->future;
+      r->textures.individual.ref[0] = r->past->texture;
+      r->textures.individual.ref[1] = r->future->texture;
       r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
       r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
       r->pipe->bind_vs_state(r->pipe, r->b_vs[1]);
@@ -1120,7 +1116,6 @@ flush(struct vl_mpeg12_mc_renderer *r)
    }
 
    r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, r->fence);
-   pipe_surface_reference(&r->fb_state.cbufs[0], NULL);
 
    if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE)
       for (i = 0; i < 3; ++i)
@@ -1328,9 +1323,9 @@ vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer)
 void
 vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
                                          *renderer,
-                                         struct pipe_texture *surface,
-                                         struct pipe_texture *past,
-                                         struct pipe_texture *future,
+                                         struct pipe_surface *surface,
+                                         struct pipe_surface *past,
+                                         struct pipe_surface *future,
                                          unsigned num_macroblocks,
                                          struct pipe_mpeg12_macroblock
                                          *mpeg12_macroblocks,
@@ -1365,8 +1360,8 @@ vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
       renderer->past = past;
       renderer->future = future;
       renderer->fence = fence;
-      renderer->surface_tex_inv_size.x = 1.0f / surface->width0;
-      renderer->surface_tex_inv_size.y = 1.0f / surface->height0;
+      renderer->surface_tex_inv_size.x = 1.0f / surface->width;
+      renderer->surface_tex_inv_size.y = 1.0f / surface->height;
    }
 
    while (num_macroblocks) {
index 532f346a17a2cccf4b1c5c71aa51ad7a41889aad..1a216b5ad4992325c7afa885978487835aec34d2 100644 (file)
@@ -87,7 +87,7 @@ struct vl_mpeg12_mc_renderer
       struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
    } vertex_bufs;
 
-   struct pipe_texture *surface, *past, *future;
+   struct pipe_surface *surface, *past, *future;
    struct pipe_fence_handle **fence;
    unsigned num_macroblocks;
    struct pipe_mpeg12_macroblock *macroblock_buf;
@@ -109,9 +109,9 @@ bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
 
 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
-                                              struct pipe_texture *surface,
-                                              struct pipe_texture *past,
-                                              struct pipe_texture *future,
+                                              struct pipe_surface *surface,
+                                              struct pipe_surface *past,
+                                              struct pipe_surface *future,
                                               unsigned num_macroblocks,
                                               struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
                                               struct pipe_fence_handle **fence);
index 2be093f505d8b8c07f2a06ef80dcb3dee64de57c..7850908b1344505200fe0d0effad6008e8d3f932 100644 (file)
@@ -77,10 +77,9 @@ sp_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe,
    assert(ctx->decode_target);
 
    vl_mpeg12_mc_renderer_render_macroblocks(&ctx->mc_renderer,
-                                            ctx->decode_target->texture,
-                                            past ? past->texture : NULL,
-                                            future ? future->texture : NULL,
-                                            num_macroblocks, mpeg12_macroblocks, fence);
+                                            ctx->decode_target,
+                                            past, future, num_macroblocks,
+                                            mpeg12_macroblocks, fence);
 }
 
 static void
@@ -141,13 +140,13 @@ sp_mpeg12_render_picture(struct pipe_video_context     *vpipe,
    assert(dst_surface);
    assert(dst_area);
 
-   vl_compositor_render(&ctx->compositor, src_surface->texture,
-                        picture_type, src_area, dst_surface->texture, dst_area, fence);
+   vl_compositor_render(&ctx->compositor, src_surface,
+                        picture_type, src_area, dst_surface, dst_area, fence);
 }
 
 static void
 sp_mpeg12_set_picture_background(struct pipe_video_context *vpipe,
-                                  struct pipe_texture *bg,
+                                  struct pipe_surface *bg,
                                   struct pipe_video_rect *bg_src_rect)
 {
    struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
@@ -161,7 +160,7 @@ sp_mpeg12_set_picture_background(struct pipe_video_context *vpipe,
 
 static void
 sp_mpeg12_set_picture_layers(struct pipe_video_context *vpipe,
-                             struct pipe_texture *layers[],
+                             struct pipe_surface *layers[],
                              struct pipe_video_rect *src_rects[],
                              struct pipe_video_rect *dst_rects[],
                              unsigned num_layers)
index 83d214cc53dcfa48abaaed8b51059259f8a52c61..f9dc625c7d7b9119efcbdf0b22640ad59d832992 100644 (file)
@@ -103,11 +103,11 @@ struct pipe_video_context
     */
    /*@{*/
    void (*set_picture_background)(struct pipe_video_context *vpipe,
-                                  struct pipe_texture *bg,
+                                  struct pipe_surface *bg,
                                   struct pipe_video_rect *bg_src_rect);
 
    void (*set_picture_layers)(struct pipe_video_context *vpipe,
-                              struct pipe_texture *layers[],
+                              struct pipe_surface *layers[],
                               struct pipe_video_rect *src_rects[],
                               struct pipe_video_rect *dst_rects[],
                               unsigned num_layers);