2 * Mesa 3-D graphics library
4 * Copyright (C) 2015 LunarG, Inc.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
25 * Chia-I Wu <olv@lunarg.com>
28 #ifndef ILO_STATE_SOL_H
29 #define ILO_STATE_SOL_H
31 #include "genhw/genhw.h"
37 * From the Ivy Bridge PRM, volume 2 part 1, page 193:
39 * "Incoming topologies are tagged with a 2-bit StreamID."
41 #define ILO_STATE_SOL_MAX_STREAM_COUNT 4
44 * From the Ivy Bridge PRM, volume 2 part 1, page 195:
46 * "Up to four SO buffers are supported."
48 #define ILO_STATE_SOL_MAX_BUFFER_COUNT 4
51 * From the Ivy Bridge PRM, volume 2 part 1, page 201:
55 #define ILO_STATE_SOL_MAX_DECL_COUNT 128
58 * Output a vertex attribute.
60 struct ilo_state_sol_decl_info
{
61 /* select an attribute from read ones */
65 /* which components to write */
66 uint8_t component_base
;
67 uint8_t component_count
;
69 /* destination buffer */
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
;
80 const struct ilo_state_sol_decl_info
*decls
;
83 struct ilo_state_sol_info
{
89 enum gen_reorder_mode tristrip_reorder
;
92 /* ignored when SOL is disabled */
93 uint8_t render_stream
;
95 /* a buffer is disabled when its stride is zero */
96 uint16_t buffer_strides
[ILO_STATE_SOL_MAX_BUFFER_COUNT
];
98 struct ilo_state_sol_stream_info streams
[ILO_STATE_SOL_MAX_STREAM_COUNT
];
101 struct ilo_state_sol
{
102 uint32_t streamout
[2];
112 struct ilo_state_sol_buffer_info
{
113 const struct ilo_vma
*vma
;
117 /* Gen8+ only; at least sizeof(uint32_t) bytes */
118 const struct ilo_vma
*write_offset_vma
;
119 uint32_t write_offset_offset
;
121 bool write_offset_load
;
122 bool write_offset_save
;
124 bool write_offset_imm_enable
;
125 uint32_t write_offset_imm
;
128 struct ilo_state_sol_buffer
{
131 const struct ilo_vma
*vma
;
132 const struct ilo_vma
*write_offset_vma
;
136 ilo_state_sol_data_size(const struct ilo_dev
*dev
, uint8_t max_decl_count
)
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;
144 ilo_state_sol_init(struct ilo_state_sol
*sol
,
145 const struct ilo_dev
*dev
,
146 const struct ilo_state_sol_info
*info
);
149 ilo_state_sol_init_disabled(struct ilo_state_sol
*sol
,
150 const struct ilo_dev
*dev
,
151 bool render_disable
);
154 ilo_state_sol_buffer_size(const struct ilo_dev
*dev
, uint32_t size
,
155 uint32_t *alignment
);
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
);
163 ilo_state_sol_buffer_init_disabled(struct ilo_state_sol_buffer
*sb
,
164 const struct ilo_dev
*dev
);
166 #endif /* ILO_STATE_SOL_H */