2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
34 #include "intel_batchbuffer.h"
35 #include "intel_fbo.h"
36 #include "intel_mipmap_tree.h"
37 #include "intel_regions.h"
39 #include "brw_context.h"
40 #include "brw_state.h"
41 #include "brw_defines.h"
43 /* Constant single cliprect for framebuffer object or DRI2 drawing */
44 static void upload_drawing_rect(struct brw_context
*brw
)
46 struct intel_context
*intel
= &brw
->intel
;
47 struct gl_context
*ctx
= &intel
->ctx
;
50 OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE
<< 16 | (4 - 2));
51 OUT_BATCH(0); /* xmin, ymin */
52 OUT_BATCH(((ctx
->DrawBuffer
->Width
- 1) & 0xffff) |
53 ((ctx
->DrawBuffer
->Height
- 1) << 16));
58 const struct brw_tracked_state brw_drawing_rect
= {
61 .brw
= BRW_NEW_CONTEXT
,
64 .emit
= upload_drawing_rect
68 * Upload the binding table pointers, which point each stage's array of surface
71 * The binding table pointers are relative to the surface state base address,
72 * which points at the batchbuffer containing the streamed batch state.
74 static void upload_binding_table_pointers(struct brw_context
*brw
)
76 struct intel_context
*intel
= &brw
->intel
;
79 OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS
<< 16 | (6 - 2));
80 OUT_BATCH(brw
->bind
.bo_offset
);
81 OUT_BATCH(0); /* gs */
82 OUT_BATCH(0); /* clip */
83 OUT_BATCH(0); /* sf */
84 OUT_BATCH(brw
->bind
.bo_offset
);
88 const struct brw_tracked_state brw_binding_table_pointers
= {
91 .brw
= (BRW_NEW_BATCH
|
92 BRW_NEW_STATE_BASE_ADDRESS
|
93 BRW_NEW_VS_BINDING_TABLE
|
94 BRW_NEW_GS_BINDING_TABLE
|
95 BRW_NEW_PS_BINDING_TABLE
),
98 .emit
= upload_binding_table_pointers
,
102 * Upload the binding table pointers, which point each stage's array of surface
105 * The binding table pointers are relative to the surface state base address,
106 * which points at the batchbuffer containing the streamed batch state.
108 static void upload_gen6_binding_table_pointers(struct brw_context
*brw
)
110 struct intel_context
*intel
= &brw
->intel
;
113 OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS
<< 16 |
114 GEN6_BINDING_TABLE_MODIFY_VS
|
115 GEN6_BINDING_TABLE_MODIFY_GS
|
116 GEN6_BINDING_TABLE_MODIFY_PS
|
118 OUT_BATCH(brw
->bind
.bo_offset
); /* vs */
119 OUT_BATCH(0); /* gs */
120 OUT_BATCH(brw
->bind
.bo_offset
); /* wm/ps */
124 const struct brw_tracked_state gen6_binding_table_pointers
= {
127 .brw
= (BRW_NEW_BATCH
|
128 BRW_NEW_STATE_BASE_ADDRESS
|
129 BRW_NEW_VS_BINDING_TABLE
|
130 BRW_NEW_GS_BINDING_TABLE
|
131 BRW_NEW_PS_BINDING_TABLE
),
134 .emit
= upload_gen6_binding_table_pointers
,
138 * Upload pointers to the per-stage state.
140 * The state pointers in this packet are all relative to the general state
141 * base address set by CMD_STATE_BASE_ADDRESS, which is 0.
143 static void upload_pipelined_state_pointers(struct brw_context
*brw
)
145 struct intel_context
*intel
= &brw
->intel
;
147 if (intel
->gen
== 5) {
148 /* Need to flush before changing clip max threads for errata. */
155 OUT_BATCH(_3DSTATE_PIPELINED_POINTERS
<< 16 | (7 - 2));
156 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
157 brw
->vs
.state_offset
);
158 if (brw
->gs
.prog_active
)
159 OUT_RELOC(brw
->intel
.batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
160 brw
->gs
.state_offset
| 1);
163 OUT_RELOC(brw
->intel
.batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
164 brw
->clip
.state_offset
| 1);
165 OUT_RELOC(brw
->intel
.batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
166 brw
->sf
.state_offset
);
167 OUT_RELOC(brw
->intel
.batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
168 brw
->wm
.state_offset
);
169 OUT_RELOC(brw
->intel
.batch
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
170 brw
->cc
.state_offset
);
173 brw
->state
.dirty
.brw
|= BRW_NEW_PSP
;
176 static void upload_psp_urb_cbs(struct brw_context
*brw
)
178 upload_pipelined_state_pointers(brw
);
179 brw_upload_urb_fence(brw
);
180 brw_upload_cs_urb_state(brw
);
183 const struct brw_tracked_state brw_psp_urb_cbs
= {
186 .brw
= (BRW_NEW_URB_FENCE
|
188 BRW_NEW_STATE_BASE_ADDRESS
),
189 .cache
= (CACHE_NEW_VS_UNIT
|
192 CACHE_NEW_CLIP_UNIT
|
197 .emit
= upload_psp_urb_cbs
,
201 brw_depthbuffer_format(struct brw_context
*brw
)
203 struct intel_context
*intel
= &brw
->intel
;
204 struct gl_context
*ctx
= &intel
->ctx
;
205 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
206 struct intel_renderbuffer
*drb
= intel_get_renderbuffer(fb
, BUFFER_DEPTH
);
207 struct intel_renderbuffer
*srb
;
210 (srb
= intel_get_renderbuffer(fb
, BUFFER_STENCIL
)) &&
211 srb
->Base
.Format
== MESA_FORMAT_S8_Z24
) {
215 switch (drb
->Base
.Format
) {
216 case MESA_FORMAT_Z16
:
217 return BRW_DEPTHFORMAT_D16_UNORM
;
218 case MESA_FORMAT_Z32_FLOAT
:
219 return BRW_DEPTHFORMAT_D32_FLOAT
;
220 case MESA_FORMAT_X8_Z24
:
221 return BRW_DEPTHFORMAT_D24_UNORM_X8_UINT
;
222 case MESA_FORMAT_S8_Z24
:
223 return BRW_DEPTHFORMAT_D24_UNORM_S8_UINT
;
225 _mesa_problem(ctx
, "Unexpected depth format %s\n",
226 _mesa_get_format_name(drb
->Base
.Format
));
227 return BRW_DEPTHFORMAT_D16_UNORM
;
231 static void emit_depthbuffer(struct brw_context
*brw
)
233 struct intel_context
*intel
= &brw
->intel
;
234 struct gl_context
*ctx
= &intel
->ctx
;
235 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
237 struct intel_renderbuffer
*depth_irb
= intel_get_renderbuffer(fb
, BUFFER_DEPTH
);
238 struct intel_renderbuffer
*stencil_irb
= intel_get_renderbuffer(fb
, BUFFER_STENCIL
);
239 struct intel_region
*hiz_region
= NULL
;
244 depth_irb
->mt
->hiz_mt
) {
245 hiz_region
= depth_irb
->mt
->hiz_mt
->region
;
248 /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both
249 * non-pipelined state that will need the PIPE_CONTROL workaround.
251 if (intel
->gen
== 6) {
252 intel_emit_post_sync_nonzero_flush(intel
);
253 intel_emit_depth_stall_flushes(intel
);
257 * If either depth or stencil buffer has packed depth/stencil format,
258 * then don't use separate stencil. Emit only a depth buffer.
260 if (depth_irb
&& depth_irb
->Base
.Format
== MESA_FORMAT_S8_Z24
) {
262 } else if (!depth_irb
&& stencil_irb
263 && stencil_irb
->Base
.Format
== MESA_FORMAT_S8_Z24
) {
264 depth_irb
= stencil_irb
;
270 else if (intel
->is_g4x
|| intel
->gen
== 5)
275 if (!depth_irb
&& !stencil_irb
) {
277 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
278 OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT
<< 18) |
279 (BRW_SURFACE_NULL
<< 29));
284 if (intel
->is_g4x
|| intel
->gen
>= 5)
292 } else if (!depth_irb
&& stencil_irb
) {
294 * There exists a separate stencil buffer but no depth buffer.
296 * The stencil buffer inherits most of its fields from
297 * 3DSTATE_DEPTH_BUFFER: namely the tile walk, surface type, width, and
300 * Since the stencil buffer has quirky pitch requirements, its region
301 * was allocated with half height and double cpp. So we need
302 * a multiplier of 2 to obtain the surface's real height.
304 * Enable the hiz bit because it and the separate stencil bit must have
305 * the same value. From Section 2.11.5.6.1.1 3DSTATE_DEPTH_BUFFER, Bit
306 * 1.21 "Separate Stencil Enable":
307 * [DevIL]: If this field is enabled, Hierarchical Depth Buffer
308 * Enable must also be enabled.
310 * [DevGT]: This field must be set to the same value (enabled or
311 * disabled) as Hierarchical Depth Buffer Enable
313 * The tiled bit must be set. From the Sandybridge PRM, Volume 2, Part 1,
314 * Section 7.5.5.1.1 3DSTATE_DEPTH_BUFFER, Bit 1.27 Tiled Surface:
315 * [DevGT+]: This field must be set to TRUE.
317 struct intel_region
*region
= stencil_irb
->mt
->region
;
319 assert(intel
->has_separate_stencil
);
320 assert(stencil_irb
->Base
.Format
== MESA_FORMAT_S8
);
323 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
324 OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT
<< 18) |
325 (1 << 21) | /* separate stencil enable */
326 (1 << 22) | /* hiz enable */
327 (BRW_TILEWALK_YMAJOR
<< 26) |
328 (1 << 27) | /* tiled surface */
329 (BRW_SURFACE_2D
<< 29));
331 OUT_BATCH(((region
->width
- 1) << 6) |
332 (2 * region
->height
- 1) << 19);
342 struct intel_region
*region
= depth_irb
->mt
->region
;
343 uint32_t tile_x
, tile_y
, offset
;
345 /* If using separate stencil, hiz must be enabled. */
346 assert(!stencil_irb
|| hiz_region
);
348 offset
= intel_renderbuffer_tile_offsets(depth_irb
, &tile_x
, &tile_y
);
350 assert(intel
->gen
< 6 || region
->tiling
== I915_TILING_Y
);
351 assert(!hiz_region
|| region
->tiling
== I915_TILING_Y
);
354 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
355 OUT_BATCH(((region
->pitch
* region
->cpp
) - 1) |
356 (brw_depthbuffer_format(brw
) << 18) |
357 ((hiz_region
? 1 : 0) << 21) | /* separate stencil enable */
358 ((hiz_region
? 1 : 0) << 22) | /* hiz enable */
359 (BRW_TILEWALK_YMAJOR
<< 26) |
360 ((region
->tiling
!= I915_TILING_NONE
) << 27) |
361 (BRW_SURFACE_2D
<< 29));
362 OUT_RELOC(region
->bo
,
363 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
365 OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW
<< 1) |
366 ((region
->width
- 1) << 6) |
367 ((region
->height
- 1) << 19));
370 if (intel
->is_g4x
|| intel
->gen
>= 5)
371 OUT_BATCH(tile_x
| (tile_y
<< 16));
373 assert(tile_x
== 0 && tile_y
== 0);
381 if (hiz_region
|| stencil_irb
) {
383 * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate
384 * stencil enable' and 'hiz enable' bits were set. Therefore we must
385 * emit 3DSTATE_HIER_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER. Even if
386 * there is no stencil buffer, 3DSTATE_STENCIL_BUFFER must be emitted;
387 * failure to do so causes hangs on gen5 and a stall on gen6.
390 /* Emit hiz buffer. */
393 OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER
<< 16) | (3 - 2));
394 OUT_BATCH(hiz_region
->pitch
* hiz_region
->cpp
- 1);
395 OUT_RELOC(hiz_region
->bo
,
396 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
401 OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER
<< 16) | (3 - 2));
407 /* Emit stencil buffer. */
409 struct intel_region
*region
= stencil_irb
->mt
->region
;
411 OUT_BATCH((_3DSTATE_STENCIL_BUFFER
<< 16) | (3 - 2));
412 OUT_BATCH(region
->pitch
* region
->cpp
- 1);
413 OUT_RELOC(region
->bo
,
414 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
419 OUT_BATCH((_3DSTATE_STENCIL_BUFFER
<< 16) | (3 - 2));
427 * On Gen >= 6, emit clear params for safety. If using hiz, then clear
428 * params must be emitted.
430 * From Section 2.11.5.6.4.1 3DSTATE_CLEAR_PARAMS:
431 * 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE packet
432 * when HiZ is enabled and the DEPTH_BUFFER_STATE changes.
434 if (intel
->gen
>= 6 || hiz_region
) {
436 intel_emit_post_sync_nonzero_flush(intel
);
439 OUT_BATCH(_3DSTATE_CLEAR_PARAMS
<< 16 | (2 - 2));
445 const struct brw_tracked_state brw_depthbuffer
= {
447 .mesa
= _NEW_BUFFERS
,
448 .brw
= BRW_NEW_BATCH
,
451 .emit
= emit_depthbuffer
,
456 /***********************************************************************
457 * Polygon stipple packet
460 static void upload_polygon_stipple(struct brw_context
*brw
)
462 struct intel_context
*intel
= &brw
->intel
;
463 struct gl_context
*ctx
= &brw
->intel
.ctx
;
467 if (!ctx
->Polygon
.StippleFlag
)
471 intel_emit_post_sync_nonzero_flush(intel
);
474 OUT_BATCH(_3DSTATE_POLY_STIPPLE_PATTERN
<< 16 | (33 - 2));
476 /* Polygon stipple is provided in OpenGL order, i.e. bottom
477 * row first. If we're rendering to a window (i.e. the
478 * default frame buffer object, 0), then we need to invert
479 * it to match our pixel layout. But if we're rendering
480 * to a FBO (i.e. any named frame buffer object), we *don't*
481 * need to invert - we already match the layout.
483 if (ctx
->DrawBuffer
->Name
== 0) {
484 for (i
= 0; i
< 32; i
++)
485 OUT_BATCH(ctx
->PolygonStipple
[31 - i
]); /* invert */
488 for (i
= 0; i
< 32; i
++)
489 OUT_BATCH(ctx
->PolygonStipple
[i
]);
494 const struct brw_tracked_state brw_polygon_stipple
= {
496 .mesa
= (_NEW_POLYGONSTIPPLE
|
498 .brw
= BRW_NEW_CONTEXT
,
501 .emit
= upload_polygon_stipple
505 /***********************************************************************
506 * Polygon stipple offset packet
509 static void upload_polygon_stipple_offset(struct brw_context
*brw
)
511 struct intel_context
*intel
= &brw
->intel
;
512 struct gl_context
*ctx
= &brw
->intel
.ctx
;
515 if (!ctx
->Polygon
.StippleFlag
)
519 intel_emit_post_sync_nonzero_flush(intel
);
522 OUT_BATCH(_3DSTATE_POLY_STIPPLE_OFFSET
<< 16 | (2-2));
526 * If we're drawing to a system window (ctx->DrawBuffer->Name == 0),
527 * we have to invert the Y axis in order to match the OpenGL
528 * pixel coordinate system, and our offset must be matched
529 * to the window position. If we're drawing to a FBO
530 * (ctx->DrawBuffer->Name != 0), then our native pixel coordinate
531 * system works just fine, and there's no window system to
534 if (brw
->intel
.ctx
.DrawBuffer
->Name
== 0)
535 OUT_BATCH((32 - (ctx
->DrawBuffer
->Height
& 31)) & 31);
541 const struct brw_tracked_state brw_polygon_stipple_offset
= {
543 .mesa
= (_NEW_BUFFERS
|
545 .brw
= BRW_NEW_CONTEXT
,
548 .emit
= upload_polygon_stipple_offset
551 /**********************************************************************
554 static void upload_aa_line_parameters(struct brw_context
*brw
)
556 struct intel_context
*intel
= &brw
->intel
;
557 struct gl_context
*ctx
= &brw
->intel
.ctx
;
559 if (!ctx
->Line
.SmoothFlag
|| !brw
->has_aa_line_parameters
)
563 intel_emit_post_sync_nonzero_flush(intel
);
565 OUT_BATCH(_3DSTATE_AA_LINE_PARAMETERS
<< 16 | (3 - 2));
566 /* use legacy aa line coverage computation */
572 const struct brw_tracked_state brw_aa_line_parameters
= {
575 .brw
= BRW_NEW_CONTEXT
,
578 .emit
= upload_aa_line_parameters
581 /***********************************************************************
582 * Line stipple packet
585 static void upload_line_stipple(struct brw_context
*brw
)
587 struct intel_context
*intel
= &brw
->intel
;
588 struct gl_context
*ctx
= &brw
->intel
.ctx
;
592 if (!ctx
->Line
.StippleFlag
)
596 intel_emit_post_sync_nonzero_flush(intel
);
599 OUT_BATCH(_3DSTATE_LINE_STIPPLE_PATTERN
<< 16 | (3 - 2));
600 OUT_BATCH(ctx
->Line
.StipplePattern
);
601 tmp
= 1.0 / (GLfloat
) ctx
->Line
.StippleFactor
;
602 tmpi
= tmp
* (1<<13);
603 OUT_BATCH(tmpi
<< 16 | ctx
->Line
.StippleFactor
);
607 const struct brw_tracked_state brw_line_stipple
= {
610 .brw
= BRW_NEW_CONTEXT
,
613 .emit
= upload_line_stipple
617 /***********************************************************************
618 * Misc invarient state packets
621 static void upload_invarient_state( struct brw_context
*brw
)
623 struct intel_context
*intel
= &brw
->intel
;
625 /* 3DSTATE_SIP, 3DSTATE_MULTISAMPLE, etc. are nonpipelined. */
627 intel_emit_post_sync_nonzero_flush(intel
);
629 /* Select the 3D pipeline (as opposed to media) */
631 OUT_BATCH(brw
->CMD_PIPELINE_SELECT
<< 16 | 0);
634 if (intel
->gen
< 6) {
635 /* Disable depth offset clamping. */
637 OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP
<< 16 | (2 - 2));
642 if (intel
->gen
>= 6) {
644 int len
= intel
->gen
>= 7 ? 4 : 3;
647 OUT_BATCH(_3DSTATE_MULTISAMPLE
<< 16 | (len
- 2));
648 OUT_BATCH(MS_PIXEL_LOCATION_CENTER
|
650 OUT_BATCH(0); /* positions for 4/8-sample */
656 OUT_BATCH(_3DSTATE_SAMPLE_MASK
<< 16 | (2 - 2));
660 if (intel
->gen
< 7) {
661 for (i
= 0; i
< 4; i
++) {
663 OUT_BATCH(_3DSTATE_GS_SVB_INDEX
<< 16 | (4 - 2));
664 OUT_BATCH(i
<< SVB_INDEX_SHIFT
);
666 OUT_BATCH(0xffffffff);
673 OUT_BATCH(CMD_STATE_SIP
<< 16 | (2 - 2));
678 OUT_BATCH(brw
->CMD_VF_STATISTICS
<< 16 |
679 (unlikely(INTEL_DEBUG
& DEBUG_STATS
) ? 1 : 0));
683 const struct brw_tracked_state brw_invarient_state
= {
686 .brw
= BRW_NEW_CONTEXT
,
689 .emit
= upload_invarient_state
693 * Define the base addresses which some state is referenced from.
695 * This allows us to avoid having to emit relocations for the objects,
696 * and is actually required for binding table pointers on gen6.
698 * Surface state base address covers binding table pointers and
699 * surface state objects, but not the surfaces that the surface state
702 static void upload_state_base_address( struct brw_context
*brw
)
704 struct intel_context
*intel
= &brw
->intel
;
706 /* FINISHME: According to section 3.6.1 "STATE_BASE_ADDRESS" of
707 * vol1a of the G45 PRM, MI_FLUSH with the ISC invalidate should be
708 * programmed prior to STATE_BASE_ADDRESS.
710 * However, given that the instruction SBA (general state base
711 * address) on this chipset is always set to 0 across X and GL,
712 * maybe this isn't required for us in particular.
715 if (intel
->gen
>= 6) {
717 intel_emit_post_sync_nonzero_flush(intel
);
720 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (10 - 2));
721 /* General state base address: stateless DP read/write requests */
723 /* Surface state base address:
724 * BINDING_TABLE_STATE
727 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0, 1);
728 /* Dynamic state base address:
730 * SAMPLER_BORDER_COLOR_STATE
731 * CLIP, SF, WM/CC viewport state
733 * DEPTH_STENCIL_STATE
735 * Push constants (when INSTPM: CONSTANT_BUFFER Address Offset
736 * Disable is clear, which we rely on)
738 OUT_RELOC(intel
->batch
.bo
, (I915_GEM_DOMAIN_RENDER
|
739 I915_GEM_DOMAIN_INSTRUCTION
), 0, 1);
741 OUT_BATCH(1); /* Indirect object base address: MEDIA_OBJECT data */
742 OUT_RELOC(brw
->cache
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
743 1); /* Instruction base address: shader kernels (incl. SIP) */
745 OUT_BATCH(1); /* General state upper bound */
746 OUT_BATCH(1); /* Dynamic state upper bound */
747 OUT_BATCH(1); /* Indirect object upper bound */
748 OUT_BATCH(1); /* Instruction access upper bound */
750 } else if (intel
->gen
== 5) {
752 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (8 - 2));
753 OUT_BATCH(1); /* General state base address */
754 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0,
755 1); /* Surface state base address */
756 OUT_BATCH(1); /* Indirect object base address */
757 OUT_RELOC(brw
->cache
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
758 1); /* Instruction base address */
759 OUT_BATCH(1); /* General state upper bound */
760 OUT_BATCH(1); /* Indirect object upper bound */
761 OUT_BATCH(1); /* Instruction access upper bound */
765 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (6 - 2));
766 OUT_BATCH(1); /* General state base address */
767 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0,
768 1); /* Surface state base address */
769 OUT_BATCH(1); /* Indirect object base address */
770 OUT_BATCH(1); /* General state upper bound */
771 OUT_BATCH(1); /* Indirect object upper bound */
775 /* According to section 3.6.1 of VOL1 of the 965 PRM,
776 * STATE_BASE_ADDRESS updates require a reissue of:
778 * 3DSTATE_PIPELINE_POINTERS
779 * 3DSTATE_BINDING_TABLE_POINTERS
780 * MEDIA_STATE_POINTERS
782 * and this continues through Ironlake. The Sandy Bridge PRM, vol
783 * 1 part 1 says that the folowing packets must be reissued:
785 * 3DSTATE_CC_POINTERS
786 * 3DSTATE_BINDING_TABLE_POINTERS
787 * 3DSTATE_SAMPLER_STATE_POINTERS
788 * 3DSTATE_VIEWPORT_STATE_POINTERS
789 * MEDIA_STATE_POINTERS
791 * Those are always reissued following SBA updates anyway (new
792 * batch time), except in the case of the program cache BO
793 * changing. Having a separate state flag makes the sequence more
797 brw
->state
.dirty
.brw
|= BRW_NEW_STATE_BASE_ADDRESS
;
800 const struct brw_tracked_state brw_state_base_address
= {
803 .brw
= (BRW_NEW_BATCH
|
804 BRW_NEW_PROGRAM_CACHE
),
807 .emit
= upload_state_base_address