From: Christian König Date: Thu, 5 May 2011 18:09:34 +0000 (+0200) Subject: [g3dvl] move zscan into shaders X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6ad846ee78d9d8ba93dcecdefbf89f2b981333ef;p=mesa.git [g3dvl] move zscan into shaders --- diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c index aee804a5de1..36eed519092 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_bitstream.c @@ -55,6 +55,7 @@ #include #include "vl_vlc.h" +#include "vl_zscan.h" #include "vl_mpeg12_bitstream.h" /* take num bits from the high part of bit_buf and zero extend them */ @@ -457,29 +458,6 @@ static const MBAtab MBA_11 [] = { { 7, 7}, { 7, 7}, { 7, 7}, { 7, 7} }; -/* original (non-patched) scan tables */ -static const uint8_t mpeg2_scan_norm_orig[64] = -{ - /* Zig-Zag scan pattern */ - 0, 1, 8,16, 9, 2, 3,10, - 17,24,32,25,18,11, 4, 5, - 12,19,26,33,40,48,41,34, - 27,20,13, 6, 7,14,21,28, - 35,42,49,56,57,50,43,36, - 29,22,15,23,30,37,44,51, - 58,59,52,45,38,31,39,46, - 53,60,61,54,47,55,62,63 -}; - -static const uint8_t mpeg2_scan_alt_orig[64] = -{ - /* Alternate scan pattern */ - 0,8,16,24,1,9,2,10,17,25,32,40,48,56,57,49, - 41,33,26,18,3,11,4,12,19,27,34,42,50,58,35,43, - 51,59,20,28,5,13,6,14,21,29,36,44,52,60,37,45, - 53,61,22,30,7,15,23,31,38,46,54,62,39,47,55,63 -}; - static const int non_linear_quantizer_scale[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 22, @@ -749,20 +727,13 @@ get_chroma_dc_dct_diff(struct vl_mpg12_bs *bs) static inline void get_intra_block_B14(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, - int quantizer_scale, short *dest) + const int scan[64], int quantizer_scale, short *dest) { int i, j, val; - const uint8_t *scan; uint8_t *quant_matrix = picture->intra_quantizer_matrix; int mismatch; const DCTtab *tab; - if (!picture->alternate_scan) { - scan = mpeg2_scan_norm_orig; - } else { - scan = mpeg2_scan_alt_orig; - } - i = 0; mismatch = ~dest[0]; @@ -788,7 +759,7 @@ get_intra_block_B14(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1); SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; bs->vlc.buf <<= 1; @@ -817,7 +788,7 @@ get_intra_block_B14(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (vl_vlc_sbits(&bs->vlc, 12) * quantizer_scale * quant_matrix[j]) / 16; SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; vl_vlc_dumpbits(&bs->vlc, 12); @@ -857,20 +828,13 @@ get_intra_block_B14(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi static inline void get_intra_block_B15(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, - int quantizer_scale, short *dest) + const int scan[64], int quantizer_scale, short *dest) { int i, j, val; - const uint8_t *scan; uint8_t *quant_matrix = picture->intra_quantizer_matrix; int mismatch; const DCTtab * tab; - if (!picture->alternate_scan) { - scan = mpeg2_scan_norm_orig; - } else { - scan = mpeg2_scan_alt_orig; - } - i = 0; mismatch = ~dest[0]; @@ -894,7 +858,7 @@ get_intra_block_B15(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1); SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; bs->vlc.buf <<= 1; @@ -922,7 +886,7 @@ get_intra_block_B15(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (vl_vlc_sbits(&bs->vlc, 12) * quantizer_scale * quant_matrix[j]) / 16; SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; vl_vlc_dumpbits(&bs->vlc, 12); @@ -963,10 +927,9 @@ get_intra_block_B15(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi static inline void get_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, - int quantizer_scale, short *dest) + const int scan[64], int quantizer_scale, short *dest) { int i, j, val; - const uint8_t *scan; uint8_t *quant_matrix = picture->non_intra_quantizer_matrix; int mismatch; const DCTtab *tab; @@ -974,12 +937,6 @@ get_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi i = -1; mismatch = 1; - if (!picture->alternate_scan) { - scan = mpeg2_scan_norm_orig; - } else { - scan = mpeg2_scan_alt_orig; - } - vl_vlc_needbits(&bs->vlc); if (bs->vlc.buf >= 0x28000000) { tab = DCT_B14DC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5); @@ -1007,7 +964,7 @@ get_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1); SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; bs->vlc.buf <<= 1; @@ -1040,7 +997,7 @@ get_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi val = (val * quantizer_scale * quant_matrix[j]) / 32; SATURATE (val); - dest[j] = val; + dest[i] = val; mismatch ^= val; vl_vlc_dumpbits(&bs->vlc, 12); @@ -1079,21 +1036,14 @@ get_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi static inline void get_mpeg1_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, - int quantizer_scale, short *dest) + const int scan[64], int quantizer_scale, short *dest) { int i, j, val; - const uint8_t *scan; uint8_t *quant_matrix = picture->intra_quantizer_matrix; const DCTtab * tab; i = 0; - if (!picture->alternate_scan) { - scan = mpeg2_scan_norm_orig; - } else { - scan = mpeg2_scan_alt_orig; - } - vl_vlc_needbits(&bs->vlc); while (1) { @@ -1118,7 +1068,7 @@ get_mpeg1_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1); SATURATE (val); - dest[j] = val; + dest[i] = val; bs->vlc.buf <<= 1; vl_vlc_needbits(&bs->vlc); @@ -1154,7 +1104,7 @@ get_mpeg1_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * val = (val + ~SBITS (val, 1)) | 1; SATURATE (val); - dest[j] = val; + dest[i] = val; vl_vlc_dumpbits(&bs->vlc, 8); vl_vlc_needbits(&bs->vlc); @@ -1191,21 +1141,14 @@ get_mpeg1_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * static inline void get_mpeg1_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, - int quantizer_scale, short *dest) + const int scan[64], int quantizer_scale, short *dest) { int i, j, val; - const uint8_t * scan; uint8_t *quant_matrix = picture->non_intra_quantizer_matrix; const DCTtab * tab; i = -1; - if (!picture->alternate_scan) { - scan = mpeg2_scan_norm_orig; - } else { - scan = mpeg2_scan_alt_orig; - } - vl_vlc_needbits(&bs->vlc); if (bs->vlc.buf >= 0x28000000) { tab = DCT_B14DC_5 + (vl_vlc_ubits(&bs->vlc, 5) - 5); @@ -1236,7 +1179,7 @@ get_mpeg1_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_des val = (val ^ vl_vlc_sbits(&bs->vlc, 1)) - vl_vlc_sbits(&bs->vlc, 1); SATURATE (val); - dest[j] = val; + dest[i] = val; bs->vlc.buf <<= 1; vl_vlc_needbits(&bs->vlc); @@ -1276,7 +1219,7 @@ get_mpeg1_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_des val = (val + ~SBITS (val, 1)) | 1; SATURATE (val); - dest[j] = val; + dest[i] = val; vl_vlc_dumpbits(&bs->vlc, 8); vl_vlc_needbits(&bs->vlc); @@ -1312,8 +1255,8 @@ get_mpeg1_non_intra_block(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_des } static inline void -slice_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, int cc, unsigned x, unsigned y, - enum pipe_mpeg12_dct_type coding, int quantizer_scale, int dc_dct_pred[3]) +slice_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, const int scan[64], int cc, + unsigned x, unsigned y, enum pipe_mpeg12_dct_type coding, int quantizer_scale, int dc_dct_pred[3]) { short *dest = bs->ycbcr_buffer[cc]; @@ -1334,11 +1277,11 @@ slice_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pictur dest[0] = dc_dct_pred[cc] << (3 - picture->intra_dc_precision); if (picture->mpeg1) { if (picture->picture_coding_type != D_TYPE) - get_mpeg1_intra_block(bs, picture, quantizer_scale, dest); + get_mpeg1_intra_block(bs, picture, scan, quantizer_scale, dest); } else if (picture->intra_vlc_format) - get_intra_block_B15(bs, picture, quantizer_scale, dest); + get_intra_block_B15(bs, picture, scan, quantizer_scale, dest); else - get_intra_block_B14(bs, picture, quantizer_scale, dest); + get_intra_block_B14(bs, picture, scan, quantizer_scale, dest); bs->num_ycbcr_blocks[cc]++; bs->ycbcr_stream[cc]++; @@ -1346,7 +1289,7 @@ slice_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pictur } static inline void -slice_non_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, int cc, +slice_non_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, const int scan[64], int cc, unsigned x, unsigned y, int quantizer_scale, enum pipe_mpeg12_dct_type coding) { short *dest = bs->ycbcr_buffer[cc]; @@ -1358,9 +1301,9 @@ slice_non_intra_DCT(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * pi memset(dest, 0, sizeof(int16_t) * 64); if (picture->mpeg1) - get_mpeg1_non_intra_block(bs, picture, quantizer_scale, dest); + get_mpeg1_non_intra_block(bs, picture, scan, quantizer_scale, dest); else - get_non_intra_block(bs, picture, quantizer_scale, dest); + get_non_intra_block(bs, picture, scan, quantizer_scale, dest); bs->num_ycbcr_blocks[cc]++; bs->ycbcr_stream[cc]++; @@ -1663,7 +1606,7 @@ slice_init(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc * picture, } static inline bool -decode_slice(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture) +decode_slice(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture, const int scan[64]) { struct pipe_motionvector mv_fwd, mv_bwd; enum pipe_mpeg12_dct_type dct_type; @@ -1732,12 +1675,12 @@ decode_slice(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture) mv_bwd.top.weight = mv_bwd.bottom.weight = PIPE_VIDEO_MV_WEIGHT_MIN; // unravaled loop of 6 block(i) calls in macroblock() - slice_intra_DCT(bs, picture, 0, x*2+0, y*2+0, dct_type, quantizer_scale, dc_dct_pred); - slice_intra_DCT(bs, picture, 0, x*2+1, y*2+0, dct_type, quantizer_scale, dc_dct_pred); - slice_intra_DCT(bs, picture, 0, x*2+0, y*2+1, dct_type, quantizer_scale, dc_dct_pred); - slice_intra_DCT(bs, picture, 0, x*2+1, y*2+1, dct_type, quantizer_scale, dc_dct_pred); - slice_intra_DCT(bs, picture, 1, x, y, dct_type, quantizer_scale, dc_dct_pred); - slice_intra_DCT(bs, picture, 2, x, y, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 0, x*2+0, y*2+0, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 0, x*2+1, y*2+0, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 0, x*2+0, y*2+1, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 0, x*2+1, y*2+1, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 1, x, y, dct_type, quantizer_scale, dc_dct_pred); + slice_intra_DCT(bs, picture, scan, 2, x, y, dct_type, quantizer_scale, dc_dct_pred); if (picture->picture_coding_type == D_TYPE) { vl_vlc_needbits(&bs->vlc); @@ -1795,17 +1738,17 @@ decode_slice(struct vl_mpg12_bs *bs, struct pipe_mpeg12_picture_desc *picture) // TODO optimize not fully used for idct accel only mc. if (coded_block_pattern & 0x20) - slice_non_intra_DCT(bs, picture, 0, x*2+0, y*2+0, quantizer_scale, dct_type); // cc0 luma 0 + slice_non_intra_DCT(bs, picture, scan, 0, x*2+0, y*2+0, quantizer_scale, dct_type); // cc0 luma 0 if (coded_block_pattern & 0x10) - slice_non_intra_DCT(bs, picture, 0, x*2+1, y*2+0, quantizer_scale, dct_type); // cc0 luma 1 + slice_non_intra_DCT(bs, picture, scan, 0, x*2+1, y*2+0, quantizer_scale, dct_type); // cc0 luma 1 if (coded_block_pattern & 0x08) - slice_non_intra_DCT(bs, picture, 0, x*2+0, y*2+1, quantizer_scale, dct_type); // cc0 luma 2 + slice_non_intra_DCT(bs, picture, scan, 0, x*2+0, y*2+1, quantizer_scale, dct_type); // cc0 luma 2 if (coded_block_pattern & 0x04) - slice_non_intra_DCT(bs, picture, 0, x*2+1, y*2+1, quantizer_scale, dct_type); // cc0 luma 3 + slice_non_intra_DCT(bs, picture, scan, 0, x*2+1, y*2+1, quantizer_scale, dct_type); // cc0 luma 3 if (coded_block_pattern & 0x2) - slice_non_intra_DCT(bs, picture, 1, x, y, quantizer_scale, dct_type); // cc1 croma + slice_non_intra_DCT(bs, picture, scan, 1, x, y, quantizer_scale, dct_type); // cc1 croma if (coded_block_pattern & 0x1) - slice_non_intra_DCT(bs, picture, 2, x, y, quantizer_scale, dct_type); // cc2 croma + slice_non_intra_DCT(bs, picture, scan, 2, x, y, quantizer_scale, dct_type); // cc2 croma } dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0; @@ -1918,6 +1861,8 @@ void vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const void *buffer, struct pipe_mpeg12_picture_desc *picture, unsigned num_ycbcr_blocks[3]) { + const int *scan; + assert(bs); assert(num_ycbcr_blocks); assert(buffer && num_bytes); @@ -1926,5 +1871,7 @@ vl_mpg12_bs_decode(struct vl_mpg12_bs *bs, unsigned num_bytes, const void *buffe vl_vlc_init(&bs->vlc, buffer, num_bytes); - while(decode_slice(bs, picture)); + scan = picture->alternate_scan ? vl_zscan_alternate : vl_zscan_normal; + + while(decode_slice(bs, picture, scan)); } diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 4ac3b90ad78..b7d9b4706a5 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -358,6 +358,9 @@ vl_mpeg12_buffer_map(struct pipe_video_decode_buffer *buffer) mv_stream[i] = vl_vb_get_mv_stream(&buf->vertex_stream, i); vl_mpg12_bs_set_buffers(&buf->bs, ycbcr_stream, buf->texels, mv_stream); + } else { + for (i = 0; i < VL_MAX_PLANES; ++i) + vl_zscan_set_layout(&buf->zscan[i], dec->zscan_linear); } } @@ -409,6 +412,16 @@ vl_mpeg12_buffer_decode_bitstream(struct pipe_video_decode_buffer *buffer, unsigned num_ycbcr_blocks[3]) { struct vl_mpeg12_buffer *buf = (struct vl_mpeg12_buffer*)buffer; + struct vl_mpeg12_decoder *dec; + unsigned i; + + assert(buf); + + dec = (struct vl_mpeg12_decoder *)buf->base.decoder; + assert(dec); + + for (i = 0; i < VL_MAX_PLANES; ++i) + vl_zscan_set_layout(&buf->zscan[i], picture->alternate_scan ? dec->zscan_alternate : dec->zscan_normal); vl_mpg12_bs_decode(&buf->bs, num_bytes, data, picture, num_ycbcr_blocks); } @@ -464,6 +477,10 @@ vl_mpeg12_destroy(struct pipe_video_decoder *decoder) pipe_resource_reference(&dec->quads.buffer, NULL); pipe_resource_reference(&dec->pos.buffer, NULL); + pipe_sampler_view_reference(&dec->zscan_linear, NULL); + pipe_sampler_view_reference(&dec->zscan_normal, NULL); + pipe_sampler_view_reference(&dec->zscan_alternate, NULL); + FREE(dec); } @@ -676,8 +693,6 @@ find_first_supported_format(struct vl_mpeg12_decoder *dec, static bool init_zscan(struct vl_mpeg12_decoder *dec) { - struct pipe_sampler_view *layout; - unsigned num_channels; assert(dec); @@ -693,7 +708,9 @@ init_zscan(struct vl_mpeg12_decoder *dec) if (dec->zscan_source_format == PIPE_FORMAT_NONE) return false; - layout = vl_zscan_linear(dec->pipe, dec->blocks_per_line); + dec->zscan_linear = vl_zscan_layout(dec->pipe, vl_zscan_linear, dec->blocks_per_line); + dec->zscan_normal = vl_zscan_layout(dec->pipe, vl_zscan_normal, dec->blocks_per_line); + dec->zscan_alternate = vl_zscan_layout(dec->pipe, vl_zscan_alternate, dec->blocks_per_line); num_channels = dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT ? 4 : 1; @@ -701,14 +718,10 @@ init_zscan(struct vl_mpeg12_decoder *dec) dec->blocks_per_line, dec->max_blocks, num_channels)) return false; - vl_zscan_set_layout(&dec->zscan_y, layout); - if (!vl_zscan_init(&dec->zscan_c, dec->pipe, dec->chroma_width, dec->chroma_height, dec->blocks_per_line, dec->max_blocks, num_channels)) return false; - vl_zscan_set_layout(&dec->zscan_c, layout); - return true; } diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h index 66356694b59..0ea71d11ca7 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.h @@ -64,6 +64,10 @@ struct vl_mpeg12_decoder void *sampler_ycbcr; + struct pipe_sampler_view *zscan_linear; + struct pipe_sampler_view *zscan_normal; + struct pipe_sampler_view *zscan_alternate; + struct vl_zscan zscan_y, zscan_c; struct vl_idct idct_y, idct_c; struct vl_mc mc_y, mc_c; diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 4d4d3fd6d95..d06c567bfb4 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -48,6 +48,45 @@ enum VS_OUTPUT VS_O_VTEX }; +const int vl_zscan_linear[] = +{ + /* Linear scan pattern */ + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9,10,11,12,13,14,15, + 16,17,18,19,20,21,22,23, + 24,25,26,27,28,29,30,31, + 32,33,34,35,36,37,38,39, + 40,41,42,43,44,45,46,47, + 48,49,50,51,52,53,54,55, + 56,57,58,59,60,61,62,63 +}; + +const int vl_zscan_normal[] = +{ + /* Zig-Zag scan pattern */ + 0, 1, 8,16, 9, 2, 3,10, + 17,24,32,25,18,11, 4, 5, + 12,19,26,33,40,48,41,34, + 27,20,13, 6, 7,14,21,28, + 35,42,49,56,57,50,43,36, + 29,22,15,23,30,37,44,51, + 58,59,52,45,38,31,39,46, + 53,60,61,54,47,55,62,63 +}; + +const int vl_zscan_alternate[] = +{ + /* Alternate scan pattern */ + 0, 8,16,24, 1, 9, 2,10, + 17,25,32,40,48,56,57,49, + 41,33,26,18, 3,11, 4,12, + 19,27,34,42,50,58,35,43, + 51,59,20,28, 5,13, 6,14, + 21,29,36,44,52,60,37,45, + 53,61,22,30, 7,15,23,31, + 38,46,54,62,39,47,55,63 +}; + static void * create_vert_shader(struct vl_zscan *zscan) { @@ -288,10 +327,12 @@ cleanup_state(struct vl_zscan *zscan) } struct pipe_sampler_view * -vl_zscan_linear(struct pipe_context *pipe, unsigned blocks_per_line) +vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line) { const unsigned total_size = blocks_per_line * BLOCK_WIDTH * BLOCK_HEIGHT; + int patched_layout[64]; + struct pipe_resource res_tmpl, *res; struct pipe_sampler_view sv_tmpl, *sv; struct pipe_transfer *buf_transfer; @@ -306,7 +347,10 @@ vl_zscan_linear(struct pipe_context *pipe, unsigned blocks_per_line) 1 }; - assert(pipe && blocks_per_line); + assert(pipe && layout && blocks_per_line); + + for (i = 0; i < 64; ++i) + patched_layout[layout[i]] = i; memset(&res_tmpl, 0, sizeof(res_tmpl)); res_tmpl.target = PIPE_TEXTURE_2D; @@ -340,7 +384,7 @@ vl_zscan_linear(struct pipe_context *pipe, unsigned blocks_per_line) for (i = 0; i < blocks_per_line; ++i) for (y = 0; y < BLOCK_HEIGHT; ++y) for (x = 0; x < BLOCK_WIDTH; ++x) { - float addr = x + y * BLOCK_WIDTH + + float addr = patched_layout[x + y * BLOCK_WIDTH] + i * BLOCK_WIDTH * BLOCK_HEIGHT; addr /= total_size; @@ -414,15 +458,6 @@ vl_zscan_cleanup(struct vl_zscan *zscan) cleanup_state(zscan); } -void -vl_zscan_set_layout(struct vl_zscan *zscan, struct pipe_sampler_view *layout) -{ - assert(zscan); - assert(layout); - - pipe_sampler_view_reference(&zscan->scan, layout); -} - #if 0 // TODO void @@ -440,8 +475,6 @@ vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, buffer->zscan = zscan; pipe_sampler_view_reference(&buffer->src, src); - pipe_sampler_view_reference(&buffer->scan, zscan->scan); - pipe_sampler_view_reference(&buffer->quant, zscan->quant); buffer->viewport.scale[0] = dst->width; buffer->viewport.scale[1] = dst->height; @@ -466,11 +499,20 @@ vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer) assert(buffer); pipe_sampler_view_reference(&buffer->src, NULL); - pipe_sampler_view_reference(&buffer->scan, NULL); + pipe_sampler_view_reference(&buffer->layout, NULL); pipe_sampler_view_reference(&buffer->quant, NULL); pipe_surface_reference(&buffer->fb_state.cbufs[0], NULL); } +void +vl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout) +{ + assert(buffer); + assert(layout); + + pipe_sampler_view_reference(&buffer->layout, layout); +} + void vl_zscan_render(struct vl_zscan_buffer *buffer, unsigned num_instances) { diff --git a/src/gallium/auxiliary/vl/vl_zscan.h b/src/gallium/auxiliary/vl/vl_zscan.h index 28b990ca83b..ccc6bc4a8a1 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.h +++ b/src/gallium/auxiliary/vl/vl_zscan.h @@ -54,7 +54,6 @@ struct vl_zscan void *vs, *fs; - struct pipe_sampler_view *scan; struct pipe_sampler_view *quant; }; @@ -65,20 +64,16 @@ struct vl_zscan_buffer struct pipe_viewport_state viewport; struct pipe_framebuffer_state fb_state; - struct pipe_sampler_view *src, *scan, *quant; + struct pipe_sampler_view *src, *layout, *quant; struct pipe_surface *dst; }; -struct pipe_sampler_view * -vl_zscan_linear(struct pipe_context *pipe, unsigned blocks_per_line); +extern const int vl_zscan_linear[]; +extern const int vl_zscan_normal[]; +extern const int vl_zscan_alternate[]; -#if 0 struct pipe_sampler_view * -vl_zscan_normal(struct pipe_context *pipe, unsigned blocks_per_line); - -struct pipe_sampler_view * -vl_zscan_alternate(struct pipe_context *pipe, unsigned blocks_per_line); -#endif +vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line); bool vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe, @@ -86,9 +81,6 @@ vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe, unsigned blocks_per_line, unsigned blocks_total, unsigned num_channels); -void -vl_zscan_set_layout(struct vl_zscan *zscan, struct pipe_sampler_view *layout); - void vl_zscan_cleanup(struct vl_zscan *zscan); @@ -104,6 +96,9 @@ vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, void vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer); +void +vl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout); + void vl_zscan_render(struct vl_zscan_buffer *buffer, unsigned num_instances);