vl_idct.h revision fcdf50f74befad8d89eb3f9cdfd88b82d1daa98c
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 33/* shader based inverse distinct cosinus transformation 34 * expect usage of vl_vertex_buffers as a todo list 35 */ 36struct vl_idct 37{ 38 struct pipe_context *pipe; 39 40 unsigned buffer_width; 41 unsigned buffer_height; 42 unsigned blocks_x, blocks_y; 43 44 void *rs_state; 45 46 void *samplers[2]; 47 48 void *matrix_vs, *transpose_vs; 49 void *matrix_fs, *transpose_fs; 50 51 struct pipe_sampler_view *matrix; 52}; 53 54/* a set of buffers to work with */ 55struct vl_idct_buffer 56{ 57 struct pipe_viewport_state viewport[2]; 58 struct pipe_framebuffer_state fb_state[2]; 59 60 union 61 { 62 struct pipe_sampler_view *all[4]; 63 struct pipe_sampler_view *stage[2][2]; 64 struct { 65 struct pipe_sampler_view *matrix, *source; 66 struct pipe_sampler_view *transpose, *intermediate; 67 } individual; 68 } sampler_views; 69}; 70 71/* upload the idct matrix, which can be shared by all idct instances of a pipe */ 72struct pipe_sampler_view *vl_idct_upload_matrix(struct pipe_context *pipe, float scale); 73 74/* init an idct instance */ 75bool vl_idct_init(struct vl_idct *idct, struct pipe_context *pipe, 76 unsigned buffer_width, unsigned buffer_height, 77 unsigned blocks_x, unsigned blocks_y, 78 struct pipe_sampler_view *matrix); 79 80/* destroy an idct instance */ 81void vl_idct_cleanup(struct vl_idct *idct); 82 83/* init a buffer assosiated with agiven idct instance */ 84bool vl_idct_init_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer, 85 struct pipe_sampler_view *source, struct pipe_surface *destination); 86 87/* cleanup a buffer of an idct instance */ 88void vl_idct_cleanup_buffer(struct vl_idct *idct, struct vl_idct_buffer *buffer); 89 90/* flush the buffer and start rendering, vertex buffers needs to be setup before calling this */ 91void vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer, unsigned num_verts); 92 93#endif 94