xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/vl/vl_zscan.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2011 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 VMWARE 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_zscan_h
29 #define vl_zscan_h
30 
31 #include "util/vl_zscan_data.h"
32 #include "util/compiler.h"
33 #include "pipe/p_state.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * shader based zscan and quantification
41  * expect usage of vl_vertex_buffers as a todo list
42  */
43 struct vl_zscan
44 {
45    struct pipe_context *pipe;
46 
47    unsigned buffer_width;
48    unsigned buffer_height;
49 
50    unsigned num_channels;
51 
52    unsigned blocks_per_line;
53    unsigned blocks_total;
54 
55    void *rs_state;
56    void *blend;
57 
58    void *samplers[3];
59 
60    void *vs, *fs;
61 };
62 
63 struct vl_zscan_buffer
64 {
65    struct pipe_viewport_state viewport;
66    struct pipe_framebuffer_state fb_state;
67 
68    struct pipe_sampler_view *src, *layout, *quant;
69    struct pipe_surface *dst;
70 };
71 
72 struct pipe_sampler_view *
73 vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks_per_line);
74 
75 bool
76 vl_zscan_init(struct vl_zscan *zscan, struct pipe_context *pipe,
77               unsigned buffer_width, unsigned buffer_height,
78               unsigned blocks_per_line, unsigned blocks_total,
79               unsigned num_channels);
80 
81 void
82 vl_zscan_cleanup(struct vl_zscan *zscan);
83 
84 bool
85 vl_zscan_init_buffer(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
86                      struct pipe_sampler_view *src, struct pipe_surface *dst);
87 
88 void
89 vl_zscan_cleanup_buffer(struct vl_zscan_buffer *buffer);
90 
91 void
92 vl_zscan_set_layout(struct vl_zscan_buffer *buffer, struct pipe_sampler_view *layout);
93 
94 void
95 vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
96                       const uint8_t matrix[64], bool intra);
97 
98 void
99 vl_zscan_render(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, unsigned num_instances);
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #endif
106