1848b8605Smrg/**************************************************************************
2848b8605Smrg *
3848b8605Smrg * Copyright 2011 Christian König
4848b8605Smrg * All Rights Reserved.
5848b8605Smrg *
6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg * copy of this software and associated documentation files (the
8848b8605Smrg * "Software"), to deal in the Software without restriction, including
9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish,
10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to
11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to
12848b8605Smrg * the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice (including the
15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions
16848b8605Smrg * of the Software.
17848b8605Smrg *
18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25848b8605Smrg *
26848b8605Smrg **************************************************************************/
27848b8605Smrg
28848b8605Smrg#ifndef vl_zscan_h
29848b8605Smrg#define vl_zscan_h
30848b8605Smrg
31848b8605Smrg#include "pipe/p_compiler.h"
32848b8605Smrg#include "pipe/p_state.h"
33848b8605Smrg
34848b8605Smrg/*
35848b8605Smrg * shader based zscan and quantification
36848b8605Smrg * expect usage of vl_vertex_buffers as a todo list
37848b8605Smrg */
38848b8605Smrgstruct vl_zscan
39848b8605Smrg{
40848b8605Smrg   struct pipe_context *pipe;
41848b8605Smrg
42848b8605Smrg   unsigned buffer_width;
43848b8605Smrg   unsigned buffer_height;
44848b8605Smrg
45848b8605Smrg   unsigned num_channels;
46848b8605Smrg
47848b8605Smrg   unsigned blocks_per_line;
48848b8605Smrg   unsigned blocks_total;
49848b8605Smrg
50848b8605Smrg   void *rs_state;
51848b8605Smrg   void *blend;
52848b8605Smrg
53848b8605Smrg   void *samplers[3];
54848b8605Smrg
55848b8605Smrg   void *vs, *fs;
56848b8605Smrg};
57848b8605Smrg
58848b8605Smrgstruct vl_zscan_buffer
59848b8605Smrg{
60848b8605Smrg   struct pipe_viewport_state viewport;
61848b8605Smrg   struct pipe_framebuffer_state fb_state;
62848b8605Smrg
63848b8605Smrg   struct pipe_sampler_view *src, *layout, *quant;
64848b8605Smrg   struct pipe_surface *dst;
65848b8605Smrg};
66848b8605Smrg
67b8e80941Smrgextern const int vl_zscan_normal_16[];
68848b8605Smrgextern const int vl_zscan_linear[];
69848b8605Smrgextern const int vl_zscan_normal[];
70848b8605Smrgextern const int vl_zscan_alternate[];
71b8e80941Smrgextern const int vl_zscan_h265_up_right_diagonal_16[];
72b8e80941Smrgextern const int vl_zscan_h265_up_right_diagonal[];
73848b8605Smrg
74848b8605Smrgstruct pipe_sampler_view *
75848b8605Smrgvl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line);
76848b8605Smrg
77848b8605Smrgbool
78848b8605Smrgvl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe,
79848b8605Smrg              unsigned buffer_width, unsigned buffer_height,
80848b8605Smrg              unsigned blocks_per_line, unsigned blocks_total,
81848b8605Smrg              unsigned num_channels);
82848b8605Smrg
83848b8605Smrgvoid
84848b8605Smrgvl_zscan_cleanup(struct vl_zscan *zscan);
85848b8605Smrg
86848b8605Smrgbool
87848b8605Smrgvl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
88848b8605Smrg                     struct pipe_sampler_view *src, struct pipe_surface *dst);
89848b8605Smrg
90848b8605Smrgvoid
91848b8605Smrgvl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer);
92848b8605Smrg
93848b8605Smrgvoid
94848b8605Smrgvl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout);
95848b8605Smrg
96848b8605Smrgvoid
97848b8605Smrgvl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
98848b8605Smrg                      const uint8_t matrix[64], bool intra);
99848b8605Smrg
100848b8605Smrgvoid
101848b8605Smrgvl_zscan_render(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, unsigned num_instances);
102848b8605Smrg
103848b8605Smrg#endif
104