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 #include "util/u_resource.h"
29 #include "brw_defines.h"
30 #include "intel_reg.h"
32 #include "ilo_format.h"
33 #include "ilo_resource.h"
34 #include "ilo_shader.h"
35 #include "ilo_gpe_gen7.h"
38 ilo_gpe_init_gs_cso_gen7(const struct ilo_dev_info
*dev
,
39 const struct ilo_shader_state
*gs
,
40 struct ilo_shader_cso
*cso
)
42 int start_grf
, vue_read_len
, max_threads
;
43 uint32_t dw2
, dw4
, dw5
;
45 ILO_GPE_VALID_GEN(dev
, 7, 7);
47 start_grf
= ilo_shader_get_kernel_param(gs
, ILO_KERNEL_URB_DATA_START_REG
);
48 vue_read_len
= ilo_shader_get_kernel_param(gs
, ILO_KERNEL_INPUT_COUNT
);
51 vue_read_len
= (vue_read_len
+ 1) / 2;
55 max_threads
= (dev
->gt
== 2) ? 128 : 36;
62 dw2
= (true) ? 0 : GEN6_GS_FLOATING_POINT_MODE_ALT
;
64 dw4
= vue_read_len
<< GEN6_GS_URB_READ_LENGTH_SHIFT
|
65 GEN7_GS_INCLUDE_VERTEX_HANDLES
|
66 0 << GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT
|
67 start_grf
<< GEN6_GS_DISPATCH_START_GRF_SHIFT
;
69 dw5
= (max_threads
- 1) << GEN6_GS_MAX_THREADS_SHIFT
|
70 GEN6_GS_STATISTICS_ENABLE
|
73 STATIC_ASSERT(Elements(cso
->payload
) >= 3);
74 cso
->payload
[0] = dw2
;
75 cso
->payload
[1] = dw4
;
76 cso
->payload
[2] = dw5
;
80 ilo_gpe_init_rasterizer_wm_gen7(const struct ilo_dev_info
*dev
,
81 const struct pipe_rasterizer_state
*state
,
82 struct ilo_rasterizer_wm
*wm
)
86 ILO_GPE_VALID_GEN(dev
, 7, 7);
88 dw1
= GEN7_WM_POSITION_ZW_PIXEL
|
89 GEN7_WM_LINE_AA_WIDTH_2_0
|
90 GEN7_WM_MSRAST_OFF_PIXEL
;
92 /* same value as in 3DSTATE_SF */
93 if (state
->line_smooth
)
94 dw1
|= GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0
;
96 if (state
->poly_stipple_enable
)
97 dw1
|= GEN7_WM_POLYGON_STIPPLE_ENABLE
;
98 if (state
->line_stipple_enable
)
99 dw1
|= GEN7_WM_LINE_STIPPLE_ENABLE
;
101 if (state
->bottom_edge_rule
)
102 dw1
|= GEN7_WM_POINT_RASTRULE_UPPER_RIGHT
;
104 dw2
= GEN7_WM_MSDISPMODE_PERSAMPLE
;
107 * assertion that makes sure
109 * dw1 |= wm->dw_msaa_rast;
110 * dw2 |= wm->dw_msaa_disp;
114 STATIC_ASSERT(GEN7_WM_MSRAST_OFF_PIXEL
== 0 &&
115 GEN7_WM_MSDISPMODE_PERSAMPLE
== 0);
118 (state
->multisample
) ? GEN7_WM_MSRAST_ON_PATTERN
: 0;
119 wm
->dw_msaa_disp
= GEN7_WM_MSDISPMODE_PERPIXEL
;
121 STATIC_ASSERT(Elements(wm
->payload
) >= 2);
122 wm
->payload
[0] = dw1
;
123 wm
->payload
[1] = dw2
;
127 ilo_gpe_init_fs_cso_gen7(const struct ilo_dev_info
*dev
,
128 const struct ilo_shader_state
*fs
,
129 struct ilo_shader_cso
*cso
)
131 int start_grf
, max_threads
;
132 uint32_t dw2
, dw4
, dw5
;
133 uint32_t wm_interps
, wm_dw1
;
135 ILO_GPE_VALID_GEN(dev
, 7, 7);
137 start_grf
= ilo_shader_get_kernel_param(fs
, ILO_KERNEL_URB_DATA_START_REG
);
138 /* see brwCreateContext() */
139 max_threads
= (dev
->gt
== 2) ? 172 : 48;
141 dw2
= (true) ? 0 : GEN7_PS_FLOATING_POINT_MODE_ALT
;
143 dw4
= (max_threads
- 1) << IVB_PS_MAX_THREADS_SHIFT
|
144 GEN7_PS_POSOFFSET_NONE
;
147 dw4
|= GEN7_PS_PUSH_CONSTANT_ENABLE
;
149 if (ilo_shader_get_kernel_param(fs
, ILO_KERNEL_INPUT_COUNT
))
150 dw4
|= GEN7_PS_ATTRIBUTE_ENABLE
;
152 assert(!ilo_shader_get_kernel_param(fs
, ILO_KERNEL_FS_DISPATCH_16_OFFSET
));
153 dw4
|= GEN7_PS_8_DISPATCH_ENABLE
;
155 dw5
= start_grf
<< GEN7_PS_DISPATCH_START_GRF_SHIFT_0
|
156 0 << GEN7_PS_DISPATCH_START_GRF_SHIFT_1
|
157 0 << GEN7_PS_DISPATCH_START_GRF_SHIFT_2
;
159 /* FS affects 3DSTATE_WM too */
163 * TODO set this bit only when
165 * a) fs writes colors and color is not masked, or
166 * b) fs writes depth, or
169 wm_dw1
|= GEN7_WM_DISPATCH_ENABLE
;
172 * From the Ivy Bridge PRM, volume 2 part 1, page 278:
174 * "This bit (Pixel Shader Kill Pixel), if ENABLED, indicates that
175 * the PS kernel or color calculator has the ability to kill
176 * (discard) pixels or samples, other than due to depth or stencil
177 * testing. This bit is required to be ENABLED in the following
180 * - The API pixel shader program contains "killpix" or "discard"
181 * instructions, or other code in the pixel shader kernel that
182 * can cause the final pixel mask to differ from the pixel mask
183 * received on dispatch.
185 * - A sampler with chroma key enabled with kill pixel mode is used
186 * by the pixel shader.
188 * - Any render target has Alpha Test Enable or AlphaToCoverage
191 * - The pixel shader kernel generates and outputs oMask.
193 * Note: As ClipDistance clipping is fully supported in hardware
194 * and therefore not via PS instructions, there should be no need
195 * to ENABLE this bit due to ClipDistance clipping."
197 if (ilo_shader_get_kernel_param(fs
, ILO_KERNEL_FS_USE_KILL
))
198 wm_dw1
|= GEN7_WM_KILL_ENABLE
;
200 if (ilo_shader_get_kernel_param(fs
, ILO_KERNEL_FS_OUTPUT_Z
))
201 wm_dw1
|= GEN7_WM_PSCDEPTH_ON
;
203 if (ilo_shader_get_kernel_param(fs
, ILO_KERNEL_FS_INPUT_Z
))
204 wm_dw1
|= GEN7_WM_USES_SOURCE_DEPTH
;
206 if (ilo_shader_get_kernel_param(fs
, ILO_KERNEL_FS_INPUT_W
))
207 wm_dw1
|= GEN7_WM_USES_SOURCE_W
;
209 wm_interps
= ilo_shader_get_kernel_param(fs
,
210 ILO_KERNEL_FS_BARYCENTRIC_INTERPOLATIONS
);
212 wm_dw1
|= wm_interps
<< GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT
;
214 STATIC_ASSERT(Elements(cso
->payload
) >= 4);
215 cso
->payload
[0] = dw2
;
216 cso
->payload
[1] = dw4
;
217 cso
->payload
[2] = dw5
;
218 cso
->payload
[3] = wm_dw1
;
222 ilo_gpe_init_view_surface_null_gen7(const struct ilo_dev_info
*dev
,
223 unsigned width
, unsigned height
,
224 unsigned depth
, unsigned level
,
225 struct ilo_view_surface
*surf
)
229 ILO_GPE_VALID_GEN(dev
, 7, 7);
232 * From the Ivy Bridge PRM, volume 4 part 1, page 62:
234 * "A null surface is used in instances where an actual surface is not
235 * bound. When a write message is generated to a null surface, no
236 * actual surface is written to. When a read message (including any
237 * sampling engine message) is generated to a null surface, the result
238 * is all zeros. Note that a null surface type is allowed to be used
239 * with all messages, even if it is not specificially indicated as
240 * supported. All of the remaining fields in surface state are ignored
241 * for null surfaces, with the following exceptions:
243 * * Width, Height, Depth, LOD, and Render Target View Extent fields
244 * must match the depth buffer's corresponding state for all render
245 * target surfaces, including null.
246 * * All sampling engine and data port messages support null surfaces
247 * with the above behavior, even if not mentioned as specifically
248 * supported, except for the following:
249 * * Data Port Media Block Read/Write messages.
250 * * The Surface Type of a surface used as a render target (accessed
251 * via the Data Port's Render Target Write message) must be the same
252 * as the Surface Type of all other render targets and of the depth
253 * buffer (defined in 3DSTATE_DEPTH_BUFFER), unless either the depth
254 * buffer or render targets are SURFTYPE_NULL."
256 * From the Ivy Bridge PRM, volume 4 part 1, page 65:
258 * "If Surface Type is SURFTYPE_NULL, this field (Tiled Surface) must be
262 STATIC_ASSERT(Elements(surf
->payload
) >= 8);
265 dw
[0] = BRW_SURFACE_NULL
<< BRW_SURFACE_TYPE_SHIFT
|
266 BRW_SURFACEFORMAT_B8G8R8A8_UNORM
<< BRW_SURFACE_FORMAT_SHIFT
|
267 BRW_SURFACE_TILED
<< 13;
271 dw
[2] = SET_FIELD(height
- 1, GEN7_SURFACE_HEIGHT
) |
272 SET_FIELD(width
- 1, GEN7_SURFACE_WIDTH
);
274 dw
[3] = SET_FIELD(depth
- 1, BRW_SURFACE_DEPTH
);
286 ilo_gpe_init_view_surface_for_buffer_gen7(const struct ilo_dev_info
*dev
,
287 const struct ilo_buffer
*buf
,
288 unsigned offset
, unsigned size
,
289 unsigned struct_size
,
290 enum pipe_format elem_format
,
291 bool is_rt
, bool render_cache_rw
,
292 struct ilo_view_surface
*surf
)
294 const bool typed
= (elem_format
!= PIPE_FORMAT_NONE
);
295 const bool structured
= (!typed
&& struct_size
> 1);
296 const int elem_size
= (typed
) ?
297 util_format_get_blocksize(elem_format
) : 1;
298 int width
, height
, depth
, pitch
;
299 int surface_type
, surface_format
, num_entries
;
302 ILO_GPE_VALID_GEN(dev
, 7, 7);
304 surface_type
= (structured
) ? 5 : BRW_SURFACE_BUFFER
;
306 surface_format
= (typed
) ?
307 ilo_translate_color_format(elem_format
) : BRW_SURFACEFORMAT_RAW
;
309 num_entries
= size
/ struct_size
;
310 /* see if there is enough space to fit another element */
311 if (size
% struct_size
>= elem_size
&& !structured
)
315 * From the Ivy Bridge PRM, volume 4 part 1, page 67:
317 * "For SURFTYPE_BUFFER render targets, this field (Surface Base
318 * Address) specifies the base address of first element of the
319 * surface. The surface is interpreted as a simple array of that
320 * single element type. The address must be naturally-aligned to the
321 * element size (e.g., a buffer containing R32G32B32A32_FLOAT elements
322 * must be 16-byte aligned)
324 * For SURFTYPE_BUFFER non-rendertarget surfaces, this field specifies
325 * the base address of the first element of the surface, computed in
326 * software by adding the surface base address to the byte offset of
327 * the element in the buffer."
330 assert(offset
% elem_size
== 0);
333 * From the Ivy Bridge PRM, volume 4 part 1, page 68:
335 * "For typed buffer and structured buffer surfaces, the number of
336 * entries in the buffer ranges from 1 to 2^27. For raw buffer
337 * surfaces, the number of entries in the buffer is the number of
338 * bytes which can range from 1 to 2^30."
340 assert(num_entries
>= 1 &&
341 num_entries
<= 1 << ((typed
|| structured
) ? 27 : 30));
344 * From the Ivy Bridge PRM, volume 4 part 1, page 69:
346 * "For SURFTYPE_BUFFER: The low two bits of this field (Width) must be
347 * 11 if the Surface Format is RAW (the size of the buffer must be a
348 * multiple of 4 bytes)."
350 * From the Ivy Bridge PRM, volume 4 part 1, page 70:
352 * "For surfaces of type SURFTYPE_BUFFER and SURFTYPE_STRBUF, this
353 * field (Surface Pitch) indicates the size of the structure."
355 * "For linear surfaces with Surface Type of SURFTYPE_STRBUF, the pitch
356 * must be a multiple of 4 bytes."
359 assert(struct_size
% 4 == 0);
361 assert(num_entries
% 4 == 0);
368 width
= (num_entries
& 0x0000007f);
370 height
= (num_entries
& 0x001fff80) >> 7;
372 depth
= (num_entries
& 0x7fe00000) >> 21;
373 /* limit to [26:21] */
374 if (typed
|| structured
)
377 STATIC_ASSERT(Elements(surf
->payload
) >= 8);
380 dw
[0] = surface_type
<< BRW_SURFACE_TYPE_SHIFT
|
381 surface_format
<< BRW_SURFACE_FORMAT_SHIFT
;
383 dw
[0] |= BRW_SURFACE_RC_READ_WRITE
;
387 dw
[2] = SET_FIELD(height
, GEN7_SURFACE_HEIGHT
) |
388 SET_FIELD(width
, GEN7_SURFACE_WIDTH
);
390 dw
[3] = SET_FIELD(depth
, BRW_SURFACE_DEPTH
) |
399 /* do not increment reference count */
404 ilo_gpe_init_view_surface_for_texture_gen7(const struct ilo_dev_info
*dev
,
405 const struct ilo_texture
*tex
,
406 enum pipe_format format
,
407 unsigned first_level
,
409 unsigned first_layer
,
411 bool is_rt
, bool render_cache_rw
,
412 struct ilo_view_surface
*surf
)
414 int surface_type
, surface_format
;
415 int width
, height
, depth
, pitch
, lod
;
416 unsigned layer_offset
, x_offset
, y_offset
;
419 ILO_GPE_VALID_GEN(dev
, 7, 7);
421 surface_type
= ilo_gpe_gen6_translate_texture(tex
->base
.target
);
422 assert(surface_type
!= BRW_SURFACE_BUFFER
);
424 if (format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
&& tex
->separate_s8
)
425 format
= PIPE_FORMAT_Z32_FLOAT
;
428 surface_format
= ilo_translate_render_format(format
);
430 surface_format
= ilo_translate_texture_format(format
);
431 assert(surface_format
>= 0);
433 width
= tex
->base
.width0
;
434 height
= tex
->base
.height0
;
435 depth
= (tex
->base
.target
== PIPE_TEXTURE_3D
) ?
436 tex
->base
.depth0
: num_layers
;
437 pitch
= tex
->bo_stride
;
439 if (surface_type
== BRW_SURFACE_CUBE
) {
441 * From the Ivy Bridge PRM, volume 4 part 1, page 70:
443 * "For SURFTYPE_CUBE:For Sampling Engine Surfaces, the range of
444 * this field is [0,340], indicating the number of cube array
445 * elements (equal to the number of underlying 2D array elements
446 * divided by 6). For other surfaces, this field must be zero."
448 * When is_rt is true, we treat the texture as a 2D one to avoid the
452 surface_type
= BRW_SURFACE_2D
;
455 assert(num_layers
% 6 == 0);
456 depth
= num_layers
/ 6;
460 /* sanity check the size */
461 assert(width
>= 1 && height
>= 1 && depth
>= 1 && pitch
>= 1);
462 assert(first_layer
< 2048 && num_layers
<= 2048);
463 switch (surface_type
) {
465 assert(width
<= 16384 && height
== 1 && depth
<= 2048);
468 assert(width
<= 16384 && height
<= 16384 && depth
<= 2048);
471 assert(width
<= 2048 && height
<= 2048 && depth
<= 2048);
473 assert(first_layer
== 0);
475 case BRW_SURFACE_CUBE
:
476 assert(width
<= 16384 && height
<= 16384 && depth
<= 86);
477 assert(width
== height
);
479 assert(first_layer
== 0);
482 assert(!"unexpected surface type");
488 * Compute the offset to the layer manually.
490 * For rendering, the hardware requires LOD to be the same for all
491 * render targets and the depth buffer. We need to compute the offset
492 * to the layer manually and always set LOD to 0.
495 /* we lose the capability for layered rendering */
496 assert(num_layers
== 1);
498 layer_offset
= ilo_texture_get_slice_offset(tex
,
499 first_level
, first_layer
, &x_offset
, &y_offset
);
501 assert(x_offset
% 4 == 0);
502 assert(y_offset
% 2 == 0);
506 /* derive the size for the LOD */
507 width
= u_minify(width
, first_level
);
508 height
= u_minify(height
, first_level
);
509 if (surface_type
== BRW_SURFACE_3D
)
510 depth
= u_minify(depth
, first_level
);
524 assert(num_levels
== 1);
532 lod
= num_levels
- 1;
536 * From the Ivy Bridge PRM, volume 4 part 1, page 68:
538 * "The Base Address for linear render target surfaces and surfaces
539 * accessed with the typed surface read/write data port messages must
540 * be element-size aligned, for non-YUV surface formats, or a multiple
541 * of 2 element-sizes for YUV surface formats. Other linear surfaces
542 * have no alignment requirements (byte alignment is sufficient)."
544 * From the Ivy Bridge PRM, volume 4 part 1, page 70:
546 * "For linear render target surfaces and surfaces accessed with the
547 * typed data port messages, the pitch must be a multiple of the
548 * element size for non-YUV surface formats. Pitch must be a multiple
549 * of 2 * element size for YUV surface formats. For linear surfaces
550 * with Surface Type of SURFTYPE_STRBUF, the pitch must be a multiple
551 * of 4 bytes.For other linear surfaces, the pitch can be any multiple
554 * From the Ivy Bridge PRM, volume 4 part 1, page 74:
556 * "For linear surfaces, this field (X Offset) must be zero."
558 if (tex
->tiling
== INTEL_TILING_NONE
) {
560 const int elem_size
= util_format_get_blocksize(format
);
561 assert(layer_offset
% elem_size
== 0);
562 assert(pitch
% elem_size
== 0);
568 STATIC_ASSERT(Elements(surf
->payload
) >= 8);
571 dw
[0] = surface_type
<< BRW_SURFACE_TYPE_SHIFT
|
572 surface_format
<< BRW_SURFACE_FORMAT_SHIFT
|
573 ilo_gpe_gen6_translate_winsys_tiling(tex
->tiling
) << 13;
576 * From the Ivy Bridge PRM, volume 4 part 1, page 63:
578 * "If this field (Surface Array) is enabled, the Surface Type must be
579 * SURFTYPE_1D, SURFTYPE_2D, or SURFTYPE_CUBE. If this field is
580 * disabled and Surface Type is SURFTYPE_1D, SURFTYPE_2D, or
581 * SURFTYPE_CUBE, the Depth field must be set to zero."
583 * For non-3D sampler surfaces, resinfo (the sampler message) always
584 * returns zero for the number of layers when this field is not set.
586 if (surface_type
!= BRW_SURFACE_3D
) {
587 if (util_resource_is_array_texture(&tex
->base
))
588 dw
[0] |= GEN7_SURFACE_IS_ARRAY
;
594 dw
[0] |= GEN7_SURFACE_VALIGN_4
;
597 dw
[0] |= GEN7_SURFACE_HALIGN_8
;
599 if (tex
->array_spacing_full
)
600 dw
[0] |= GEN7_SURFACE_ARYSPC_FULL
;
602 dw
[0] |= GEN7_SURFACE_ARYSPC_LOD0
;
605 dw
[0] |= BRW_SURFACE_RC_READ_WRITE
;
607 if (surface_type
== BRW_SURFACE_CUBE
&& !is_rt
)
608 dw
[0] |= BRW_SURFACE_CUBEFACE_ENABLES
;
610 dw
[1] = layer_offset
;
612 dw
[2] = SET_FIELD(height
- 1, GEN7_SURFACE_HEIGHT
) |
613 SET_FIELD(width
- 1, GEN7_SURFACE_WIDTH
);
615 dw
[3] = SET_FIELD(depth
- 1, BRW_SURFACE_DEPTH
) |
618 dw
[4] = first_layer
<< 18 |
619 (num_layers
- 1) << 7;
622 * MSFMT_MSS means the samples are not interleaved and MSFMT_DEPTH_STENCIL
623 * means the samples are interleaved. The layouts are the same when the
624 * number of samples is 1.
626 if (tex
->interleaved
&& tex
->base
.nr_samples
> 1) {
628 dw
[4] |= GEN7_SURFACE_MSFMT_DEPTH_STENCIL
;
631 dw
[4] |= GEN7_SURFACE_MSFMT_MSS
;
634 if (tex
->base
.nr_samples
> 4)
635 dw
[4] |= GEN7_SURFACE_MULTISAMPLECOUNT_8
;
636 else if (tex
->base
.nr_samples
> 2)
637 dw
[4] |= GEN7_SURFACE_MULTISAMPLECOUNT_4
;
639 dw
[4] |= GEN7_SURFACE_MULTISAMPLECOUNT_1
;
641 dw
[5] = x_offset
<< BRW_SURFACE_X_OFFSET_SHIFT
|
642 y_offset
<< BRW_SURFACE_Y_OFFSET_SHIFT
|
643 SET_FIELD(first_level
, GEN7_SURFACE_MIN_LOD
) |
649 /* do not increment reference count */
654 ilo_gpe_gen7_estimate_command_size(const struct ilo_dev_info
*dev
,
655 enum ilo_gpe_gen7_command cmd
,
658 static const struct {
661 } gen7_command_size_table
[ILO_GPE_GEN7_COMMAND_COUNT
] = {
662 [ILO_GPE_GEN7_STATE_BASE_ADDRESS
] = { 0, 10 },
663 [ILO_GPE_GEN7_STATE_SIP
] = { 0, 2 },
664 [ILO_GPE_GEN7_3DSTATE_VF_STATISTICS
] = { 0, 1 },
665 [ILO_GPE_GEN7_PIPELINE_SELECT
] = { 0, 1 },
666 [ILO_GPE_GEN7_MEDIA_VFE_STATE
] = { 0, 8 },
667 [ILO_GPE_GEN7_MEDIA_CURBE_LOAD
] = { 0, 4 },
668 [ILO_GPE_GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD
] = { 0, 4 },
669 [ILO_GPE_GEN7_MEDIA_STATE_FLUSH
] = { 0, 2 },
670 [ILO_GPE_GEN7_GPGPU_WALKER
] = { 0, 11 },
671 [ILO_GPE_GEN7_3DSTATE_CLEAR_PARAMS
] = { 0, 3 },
672 [ILO_GPE_GEN7_3DSTATE_DEPTH_BUFFER
] = { 0, 7 },
673 [ILO_GPE_GEN7_3DSTATE_STENCIL_BUFFER
] = { 0, 3 },
674 [ILO_GPE_GEN7_3DSTATE_HIER_DEPTH_BUFFER
] = { 0, 3 },
675 [ILO_GPE_GEN7_3DSTATE_VERTEX_BUFFERS
] = { 1, 4 },
676 [ILO_GPE_GEN7_3DSTATE_VERTEX_ELEMENTS
] = { 1, 2 },
677 [ILO_GPE_GEN7_3DSTATE_INDEX_BUFFER
] = { 0, 3 },
678 [ILO_GPE_GEN7_3DSTATE_CC_STATE_POINTERS
] = { 0, 2 },
679 [ILO_GPE_GEN7_3DSTATE_SCISSOR_STATE_POINTERS
] = { 0, 2 },
680 [ILO_GPE_GEN7_3DSTATE_VS
] = { 0, 6 },
681 [ILO_GPE_GEN7_3DSTATE_GS
] = { 0, 7 },
682 [ILO_GPE_GEN7_3DSTATE_CLIP
] = { 0, 4 },
683 [ILO_GPE_GEN7_3DSTATE_SF
] = { 0, 7 },
684 [ILO_GPE_GEN7_3DSTATE_WM
] = { 0, 3 },
685 [ILO_GPE_GEN7_3DSTATE_CONSTANT_VS
] = { 0, 7 },
686 [ILO_GPE_GEN7_3DSTATE_CONSTANT_GS
] = { 0, 7 },
687 [ILO_GPE_GEN7_3DSTATE_CONSTANT_PS
] = { 0, 7 },
688 [ILO_GPE_GEN7_3DSTATE_SAMPLE_MASK
] = { 0, 2 },
689 [ILO_GPE_GEN7_3DSTATE_CONSTANT_HS
] = { 0, 7 },
690 [ILO_GPE_GEN7_3DSTATE_CONSTANT_DS
] = { 0, 7 },
691 [ILO_GPE_GEN7_3DSTATE_HS
] = { 0, 7 },
692 [ILO_GPE_GEN7_3DSTATE_TE
] = { 0, 4 },
693 [ILO_GPE_GEN7_3DSTATE_DS
] = { 0, 6 },
694 [ILO_GPE_GEN7_3DSTATE_STREAMOUT
] = { 0, 3 },
695 [ILO_GPE_GEN7_3DSTATE_SBE
] = { 0, 14 },
696 [ILO_GPE_GEN7_3DSTATE_PS
] = { 0, 8 },
697 [ILO_GPE_GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP
] = { 0, 2 },
698 [ILO_GPE_GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC
] = { 0, 2 },
699 [ILO_GPE_GEN7_3DSTATE_BLEND_STATE_POINTERS
] = { 0, 2 },
700 [ILO_GPE_GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS
] = { 0, 2 },
701 [ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS
] = { 0, 2 },
702 [ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS
] = { 0, 2 },
703 [ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS
] = { 0, 2 },
704 [ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS
] = { 0, 2 },
705 [ILO_GPE_GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS
] = { 0, 2 },
706 [ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS
] = { 0, 2 },
707 [ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_HS
] = { 0, 2 },
708 [ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_DS
] = { 0, 2 },
709 [ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS
] = { 0, 2 },
710 [ILO_GPE_GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS
] = { 0, 2 },
711 [ILO_GPE_GEN7_3DSTATE_URB_VS
] = { 0, 2 },
712 [ILO_GPE_GEN7_3DSTATE_URB_HS
] = { 0, 2 },
713 [ILO_GPE_GEN7_3DSTATE_URB_DS
] = { 0, 2 },
714 [ILO_GPE_GEN7_3DSTATE_URB_GS
] = { 0, 2 },
715 [ILO_GPE_GEN7_3DSTATE_DRAWING_RECTANGLE
] = { 0, 4 },
716 [ILO_GPE_GEN7_3DSTATE_POLY_STIPPLE_OFFSET
] = { 0, 2 },
717 [ILO_GPE_GEN7_3DSTATE_POLY_STIPPLE_PATTERN
] = { 0, 33, },
718 [ILO_GPE_GEN7_3DSTATE_LINE_STIPPLE
] = { 0, 3 },
719 [ILO_GPE_GEN7_3DSTATE_AA_LINE_PARAMETERS
] = { 0, 3 },
720 [ILO_GPE_GEN7_3DSTATE_MULTISAMPLE
] = { 0, 4 },
721 [ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS
] = { 0, 2 },
722 [ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_HS
] = { 0, 2 },
723 [ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_DS
] = { 0, 2 },
724 [ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_GS
] = { 0, 2 },
725 [ILO_GPE_GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS
] = { 0, 2 },
726 [ILO_GPE_GEN7_3DSTATE_SO_DECL_LIST
] = { 3, 2 },
727 [ILO_GPE_GEN7_3DSTATE_SO_BUFFER
] = { 0, 4 },
728 [ILO_GPE_GEN7_PIPE_CONTROL
] = { 0, 5 },
729 [ILO_GPE_GEN7_3DPRIMITIVE
] = { 0, 7 },
731 const int header
= gen7_command_size_table
[cmd
].header
;
732 const int body
= gen7_command_size_table
[cmd
].body
;
733 const int count
= arg
;
735 ILO_GPE_VALID_GEN(dev
, 7, 7);
736 assert(cmd
< ILO_GPE_GEN7_COMMAND_COUNT
);
738 return (likely(count
)) ? header
+ body
* count
: 0;
742 ilo_gpe_gen7_estimate_state_size(const struct ilo_dev_info
*dev
,
743 enum ilo_gpe_gen7_state state
,
746 static const struct {
750 } gen7_state_size_table
[ILO_GPE_GEN7_STATE_COUNT
] = {
751 [ILO_GPE_GEN7_INTERFACE_DESCRIPTOR_DATA
] = { 8, 8, true },
752 [ILO_GPE_GEN7_SF_CLIP_VIEWPORT
] = { 16, 16, true },
753 [ILO_GPE_GEN7_CC_VIEWPORT
] = { 8, 2, true },
754 [ILO_GPE_GEN7_COLOR_CALC_STATE
] = { 16, 6, false },
755 [ILO_GPE_GEN7_BLEND_STATE
] = { 16, 2, true },
756 [ILO_GPE_GEN7_DEPTH_STENCIL_STATE
] = { 16, 3, false },
757 [ILO_GPE_GEN7_SCISSOR_RECT
] = { 8, 2, true },
758 [ILO_GPE_GEN7_BINDING_TABLE_STATE
] = { 8, 1, true },
759 [ILO_GPE_GEN7_SURFACE_STATE
] = { 8, 8, false },
760 [ILO_GPE_GEN7_SAMPLER_STATE
] = { 8, 4, true },
761 [ILO_GPE_GEN7_SAMPLER_BORDER_COLOR_STATE
] = { 8, 4, false },
762 [ILO_GPE_GEN7_PUSH_CONSTANT_BUFFER
] = { 8, 1, true },
764 const int alignment
= gen7_state_size_table
[state
].alignment
;
765 const int body
= gen7_state_size_table
[state
].body
;
766 const bool is_array
= gen7_state_size_table
[state
].is_array
;
767 const int count
= arg
;
770 ILO_GPE_VALID_GEN(dev
, 7, 7);
771 assert(state
< ILO_GPE_GEN7_STATE_COUNT
);
775 estimate
= (alignment
- 1) + body
* count
;
778 estimate
= (alignment
- 1) + body
;
779 /* all states are aligned */
781 estimate
+= util_align_npot(body
, alignment
) * (count
- 1);