[g3dvl] make number of idct render targets configurable
authorChristian König <deathsimple@vodafone.de>
Sun, 10 Apr 2011 17:08:11 +0000 (19:08 +0200)
committerChristian König <deathsimple@vodafone.de>
Sun, 10 Apr 2011 17:08:11 +0000 (19:08 +0200)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_idct.h
src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
src/gallium/auxiliary/vl/vl_mpeg12_decoder.h

index 5d5ead31f7dbc158a6b31443056bfb4fe2c94fbf..3502f4c1eaae4f8ef93ecff553541dd23555056f 100644 (file)
@@ -38,8 +38,6 @@
 #include <tgsi/tgsi_ureg.h>
 #include "vl_types.h"
 
-#define NR_RENDER_TARGETS 4
-
 enum VS_OUTPUT
 {
    VS_O_VPOS,
@@ -171,7 +169,7 @@ create_vert_shader(struct vl_idct *idct, bool matrix_stage)
       ureg_MUL(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_XY), ureg_src(t_tex), scale);
       ureg_MUL(shader, ureg_writemask(t_tex, TGSI_WRITEMASK_Z),
          ureg_scalar(vrect, TGSI_SWIZZLE_X),
-         ureg_imm1f(shader, BLOCK_WIDTH / NR_RENDER_TARGETS));
+         ureg_imm1f(shader, BLOCK_WIDTH / idct->nr_of_render_targets));
 
       ureg_MOV(shader, ureg_writemask(o_vpos, TGSI_WRITEMASK_XY), ureg_src(t_tex));
 
@@ -250,7 +248,7 @@ create_matrix_frag_shader(struct vl_idct *idct)
    struct ureg_src l_addr[2], r_addr[2];
 
    struct ureg_dst l[4][2], r[2];
-   struct ureg_dst fragment[NR_RENDER_TARGETS];
+   struct ureg_dst fragment[idct->nr_of_render_targets];
 
    unsigned i, j;
 
@@ -264,7 +262,7 @@ create_matrix_frag_shader(struct vl_idct *idct)
    r_addr[0] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR0, TGSI_INTERPOLATE_LINEAR);
    r_addr[1] = ureg_DECL_fs_input(shader, TGSI_SEMANTIC_GENERIC, VS_O_R_ADDR1, TGSI_INTERPOLATE_LINEAR);
 
-   for (i = 0; i < NR_RENDER_TARGETS; ++i)
+   for (i = 0; i < idct->nr_of_render_targets; ++i)
        fragment[i] = ureg_DECL_output(shader, TGSI_SEMANTIC_COLOR, i);
 
    for (i = 0; i < 4; ++i) {
@@ -286,7 +284,7 @@ create_matrix_frag_shader(struct vl_idct *idct)
       fetch_four(shader, l[i], s_addr, ureg_DECL_sampler(shader, 1));
    }
 
-   for (i = 0; i < NR_RENDER_TARGETS; ++i) {
+   for (i = 0; i < idct->nr_of_render_targets; ++i) {
       if(i > 0)
          increment_addr(shader, r, r_addr, true, true, i, BLOCK_HEIGHT);
 
@@ -465,8 +463,8 @@ init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
 
    buffer->fb_state[0].width = tex->width0;
    buffer->fb_state[0].height = tex->height0;
-   buffer->fb_state[0].nr_cbufs = NR_RENDER_TARGETS;
-   for(i = 0; i < NR_RENDER_TARGETS; ++i) {
+   buffer->fb_state[0].nr_cbufs = idct->nr_of_render_targets;
+   for(i = 0; i < idct->nr_of_render_targets; ++i) {
       memset(&surf_templ, 0, sizeof(surf_templ));
       surf_templ.format = tex->format;
       surf_templ.u.tex.first_layer = i;
@@ -485,7 +483,7 @@ init_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
    return true;
 
 error_surfaces:
-   for(i = 0; i < NR_RENDER_TARGETS; ++i)
+   for(i = 0; i < idct->nr_of_render_targets; ++i)
       pipe_surface_reference(&buffer->fb_state[0].cbufs[i], NULL);
 
    return false;
@@ -498,7 +496,7 @@ cleanup_intermediate(struct vl_idct *idct, struct vl_idct_buffer *buffer)
 
    assert(idct && buffer);
 
-   for(i = 0; i < NR_RENDER_TARGETS; ++i)
+   for(i = 0; i < idct->nr_of_render_targets; ++i)
       pipe_surface_reference(&buffer->fb_state[0].cbufs[i], NULL);
 
    pipe_sampler_view_reference(&buffer->sampler_views.individual.intermediate, NULL);
@@ -584,6 +582,7 @@ error_matrix:
 bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
                   unsigned buffer_width, unsigned buffer_height,
                   unsigned blocks_x, unsigned blocks_y,
+                  unsigned nr_of_render_targets,
                   struct pipe_sampler_view *matrix)
 {
    assert(idct && pipe && matrix);
@@ -593,6 +592,7 @@ bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
    idct->buffer_height = buffer_height;
    idct->blocks_x = blocks_x;
    idct->blocks_y = blocks_y;
+   idct->nr_of_render_targets = nr_of_render_targets;
    pipe_sampler_view_reference(&idct->matrix, matrix);
 
    if(!init_shaders(idct))
@@ -666,7 +666,7 @@ vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer)
 
    assert(idct && buffer);
 
-   for(i = 0; i < NR_RENDER_TARGETS; ++i)
+   for(i = 0; i < idct->nr_of_render_targets; ++i)
       pipe_surface_reference(&buffer->fb_state[0].cbufs[i], NULL);
 
    pipe_surface_reference(&buffer->fb_state[1].cbufs[0], NULL);
index 4ad798a855bf5eccc649c9ddb7f7d8872fbaa0be..e695e32efe3907e0d16a53ca619e55004a7596af 100644 (file)
@@ -40,6 +40,7 @@ struct vl_idct
    unsigned buffer_width;
    unsigned buffer_height;
    unsigned blocks_x, blocks_y;
+   unsigned nr_of_render_targets;
 
    void *rs_state;
 
@@ -75,6 +76,7 @@ struct pipe_sampler_view *vl_idct_upload_matrix(struct pipe_context *pipe, float
 bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
                   unsigned buffer_width, unsigned buffer_height,
                   unsigned blocks_x, unsigned blocks_y,
+                  unsigned nr_of_render_targets,
                   struct pipe_sampler_view *matrix);
 
 /* destroy an idct instance */
index afb69e9c3bf0c99c755e55bd90e1e7bedb842f04..6d0d132db20be2a4ea0c277cc76743885feb1142 100644 (file)
@@ -311,7 +311,8 @@ vl_mpeg12_create_buffer(struct pipe_video_decoder *decoder)
          goto error_idct_source;
 
       buffer->idct_intermediate = vl_video_buffer_init(dec->base.context, dec->pipe,
-                                                       dec->base.width / 4, dec->base.height / 4, 4,
+                                                       dec->base.width / dec->nr_of_idct_render_targets,
+                                                       dec->base.height / 4, dec->nr_of_idct_render_targets,
                                                        dec->base.chroma_format, 3,
                                                        idct_source_formats,
                                                        PIPE_USAGE_STATIC);
@@ -550,11 +551,13 @@ init_idct(struct vl_mpeg12_decoder *dec, unsigned buffer_width, unsigned buffer_
    unsigned chroma_width, chroma_height, chroma_blocks_x, chroma_blocks_y;
    struct pipe_sampler_view *idct_matrix;
 
+   dec->nr_of_idct_render_targets = 4;
+
    if (!(idct_matrix = vl_idct_upload_matrix(dec->pipe, sqrt(SCALE_FACTOR_16_TO_9))))
       goto error_idct_matrix;
 
    if (!vl_idct_init(&dec->idct_y, dec->pipe, buffer_width, buffer_height,
-                     2, 2, idct_matrix))
+                     2, 2, dec->nr_of_idct_render_targets, idct_matrix))
       goto error_idct_y;
 
    if (dec->base.chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
@@ -575,7 +578,8 @@ init_idct(struct vl_mpeg12_decoder *dec, unsigned buffer_width, unsigned buffer_
    }
 
    if(!vl_idct_init(&dec->idct_c, dec->pipe, chroma_width, chroma_height,
-                    chroma_blocks_x, chroma_blocks_y, idct_matrix))
+                    chroma_blocks_x, chroma_blocks_y,
+                    dec->nr_of_idct_render_targets, idct_matrix))
       goto error_idct_c;
 
    pipe_sampler_view_reference(&idct_matrix, NULL);
index 9be807198fe83459d38834b010ff9d9f325efb14..c2eb7dd17de8b9cca9621deff2a47eea73b49377 100644 (file)
@@ -45,6 +45,7 @@ struct vl_mpeg12_decoder
    struct pipe_context *pipe;
 
    const unsigned (*empty_block_mask)[3][2][2];
+   unsigned nr_of_idct_render_targets;
 
    struct pipe_vertex_buffer quads;
    void *ves[VL_MAX_PLANES];