[g3dvl] start to cleanup the mess
[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
34 struct vl_idct
35 {
36 struct pipe_context *pipe;
37
38 unsigned buffer_width;
39 unsigned buffer_height;
40 unsigned blocks_x, blocks_y;
41
42 void *rs_state;
43
44 union
45 {
46 void *all[4];
47 void *stage[2][2];
48 struct {
49 void *matrix, *source;
50 void *transpose, *intermediate;
51 } individual;
52 } samplers;
53
54 void *matrix_vs, *transpose_vs;
55 void *matrix_fs, *transpose_fs;
56
57 struct pipe_resource *matrix;
58 };
59
60 struct vl_idct_buffer
61 {
62 struct pipe_viewport_state viewport[2];
63 struct pipe_framebuffer_state fb_state[2];
64
65 struct pipe_resource *destination;
66
67 union
68 {
69 struct pipe_sampler_view *all[4];
70 struct pipe_sampler_view *stage[2][2];
71 struct {
72 struct pipe_sampler_view *matrix, *source;
73 struct pipe_sampler_view *transpose, *intermediate;
74 } individual;
75 } sampler_views;
76
77 union
78 {
79 struct pipe_resource *all[4];
80 struct pipe_resource *stage[2][2];
81 struct {
82 struct pipe_resource *matrix, *source;
83 struct pipe_resource *transpose, *intermediate;
84 } individual;
85 } textures;
86
87 struct pipe_transfer *tex_transfer;
88 short *texels;
89 };
90
91 struct pipe_resource *vl_idct_upload_matrix(struct pipe_context *pipe);
92
93 bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe,
94 unsigned buffer_width, unsigned buffer_height,
95 unsigned blocks_x, unsigned blocks_y,
96 int color_swizzle, struct pipe_resource *matrix);
97
98 void vl_idct_cleanup(struct vl_idct *idct);
99
100 bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer,
101 struct pipe_resource *dst);
102
103 void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer);
104
105 void vl_idct_map_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
106
107 void vl_idct_add_block(struct vl_idct_buffer *buffer, unsigned x, unsigned y, short *block);
108
109 void vl_idct_unmap_buffers(struct vl_idct *idct, struct vl_idct_buffer *buffer);
110
111 void vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_verts);
112
113 #endif