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_VF_H
29 #define ILO_STATE_VF_H
31 #include "genhw/genhw.h"
37 * From the Sandy Bridge PRM, volume 2 part 1, page 93:
39 * "Up to 34 (DevSNB+) vertex elements are supported."
41 * "Up to 33 VBs are supported"
43 * Reserve two VEs and one VB for internal use.
45 #define ILO_STATE_VF_MAX_ELEMENT_COUNT (34 - 2)
46 #define ILO_STATE_VF_MAX_BUFFER_COUNT (33 - 1)
48 enum ilo_state_vf_dirty_bits
{
49 ILO_STATE_VF_3DSTATE_VERTEX_ELEMENTS
= (1 << 0),
50 ILO_STATE_VF_3DSTATE_VF_SGVS
= (1 << 1),
51 ILO_STATE_VF_3DSTATE_VF_INSTANCING
= (1 << 2),
52 ILO_STATE_VF_3DSTATE_VERTEX_BUFFERS
= (1 << 3),
53 ILO_STATE_VF_3DSTATE_VF
= (1 << 4),
54 ILO_STATE_VF_3DSTATE_INDEX_BUFFER
= (1 << 5),
58 * Fetch a 128-bit vertex attribute.
60 struct ilo_state_vf_element_info
{
62 uint16_t vertex_offset
;
63 enum gen_surface_format format
;
66 uint8_t component_count
;
69 /* must be the same for those share the same buffer before Gen8 */
70 bool instancing_enable
;
71 uint32_t instancing_step_rate
;
77 struct ilo_state_vf_params_info
{
78 enum gen_3dprim_type cv_topology
;
80 /* prepend an attribute of zeros */
83 /* prepend an attribute of VertexID and/or InstanceID */
84 bool prepend_vertexid
;
85 bool prepend_instanceid
;
87 bool last_element_edge_flag
;
89 enum gen_index_format cv_index_format
;
90 bool cut_index_enable
;
97 struct ilo_state_vf_info
{
101 const struct ilo_state_vf_element_info
*elements
;
102 uint8_t element_count
;
104 struct ilo_state_vf_params_info params
;
107 struct ilo_state_vf
{
108 uint32_t (*user_ve
)[2];
109 uint32_t (*user_instancing
)[2];
110 int8_t vb_to_first_elem
[ILO_STATE_VF_MAX_BUFFER_COUNT
];
111 uint8_t user_ve_count
;
113 bool edge_flag_supported
;
114 uint32_t last_user_ve
[2][2];
116 /* two VEs are reserved for internal use */
117 uint32_t internal_ve
[2][2];
118 uint8_t internal_ve_count
;
125 struct ilo_state_vf_delta
{
131 struct ilo_state_vertex_buffer_info
{
132 const struct ilo_buffer
*buf
;
138 /* doubles must be at 64-bit aligned addresses */
140 uint8_t cv_double_vertex_offset_mod_8
;
143 struct ilo_state_vertex_buffer
{
148 /* managed by users */
153 ilo_state_vf_data_size(const struct ilo_dev
*dev
, uint8_t element_count
)
155 const struct ilo_state_vf
*vf
= NULL
;
156 return (sizeof(vf
->user_ve
[0]) +
157 sizeof(vf
->user_instancing
[0])) * element_count
;
161 ilo_state_vf_init(struct ilo_state_vf
*vf
,
162 const struct ilo_dev
*dev
,
163 const struct ilo_state_vf_info
*info
);
166 ilo_state_vf_init_for_rectlist(struct ilo_state_vf
*vf
,
167 const struct ilo_dev
*dev
,
168 void *data
, size_t data_size
,
169 const struct ilo_state_vf_element_info
*elements
,
170 uint8_t element_count
);
173 ilo_state_vf_set_params(struct ilo_state_vf
*vf
,
174 const struct ilo_dev
*dev
,
175 const struct ilo_state_vf_params_info
*params
);
178 * Return the number of attributes in the VUE.
180 static inline uint8_t
181 ilo_state_vf_get_attr_count(const struct ilo_state_vf
*vf
)
183 return vf
->internal_ve_count
+ vf
->user_ve_count
;
187 ilo_state_vf_full_delta(const struct ilo_state_vf
*vf
,
188 const struct ilo_dev
*dev
,
189 struct ilo_state_vf_delta
*delta
);
192 ilo_state_vf_get_delta(const struct ilo_state_vf
*vf
,
193 const struct ilo_dev
*dev
,
194 const struct ilo_state_vf
*old
,
195 struct ilo_state_vf_delta
*delta
);
198 ilo_state_vertex_buffer_set_info(struct ilo_state_vertex_buffer
*vb
,
199 const struct ilo_dev
*dev
,
200 const struct ilo_state_vertex_buffer_info
*info
);
202 #endif /* ILO_STATE_VF_H */