vl_vertex_buffers.h revision d3770d6229d95e9beb67358ae2b2c8824ed3ae58
1d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling/**************************************************************************
2d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling *
3d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * Copyright 2010 Christian König
4d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * All Rights Reserved.
5d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling *
6d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * Permission is hereby granted, free of charge, to any person obtaining a
7d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * copy of this software and associated documentation files (the
8d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * "Software"), to deal in the Software without restriction, including
9d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * without limitation the rights to use, copy, modify, merge, publish,
10d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * distribute, sub license, and/or sell copies of the Software, and to
11d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * permit persons to whom the Software is furnished to do so, subject to
12d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * the following conditions:
13d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling *
14d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * The above copyright notice and this permission notice (including the
15d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * next paragraph) shall be included in all copies or substantial portions
16d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * of the Software.
17d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling *
18d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling *
26d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling **************************************************************************/
27d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#ifndef vl_vertex_buffers_h
28d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#define vl_vertex_buffers_h
292d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
30d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#include <pipe/p_state.h>
31d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#include <pipe/p_video_state.h>
32d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling
33d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#include "vl_defines.h"
34d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling#include "vl_types.h"
35d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling
36d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling/* vertex buffers act as a todo list
372d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines * uploading all the usefull informations to video ram
38d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling * so a vertex shader can work with them
39d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling */
402d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
41d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling/* inputs to the vertex shaders */
42d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendlingenum VS_INPUT
43d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling{
44d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   VS_I_RECT = 0,
45d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   VS_I_VPOS = 1,
46d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling
47d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   VS_I_BLOCK_NUM = 2,
482d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
49d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   VS_I_MV_TOP = 2,
50d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   VS_I_MV_BOTTOM = 3,
51d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling
52d06f2fc03087e7cccda19bd550bf6fb3bc2f5ae7Bill Wendling   NUM_VS_INPUTS = 4
53};
54
55enum vl_mv_weight
56{
57   PIPE_VIDEO_MV_WEIGHT_MIN = 0,
58   PIPE_VIDEO_MV_WEIGHT_HALF = 128,
59   PIPE_VIDEO_MV_WEIGHT_MAX = 256
60};
61
62enum vl_field_select
63{
64   PIPE_VIDEO_FRAME = 0,
65   PIPE_VIDEO_TOP_FIELD = 1,
66   PIPE_VIDEO_BOTTOM_FIELD = 3,
67
68   /* TODO
69   PIPE_VIDEO_DUALPRIME
70   PIPE_VIDEO_16x8
71   */
72};
73
74struct vl_motionvector
75{
76   struct {
77      int16_t x, y;
78      int16_t field_select; /**< enum pipe_video_field_select */
79      int16_t weight;  /**< enum pipe_video_mv_weight  */
80   } top, bottom;
81};
82
83struct vl_ycbcr_block
84{
85   uint8_t x, y;
86   uint8_t intra;
87   uint8_t coding;
88};
89
90struct vl_vertex_buffer
91{
92   unsigned width, height;
93
94   struct {
95      struct pipe_resource  *resource;
96      struct pipe_transfer  *transfer;
97      struct vl_ycbcr_block *vertex_stream;
98   } ycbcr[VL_MAX_PLANES];
99
100   struct {
101      struct pipe_resource   *resource;
102      struct pipe_transfer   *transfer;
103      struct vl_motionvector *vertex_stream;
104   } mv[VL_MAX_REF_FRAMES];
105};
106
107struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe);
108
109struct pipe_vertex_buffer vl_vb_upload_pos(struct pipe_context *pipe, unsigned width, unsigned height);
110
111struct pipe_vertex_buffer vl_vb_upload_block_num(struct pipe_context *pipe, unsigned num_blocks);
112
113void *vl_vb_get_ves_ycbcr(struct pipe_context *pipe);
114
115void *vl_vb_get_ves_mv(struct pipe_context *pipe);
116
117bool vl_vb_init(struct vl_vertex_buffer *buffer,
118                struct pipe_context *pipe,
119                unsigned width, unsigned height);
120
121unsigned vl_vb_attributes_per_plock(struct vl_vertex_buffer *buffer);
122
123void vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
124
125struct pipe_vertex_buffer vl_vb_get_ycbcr(struct vl_vertex_buffer *buffer, int component);
126
127struct vl_ycbcr_block *vl_vb_get_ycbcr_stream(struct vl_vertex_buffer *buffer, int component);
128
129struct pipe_vertex_buffer vl_vb_get_mv(struct vl_vertex_buffer *buffer, int ref_frame);
130
131unsigned vl_vb_get_mv_stream_stride(struct vl_vertex_buffer *buffer);
132
133struct vl_motionvector *vl_vb_get_mv_stream(struct vl_vertex_buffer *buffer, int ref_frame);
134
135void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);
136
137void vl_vb_cleanup(struct vl_vertex_buffer *buffer);
138
139#endif /* vl_vertex_buffers_h */
140