ilo: EOL drop unmaintained gallium drv from buildsys
[mesa.git] / src / gallium / drivers / ilo / core / ilo_state_sol.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2015 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_STATE_SOL_H
29 #define ILO_STATE_SOL_H
30
31 #include "genhw/genhw.h"
32
33 #include "ilo_core.h"
34 #include "ilo_dev.h"
35
36 /*
37 * From the Ivy Bridge PRM, volume 2 part 1, page 193:
38 *
39 * "Incoming topologies are tagged with a 2-bit StreamID."
40 */
41 #define ILO_STATE_SOL_MAX_STREAM_COUNT 4
42
43 /*
44 * From the Ivy Bridge PRM, volume 2 part 1, page 195:
45 *
46 * "Up to four SO buffers are supported."
47 */
48 #define ILO_STATE_SOL_MAX_BUFFER_COUNT 4
49
50 /*
51 * From the Ivy Bridge PRM, volume 2 part 1, page 201:
52 *
53 * "All 128 decls..."
54 */
55 #define ILO_STATE_SOL_MAX_DECL_COUNT 128
56
57 /**
58 * Output a vertex attribute.
59 */
60 struct ilo_state_sol_decl_info {
61 /* select an attribute from read ones */
62 uint8_t attr;
63 bool is_hole;
64
65 /* which components to write */
66 uint8_t component_base;
67 uint8_t component_count;
68
69 /* destination buffer */
70 uint8_t buffer;
71 };
72
73 struct ilo_state_sol_stream_info {
74 /* which VUE attributes to read */
75 uint8_t cv_vue_attr_count;
76 uint8_t vue_read_base;
77 uint8_t vue_read_count;
78
79 uint8_t decl_count;
80 const struct ilo_state_sol_decl_info *decls;
81 };
82
83 struct ilo_state_sol_info {
84 void *data;
85 size_t data_size;
86
87 bool sol_enable;
88 bool stats_enable;
89 enum gen_reorder_mode tristrip_reorder;
90
91 bool render_disable;
92 /* ignored when SOL is disabled */
93 uint8_t render_stream;
94
95 /* a buffer is disabled when its stride is zero */
96 uint16_t buffer_strides[ILO_STATE_SOL_MAX_BUFFER_COUNT];
97
98 struct ilo_state_sol_stream_info streams[ILO_STATE_SOL_MAX_STREAM_COUNT];
99 };
100
101 struct ilo_state_sol {
102 uint32_t streamout[2];
103 uint16_t strides[4];
104
105 uint32_t so_decl[2];
106 uint32_t (*decl)[2];
107 uint8_t decl_count;
108 };
109
110 struct ilo_vma;
111
112 struct ilo_state_sol_buffer_info {
113 const struct ilo_vma *vma;
114 uint32_t offset;
115 uint32_t size;
116
117 /* Gen8+ only; at least sizeof(uint32_t) bytes */
118 const struct ilo_vma *write_offset_vma;
119 uint32_t write_offset_offset;
120
121 bool write_offset_load;
122 bool write_offset_save;
123
124 bool write_offset_imm_enable;
125 uint32_t write_offset_imm;
126 };
127
128 struct ilo_state_sol_buffer {
129 uint32_t so_buf[5];
130
131 const struct ilo_vma *vma;
132 const struct ilo_vma *write_offset_vma;
133 };
134
135 static inline size_t
136 ilo_state_sol_data_size(const struct ilo_dev *dev, uint8_t max_decl_count)
137 {
138 const struct ilo_state_sol *so = NULL;
139 return (ilo_dev_gen(dev) >= ILO_GEN(7)) ?
140 sizeof(so->decl[0]) * max_decl_count : 0;
141 }
142
143 bool
144 ilo_state_sol_init(struct ilo_state_sol *sol,
145 const struct ilo_dev *dev,
146 const struct ilo_state_sol_info *info);
147
148 bool
149 ilo_state_sol_init_disabled(struct ilo_state_sol *sol,
150 const struct ilo_dev *dev,
151 bool render_disable);
152
153 uint32_t
154 ilo_state_sol_buffer_size(const struct ilo_dev *dev, uint32_t size,
155 uint32_t *alignment);
156
157 bool
158 ilo_state_sol_buffer_init(struct ilo_state_sol_buffer *sb,
159 const struct ilo_dev *dev,
160 const struct ilo_state_sol_buffer_info *info);
161
162 bool
163 ilo_state_sol_buffer_init_disabled(struct ilo_state_sol_buffer *sb,
164 const struct ilo_dev *dev);
165
166 #endif /* ILO_STATE_SOL_H */