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
= (1 << 2),
52 ILO_STATE_VF_3DSTATE_INDEX_BUFFER
= (1 << 3),
56 * Fetch a 128-bit vertex attribute.
58 struct ilo_state_vf_element_info
{
60 uint16_t vertex_offset
;
61 enum gen_surface_format format
;
64 uint8_t component_count
;
72 struct ilo_state_vf_params_info
{
73 enum gen_3dprim_type cv_topology
;
75 /* prepend an attribute of zeros */
78 /* prepend an attribute of VertexID and/or InstanceID */
79 bool prepend_vertexid
;
80 bool prepend_instanceid
;
82 bool last_element_edge_flag
;
84 enum gen_index_format cv_index_format
;
85 bool cut_index_enable
;
92 struct ilo_state_vf_info
{
96 const struct ilo_state_vf_element_info
*elements
;
97 uint8_t element_count
;
99 struct ilo_state_vf_params_info params
;
102 struct ilo_state_vf
{
103 /* two VEs are reserved for internal use */
104 uint32_t internal_ve
[2][2];
105 uint32_t (*user_ve
)[2];
106 uint8_t internal_ve_count
;
107 uint8_t user_ve_count
;
111 uint32_t last_user_ve
[2][2];
112 bool edge_flag_supported
;
117 struct ilo_state_vf_delta
{
122 ilo_state_vf_data_size(const struct ilo_dev
*dev
, uint8_t element_count
)
124 const struct ilo_state_vf
*vf
= NULL
;
125 return sizeof(vf
->user_ve
[0]) * element_count
;
129 ilo_state_vf_init(struct ilo_state_vf
*vf
,
130 const struct ilo_dev
*dev
,
131 const struct ilo_state_vf_info
*info
);
134 ilo_state_vf_init_for_rectlist(struct ilo_state_vf
*vf
,
135 const struct ilo_dev
*dev
,
136 void *data
, size_t data_size
,
137 const struct ilo_state_vf_element_info
*elements
,
138 uint8_t element_count
);
141 ilo_state_vf_set_params(struct ilo_state_vf
*vf
,
142 const struct ilo_dev
*dev
,
143 const struct ilo_state_vf_params_info
*params
);
146 * Return the number of attributes in the VUE.
148 static inline uint8_t
149 ilo_state_vf_get_attr_count(const struct ilo_state_vf
*vf
)
151 return vf
->internal_ve_count
+ vf
->user_ve_count
;
155 ilo_state_vf_full_delta(const struct ilo_state_vf
*vf
,
156 const struct ilo_dev
*dev
,
157 struct ilo_state_vf_delta
*delta
);
160 ilo_state_vf_get_delta(const struct ilo_state_vf
*vf
,
161 const struct ilo_dev
*dev
,
162 const struct ilo_state_vf
*old
,
163 struct ilo_state_vf_delta
*delta
);
165 #endif /* ILO_STATE_VF_H */