Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / auxiliary / vl / vl_mpeg12_mc_renderer.h
1 #ifndef vl_mpeg12_mc_renderer_h
2 #define vl_mpeg12_mc_renderer_h
3
4 #include <pipe/p_compiler.h>
5 #include <pipe/p_state.h>
6 #include <pipe/p_video_state.h>
7
8 struct pipe_context;
9 struct pipe_video_surface;
10 struct pipe_macroblock;
11
12 /* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
13 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
14 {
15 VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
16 VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
17 };
18
19 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
20 {
21 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL, /* Waste of memory bandwidth */
22 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, /* Can only do point-filtering when interpolating subsampled chroma channels */
23 VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE /* Needs conditional texel fetch! */
24 };
25
26 struct vl_mpeg12_mc_renderer
27 {
28 struct pipe_context *pipe;
29 unsigned picture_width;
30 unsigned picture_height;
31 enum pipe_video_chroma_format chroma_format;
32 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
33 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling;
34 bool pot_buffers;
35 unsigned macroblocks_per_batch;
36
37 struct pipe_viewport_state viewport;
38 struct pipe_constant_buffer vs_const_buf;
39 struct pipe_constant_buffer fs_const_buf;
40 struct pipe_framebuffer_state fb_state;
41 struct pipe_vertex_element vertex_elems[8];
42
43 union
44 {
45 void *all[5];
46 struct { void *y, *cb, *cr, *ref[2]; } individual;
47 } samplers;
48
49 void *i_vs, *p_vs[2], *b_vs[2];
50 void *i_fs, *p_fs[2], *b_fs[2];
51
52 union
53 {
54 struct pipe_texture *all[5];
55 struct { struct pipe_texture *y, *cb, *cr, *ref[2]; } individual;
56 } textures;
57
58 union
59 {
60 struct pipe_vertex_buffer all[3];
61 struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
62 } vertex_bufs;
63
64 struct pipe_texture *surface, *past, *future;
65 struct pipe_fence_handle **fence;
66 unsigned num_macroblocks;
67 struct pipe_mpeg12_macroblock *macroblock_buf;
68 struct pipe_transfer *tex_transfer[3];
69 short *texels[3];
70 struct { float x, y; } surface_tex_inv_size;
71 struct { float x, y; } zero_block[3];
72 };
73
74 bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
75 struct pipe_context *pipe,
76 unsigned picture_width,
77 unsigned picture_height,
78 enum pipe_video_chroma_format chroma_format,
79 enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
80 enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
81 bool pot_buffers);
82
83 void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
84
85 void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
86 struct pipe_texture *surface,
87 struct pipe_texture *past,
88 struct pipe_texture *future,
89 unsigned num_macroblocks,
90 struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
91 struct pipe_fence_handle **fence);
92
93 #endif /* vl_mpeg12_mc_renderer_h */