1 /**************************************************************************
3 * Copyright 2010 Christian König
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
31 #include <pipe/p_state.h>
33 #include <tgsi/tgsi_ureg.h>
35 /* shader based inverse distinct cosinus transformation
36 * expect usage of vl_vertex_buffers as a todo list
40 struct pipe_context
*pipe
;
42 unsigned buffer_width
;
43 unsigned buffer_height
;
44 unsigned nr_of_render_targets
;
51 void *vs_mismatch
, *fs_mismatch
;
54 struct pipe_sampler_view
*matrix
;
55 struct pipe_sampler_view
*transpose
;
58 /* a set of buffers to work with */
63 struct pipe_viewport_state viewport_mismatch
;
64 struct pipe_viewport_state viewport
;
66 struct pipe_framebuffer_state fb_state_mismatch
;
67 struct pipe_framebuffer_state fb_state
;
71 struct pipe_sampler_view
*all
[4];
72 struct pipe_sampler_view
*stage
[2][2];
74 struct pipe_sampler_view
*source
, *matrix
;
75 struct pipe_sampler_view
*intermediate
, *transpose
;
80 /* upload the idct matrix, which can be shared by all idct instances of a pipe */
81 struct pipe_sampler_view
*
82 vl_idct_upload_matrix(struct pipe_context
*pipe
, float scale
);
85 vl_idct_stage2_vert_shader(struct vl_idct
*idct
, struct ureg_program
*shader
,
86 unsigned first_output
, struct ureg_dst tex
);
89 vl_idct_stage2_frag_shader(struct vl_idct
*idct
, struct ureg_program
*shader
,
90 unsigned first_input
, struct ureg_dst fragment
);
92 /* init an idct instance */
94 vl_idct_init(struct vl_idct
*idct
, struct pipe_context
*pipe
,
95 unsigned buffer_width
, unsigned buffer_height
,
96 unsigned nr_of_render_targets
,
97 struct pipe_sampler_view
*matrix
,
98 struct pipe_sampler_view
*transpose
);
100 /* destroy an idct instance */
102 vl_idct_cleanup(struct vl_idct
*idct
);
104 /* init a buffer assosiated with agiven idct instance */
106 vl_idct_init_buffer(struct vl_idct
*idct
, struct vl_idct_buffer
*buffer
,
107 struct pipe_sampler_view
*source
,
108 struct pipe_sampler_view
*intermediate
);
110 /* cleanup a buffer of an idct instance */
112 vl_idct_cleanup_buffer(struct vl_idct_buffer
*buffer
);
114 /* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */
116 vl_idct_flush(struct vl_idct_buffer
*buffer
, unsigned num_verts
);
119 vl_idct_prepare_stage2(struct vl_idct_buffer
*buffer
);