[g3dvl] remove unused color_swizzle from idct code
[mesa.git] / src / gallium / auxiliary / vl / vl_idct.h
1 /**************************************************************************
2 *
3 * Copyright 2010 Christian König
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef vl_idct_h
29 #define vl_idct_h
30
31 #include <pipe/p_state.h>
32 #include "vl_vertex_buffers.h"
33 #include "vl_ycbcr_buffer.h"
34
35 /* shader based inverse distinct cosinus transformation
36 * expect usage of vl_vertex_buffers as a todo list
37 */
38 struct vl_idct
39 {
40 struct pipe_context *pipe;
41
42 unsigned buffer_width;
43 unsigned buffer_height;
44 unsigned blocks_x, blocks_y;
45
46 void *rs_state;
47
48 void *samplers[2];
49
50 void *matrix_vs, *transpose_vs;
51 void *matrix_fs, *transpose_fs;
52
53 struct pipe_sampler_view *matrix;
54 };
55
56 /* a set of buffers to work with */
57 struct vl_idct_buffer
58 {
59 struct pipe_viewport_state viewport[2];
60 struct pipe_framebuffer_state fb_state[2];
61
62 union
63 {
64 struct pipe_sampler_view *all[4];
65 struct pipe_sampler_view *stage[2][2];
66 struct {
67 struct pipe_sampler_view *matrix, *source;
68 struct pipe_sampler_view *transpose, *intermediate;
69 } individual;
70 } sampler_views;
71
72 struct pipe_transfer *tex_transfer;
73 short *texels;
74 };
75
76 /* upload the idct matrix, which can be shared by all idct instances of a pipe */
77 struct pipe_sampler_view *vl_idct_upload_matrix(struct pipe_context *pipe);
78
79 /* init an idct instance */
80 bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
81 unsigned buffer_width, unsigned buffer_height,
82 unsigned blocks_x, unsigned blocks_y,
83 struct pipe_sampler_view *matrix);
84
85 /* destroy an idct instance */
86 void vl_idct_cleanup(struct vl_idct *idct);
87
88 /* init a buffer assosiated with agiven idct instance */
89 bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
90 struct pipe_sampler_view *source, struct pipe_surface *destination);
91
92 /* cleanup a buffer of an idct instance */
93 void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
94
95 /* map a buffer for use with vl_idct_add_block */
96 void vl_idct_map_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
97
98 /* add an block of to be tranformed data a the given x and y coordinate */
99 void vl_idct_add_block(struct vl_idct_buffer *buffer, unsigned x, unsigned y, short *block);
100
101 /* unmaps the buffers before flushing */
102 void vl_idct_unmap_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
103
104 /* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */
105 void vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_verts);
106
107 #endif