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>
28 #ifndef ILO_GPE_GEN7_H
29 #define ILO_GPE_GEN7_H
31 #include "ilo_common.h"
32 #include "ilo_gpe_gen6.h"
35 * Commands that GEN7 GPE could emit.
37 enum ilo_gpe_gen7_command
{
38 ILO_GPE_GEN7_STATE_BASE_ADDRESS
, /* (0x0, 0x1, 0x01) */
39 ILO_GPE_GEN7_STATE_SIP
, /* (0x0, 0x1, 0x02) */
40 ILO_GPE_GEN7_3DSTATE_VF_STATISTICS
, /* (0x1, 0x0, 0x0b) */
41 ILO_GPE_GEN7_PIPELINE_SELECT
, /* (0x1, 0x1, 0x04) */
42 ILO_GPE_GEN7_MEDIA_VFE_STATE
, /* (0x2, 0x0, 0x00) */
43 ILO_GPE_GEN7_MEDIA_CURBE_LOAD
, /* (0x2, 0x0, 0x01) */
44 ILO_GPE_GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD
, /* (0x2, 0x0, 0x02) */
45 ILO_GPE_GEN7_MEDIA_STATE_FLUSH
, /* (0x2, 0x0, 0x04) */
46 ILO_GPE_GEN7_GPGPU_WALKER
, /* (0x2, 0x1, 0x05) */
47 ILO_GPE_GEN7_3DSTATE_CLEAR_PARAMS
, /* (0x3, 0x0, 0x04) */
48 ILO_GPE_GEN7_3DSTATE_DEPTH_BUFFER
, /* (0x3, 0x0, 0x05) */
49 ILO_GPE_GEN7_3DSTATE_STENCIL_BUFFER
, /* (0x3, 0x0, 0x06) */
50 ILO_GPE_GEN7_3DSTATE_HIER_DEPTH_BUFFER
, /* (0x3, 0x0, 0x07) */
51 ILO_GPE_GEN7_3DSTATE_VERTEX_BUFFERS
, /* (0x3, 0x0, 0x08) */
52 ILO_GPE_GEN7_3DSTATE_VERTEX_ELEMENTS
, /* (0x3, 0x0, 0x09) */
53 ILO_GPE_GEN7_3DSTATE_INDEX_BUFFER
, /* (0x3, 0x0, 0x0a) */
54 ILO_GPE_GEN7_3DSTATE_CC_STATE_POINTERS
, /* (0x3, 0x0, 0x0e) */
55 ILO_GPE_GEN7_3DSTATE_SCISSOR_STATE_POINTERS
, /* (0x3, 0x0, 0x0f) */
56 ILO_GPE_GEN7_3DSTATE_VS
, /* (0x3, 0x0, 0x10) */
57 ILO_GPE_GEN7_3DSTATE_GS
, /* (0x3, 0x0, 0x11) */
58 ILO_GPE_GEN7_3DSTATE_CLIP
, /* (0x3, 0x0, 0x12) */
59 ILO_GPE_GEN7_3DSTATE_SF
, /* (0x3, 0x0, 0x13) */
60 ILO_GPE_GEN7_3DSTATE_WM
, /* (0x3, 0x0, 0x14) */
61 ILO_GPE_GEN7_3DSTATE_CONSTANT_VS
, /* (0x3, 0x0, 0x15) */
62 ILO_GPE_GEN7_3DSTATE_CONSTANT_GS
, /* (0x3, 0x0, 0x16) */
63 ILO_GPE_GEN7_3DSTATE_CONSTANT_PS
, /* (0x3, 0x0, 0x17) */
64 ILO_GPE_GEN7_3DSTATE_SAMPLE_MASK
, /* (0x3, 0x0, 0x18) */
65 ILO_GPE_GEN7_3DSTATE_CONSTANT_HS
, /* (0x3, 0x0, 0x19) */
66 ILO_GPE_GEN7_3DSTATE_CONSTANT_DS
, /* (0x3, 0x0, 0x1a) */
67 ILO_GPE_GEN7_3DSTATE_HS
, /* (0x3, 0x0, 0x1b) */
68 ILO_GPE_GEN7_3DSTATE_TE
, /* (0x3, 0x0, 0x1c) */
69 ILO_GPE_GEN7_3DSTATE_DS
, /* (0x3, 0x0, 0x1d) */
70 ILO_GPE_GEN7_3DSTATE_STREAMOUT
, /* (0x3, 0x0, 0x1e) */
71 ILO_GPE_GEN7_3DSTATE_SBE
, /* (0x3, 0x0, 0x1f) */
72 ILO_GPE_GEN7_3DSTATE_PS
, /* (0x3, 0x0, 0x20) */
73 ILO_GPE_GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP
, /* (0x3, 0x0, 0x21) */
74 ILO_GPE_GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC
, /* (0x3, 0x0, 0x23) */
75 ILO_GPE_GEN7_3DSTATE_BLEND_STATE_POINTERS
, /* (0x3, 0x0, 0x24) */
76 ILO_GPE_GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS
, /* (0x3, 0x0, 0x25) */
77 ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS
, /* (0x3, 0x0, 0x26) */
78 ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS
, /* (0x3, 0x0, 0x27) */
79 ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS
, /* (0x3, 0x0, 0x28) */
80 ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS
, /* (0x3, 0x0, 0x29) */
81 ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS
, /* (0x3, 0x0, 0x2a) */
82 ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS
, /* (0x3, 0x0, 0x2b) */
83 ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_HS
, /* (0x3, 0x0, 0x2c) */
84 ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_DS
, /* (0x3, 0x0, 0x2d) */
85 ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS
, /* (0x3, 0x0, 0x2e) */
86 ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS
, /* (0x3, 0x0, 0x2f) */
87 ILO_GPE_GEN7_3DSTATE_URB_VS
, /* (0x3, 0x0, 0x30) */
88 ILO_GPE_GEN7_3DSTATE_URB_HS
, /* (0x3, 0x0, 0x31) */
89 ILO_GPE_GEN7_3DSTATE_URB_DS
, /* (0x3, 0x0, 0x32) */
90 ILO_GPE_GEN7_3DSTATE_URB_GS
, /* (0x3, 0x0, 0x33) */
91 ILO_GPE_GEN7_3DSTATE_DRAWING_RECTANGLE
, /* (0x3, 0x1, 0x00) */
92 ILO_GPE_GEN7_3DSTATE_POLY_STIPPLE_OFFSET
, /* (0x3, 0x1, 0x06) */
93 ILO_GPE_GEN7_3DSTATE_POLY_STIPPLE_PATTERN
, /* (0x3, 0x1, 0x07) */
94 ILO_GPE_GEN7_3DSTATE_LINE_STIPPLE
, /* (0x3, 0x1, 0x08) */
95 ILO_GPE_GEN7_3DSTATE_AA_LINE_PARAMETERS
, /* (0x3, 0x1, 0x0a) */
96 ILO_GPE_GEN7_3DSTATE_MULTISAMPLE
, /* (0x3, 0x1, 0x0d) */
97 ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS
, /* (0x3, 0x1, 0x12) */
98 ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_HS
, /* (0x3, 0x1, 0x13) */
99 ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_DS
, /* (0x3, 0x1, 0x14) */
100 ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_GS
, /* (0x3, 0x1, 0x15) */
101 ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS
, /* (0x3, 0x1, 0x16) */
102 ILO_GPE_GEN7_3DSTATE_SO_DECL_LIST
, /* (0x3, 0x1, 0x17) */
103 ILO_GPE_GEN7_3DSTATE_SO_BUFFER
, /* (0x3, 0x1, 0x18) */
104 ILO_GPE_GEN7_PIPE_CONTROL
, /* (0x3, 0x2, 0x00) */
105 ILO_GPE_GEN7_3DPRIMITIVE
, /* (0x3, 0x3, 0x00) */
107 ILO_GPE_GEN7_COMMAND_COUNT
,
111 * Indirect states that GEN7 GPE could emit.
113 enum ilo_gpe_gen7_state
{
114 ILO_GPE_GEN7_INTERFACE_DESCRIPTOR_DATA
,
115 ILO_GPE_GEN7_SF_CLIP_VIEWPORT
,
116 ILO_GPE_GEN7_CC_VIEWPORT
,
117 ILO_GPE_GEN7_COLOR_CALC_STATE
,
118 ILO_GPE_GEN7_BLEND_STATE
,
119 ILO_GPE_GEN7_DEPTH_STENCIL_STATE
,
120 ILO_GPE_GEN7_SCISSOR_RECT
,
121 ILO_GPE_GEN7_BINDING_TABLE_STATE
,
122 ILO_GPE_GEN7_SURFACE_STATE
,
123 ILO_GPE_GEN7_SAMPLER_STATE
,
124 ILO_GPE_GEN7_SAMPLER_BORDER_COLOR_STATE
,
125 ILO_GPE_GEN7_PUSH_CONSTANT_BUFFER
,
127 ILO_GPE_GEN7_STATE_COUNT
,
130 typedef ilo_gpe_gen6_STATE_BASE_ADDRESS ilo_gpe_gen7_STATE_BASE_ADDRESS
;
131 typedef ilo_gpe_gen6_STATE_SIP ilo_gpe_gen7_STATE_SIP
;
132 typedef ilo_gpe_gen6_3DSTATE_VF_STATISTICS ilo_gpe_gen7_3DSTATE_VF_STATISTICS
;
133 typedef ilo_gpe_gen6_PIPELINE_SELECT ilo_gpe_gen7_PIPELINE_SELECT
;
134 typedef ilo_gpe_gen6_MEDIA_VFE_STATE ilo_gpe_gen7_MEDIA_VFE_STATE
;
135 typedef ilo_gpe_gen6_MEDIA_CURBE_LOAD ilo_gpe_gen7_MEDIA_CURBE_LOAD
;
136 typedef ilo_gpe_gen6_MEDIA_INTERFACE_DESCRIPTOR_LOAD ilo_gpe_gen7_MEDIA_INTERFACE_DESCRIPTOR_LOAD
;
137 typedef ilo_gpe_gen6_MEDIA_STATE_FLUSH ilo_gpe_gen7_MEDIA_STATE_FLUSH
;
140 (*ilo_gpe_gen7_GPGPU_WALKER
)(const struct ilo_dev_info
*dev
,
143 typedef ilo_gpe_gen6_3DSTATE_CLEAR_PARAMS ilo_gpe_gen7_3DSTATE_CLEAR_PARAMS
;
144 typedef ilo_gpe_gen6_3DSTATE_DEPTH_BUFFER ilo_gpe_gen7_3DSTATE_DEPTH_BUFFER
;
145 typedef ilo_gpe_gen6_3DSTATE_STENCIL_BUFFER ilo_gpe_gen7_3DSTATE_STENCIL_BUFFER
;
146 typedef ilo_gpe_gen6_3DSTATE_HIER_DEPTH_BUFFER ilo_gpe_gen7_3DSTATE_HIER_DEPTH_BUFFER
;
147 typedef ilo_gpe_gen6_3DSTATE_VERTEX_BUFFERS ilo_gpe_gen7_3DSTATE_VERTEX_BUFFERS
;
148 typedef ilo_gpe_gen6_3DSTATE_VERTEX_ELEMENTS ilo_gpe_gen7_3DSTATE_VERTEX_ELEMENTS
;
149 typedef ilo_gpe_gen6_3DSTATE_INDEX_BUFFER ilo_gpe_gen7_3DSTATE_INDEX_BUFFER
;
152 (*ilo_gpe_gen7_3DSTATE_CC_STATE_POINTERS
)(const struct ilo_dev_info
*dev
,
153 uint32_t color_calc_state
,
156 typedef ilo_gpe_gen6_3DSTATE_SCISSOR_STATE_POINTERS ilo_gpe_gen7_3DSTATE_SCISSOR_STATE_POINTERS
;
157 typedef ilo_gpe_gen6_3DSTATE_VS ilo_gpe_gen7_3DSTATE_VS
;
160 (*ilo_gpe_gen7_3DSTATE_GS
)(const struct ilo_dev_info
*dev
,
161 const struct ilo_shader_state
*gs
,
165 typedef ilo_gpe_gen6_3DSTATE_CLIP ilo_gpe_gen7_3DSTATE_CLIP
;
168 (*ilo_gpe_gen7_3DSTATE_SF
)(const struct ilo_dev_info
*dev
,
169 const struct ilo_rasterizer_state
*rasterizer
,
170 const struct pipe_surface
*zs_surf
,
174 (*ilo_gpe_gen7_3DSTATE_WM
)(const struct ilo_dev_info
*dev
,
175 const struct ilo_shader_state
*fs
,
176 const struct ilo_rasterizer_state
*rasterizer
,
180 typedef ilo_gpe_gen6_3DSTATE_CONSTANT_VS ilo_gpe_gen7_3DSTATE_CONSTANT_VS
;
181 typedef ilo_gpe_gen6_3DSTATE_CONSTANT_GS ilo_gpe_gen7_3DSTATE_CONSTANT_GS
;
182 typedef ilo_gpe_gen6_3DSTATE_CONSTANT_PS ilo_gpe_gen7_3DSTATE_CONSTANT_PS
;
185 (*ilo_gpe_gen7_3DSTATE_SAMPLE_MASK
)(const struct ilo_dev_info
*dev
,
186 unsigned sample_mask
,
191 (*ilo_gpe_gen7_3DSTATE_CONSTANT_HS
)(const struct ilo_dev_info
*dev
,
192 const uint32_t *bufs
, const int *sizes
,
197 (*ilo_gpe_gen7_3DSTATE_CONSTANT_DS
)(const struct ilo_dev_info
*dev
,
198 const uint32_t *bufs
, const int *sizes
,
203 (*ilo_gpe_gen7_3DSTATE_HS
)(const struct ilo_dev_info
*dev
,
204 const struct ilo_shader_state
*hs
,
209 (*ilo_gpe_gen7_3DSTATE_TE
)(const struct ilo_dev_info
*dev
,
213 (*ilo_gpe_gen7_3DSTATE_DS
)(const struct ilo_dev_info
*dev
,
214 const struct ilo_shader_state
*ds
,
219 (*ilo_gpe_gen7_3DSTATE_STREAMOUT
)(const struct ilo_dev_info
*dev
,
220 unsigned buffer_mask
,
221 int vertex_attrib_count
,
222 bool rasterizer_discard
,
226 (*ilo_gpe_gen7_3DSTATE_SBE
)(const struct ilo_dev_info
*dev
,
227 const struct ilo_rasterizer_state
*rasterizer
,
228 const struct ilo_shader_state
*fs
,
229 const struct ilo_shader_state
*last_sh
,
233 (*ilo_gpe_gen7_3DSTATE_PS
)(const struct ilo_dev_info
*dev
,
234 const struct ilo_shader_state
*fs
,
235 int num_samplers
, bool dual_blend
,
239 (*ilo_gpe_gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP
)(const struct ilo_dev_info
*dev
,
244 (*ilo_gpe_gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC
)(const struct ilo_dev_info
*dev
,
249 (*ilo_gpe_gen7_3DSTATE_BLEND_STATE_POINTERS
)(const struct ilo_dev_info
*dev
,
254 (*ilo_gpe_gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS
)(const struct ilo_dev_info
*dev
,
255 uint32_t depth_stencil
,
259 (*ilo_gpe_gen7_3DSTATE_BINDING_TABLE_POINTERS_VS
)(const struct ilo_dev_info
*dev
,
260 uint32_t binding_table
,
264 (*ilo_gpe_gen7_3DSTATE_BINDING_TABLE_POINTERS_HS
)(const struct ilo_dev_info
*dev
,
265 uint32_t binding_table
,
269 (*ilo_gpe_gen7_3DSTATE_BINDING_TABLE_POINTERS_DS
)(const struct ilo_dev_info
*dev
,
270 uint32_t binding_table
,
274 (*ilo_gpe_gen7_3DSTATE_BINDING_TABLE_POINTERS_GS
)(const struct ilo_dev_info
*dev
,
275 uint32_t binding_table
,
279 (*ilo_gpe_gen7_3DSTATE_BINDING_TABLE_POINTERS_PS
)(const struct ilo_dev_info
*dev
,
280 uint32_t binding_table
,
284 (*ilo_gpe_gen7_3DSTATE_SAMPLER_STATE_POINTERS_VS
)(const struct ilo_dev_info
*dev
,
285 uint32_t sampler_state
,
289 (*ilo_gpe_gen7_3DSTATE_SAMPLER_STATE_POINTERS_HS
)(const struct ilo_dev_info
*dev
,
290 uint32_t sampler_state
,
294 (*ilo_gpe_gen7_3DSTATE_SAMPLER_STATE_POINTERS_DS
)(const struct ilo_dev_info
*dev
,
295 uint32_t sampler_state
,
299 (*ilo_gpe_gen7_3DSTATE_SAMPLER_STATE_POINTERS_GS
)(const struct ilo_dev_info
*dev
,
300 uint32_t sampler_state
,
304 (*ilo_gpe_gen7_3DSTATE_SAMPLER_STATE_POINTERS_PS
)(const struct ilo_dev_info
*dev
,
305 uint32_t sampler_state
,
309 (*ilo_gpe_gen7_3DSTATE_URB_VS
)(const struct ilo_dev_info
*dev
,
310 int offset
, int size
, int entry_size
,
314 (*ilo_gpe_gen7_3DSTATE_URB_HS
)(const struct ilo_dev_info
*dev
,
315 int offset
, int size
, int entry_size
,
319 (*ilo_gpe_gen7_3DSTATE_URB_DS
)(const struct ilo_dev_info
*dev
,
320 int offset
, int size
, int entry_size
,
324 (*ilo_gpe_gen7_3DSTATE_URB_GS
)(const struct ilo_dev_info
*dev
,
325 int offset
, int size
, int entry_size
,
328 typedef ilo_gpe_gen6_3DSTATE_DRAWING_RECTANGLE ilo_gpe_gen7_3DSTATE_DRAWING_RECTANGLE
;
329 typedef ilo_gpe_gen6_3DSTATE_POLY_STIPPLE_OFFSET ilo_gpe_gen7_3DSTATE_POLY_STIPPLE_OFFSET
;
330 typedef ilo_gpe_gen6_3DSTATE_POLY_STIPPLE_PATTERN ilo_gpe_gen7_3DSTATE_POLY_STIPPLE_PATTERN
;
331 typedef ilo_gpe_gen6_3DSTATE_LINE_STIPPLE ilo_gpe_gen7_3DSTATE_LINE_STIPPLE
;
332 typedef ilo_gpe_gen6_3DSTATE_AA_LINE_PARAMETERS ilo_gpe_gen7_3DSTATE_AA_LINE_PARAMETERS
;
333 typedef ilo_gpe_gen6_3DSTATE_MULTISAMPLE ilo_gpe_gen7_3DSTATE_MULTISAMPLE
;
336 (*ilo_gpe_gen7_3DSTATE_PUSH_CONSTANT_ALLOC_VS
)(const struct ilo_dev_info
*dev
,
337 int offset
, int size
,
341 (*ilo_gpe_gen7_3DSTATE_PUSH_CONSTANT_ALLOC_HS
)(const struct ilo_dev_info
*dev
,
342 int offset
, int size
,
346 (*ilo_gpe_gen7_3DSTATE_PUSH_CONSTANT_ALLOC_DS
)(const struct ilo_dev_info
*dev
,
347 int offset
, int size
,
351 (*ilo_gpe_gen7_3DSTATE_PUSH_CONSTANT_ALLOC_GS
)(const struct ilo_dev_info
*dev
,
352 int offset
, int size
,
356 (*ilo_gpe_gen7_3DSTATE_PUSH_CONSTANT_ALLOC_PS
)(const struct ilo_dev_info
*dev
,
357 int offset
, int size
,
361 (*ilo_gpe_gen7_3DSTATE_SO_DECL_LIST
)(const struct ilo_dev_info
*dev
,
362 const struct pipe_stream_output_info
*so_info
,
366 (*ilo_gpe_gen7_3DSTATE_SO_BUFFER
)(const struct ilo_dev_info
*dev
,
367 int index
, int base
, int stride
,
368 const struct pipe_stream_output_target
*so_target
,
371 typedef ilo_gpe_gen6_PIPE_CONTROL ilo_gpe_gen7_PIPE_CONTROL
;
372 typedef ilo_gpe_gen6_3DPRIMITIVE ilo_gpe_gen7_3DPRIMITIVE
;
373 typedef ilo_gpe_gen6_INTERFACE_DESCRIPTOR_DATA ilo_gpe_gen7_INTERFACE_DESCRIPTOR_DATA
;
376 (*ilo_gpe_gen7_SF_CLIP_VIEWPORT
)(const struct ilo_dev_info
*dev
,
377 const struct ilo_viewport_cso
*viewports
,
378 unsigned num_viewports
,
381 typedef ilo_gpe_gen6_CC_VIEWPORT ilo_gpe_gen7_CC_VIEWPORT
;
382 typedef ilo_gpe_gen6_COLOR_CALC_STATE ilo_gpe_gen7_COLOR_CALC_STATE
;
383 typedef ilo_gpe_gen6_BLEND_STATE ilo_gpe_gen7_BLEND_STATE
;
384 typedef ilo_gpe_gen6_DEPTH_STENCIL_STATE ilo_gpe_gen7_DEPTH_STENCIL_STATE
;
385 typedef ilo_gpe_gen6_SCISSOR_RECT ilo_gpe_gen7_SCISSOR_RECT
;
386 typedef ilo_gpe_gen6_BINDING_TABLE_STATE ilo_gpe_gen7_BINDING_TABLE_STATE
;
387 typedef ilo_gpe_gen6_SURFACE_STATE ilo_gpe_gen7_SURFACE_STATE
;
388 typedef ilo_gpe_gen6_SAMPLER_STATE ilo_gpe_gen7_SAMPLER_STATE
;
389 typedef ilo_gpe_gen6_SAMPLER_BORDER_COLOR_STATE ilo_gpe_gen7_SAMPLER_BORDER_COLOR_STATE
;
390 typedef ilo_gpe_gen6_push_constant_buffer ilo_gpe_gen7_push_constant_buffer
;
393 * GEN7 graphics processing engine
397 struct ilo_gpe_gen7
{
398 int (*estimate_command_size
)(const struct ilo_dev_info
*dev
,
399 enum ilo_gpe_gen7_command cmd
,
402 int (*estimate_state_size
)(const struct ilo_dev_info
*dev
,
403 enum ilo_gpe_gen7_state state
,
406 #define GEN7_EMIT(name) ilo_gpe_gen7_ ## name emit_ ## name
407 GEN7_EMIT(STATE_BASE_ADDRESS
);
408 GEN7_EMIT(STATE_SIP
);
409 GEN7_EMIT(3DSTATE_VF_STATISTICS
);
410 GEN7_EMIT(PIPELINE_SELECT
);
411 GEN7_EMIT(MEDIA_VFE_STATE
);
412 GEN7_EMIT(MEDIA_CURBE_LOAD
);
413 GEN7_EMIT(MEDIA_INTERFACE_DESCRIPTOR_LOAD
);
414 GEN7_EMIT(MEDIA_STATE_FLUSH
);
415 GEN7_EMIT(GPGPU_WALKER
);
416 GEN7_EMIT(3DSTATE_CLEAR_PARAMS
);
417 GEN7_EMIT(3DSTATE_DEPTH_BUFFER
);
418 GEN7_EMIT(3DSTATE_STENCIL_BUFFER
);
419 GEN7_EMIT(3DSTATE_HIER_DEPTH_BUFFER
);
420 GEN7_EMIT(3DSTATE_VERTEX_BUFFERS
);
421 GEN7_EMIT(3DSTATE_VERTEX_ELEMENTS
);
422 GEN7_EMIT(3DSTATE_INDEX_BUFFER
);
423 GEN7_EMIT(3DSTATE_CC_STATE_POINTERS
);
424 GEN7_EMIT(3DSTATE_SCISSOR_STATE_POINTERS
);
425 GEN7_EMIT(3DSTATE_VS
);
426 GEN7_EMIT(3DSTATE_GS
);
427 GEN7_EMIT(3DSTATE_CLIP
);
428 GEN7_EMIT(3DSTATE_SF
);
429 GEN7_EMIT(3DSTATE_WM
);
430 GEN7_EMIT(3DSTATE_CONSTANT_VS
);
431 GEN7_EMIT(3DSTATE_CONSTANT_GS
);
432 GEN7_EMIT(3DSTATE_CONSTANT_PS
);
433 GEN7_EMIT(3DSTATE_SAMPLE_MASK
);
434 GEN7_EMIT(3DSTATE_CONSTANT_HS
);
435 GEN7_EMIT(3DSTATE_CONSTANT_DS
);
436 GEN7_EMIT(3DSTATE_HS
);
437 GEN7_EMIT(3DSTATE_TE
);
438 GEN7_EMIT(3DSTATE_DS
);
439 GEN7_EMIT(3DSTATE_STREAMOUT
);
440 GEN7_EMIT(3DSTATE_SBE
);
441 GEN7_EMIT(3DSTATE_PS
);
442 GEN7_EMIT(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP
);
443 GEN7_EMIT(3DSTATE_VIEWPORT_STATE_POINTERS_CC
);
444 GEN7_EMIT(3DSTATE_BLEND_STATE_POINTERS
);
445 GEN7_EMIT(3DSTATE_DEPTH_STENCIL_STATE_POINTERS
);
446 GEN7_EMIT(3DSTATE_BINDING_TABLE_POINTERS_VS
);
447 GEN7_EMIT(3DSTATE_BINDING_TABLE_POINTERS_HS
);
448 GEN7_EMIT(3DSTATE_BINDING_TABLE_POINTERS_DS
);
449 GEN7_EMIT(3DSTATE_BINDING_TABLE_POINTERS_GS
);
450 GEN7_EMIT(3DSTATE_BINDING_TABLE_POINTERS_PS
);
451 GEN7_EMIT(3DSTATE_SAMPLER_STATE_POINTERS_VS
);
452 GEN7_EMIT(3DSTATE_SAMPLER_STATE_POINTERS_HS
);
453 GEN7_EMIT(3DSTATE_SAMPLER_STATE_POINTERS_DS
);
454 GEN7_EMIT(3DSTATE_SAMPLER_STATE_POINTERS_GS
);
455 GEN7_EMIT(3DSTATE_SAMPLER_STATE_POINTERS_PS
);
456 GEN7_EMIT(3DSTATE_URB_VS
);
457 GEN7_EMIT(3DSTATE_URB_HS
);
458 GEN7_EMIT(3DSTATE_URB_DS
);
459 GEN7_EMIT(3DSTATE_URB_GS
);
460 GEN7_EMIT(3DSTATE_DRAWING_RECTANGLE
);
461 GEN7_EMIT(3DSTATE_POLY_STIPPLE_OFFSET
);
462 GEN7_EMIT(3DSTATE_POLY_STIPPLE_PATTERN
);
463 GEN7_EMIT(3DSTATE_LINE_STIPPLE
);
464 GEN7_EMIT(3DSTATE_AA_LINE_PARAMETERS
);
465 GEN7_EMIT(3DSTATE_MULTISAMPLE
);
466 GEN7_EMIT(3DSTATE_PUSH_CONSTANT_ALLOC_VS
);
467 GEN7_EMIT(3DSTATE_PUSH_CONSTANT_ALLOC_HS
);
468 GEN7_EMIT(3DSTATE_PUSH_CONSTANT_ALLOC_DS
);
469 GEN7_EMIT(3DSTATE_PUSH_CONSTANT_ALLOC_GS
);
470 GEN7_EMIT(3DSTATE_PUSH_CONSTANT_ALLOC_PS
);
471 GEN7_EMIT(3DSTATE_SO_DECL_LIST
);
472 GEN7_EMIT(3DSTATE_SO_BUFFER
);
473 GEN7_EMIT(PIPE_CONTROL
);
474 GEN7_EMIT(3DPRIMITIVE
);
475 GEN7_EMIT(INTERFACE_DESCRIPTOR_DATA
);
476 GEN7_EMIT(SF_CLIP_VIEWPORT
);
477 GEN7_EMIT(CC_VIEWPORT
);
478 GEN7_EMIT(COLOR_CALC_STATE
);
479 GEN7_EMIT(BLEND_STATE
);
480 GEN7_EMIT(DEPTH_STENCIL_STATE
);
481 GEN7_EMIT(SCISSOR_RECT
);
482 GEN7_EMIT(BINDING_TABLE_STATE
);
483 GEN7_EMIT(SURFACE_STATE
);
484 GEN7_EMIT(SAMPLER_STATE
);
485 GEN7_EMIT(SAMPLER_BORDER_COLOR_STATE
);
486 GEN7_EMIT(push_constant_buffer
);
490 const struct ilo_gpe_gen7
*
491 ilo_gpe_gen7_get(void);
494 gen7_emit_GPGPU_WALKER(const struct ilo_dev_info
*dev
,
497 assert(!"GPGPU_WALKER unsupported");
501 gen7_emit_3DSTATE_CLEAR_PARAMS(const struct ilo_dev_info
*dev
,
505 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x04);
506 const uint8_t cmd_len
= 3;
508 ILO_GPE_VALID_GEN(dev
, 7, 7);
510 ilo_cp_begin(cp
, cmd_len
);
511 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
512 ilo_cp_write(cp
, clear_val
);
518 gen7_emit_3dstate_pointer(const struct ilo_dev_info
*dev
,
519 int subop
, uint32_t pointer
,
522 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, subop
);
523 const uint8_t cmd_len
= 2;
525 ILO_GPE_VALID_GEN(dev
, 7, 7);
527 ilo_cp_begin(cp
, cmd_len
);
528 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
529 ilo_cp_write(cp
, pointer
);
534 gen7_emit_3DSTATE_CC_STATE_POINTERS(const struct ilo_dev_info
*dev
,
535 uint32_t color_calc_state
,
538 gen7_emit_3dstate_pointer(dev
, 0x0e, color_calc_state
, cp
);
542 gen7_emit_3DSTATE_GS(const struct ilo_dev_info
*dev
,
543 const struct ilo_shader_state
*gs
,
547 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x11);
548 const uint8_t cmd_len
= 7;
549 const struct ilo_shader_cso
*cso
;
550 uint32_t dw2
, dw4
, dw5
;
552 ILO_GPE_VALID_GEN(dev
, 7, 7);
555 ilo_cp_begin(cp
, cmd_len
);
556 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
561 ilo_cp_write(cp
, GEN6_GS_STATISTICS_ENABLE
);
567 cso
= ilo_shader_get_kernel_cso(gs
);
568 dw2
= cso
->payload
[0];
569 dw4
= cso
->payload
[1];
570 dw5
= cso
->payload
[2];
572 dw2
|= ((num_samplers
+ 3) / 4) << GEN6_GS_SAMPLER_COUNT_SHIFT
;
574 ilo_cp_begin(cp
, cmd_len
);
575 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
576 ilo_cp_write(cp
, ilo_shader_get_kernel_offset(gs
));
577 ilo_cp_write(cp
, dw2
);
578 ilo_cp_write(cp
, 0); /* scratch */
579 ilo_cp_write(cp
, dw4
);
580 ilo_cp_write(cp
, dw5
);
586 gen7_emit_3DSTATE_SF(const struct ilo_dev_info
*dev
,
587 const struct ilo_rasterizer_state
*rasterizer
,
588 const struct pipe_surface
*zs_surf
,
591 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x13);
592 const uint8_t cmd_len
= 7;
593 const int num_samples
= 1;
596 ILO_GPE_VALID_GEN(dev
, 7, 7);
598 ilo_gpe_gen6_fill_3dstate_sf_raster(dev
,
599 rasterizer
, num_samples
,
600 (zs_surf
) ? zs_surf
->format
: PIPE_FORMAT_NONE
,
601 payload
, Elements(payload
));
603 ilo_cp_begin(cp
, cmd_len
);
604 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
605 ilo_cp_write_multi(cp
, payload
, 6);
610 gen7_emit_3DSTATE_WM(const struct ilo_dev_info
*dev
,
611 const struct ilo_shader_state
*fs
,
612 const struct ilo_rasterizer_state
*rasterizer
,
616 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x14);
617 const uint8_t cmd_len
= 3;
618 const int num_samples
= 1;
621 ILO_GPE_VALID_GEN(dev
, 7, 7);
623 /* see ilo_gpe_init_rasterizer_wm() */
624 dw1
= rasterizer
->wm
.payload
[0];
625 dw2
= rasterizer
->wm
.payload
[1];
627 dw1
|= GEN7_WM_STATISTICS_ENABLE
;
630 dw1
|= GEN7_WM_DEPTH_CLEAR
;
631 dw1
|= GEN7_WM_DEPTH_RESOLVE
;
632 dw1
|= GEN7_WM_HIERARCHICAL_DEPTH_RESOLVE
;
636 const struct ilo_shader_cso
*fs_cso
= ilo_shader_get_kernel_cso(fs
);
638 dw1
|= fs_cso
->payload
[3];
642 dw1
|= GEN7_WM_DISPATCH_ENABLE
|
646 if (num_samples
> 1) {
647 dw1
|= rasterizer
->wm
.dw_msaa_rast
;
648 dw2
|= rasterizer
->wm
.dw_msaa_disp
;
651 ilo_cp_begin(cp
, cmd_len
);
652 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
653 ilo_cp_write(cp
, dw1
);
654 ilo_cp_write(cp
, dw2
);
659 gen7_emit_3dstate_constant(const struct ilo_dev_info
*dev
,
661 const uint32_t *bufs
, const int *sizes
,
665 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, subop
);
666 const uint8_t cmd_len
= 7;
668 int total_read_length
, i
;
670 ILO_GPE_VALID_GEN(dev
, 7, 7);
672 /* VS, HS, DS, GS, and PS variants */
673 assert(subop
>= 0x15 && subop
<= 0x1a && subop
!= 0x18);
675 assert(num_bufs
<= 4);
680 total_read_length
= 0;
681 for (i
= 0; i
< 4; i
++) {
685 * From the Ivy Bridge PRM, volume 2 part 1, page 112:
687 * "Constant buffers must be enabled in order from Constant Buffer 0
688 * to Constant Buffer 3 within this command. For example, it is
689 * not allowed to enable Constant Buffer 1 by programming a
690 * non-zero value in the VS Constant Buffer 1 Read Length without a
691 * non-zero value in VS Constant Buffer 0 Read Length."
693 if (i
>= num_bufs
|| !sizes
[i
]) {
695 assert(i
>= num_bufs
|| !sizes
[i
]);
701 /* read lengths are in 256-bit units */
702 read_len
= (sizes
[i
] + 31) / 32;
703 /* the lower 5 bits are used for memory object control state */
704 assert(bufs
[i
] % 32 == 0);
706 dw
[i
/ 2] |= read_len
<< ((i
% 2) ? 16 : 0);
709 total_read_length
+= read_len
;
713 * From the Ivy Bridge PRM, volume 2 part 1, page 113:
715 * "The sum of all four read length fields must be less than or equal
718 assert(total_read_length
<= 64);
720 ilo_cp_begin(cp
, cmd_len
);
721 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
722 ilo_cp_write_multi(cp
, dw
, 6);
727 gen7_emit_3DSTATE_CONSTANT_VS(const struct ilo_dev_info
*dev
,
728 const uint32_t *bufs
, const int *sizes
,
732 gen7_emit_3dstate_constant(dev
, 0x15, bufs
, sizes
, num_bufs
, cp
);
736 gen7_emit_3DSTATE_CONSTANT_GS(const struct ilo_dev_info
*dev
,
737 const uint32_t *bufs
, const int *sizes
,
741 gen7_emit_3dstate_constant(dev
, 0x16, bufs
, sizes
, num_bufs
, cp
);
745 gen7_emit_3DSTATE_CONSTANT_PS(const struct ilo_dev_info
*dev
,
746 const uint32_t *bufs
, const int *sizes
,
750 gen7_emit_3dstate_constant(dev
, 0x17, bufs
, sizes
, num_bufs
, cp
);
754 gen7_emit_3DSTATE_SAMPLE_MASK(const struct ilo_dev_info
*dev
,
755 unsigned sample_mask
,
759 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x18);
760 const uint8_t cmd_len
= 2;
761 const unsigned valid_mask
= ((1 << num_samples
) - 1) | 0x1;
763 ILO_GPE_VALID_GEN(dev
, 7, 7);
766 * From the Ivy Bridge PRM, volume 2 part 1, page 294:
768 * "If Number of Multisamples is NUMSAMPLES_1, bits 7:1 of this field
769 * (Sample Mask) must be zero.
771 * If Number of Multisamples is NUMSAMPLES_4, bits 7:4 of this field
774 sample_mask
&= valid_mask
;
776 ilo_cp_begin(cp
, cmd_len
);
777 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
778 ilo_cp_write(cp
, sample_mask
);
783 gen7_emit_3DSTATE_CONSTANT_HS(const struct ilo_dev_info
*dev
,
784 const uint32_t *bufs
, const int *sizes
,
788 gen7_emit_3dstate_constant(dev
, 0x19, bufs
, sizes
, num_bufs
, cp
);
792 gen7_emit_3DSTATE_CONSTANT_DS(const struct ilo_dev_info
*dev
,
793 const uint32_t *bufs
, const int *sizes
,
797 gen7_emit_3dstate_constant(dev
, 0x1a, bufs
, sizes
, num_bufs
, cp
);
801 gen7_emit_3DSTATE_HS(const struct ilo_dev_info
*dev
,
802 const struct ilo_shader_state
*hs
,
806 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x1b);
807 const uint8_t cmd_len
= 7;
809 ILO_GPE_VALID_GEN(dev
, 7, 7);
813 ilo_cp_begin(cp
, cmd_len
);
814 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
825 gen7_emit_3DSTATE_TE(const struct ilo_dev_info
*dev
,
828 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x1c);
829 const uint8_t cmd_len
= 4;
831 ILO_GPE_VALID_GEN(dev
, 7, 7);
833 ilo_cp_begin(cp
, cmd_len
);
834 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
842 gen7_emit_3DSTATE_DS(const struct ilo_dev_info
*dev
,
843 const struct ilo_shader_state
*ds
,
847 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x1d);
848 const uint8_t cmd_len
= 6;
850 ILO_GPE_VALID_GEN(dev
, 7, 7);
854 ilo_cp_begin(cp
, cmd_len
);
855 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
866 gen7_emit_3DSTATE_STREAMOUT(const struct ilo_dev_info
*dev
,
867 unsigned buffer_mask
,
868 int vertex_attrib_count
,
869 bool rasterizer_discard
,
872 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x1e);
873 const uint8_t cmd_len
= 3;
874 const bool enable
= (buffer_mask
!= 0);
878 ILO_GPE_VALID_GEN(dev
, 7, 7);
881 dw1
= 0 << SO_RENDER_STREAM_SELECT_SHIFT
;
882 if (rasterizer_discard
)
883 dw1
|= SO_RENDERING_DISABLE
;
887 ilo_cp_begin(cp
, cmd_len
);
888 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
889 ilo_cp_write(cp
, dw1
);
890 ilo_cp_write(cp
, dw2
);
895 read_len
= (vertex_attrib_count
+ 1) / 2;
899 dw1
= SO_FUNCTION_ENABLE
|
900 0 << SO_RENDER_STREAM_SELECT_SHIFT
|
901 SO_STATISTICS_ENABLE
|
904 if (rasterizer_discard
)
905 dw1
|= SO_RENDERING_DISABLE
;
909 dw1
|= SO_REORDER_TRAILING
;
911 dw2
= 0 << SO_STREAM_3_VERTEX_READ_OFFSET_SHIFT
|
912 0 << SO_STREAM_3_VERTEX_READ_LENGTH_SHIFT
|
913 0 << SO_STREAM_2_VERTEX_READ_OFFSET_SHIFT
|
914 0 << SO_STREAM_2_VERTEX_READ_LENGTH_SHIFT
|
915 0 << SO_STREAM_1_VERTEX_READ_OFFSET_SHIFT
|
916 0 << SO_STREAM_1_VERTEX_READ_LENGTH_SHIFT
|
917 0 << SO_STREAM_0_VERTEX_READ_OFFSET_SHIFT
|
918 (read_len
- 1) << SO_STREAM_0_VERTEX_READ_LENGTH_SHIFT
;
920 ilo_cp_begin(cp
, cmd_len
);
921 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
922 ilo_cp_write(cp
, dw1
);
923 ilo_cp_write(cp
, dw2
);
928 gen7_emit_3DSTATE_SBE(const struct ilo_dev_info
*dev
,
929 const struct ilo_rasterizer_state
*rasterizer
,
930 const struct ilo_shader_state
*fs
,
931 const struct ilo_shader_state
*last_sh
,
934 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x1f);
935 const uint8_t cmd_len
= 14;
938 ILO_GPE_VALID_GEN(dev
, 7, 7);
940 ilo_gpe_gen6_fill_3dstate_sf_sbe(dev
, rasterizer
,
941 fs
, last_sh
, dw
, Elements(dw
));
943 ilo_cp_begin(cp
, cmd_len
);
944 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
945 ilo_cp_write_multi(cp
, dw
, 13);
950 gen7_emit_3DSTATE_PS(const struct ilo_dev_info
*dev
,
951 const struct ilo_shader_state
*fs
,
952 int num_samplers
, bool dual_blend
,
955 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, 0x20);
956 const uint8_t cmd_len
= 8;
957 const struct ilo_shader_cso
*cso
;
958 uint32_t dw2
, dw4
, dw5
;
960 ILO_GPE_VALID_GEN(dev
, 7, 7);
963 /* see brwCreateContext() */
964 const int max_threads
= (dev
->gt
== 2) ? 172 : 48;
966 ilo_cp_begin(cp
, cmd_len
);
967 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
971 /* GPU hangs if none of the dispatch enable bits is set */
972 ilo_cp_write(cp
, (max_threads
- 1) << IVB_PS_MAX_THREADS_SHIFT
|
973 GEN7_PS_8_DISPATCH_ENABLE
);
982 cso
= ilo_shader_get_kernel_cso(fs
);
983 dw2
= cso
->payload
[0];
984 dw4
= cso
->payload
[1];
985 dw5
= cso
->payload
[2];
987 dw2
|= (num_samplers
+ 3) / 4 << GEN7_PS_SAMPLER_COUNT_SHIFT
;
990 dw4
|= GEN7_PS_DUAL_SOURCE_BLEND_ENABLE
;
992 ilo_cp_begin(cp
, cmd_len
);
993 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
994 ilo_cp_write(cp
, ilo_shader_get_kernel_offset(fs
));
995 ilo_cp_write(cp
, dw2
);
996 ilo_cp_write(cp
, 0); /* scratch */
997 ilo_cp_write(cp
, dw4
);
998 ilo_cp_write(cp
, dw5
);
999 ilo_cp_write(cp
, 0); /* kernel 1 */
1000 ilo_cp_write(cp
, 0); /* kernel 2 */
1005 gen7_emit_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(const struct ilo_dev_info
*dev
,
1006 uint32_t sf_clip_viewport
,
1009 gen7_emit_3dstate_pointer(dev
, 0x21, sf_clip_viewport
, cp
);
1013 gen7_emit_3DSTATE_VIEWPORT_STATE_POINTERS_CC(const struct ilo_dev_info
*dev
,
1014 uint32_t cc_viewport
,
1017 gen7_emit_3dstate_pointer(dev
, 0x23, cc_viewport
, cp
);
1021 gen7_emit_3DSTATE_BLEND_STATE_POINTERS(const struct ilo_dev_info
*dev
,
1022 uint32_t blend_state
,
1025 gen7_emit_3dstate_pointer(dev
, 0x24, blend_state
, cp
);
1029 gen7_emit_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(const struct ilo_dev_info
*dev
,
1030 uint32_t depth_stencil_state
,
1033 gen7_emit_3dstate_pointer(dev
, 0x25, depth_stencil_state
, cp
);
1037 gen7_emit_3DSTATE_BINDING_TABLE_POINTERS_VS(const struct ilo_dev_info
*dev
,
1038 uint32_t binding_table
,
1041 gen7_emit_3dstate_pointer(dev
, 0x26, binding_table
, cp
);
1045 gen7_emit_3DSTATE_BINDING_TABLE_POINTERS_HS(const struct ilo_dev_info
*dev
,
1046 uint32_t binding_table
,
1049 gen7_emit_3dstate_pointer(dev
, 0x27, binding_table
, cp
);
1053 gen7_emit_3DSTATE_BINDING_TABLE_POINTERS_DS(const struct ilo_dev_info
*dev
,
1054 uint32_t binding_table
,
1057 gen7_emit_3dstate_pointer(dev
, 0x28, binding_table
, cp
);
1061 gen7_emit_3DSTATE_BINDING_TABLE_POINTERS_GS(const struct ilo_dev_info
*dev
,
1062 uint32_t binding_table
,
1065 gen7_emit_3dstate_pointer(dev
, 0x29, binding_table
, cp
);
1069 gen7_emit_3DSTATE_BINDING_TABLE_POINTERS_PS(const struct ilo_dev_info
*dev
,
1070 uint32_t binding_table
,
1073 gen7_emit_3dstate_pointer(dev
, 0x2a, binding_table
, cp
);
1077 gen7_emit_3DSTATE_SAMPLER_STATE_POINTERS_VS(const struct ilo_dev_info
*dev
,
1078 uint32_t sampler_state
,
1081 gen7_emit_3dstate_pointer(dev
, 0x2b, sampler_state
, cp
);
1085 gen7_emit_3DSTATE_SAMPLER_STATE_POINTERS_HS(const struct ilo_dev_info
*dev
,
1086 uint32_t sampler_state
,
1089 gen7_emit_3dstate_pointer(dev
, 0x2c, sampler_state
, cp
);
1093 gen7_emit_3DSTATE_SAMPLER_STATE_POINTERS_DS(const struct ilo_dev_info
*dev
,
1094 uint32_t sampler_state
,
1097 gen7_emit_3dstate_pointer(dev
, 0x2d, sampler_state
, cp
);
1101 gen7_emit_3DSTATE_SAMPLER_STATE_POINTERS_GS(const struct ilo_dev_info
*dev
,
1102 uint32_t sampler_state
,
1105 gen7_emit_3dstate_pointer(dev
, 0x2e, sampler_state
, cp
);
1109 gen7_emit_3DSTATE_SAMPLER_STATE_POINTERS_PS(const struct ilo_dev_info
*dev
,
1110 uint32_t sampler_state
,
1113 gen7_emit_3dstate_pointer(dev
, 0x2f, sampler_state
, cp
);
1117 gen7_emit_3dstate_urb(const struct ilo_dev_info
*dev
,
1118 int subop
, int offset
, int size
,
1122 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x0, subop
);
1123 const uint8_t cmd_len
= 2;
1124 const int row_size
= 64; /* 512 bits */
1125 int alloc_size
, num_entries
, min_entries
, max_entries
;
1127 ILO_GPE_VALID_GEN(dev
, 7, 7);
1129 /* VS, HS, DS, and GS variants */
1130 assert(subop
>= 0x30 && subop
<= 0x33);
1132 /* in multiples of 8KB */
1133 assert(offset
% 8192 == 0);
1136 /* in multiple of 512-bit rows */
1137 alloc_size
= (entry_size
+ row_size
- 1) / row_size
;
1142 * From the Ivy Bridge PRM, volume 2 part 1, page 34:
1144 * "VS URB Entry Allocation Size equal to 4(5 512-bit URB rows) may
1145 * cause performance to decrease due to banking in the URB. Element
1146 * sizes of 16 to 20 should be programmed with six 512-bit URB rows."
1148 if (subop
== 0x30 && alloc_size
== 5)
1151 /* in multiples of 8 */
1152 num_entries
= (size
/ row_size
/ alloc_size
) & ~7;
1155 case 0x30: /* 3DSTATE_URB_VS */
1157 max_entries
= (dev
->gt
== 2) ? 704 : 512;
1159 assert(num_entries
>= min_entries
);
1160 if (num_entries
> max_entries
)
1161 num_entries
= max_entries
;
1163 case 0x31: /* 3DSTATE_URB_HS */
1164 max_entries
= (dev
->gt
== 2) ? 64 : 32;
1165 if (num_entries
> max_entries
)
1166 num_entries
= max_entries
;
1168 case 0x32: /* 3DSTATE_URB_DS */
1170 assert(num_entries
>= 138);
1172 case 0x33: /* 3DSTATE_URB_GS */
1173 max_entries
= (dev
->gt
== 2) ? 320 : 192;
1174 if (num_entries
> max_entries
)
1175 num_entries
= max_entries
;
1181 ilo_cp_begin(cp
, cmd_len
);
1182 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1183 ilo_cp_write(cp
, offset
<< GEN7_URB_STARTING_ADDRESS_SHIFT
|
1184 (alloc_size
- 1) << GEN7_URB_ENTRY_SIZE_SHIFT
|
1190 gen7_emit_3DSTATE_URB_VS(const struct ilo_dev_info
*dev
,
1191 int offset
, int size
, int entry_size
,
1194 gen7_emit_3dstate_urb(dev
, 0x30, offset
, size
, entry_size
, cp
);
1198 gen7_emit_3DSTATE_URB_HS(const struct ilo_dev_info
*dev
,
1199 int offset
, int size
, int entry_size
,
1202 gen7_emit_3dstate_urb(dev
, 0x31, offset
, size
, entry_size
, cp
);
1206 gen7_emit_3DSTATE_URB_DS(const struct ilo_dev_info
*dev
,
1207 int offset
, int size
, int entry_size
,
1210 gen7_emit_3dstate_urb(dev
, 0x32, offset
, size
, entry_size
, cp
);
1214 gen7_emit_3DSTATE_URB_GS(const struct ilo_dev_info
*dev
,
1215 int offset
, int size
, int entry_size
,
1218 gen7_emit_3dstate_urb(dev
, 0x33, offset
, size
, entry_size
, cp
);
1222 gen7_emit_3dstate_push_constant_alloc(const struct ilo_dev_info
*dev
,
1223 int subop
, int offset
, int size
,
1226 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x1, subop
);
1227 const uint8_t cmd_len
= 2;
1230 ILO_GPE_VALID_GEN(dev
, 7, 7);
1232 /* VS, HS, DS, GS, and PS variants */
1233 assert(subop
>= 0x12 && subop
<= 0x16);
1236 * From the Ivy Bridge PRM, volume 2 part 1, page 68:
1238 * "(A table that says the maximum size of each constant buffer is
1241 * From the Ivy Bridge PRM, volume 2 part 1, page 115:
1243 * "The sum of the Constant Buffer Offset and the Constant Buffer Size
1244 * may not exceed the maximum value of the Constant Buffer Size."
1246 * Thus, the valid range of buffer end is [0KB, 16KB].
1248 end
= (offset
+ size
) / 1024;
1250 assert(!"invalid constant buffer end");
1254 /* the valid range of buffer offset is [0KB, 15KB] */
1255 offset
= (offset
+ 1023) / 1024;
1257 assert(!"invalid constant buffer offset");
1266 /* the valid range of buffer size is [0KB, 15KB] */
1267 size
= end
- offset
;
1269 assert(!"invalid constant buffer size");
1273 ilo_cp_begin(cp
, cmd_len
);
1274 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1275 ilo_cp_write(cp
, offset
<< GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT
|
1281 gen7_emit_3DSTATE_PUSH_CONSTANT_ALLOC_VS(const struct ilo_dev_info
*dev
,
1282 int offset
, int size
,
1285 gen7_emit_3dstate_push_constant_alloc(dev
, 0x12, offset
, size
, cp
);
1289 gen7_emit_3DSTATE_PUSH_CONSTANT_ALLOC_HS(const struct ilo_dev_info
*dev
,
1290 int offset
, int size
,
1293 gen7_emit_3dstate_push_constant_alloc(dev
, 0x13, offset
, size
, cp
);
1297 gen7_emit_3DSTATE_PUSH_CONSTANT_ALLOC_DS(const struct ilo_dev_info
*dev
,
1298 int offset
, int size
,
1301 gen7_emit_3dstate_push_constant_alloc(dev
, 0x14, offset
, size
, cp
);
1305 gen7_emit_3DSTATE_PUSH_CONSTANT_ALLOC_GS(const struct ilo_dev_info
*dev
,
1306 int offset
, int size
,
1309 gen7_emit_3dstate_push_constant_alloc(dev
, 0x15, offset
, size
, cp
);
1313 gen7_emit_3DSTATE_PUSH_CONSTANT_ALLOC_PS(const struct ilo_dev_info
*dev
,
1314 int offset
, int size
,
1317 gen7_emit_3dstate_push_constant_alloc(dev
, 0x16, offset
, size
, cp
);
1321 gen7_emit_3DSTATE_SO_DECL_LIST(const struct ilo_dev_info
*dev
,
1322 const struct pipe_stream_output_info
*so_info
,
1325 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x1, 0x17);
1327 int buffer_selects
, num_entries
, i
;
1328 uint16_t so_decls
[128];
1330 ILO_GPE_VALID_GEN(dev
, 7, 7);
1336 int buffer_offsets
[PIPE_MAX_SO_BUFFERS
];
1338 memset(buffer_offsets
, 0, sizeof(buffer_offsets
));
1340 for (i
= 0; i
< so_info
->num_outputs
; i
++) {
1341 unsigned decl
, buf
, reg
, mask
;
1343 buf
= so_info
->output
[i
].output_buffer
;
1345 /* pad with holes */
1346 assert(buffer_offsets
[buf
] <= so_info
->output
[i
].dst_offset
);
1347 while (buffer_offsets
[buf
] < so_info
->output
[i
].dst_offset
) {
1350 num_dwords
= so_info
->output
[i
].dst_offset
- buffer_offsets
[buf
];
1354 decl
= buf
<< SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT
|
1356 ((1 << num_dwords
) - 1) << SO_DECL_COMPONENT_MASK_SHIFT
;
1358 so_decls
[num_entries
++] = decl
;
1359 buffer_offsets
[buf
] += num_dwords
;
1362 reg
= so_info
->output
[i
].register_index
;
1363 mask
= ((1 << so_info
->output
[i
].num_components
) - 1) <<
1364 so_info
->output
[i
].start_component
;
1366 decl
= buf
<< SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT
|
1367 reg
<< SO_DECL_REGISTER_INDEX_SHIFT
|
1368 mask
<< SO_DECL_COMPONENT_MASK_SHIFT
;
1370 so_decls
[num_entries
++] = decl
;
1371 buffer_selects
|= 1 << buf
;
1372 buffer_offsets
[buf
] += so_info
->output
[i
].num_components
;
1377 * From the Ivy Bridge PRM, volume 2 part 1, page 201:
1379 * "Errata: All 128 decls for all four streams must be included
1380 * whenever this command is issued. The "Num Entries [n]" fields still
1381 * contain the actual numbers of valid decls."
1383 * Also note that "DWord Length" has 9 bits for this command, and the type
1384 * of cmd_len is thus uint16_t.
1386 cmd_len
= 2 * 128 + 3;
1388 ilo_cp_begin(cp
, cmd_len
);
1389 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1390 ilo_cp_write(cp
, 0 << SO_STREAM_TO_BUFFER_SELECTS_3_SHIFT
|
1391 0 << SO_STREAM_TO_BUFFER_SELECTS_2_SHIFT
|
1392 0 << SO_STREAM_TO_BUFFER_SELECTS_1_SHIFT
|
1393 buffer_selects
<< SO_STREAM_TO_BUFFER_SELECTS_0_SHIFT
);
1394 ilo_cp_write(cp
, 0 << SO_NUM_ENTRIES_3_SHIFT
|
1395 0 << SO_NUM_ENTRIES_2_SHIFT
|
1396 0 << SO_NUM_ENTRIES_1_SHIFT
|
1397 num_entries
<< SO_NUM_ENTRIES_0_SHIFT
);
1399 for (i
= 0; i
< num_entries
; i
++) {
1400 ilo_cp_write(cp
, so_decls
[i
]);
1401 ilo_cp_write(cp
, 0);
1403 for (; i
< 128; i
++) {
1404 ilo_cp_write(cp
, 0);
1405 ilo_cp_write(cp
, 0);
1412 gen7_emit_3DSTATE_SO_BUFFER(const struct ilo_dev_info
*dev
,
1413 int index
, int base
, int stride
,
1414 const struct pipe_stream_output_target
*so_target
,
1417 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x1, 0x18);
1418 const uint8_t cmd_len
= 4;
1419 struct ilo_buffer
*buf
;
1422 ILO_GPE_VALID_GEN(dev
, 7, 7);
1424 if (!so_target
|| !so_target
->buffer
) {
1425 ilo_cp_begin(cp
, cmd_len
);
1426 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1427 ilo_cp_write(cp
, index
<< SO_BUFFER_INDEX_SHIFT
);
1428 ilo_cp_write(cp
, 0);
1429 ilo_cp_write(cp
, 0);
1434 buf
= ilo_buffer(so_target
->buffer
);
1437 assert(stride
% 4 == 0 && base
% 4 == 0);
1438 assert(so_target
->buffer_offset
% 4 == 0);
1441 base
= (base
+ so_target
->buffer_offset
) & ~3;
1442 end
= (base
+ so_target
->buffer_size
) & ~3;
1444 ilo_cp_begin(cp
, cmd_len
);
1445 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1446 ilo_cp_write(cp
, index
<< SO_BUFFER_INDEX_SHIFT
|
1448 ilo_cp_write_bo(cp
, base
, buf
->bo
, INTEL_DOMAIN_RENDER
, INTEL_DOMAIN_RENDER
);
1449 ilo_cp_write_bo(cp
, end
, buf
->bo
, INTEL_DOMAIN_RENDER
, INTEL_DOMAIN_RENDER
);
1454 gen7_emit_3DPRIMITIVE(const struct ilo_dev_info
*dev
,
1455 const struct pipe_draw_info
*info
,
1456 const struct ilo_ib_state
*ib
,
1460 const uint32_t cmd
= ILO_GPE_CMD(0x3, 0x3, 0x00);
1461 const uint8_t cmd_len
= 7;
1462 const int prim
= (rectlist
) ?
1463 _3DPRIM_RECTLIST
: ilo_gpe_gen6_translate_pipe_prim(info
->mode
);
1464 const int vb_access
= (info
->indexed
) ?
1465 GEN7_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM
:
1466 GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL
;
1467 const uint32_t vb_start
= info
->start
+
1468 ((info
->indexed
) ? ib
->draw_start_offset
: 0);
1470 ILO_GPE_VALID_GEN(dev
, 7, 7);
1472 ilo_cp_begin(cp
, cmd_len
);
1473 ilo_cp_write(cp
, cmd
| (cmd_len
- 2));
1474 ilo_cp_write(cp
, vb_access
| prim
);
1475 ilo_cp_write(cp
, info
->count
);
1476 ilo_cp_write(cp
, vb_start
);
1477 ilo_cp_write(cp
, info
->instance_count
);
1478 ilo_cp_write(cp
, info
->start_instance
);
1479 ilo_cp_write(cp
, info
->index_bias
);
1483 static inline uint32_t
1484 gen7_emit_SF_CLIP_VIEWPORT(const struct ilo_dev_info
*dev
,
1485 const struct ilo_viewport_cso
*viewports
,
1486 unsigned num_viewports
,
1489 const int state_align
= 64 / 4;
1490 const int state_len
= 16 * num_viewports
;
1491 uint32_t state_offset
, *dw
;
1494 ILO_GPE_VALID_GEN(dev
, 7, 7);
1497 * From the Ivy Bridge PRM, volume 2 part 1, page 270:
1499 * "The viewport-specific state used by both the SF and CL units
1500 * (SF_CLIP_VIEWPORT) is stored as an array of up to 16 elements, each
1501 * of which contains the DWords described below. The start of each
1502 * element is spaced 16 DWords apart. The location of first element of
1503 * the array, as specified by both Pointer to SF_VIEWPORT and Pointer
1504 * to CLIP_VIEWPORT, is aligned to a 64-byte boundary."
1506 assert(num_viewports
&& num_viewports
<= 16);
1508 dw
= ilo_cp_steal_ptr(cp
, "SF_CLIP_VIEWPORT",
1509 state_len
, state_align
, &state_offset
);
1511 for (i
= 0; i
< num_viewports
; i
++) {
1512 const struct ilo_viewport_cso
*vp
= &viewports
[i
];
1514 dw
[0] = fui(vp
->m00
);
1515 dw
[1] = fui(vp
->m11
);
1516 dw
[2] = fui(vp
->m22
);
1517 dw
[3] = fui(vp
->m30
);
1518 dw
[4] = fui(vp
->m31
);
1519 dw
[5] = fui(vp
->m32
);
1522 dw
[8] = fui(vp
->min_gbx
);
1523 dw
[9] = fui(vp
->max_gbx
);
1524 dw
[10] = fui(vp
->min_gby
);
1525 dw
[11] = fui(vp
->max_gby
);
1534 return state_offset
;
1537 #endif /* ILO_GPE_GEN7_H */