vl/buffer: use 2D_ARRAY instead of 3D textures
authorChristian König <christian.koenig@amd.com>
Tue, 30 Apr 2013 12:40:40 +0000 (14:40 +0200)
committerChristian König <christian.koenig@amd.com>
Wed, 1 May 2013 11:33:46 +0000 (13:33 +0200)
Signed-off-by: Christian König <christian.koenig@amd.com>
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_video_buffer.c
src/gallium/auxiliary/vl/vl_video_buffer.h
src/gallium/drivers/r600/r600_uvd.c
src/gallium/drivers/radeonsi/radeonsi_uvd.c
src/gallium/state_trackers/vdpau/surface.c

index 1c393a99de6ce37ad07dd1a2d64f94f59b44dda5..62f593a3203f94edb37018b306f8434f668c690a 100644 (file)
@@ -152,7 +152,7 @@ create_frag_shader_video_buffer(struct vl_compositor *c)
     * fragment = csc * texel
     */
    for (i = 0; i < 3; ++i)
-      ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_3D, tc, sampler[i]);
+      ureg_TEX(shader, ureg_writemask(texel, TGSI_WRITEMASK_X << i), TGSI_TEXTURE_2D_ARRAY, tc, sampler[i]);
 
    ureg_MOV(shader, ureg_writemask(texel, TGSI_WRITEMASK_W), ureg_imm1f(shader, 1.0f));
 
@@ -207,7 +207,7 @@ create_frag_shader_weave(struct vl_compositor *c)
                i_tc[i], ureg_imm1f(shader, 0.5f));
       ureg_ROUND(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ), ureg_src(t_tc[i]));
       ureg_MOV(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_W),
-               ureg_imm1f(shader, i ? -0.25f : 0.25f));
+               ureg_imm1f(shader, i ? 1.0f : 0.0f));
       ureg_ADD(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_YZ),
                ureg_src(t_tc[i]), ureg_imm1f(shader, 0.5f));
       ureg_MUL(shader, ureg_writemask(t_tc[i], TGSI_WRITEMASK_Y),
@@ -227,7 +227,7 @@ create_frag_shader_weave(struct vl_compositor *c)
             TGSI_SWIZZLE_X, j ? TGSI_SWIZZLE_Z : TGSI_SWIZZLE_Y, TGSI_SWIZZLE_W, TGSI_SWIZZLE_W);
 
          ureg_TEX(shader, ureg_writemask(t_texel[i], TGSI_WRITEMASK_X << j),
-                  TGSI_TEXTURE_3D, src, sampler[j]);
+                  TGSI_TEXTURE_2D_ARRAY, src, sampler[j]);
       }
 
    /* calculate linear interpolation factor
@@ -558,7 +558,7 @@ static INLINE struct u_rect
 default_rect(struct vl_compositor_layer *layer)
 {
    struct pipe_resource *res = layer->sampler_views[0]->texture;
-   struct u_rect rect = { 0, res->width0, 0, res->height0 * res->depth0 };
+   struct u_rect rect = { 0, res->width0, 0, res->height0 * res->array_size };
    return rect;
 }
 
@@ -902,14 +902,14 @@ vl_compositor_set_buffer_layer(struct vl_compositor_state *s,
          break;
 
       case VL_COMPOSITOR_BOB_TOP:
-         s->layers[layer].zw.x = 0.25f;
+         s->layers[layer].zw.x = 0.0f;
          s->layers[layer].src.tl.y += half_a_line;
          s->layers[layer].src.br.y += half_a_line;
          s->layers[layer].fs = c->fs_video_buffer;
          break;
 
       case VL_COMPOSITOR_BOB_BOTTOM:
-         s->layers[layer].zw.x = 0.75f;
+         s->layers[layer].zw.x = 1.0f;
          s->layers[layer].src.tl.y -= half_a_line;
          s->layers[layer].src.br.y -= half_a_line;
          s->layers[layer].fs = c->fs_video_buffer;
index d61dab22c2d89406e29dc31964fbd265c9e5f75d..220c3ea632f520e7babbee8cd44cd8c586df595b 100644 (file)
@@ -216,15 +216,16 @@ void
 vl_vide_buffer_template(struct pipe_resource *templ,
                         const struct pipe_video_buffer *tmpl,
                         enum pipe_format resource_format,
-                        unsigned depth, unsigned usage, unsigned plane)
+                        unsigned array_size, unsigned usage,
+                        unsigned plane)
 {
    memset(templ, 0, sizeof(*templ));
-   templ->target = depth > 1 ? PIPE_TEXTURE_3D : PIPE_TEXTURE_2D;
+   templ->target = array_size > 1 ? PIPE_TEXTURE_2D_ARRAY : PIPE_TEXTURE_2D;
    templ->format = resource_format;
    templ->width0 = tmpl->width;
    templ->height0 = tmpl->height;
-   templ->depth0 = depth;
-   templ->array_size = 1;
+   templ->depth0 = 1;
+   templ->array_size = array_size;
    templ->bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
    templ->usage = usage;
 
@@ -349,15 +350,15 @@ vl_video_buffer_surfaces(struct pipe_video_buffer *buffer)
    struct vl_video_buffer *buf = (struct vl_video_buffer *)buffer;
    struct pipe_surface surf_templ;
    struct pipe_context *pipe;
-   unsigned i, j, depth, surf;
+   unsigned i, j, array_size, surf;
 
    assert(buf);
 
    pipe = buf->base.context;
 
-   depth = buffer->interlaced ? 2 : 1;
+   array_size = buffer->interlaced ? 2 : 1;
    for (i = 0, surf = 0; i < VL_NUM_COMPONENTS; ++i) {
-      for (j = 0; j < depth; ++j, ++surf) {
+      for (j = 0; j < array_size; ++j, ++surf) {
          assert(surf < (VL_NUM_COMPONENTS * 2));
 
          if (!buf->resources[i]) {
@@ -433,7 +434,7 @@ struct pipe_video_buffer *
 vl_video_buffer_create_ex(struct pipe_context *pipe,
                           const struct pipe_video_buffer *tmpl,
                           const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
-                          unsigned depth, unsigned usage)
+                          unsigned array_size, unsigned usage)
 {
    struct pipe_resource res_tmpl;
    struct pipe_resource *resources[VL_NUM_COMPONENTS];
@@ -443,7 +444,7 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
 
    memset(resources, 0, sizeof resources);
 
-   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[0], depth, usage, 0);
+   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[0], array_size, usage, 0);
    resources[0] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[0])
       goto error;
@@ -453,7 +454,7 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
       return vl_video_buffer_create_ex2(pipe, tmpl, resources);
    }
 
-   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[1], depth, usage, 1);
+   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[1], array_size, usage, 1);
    resources[1] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[1])
       goto error;
@@ -461,7 +462,7 @@ vl_video_buffer_create_ex(struct pipe_context *pipe,
    if (resource_formats[2] == PIPE_FORMAT_NONE)
       return vl_video_buffer_create_ex2(pipe, tmpl, resources);
 
-   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[2], depth, usage, 2);
+   vl_vide_buffer_template(&res_tmpl, tmpl, resource_formats[2], array_size, usage, 2);
    resources[2] = pipe->screen->resource_create(pipe->screen, &res_tmpl);
    if (!resources[2])
       goto error;
index 6e2f8b8291afcbfd79ff52aa7851912ada574329..e666011aea100a87fb4ae924897e4759de891c0d 100644 (file)
@@ -98,7 +98,8 @@ void
 vl_vide_buffer_template(struct pipe_resource *templ,
                        const struct pipe_video_buffer *templat,
                         enum pipe_format resource_format,
-                        unsigned depth, unsigned usage, unsigned plane);
+                        unsigned array_size, unsigned usage,
+                        unsigned plane);
 
 /**
  * creates a video buffer, can be used as a standard implementation for pipe->create_video_buffer
@@ -108,13 +109,13 @@ vl_video_buffer_create(struct pipe_context *pipe,
                        const struct pipe_video_buffer *templat);
 
 /**
- * extended create function, gets depth, usage and formats for each plane seperately
+ * extended create function, gets array_size, usage and formats for each plane seperately
  */
 struct pipe_video_buffer *
 vl_video_buffer_create_ex(struct pipe_context *pipe,
                           const struct pipe_video_buffer *templat,
                           const enum pipe_format resource_formats[VL_NUM_COMPONENTS],
-                          unsigned depth, unsigned usage);
+                          unsigned array_size, unsigned usage);
 
 /**
  * even more extended create function, provide the pipe_resource for each plane
index c4c04a84b3d512e51076a9a21361ccdfdb221c15..90282380889618697dd60f09689b4c83f166fe2a 100644 (file)
@@ -61,7 +61,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
        const enum pipe_format *resource_formats;
        struct pipe_video_buffer template;
        struct pipe_resource templ;
-       unsigned i, depth;
+       unsigned i, array_size;
 
        assert(pipe);
 
@@ -70,12 +70,12 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
        if (!resource_formats)
                return NULL;
 
-       depth = tmpl->interlaced ? 2 : 1;
+       array_size = tmpl->interlaced ? 2 : 1;
        template = *tmpl;
        template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH);
-       template.height = align(tmpl->height / depth, VL_MACROBLOCK_HEIGHT);
+       template.height = align(tmpl->height / array_size, VL_MACROBLOCK_HEIGHT);
 
-       vl_vide_buffer_template(&templ, &template, resource_formats[0], depth, PIPE_USAGE_STATIC, 0);
+       vl_vide_buffer_template(&templ, &template, resource_formats[0], array_size, PIPE_USAGE_STATIC, 0);
        if (ctx->chip_class < EVERGREEN)
                templ.flags = R600_RESOURCE_FLAG_TRANSFER;
        resources[0] = (struct r600_texture *)
@@ -84,7 +84,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
                goto error;
 
        if (resource_formats[1] != PIPE_FORMAT_NONE) {
-               vl_vide_buffer_template(&templ, &template, resource_formats[1], depth, PIPE_USAGE_STATIC, 1);
+               vl_vide_buffer_template(&templ, &template, resource_formats[1], array_size, PIPE_USAGE_STATIC, 1);
                if (ctx->chip_class < EVERGREEN)
                        templ.flags = R600_RESOURCE_FLAG_TRANSFER;
                resources[1] = (struct r600_texture *)
@@ -94,7 +94,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
        }
 
        if (resource_formats[2] != PIPE_FORMAT_NONE) {
-               vl_vide_buffer_template(&templ, &template, resource_formats[2], depth, PIPE_USAGE_STATIC, 2);
+               vl_vide_buffer_template(&templ, &template, resource_formats[2], array_size, PIPE_USAGE_STATIC, 2);
                if (ctx->chip_class < EVERGREEN)
                        templ.flags = R600_RESOURCE_FLAG_TRANSFER;
                resources[2] = (struct r600_texture *)
@@ -122,7 +122,7 @@ struct pipe_video_buffer *r600_video_buffer_create(struct pipe_context *pipe,
                        resources[i]->resource.buf);
        }
 
-       template.height *= depth;
+       template.height *= array_size;
        return vl_video_buffer_create_ex2(pipe, &template, (struct pipe_resource **)resources);
 
 error:
index 1aaaac4183974a8755720b0f487446e376c9f6e3..04f672dfa5e7965300e447cf42c1a580b709af15 100644 (file)
@@ -61,7 +61,7 @@ struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe
        const enum pipe_format *resource_formats;
        struct pipe_video_buffer template;
        struct pipe_resource templ;
-       unsigned i, depth;
+       unsigned i, array_size;
 
        assert(pipe);
 
@@ -70,12 +70,12 @@ struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe
        if (!resource_formats)
                return NULL;
 
-       depth = tmpl->interlaced ? 2 : 1;
+       array_size = tmpl->interlaced ? 2 : 1;
        template = *tmpl;
        template.width = align(tmpl->width, VL_MACROBLOCK_WIDTH);
-       template.height = align(tmpl->height / depth, VL_MACROBLOCK_HEIGHT);
+       template.height = align(tmpl->height / array_size, VL_MACROBLOCK_HEIGHT);
 
-       vl_vide_buffer_template(&templ, &template, resource_formats[0], depth, PIPE_USAGE_STATIC, 0);
+       vl_vide_buffer_template(&templ, &template, resource_formats[0], array_size, PIPE_USAGE_STATIC, 0);
        /* TODO: Setting the transfer flag is only a workaround till we get tiling working */
        templ.flags = R600_RESOURCE_FLAG_TRANSFER;
        resources[0] = (struct r600_resource_texture *)
@@ -84,7 +84,7 @@ struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe
                goto error;
 
        if (resource_formats[1] != PIPE_FORMAT_NONE) {
-               vl_vide_buffer_template(&templ, &template, resource_formats[1], depth, PIPE_USAGE_STATIC, 1);
+               vl_vide_buffer_template(&templ, &template, resource_formats[1], array_size, PIPE_USAGE_STATIC, 1);
                templ.flags = R600_RESOURCE_FLAG_TRANSFER;
                resources[1] = (struct r600_resource_texture *)
                        pipe->screen->resource_create(pipe->screen, &templ);
@@ -93,7 +93,7 @@ struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe
        }
 
        if (resource_formats[2] != PIPE_FORMAT_NONE) {
-               vl_vide_buffer_template(&templ, &template, resource_formats[2], depth, PIPE_USAGE_STATIC, 2);
+               vl_vide_buffer_template(&templ, &template, resource_formats[2], array_size, PIPE_USAGE_STATIC, 2);
                templ.flags = R600_RESOURCE_FLAG_TRANSFER;
                resources[2] = (struct r600_resource_texture *)
                        pipe->screen->resource_create(pipe->screen, &templ);
@@ -120,7 +120,7 @@ struct pipe_video_buffer *radeonsi_video_buffer_create(struct pipe_context *pipe
                        resources[i]->resource.buf);
        }
 
-       template.height *= depth;
+       template.height *= array_size;
        return vl_video_buffer_create_ex2(pipe, &template, (struct pipe_resource **)resources);
 
 error:
index 5c06f8511aaf3a79ad1e2e96acd227c9f8ee4433..ad56125e0cea1be814bc9dcb671eff3a3353ec21 100644 (file)
@@ -228,7 +228,7 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
 
       vlVdpVideoSurfaceSize(vlsurface, i, &width, &height);
 
-      for (j = 0; j < sv->texture->depth0; ++j) {
+      for (j = 0; j < sv->texture->array_size; ++j) {
          struct pipe_box box = {
             0, 0, j,
             width, height, 1
@@ -244,7 +244,7 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
          }
 
          util_copy_rect(destination_data[i] + destination_pitches[i] * j, sv->texture->format,
-                        destination_pitches[i] * sv->texture->depth0, 0, 0,
+                        destination_pitches[i] * sv->texture->array_size, 0, 0,
                         box.width, box.height, map, transfer->stride, 0, 0);
 
          pipe_transfer_unmap(pipe, transfer);
@@ -315,7 +315,7 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
 
       vlVdpVideoSurfaceSize(p_surf, i, &width, &height);
 
-      for (j = 0; j < sv->texture->depth0; ++j) {
+      for (j = 0; j < sv->texture->array_size; ++j) {
          struct pipe_box dst_box = {
             0, 0, j,
             width, height, 1
@@ -324,7 +324,7 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
          pipe->transfer_inline_write(pipe, sv->texture, 0,
                                      PIPE_TRANSFER_WRITE, &dst_box,
                                      source_data[i] + source_pitches[i] * j,
-                                     source_pitches[i] * sv->texture->depth0,
+                                     source_pitches[i] * sv->texture->array_size,
                                      0);
       }
    }