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)
60 struct pipe_vertex_buffer states
[PIPE_MAX_ATTRIBS
];
61 uint32_t enabled_mask
;
65 struct pipe_index_buffer state
;
69 /* VERTEX_ELEMENT_STATE */
74 struct ilo_ve_cso cso
[PIPE_MAX_ATTRIBS
];
77 unsigned instance_divisors
[PIPE_MAX_ATTRIBS
];
78 unsigned vb_mapping
[PIPE_MAX_ATTRIBS
];
83 struct pipe_stream_output_target
*states
[ILO_MAX_SO_BUFFERS
];
85 unsigned append_bitmask
;
90 struct ilo_viewport_cso
{
92 float m00
, m11
, m22
, m30
, m31
, m32
;
94 /* guardband in NDC space */
95 float min_gbx
, min_gby
, max_gbx
, max_gby
;
97 /* viewport in screen space */
98 float min_x
, min_y
, min_z
;
99 float max_x
, max_y
, max_z
;
102 struct ilo_viewport_state
{
103 struct ilo_viewport_cso cso
[ILO_MAX_VIEWPORTS
];
106 struct pipe_viewport_state viewport0
;
109 struct ilo_scissor_state
{
111 uint32_t payload
[ILO_MAX_VIEWPORTS
* 2];
114 struct ilo_rasterizer_clip
{
118 uint32_t can_enable_guardband
;
121 struct ilo_rasterizer_state
{
122 struct pipe_rasterizer_state state
;
124 struct ilo_rasterizer_clip clip
;
127 struct ilo_dsa_state
{
128 /* DEPTH_STENCIL_STATE */
131 struct pipe_alpha_state alpha
;
134 struct ilo_blend_cso
{
139 uint32_t dw_blend_dst_alpha_forced_one
;
142 uint32_t dw_alpha_mod
;
145 struct ilo_blend_state
{
146 struct ilo_blend_cso cso
[ILO_MAX_DRAW_BUFFERS
];
148 bool independent_blend_enable
;
150 bool alpha_to_coverage
;
153 struct ilo_sampler_cso
{
154 /* SAMPLER_STATE and SAMPLER_BORDER_COLOR_STATE */
155 uint32_t payload
[15];
158 uint32_t dw_filter_aniso
;
161 uint32_t dw_wrap_cube
;
169 struct ilo_sampler_state
{
170 const struct ilo_sampler_cso
*cso
[ILO_MAX_SAMPLERS
];
174 struct ilo_view_surface
{
180 struct ilo_view_cso
{
181 struct pipe_sampler_view base
;
183 struct ilo_view_surface surface
;
186 struct ilo_view_state
{
187 struct pipe_sampler_view
*states
[ILO_MAX_SAMPLER_VIEWS
];
191 struct ilo_cbuf_cso
{
192 struct pipe_resource
*resource
;
193 struct ilo_view_surface surface
;
196 struct ilo_cbuf_state
{
197 struct ilo_cbuf_cso cso
[ILO_MAX_CONST_BUFFERS
];
201 struct ilo_resource_state
{
202 struct pipe_surface
*states
[PIPE_MAX_SHADER_RESOURCES
];
206 struct ilo_surface_cso
{
207 struct pipe_surface base
;
211 struct ilo_view_surface rt
;
215 struct ilo_fb_state
{
216 struct pipe_framebuffer_state state
;
218 unsigned num_samples
;
221 struct ilo_global_binding
{
223 * XXX These should not be treated as real resources (and there could be
224 * thousands of them). They should be treated as regions in GLOBAL
225 * resource, which is the only real resource.
227 * That is, a resource here should instead be
229 * struct ilo_global_region {
230 * struct pipe_resource base;
235 * and it describes the region [offset, offset + size) in GLOBAL
238 struct pipe_resource
*resources
[PIPE_MAX_SHADER_RESOURCES
];
239 uint32_t *handles
[PIPE_MAX_SHADER_RESOURCES
];
244 ilo_gpe_init_ve(const struct ilo_dev_info
*dev
,
246 const struct pipe_vertex_element
*states
,
247 struct ilo_ve_state
*ve
);
250 ilo_gpe_set_viewport_cso(const struct ilo_dev_info
*dev
,
251 const struct pipe_viewport_state
*state
,
252 struct ilo_viewport_cso
*vp
);
255 ilo_gpe_set_scissor(const struct ilo_dev_info
*dev
,
258 const struct pipe_scissor_state
*states
,
259 struct ilo_scissor_state
*scissor
);
262 ilo_gpe_set_scissor_null(const struct ilo_dev_info
*dev
,
263 struct ilo_scissor_state
*scissor
);
266 ilo_gpe_init_rasterizer_clip(const struct ilo_dev_info
*dev
,
267 const struct pipe_rasterizer_state
*state
,
268 struct ilo_rasterizer_clip
*clip
);
271 ilo_gpe_init_rasterizer(const struct ilo_dev_info
*dev
,
272 const struct pipe_rasterizer_state
*state
,
273 struct ilo_rasterizer_state
*rasterizer
)
275 ilo_gpe_init_rasterizer_clip(dev
, state
, &rasterizer
->clip
);
279 ilo_gpe_init_dsa(const struct ilo_dev_info
*dev
,
280 const struct pipe_depth_stencil_alpha_state
*state
,
281 struct ilo_dsa_state
*dsa
);
284 ilo_gpe_init_blend(const struct ilo_dev_info
*dev
,
285 const struct pipe_blend_state
*state
,
286 struct ilo_blend_state
*blend
);
289 ilo_gpe_init_sampler_cso(const struct ilo_dev_info
*dev
,
290 const struct pipe_sampler_state
*state
,
291 struct ilo_sampler_cso
*sampler
);
294 ilo_gpe_init_view_surface_null_gen6(const struct ilo_dev_info
*dev
,
295 unsigned width
, unsigned height
,
296 unsigned depth
, unsigned level
,
297 struct ilo_view_surface
*surf
);
300 ilo_gpe_init_view_surface_for_buffer_gen6(const struct ilo_dev_info
*dev
,
301 const struct ilo_buffer
*buf
,
302 unsigned offset
, unsigned size
,
303 unsigned struct_size
,
304 enum pipe_format elem_format
,
305 bool is_rt
, bool render_cache_rw
,
306 struct ilo_view_surface
*surf
);
309 ilo_gpe_init_view_surface_for_texture_gen6(const struct ilo_dev_info
*dev
,
310 const struct ilo_texture
*tex
,
311 enum pipe_format format
,
312 unsigned first_level
,
314 unsigned first_layer
,
316 bool is_rt
, bool render_cache_rw
,
317 struct ilo_view_surface
*surf
);
320 ilo_gpe_init_view_surface_null_gen7(const struct ilo_dev_info
*dev
,
321 unsigned width
, unsigned height
,
322 unsigned depth
, unsigned level
,
323 struct ilo_view_surface
*surf
);
326 ilo_gpe_init_view_surface_for_buffer_gen7(const struct ilo_dev_info
*dev
,
327 const struct ilo_buffer
*buf
,
328 unsigned offset
, unsigned size
,
329 unsigned struct_size
,
330 enum pipe_format elem_format
,
331 bool is_rt
, bool render_cache_rw
,
332 struct ilo_view_surface
*surf
);
335 ilo_gpe_init_view_surface_for_texture_gen7(const struct ilo_dev_info
*dev
,
336 const struct ilo_texture
*tex
,
337 enum pipe_format format
,
338 unsigned first_level
,
340 unsigned first_layer
,
342 bool is_rt
, bool render_cache_rw
,
343 struct ilo_view_surface
*surf
);
346 ilo_gpe_init_view_surface_null(const struct ilo_dev_info
*dev
,
347 unsigned width
, unsigned height
,
348 unsigned depth
, unsigned level
,
349 struct ilo_view_surface
*surf
)
351 if (dev
->gen
>= ILO_GEN(7)) {
352 ilo_gpe_init_view_surface_null_gen7(dev
,
353 width
, height
, depth
, level
, surf
);
356 ilo_gpe_init_view_surface_null_gen6(dev
,
357 width
, height
, depth
, level
, surf
);
362 ilo_gpe_init_view_surface_for_buffer(const struct ilo_dev_info
*dev
,
363 const struct ilo_buffer
*buf
,
364 unsigned offset
, unsigned size
,
365 unsigned struct_size
,
366 enum pipe_format elem_format
,
367 bool is_rt
, bool render_cache_rw
,
368 struct ilo_view_surface
*surf
)
370 if (dev
->gen
>= ILO_GEN(7)) {
371 ilo_gpe_init_view_surface_for_buffer_gen7(dev
, buf
, offset
, size
,
372 struct_size
, elem_format
, is_rt
, render_cache_rw
, surf
);
375 ilo_gpe_init_view_surface_for_buffer_gen6(dev
, buf
, offset
, size
,
376 struct_size
, elem_format
, is_rt
, render_cache_rw
, surf
);
381 ilo_gpe_init_view_surface_for_texture(const struct ilo_dev_info
*dev
,
382 const struct ilo_texture
*tex
,
383 enum pipe_format format
,
384 unsigned first_level
,
386 unsigned first_layer
,
388 bool is_rt
, bool render_cache_rw
,
389 struct ilo_view_surface
*surf
)
391 if (dev
->gen
>= ILO_GEN(7)) {
392 ilo_gpe_init_view_surface_for_texture_gen7(dev
, tex
, format
,
393 first_level
, num_levels
, first_layer
, num_layers
,
394 is_rt
, render_cache_rw
, surf
);
397 ilo_gpe_init_view_surface_for_texture_gen6(dev
, tex
, format
,
398 first_level
, num_levels
, first_layer
, num_layers
,
399 is_rt
, render_cache_rw
, surf
);
403 #endif /* ILO_GPE_H */