vl_vertex_buffers.h revision a6c76c8a90dc8995feed3c61b02dbd8408149036
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#ifndef vl_vertex_buffers_h
28#define vl_vertex_buffers_h
29
30#include <pipe/p_state.h>
31#include <pipe/p_video_state.h>
32
33#include "vl_defines.h"
34#include "vl_types.h"
35
36/* vertex buffers act as a todo list
37 * uploading all the usefull informations to video ram
38 * so a vertex shader can work with them
39 */
40
41/* inputs to the vertex shaders */
42enum VS_INPUT
43{
44   VS_I_RECT = 0,
45   VS_I_VPOS = 1,
46
47   VS_I_BLOCK_NUM = 2,
48
49   VS_I_MV_TOP = 2,
50   VS_I_MV_BOTTOM = 3,
51
52   NUM_VS_INPUTS = 4
53};
54
55struct vl_vertex_buffer
56{
57   unsigned width, height;
58
59   struct {
60      struct pipe_resource    *resource;
61      struct pipe_transfer    *transfer;
62      struct pipe_ycbcr_block *vertex_stream;
63   } ycbcr[VL_MAX_PLANES];
64
65   struct {
66      struct pipe_resource     *resource;
67      struct pipe_transfer     *transfer;
68      struct pipe_motionvector *vertex_stream;
69   } mv[VL_MAX_REF_FRAMES];
70};
71
72struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe);
73
74struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height);
75
76struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks);
77
78void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe);
79
80void *vl_vb_get_ves_mv(struct pipe_context *pipe);
81
82bool vl_vb_init(struct vl_vertex_buffer *buffer,
83                struct pipe_context *pipe,
84                unsigned width, unsigned height);
85
86unsigned vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer);
87
88void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
89
90struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component);
91
92struct pipe_ycbcr_block *vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component);
93
94struct pipe_vertex_buffer vl_vb_get_mv(struct vl_vertex_buffer *buffer, int ref_frame);
95
96unsigned vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer);
97
98struct pipe_motionvector *vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame);
99
100void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
101
102void vl_vb_cleanup(struct vl_vertex_buffer *buffer);
103
104#endif /* vl_vertex_buffers_h */
105