2 * Mesa 3-D graphics library
4 * Copyright (C) 2013 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>
31 #include "ilo_common.h"
36 #define ILO_MAX_DRAW_BUFFERS 8
37 #define ILO_MAX_CONST_BUFFERS (1 + 12)
38 #define ILO_MAX_SAMPLER_VIEWS 16
39 #define ILO_MAX_SAMPLERS 16
40 #define ILO_MAX_SO_BINDINGS 64
41 #define ILO_MAX_SO_BUFFERS 4
42 #define ILO_MAX_VIEWPORTS 1
44 #define ILO_MAX_VS_SURFACES (ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS)
45 #define ILO_VS_CONST_SURFACE(i) (i)
46 #define ILO_VS_TEXTURE_SURFACE(i) (ILO_MAX_CONST_BUFFERS + i)
48 #define ILO_MAX_GS_SURFACES (ILO_MAX_SO_BINDINGS)
49 #define ILO_GS_SO_SURFACE(i) (i)
51 #define ILO_MAX_WM_SURFACES (ILO_MAX_DRAW_BUFFERS + ILO_MAX_CONST_BUFFERS + ILO_MAX_SAMPLER_VIEWS)
52 #define ILO_WM_DRAW_SURFACE(i) (i)
53 #define ILO_WM_CONST_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + i)
54 #define ILO_WM_TEXTURE_SURFACE(i) (ILO_MAX_DRAW_BUFFERS + ILO_MAX_CONST_BUFFERS + i)
57 struct pipe_vertex_buffer states
[PIPE_MAX_ATTRIBS
];
58 uint32_t enabled_mask
;
62 struct pipe_index_buffer state
;
66 struct pipe_vertex_element states
[PIPE_MAX_ATTRIBS
];
71 struct pipe_stream_output_target
*states
[ILO_MAX_SO_BUFFERS
];
73 unsigned append_bitmask
;
78 struct ilo_viewport_cso
{
80 float m00
, m11
, m22
, m30
, m31
, m32
;
82 /* guardband in NDC space */
83 float min_gbx
, min_gby
, max_gbx
, max_gby
;
85 /* viewport in screen space */
86 float min_x
, min_y
, min_z
;
87 float max_x
, max_y
, max_z
;
90 struct ilo_viewport_state
{
91 struct ilo_viewport_cso cso
[ILO_MAX_VIEWPORTS
];
94 struct pipe_viewport_state viewport0
;
97 struct ilo_scissor_state
{
99 uint32_t payload
[ILO_MAX_VIEWPORTS
* 2];
102 struct ilo_rasterizer_state
{
103 struct pipe_rasterizer_state state
;
106 struct ilo_dsa_state
{
107 struct pipe_depth_stencil_alpha_state state
;
110 struct ilo_blend_cso
{
115 uint32_t dw_blend_dst_alpha_forced_one
;
118 uint32_t dw_alpha_mod
;
121 struct ilo_blend_state
{
122 struct ilo_blend_cso cso
[ILO_MAX_DRAW_BUFFERS
];
124 bool independent_blend_enable
;
126 bool alpha_to_coverage
;
129 struct ilo_sampler_cso
{
130 /* SAMPLER_STATE and SAMPLER_BORDER_COLOR_STATE */
131 uint32_t payload
[15];
134 uint32_t dw_filter_aniso
;
137 uint32_t dw_wrap_cube
;
145 struct ilo_sampler_state
{
146 const struct ilo_sampler_cso
*cso
[ILO_MAX_SAMPLERS
];
150 struct ilo_view_state
{
151 struct pipe_sampler_view
*states
[ILO_MAX_SAMPLER_VIEWS
];
155 struct ilo_cbuf_state
{
156 struct pipe_constant_buffer states
[ILO_MAX_CONST_BUFFERS
];
160 struct ilo_resource_state
{
161 struct pipe_surface
*states
[PIPE_MAX_SHADER_RESOURCES
];
165 struct ilo_fb_state
{
166 struct pipe_framebuffer_state state
;
168 unsigned num_samples
;
171 struct ilo_global_binding
{
173 * XXX These should not be treated as real resources (and there could be
174 * thousands of them). They should be treated as regions in GLOBAL
175 * resource, which is the only real resource.
177 * That is, a resource here should instead be
179 * struct ilo_global_region {
180 * struct pipe_resource base;
185 * and it describes the region [offset, offset + size) in GLOBAL
188 struct pipe_resource
*resources
[PIPE_MAX_SHADER_RESOURCES
];
189 uint32_t *handles
[PIPE_MAX_SHADER_RESOURCES
];
194 ilo_gpe_set_viewport_cso(const struct ilo_dev_info
*dev
,
195 const struct pipe_viewport_state
*state
,
196 struct ilo_viewport_cso
*vp
);
199 ilo_gpe_set_scissor(const struct ilo_dev_info
*dev
,
202 const struct pipe_scissor_state
*states
,
203 struct ilo_scissor_state
*scissor
);
206 ilo_gpe_set_scissor_null(const struct ilo_dev_info
*dev
,
207 struct ilo_scissor_state
*scissor
);
210 ilo_gpe_init_blend(const struct ilo_dev_info
*dev
,
211 const struct pipe_blend_state
*state
,
212 struct ilo_blend_state
*blend
);
215 ilo_gpe_init_sampler_cso(const struct ilo_dev_info
*dev
,
216 const struct pipe_sampler_state
*state
,
217 struct ilo_sampler_cso
*sampler
);
219 #endif /* ILO_GPE_H */