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(brw
->bind
.bo_offset
); /* 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
->mt
->stencil_mt
&&
212 (srb
->Base
.Format
== MESA_FORMAT_S8_Z24
||
213 srb
->Base
.Format
== MESA_FORMAT_Z32_FLOAT_X24S8
)) {
218 return BRW_DEPTHFORMAT_D32_FLOAT
;
220 switch (drb
->mt
->format
) {
221 case MESA_FORMAT_Z16
:
222 return BRW_DEPTHFORMAT_D16_UNORM
;
223 case MESA_FORMAT_Z32_FLOAT
:
224 return BRW_DEPTHFORMAT_D32_FLOAT
;
225 case MESA_FORMAT_X8_Z24
:
227 return BRW_DEPTHFORMAT_D24_UNORM_X8_UINT
;
228 else /* Gen4 doesn't support X8; use S8 instead. */
229 return BRW_DEPTHFORMAT_D24_UNORM_S8_UINT
;
230 case MESA_FORMAT_S8_Z24
:
231 return BRW_DEPTHFORMAT_D24_UNORM_S8_UINT
;
232 case MESA_FORMAT_Z32_FLOAT_X24S8
:
233 return BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT
;
235 _mesa_problem(ctx
, "Unexpected depth format %s\n",
236 _mesa_get_format_name(drb
->Base
.Format
));
237 return BRW_DEPTHFORMAT_D16_UNORM
;
241 static void emit_depthbuffer(struct brw_context
*brw
)
243 struct intel_context
*intel
= &brw
->intel
;
244 struct gl_context
*ctx
= &intel
->ctx
;
245 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
247 struct intel_renderbuffer
*depth_irb
= intel_get_renderbuffer(fb
, BUFFER_DEPTH
);
248 struct intel_renderbuffer
*stencil_irb
= intel_get_renderbuffer(fb
, BUFFER_STENCIL
);
249 struct intel_mipmap_tree
*stencil_mt
= NULL
;
250 struct intel_region
*hiz_region
= NULL
;
252 bool separate_stencil
= false;
256 depth_irb
->mt
->hiz_mt
) {
257 hiz_region
= depth_irb
->mt
->hiz_mt
->region
;
260 /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both
261 * non-pipelined state that will need the PIPE_CONTROL workaround.
263 if (intel
->gen
== 6) {
264 intel_emit_post_sync_nonzero_flush(intel
);
265 intel_emit_depth_stall_flushes(intel
);
268 /* Find the real separate stencil mt if present. */
270 stencil_mt
= stencil_irb
->mt
;
271 if (stencil_mt
->stencil_mt
)
272 stencil_mt
= stencil_mt
->stencil_mt
;
274 if (stencil_mt
->format
== MESA_FORMAT_S8
)
275 separate_stencil
= true;
278 /* If there's a packed depth/stencil bound to stencil only, we need to
279 * emit the packed depth/stencil buffer packet.
281 if (!depth_irb
&& stencil_irb
&& !separate_stencil
)
282 depth_irb
= stencil_irb
;
286 else if (intel
->is_g4x
|| intel
->gen
== 5)
291 if (!depth_irb
&& !separate_stencil
) {
293 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
294 OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT
<< 18) |
295 (BRW_SURFACE_NULL
<< 29));
300 if (intel
->is_g4x
|| intel
->gen
>= 5)
308 } else if (!depth_irb
&& separate_stencil
) {
310 * There exists a separate stencil buffer but no depth buffer.
312 * The stencil buffer inherits most of its fields from
313 * 3DSTATE_DEPTH_BUFFER: namely the tile walk, surface type, width, and
316 * Since the stencil buffer has quirky pitch requirements, its region
317 * was allocated with half height and double cpp. So we need
318 * a multiplier of 2 to obtain the surface's real height.
320 * Enable the hiz bit because it and the separate stencil bit must have
321 * the same value. From Section 2.11.5.6.1.1 3DSTATE_DEPTH_BUFFER, Bit
322 * 1.21 "Separate Stencil Enable":
323 * [DevIL]: If this field is enabled, Hierarchical Depth Buffer
324 * Enable must also be enabled.
326 * [DevGT]: This field must be set to the same value (enabled or
327 * disabled) as Hierarchical Depth Buffer Enable
329 * The tiled bit must be set. From the Sandybridge PRM, Volume 2, Part 1,
330 * Section 7.5.5.1.1 3DSTATE_DEPTH_BUFFER, Bit 1.27 Tiled Surface:
331 * [DevGT+]: This field must be set to TRUE.
333 struct intel_region
*region
= stencil_mt
->region
;
335 assert(intel
->has_separate_stencil
);
338 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
339 OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT
<< 18) |
340 (1 << 21) | /* separate stencil enable */
341 (1 << 22) | /* hiz enable */
342 (BRW_TILEWALK_YMAJOR
<< 26) |
343 (1 << 27) | /* tiled surface */
344 (BRW_SURFACE_2D
<< 29));
346 OUT_BATCH(((region
->width
- 1) << 6) |
347 (2 * region
->height
- 1) << 19);
357 struct intel_region
*region
= depth_irb
->mt
->region
;
358 uint32_t tile_x
, tile_y
, offset
;
360 /* If using separate stencil, hiz must be enabled. */
361 assert(!separate_stencil
|| hiz_region
);
363 offset
= intel_renderbuffer_tile_offsets(depth_irb
, &tile_x
, &tile_y
);
365 assert(intel
->gen
< 6 || region
->tiling
== I915_TILING_Y
);
366 assert(!hiz_region
|| region
->tiling
== I915_TILING_Y
);
369 OUT_BATCH(_3DSTATE_DEPTH_BUFFER
<< 16 | (len
- 2));
370 OUT_BATCH(((region
->pitch
* region
->cpp
) - 1) |
371 (brw_depthbuffer_format(brw
) << 18) |
372 ((hiz_region
? 1 : 0) << 21) | /* separate stencil enable */
373 ((hiz_region
? 1 : 0) << 22) | /* hiz enable */
374 (BRW_TILEWALK_YMAJOR
<< 26) |
375 ((region
->tiling
!= I915_TILING_NONE
) << 27) |
376 (BRW_SURFACE_2D
<< 29));
377 OUT_RELOC(region
->bo
,
378 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
380 OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW
<< 1) |
381 ((region
->width
- 1) << 6) |
382 ((region
->height
- 1) << 19));
385 if (intel
->is_g4x
|| intel
->gen
>= 5)
386 OUT_BATCH(tile_x
| (tile_y
<< 16));
388 assert(tile_x
== 0 && tile_y
== 0);
396 if (hiz_region
|| separate_stencil
) {
398 * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate
399 * stencil enable' and 'hiz enable' bits were set. Therefore we must
400 * emit 3DSTATE_HIER_DEPTH_BUFFER and 3DSTATE_STENCIL_BUFFER. Even if
401 * there is no stencil buffer, 3DSTATE_STENCIL_BUFFER must be emitted;
402 * failure to do so causes hangs on gen5 and a stall on gen6.
405 /* Emit hiz buffer. */
408 OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER
<< 16) | (3 - 2));
409 OUT_BATCH(hiz_region
->pitch
* hiz_region
->cpp
- 1);
410 OUT_RELOC(hiz_region
->bo
,
411 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
416 OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER
<< 16) | (3 - 2));
422 /* Emit stencil buffer. */
423 if (separate_stencil
) {
424 struct intel_region
*region
= stencil_mt
->region
;
426 OUT_BATCH((_3DSTATE_STENCIL_BUFFER
<< 16) | (3 - 2));
427 OUT_BATCH(region
->pitch
* region
->cpp
- 1);
428 OUT_RELOC(region
->bo
,
429 I915_GEM_DOMAIN_RENDER
, I915_GEM_DOMAIN_RENDER
,
434 OUT_BATCH((_3DSTATE_STENCIL_BUFFER
<< 16) | (3 - 2));
442 * On Gen >= 6, emit clear params for safety. If using hiz, then clear
443 * params must be emitted.
445 * From Section 2.11.5.6.4.1 3DSTATE_CLEAR_PARAMS:
446 * 3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE packet
447 * when HiZ is enabled and the DEPTH_BUFFER_STATE changes.
449 if (intel
->gen
>= 6 || hiz_region
) {
451 intel_emit_post_sync_nonzero_flush(intel
);
454 OUT_BATCH(_3DSTATE_CLEAR_PARAMS
<< 16 | (2 - 2));
460 const struct brw_tracked_state brw_depthbuffer
= {
462 .mesa
= _NEW_BUFFERS
,
463 .brw
= BRW_NEW_BATCH
,
466 .emit
= emit_depthbuffer
,
471 /***********************************************************************
472 * Polygon stipple packet
475 static void upload_polygon_stipple(struct brw_context
*brw
)
477 struct intel_context
*intel
= &brw
->intel
;
478 struct gl_context
*ctx
= &brw
->intel
.ctx
;
482 if (!ctx
->Polygon
.StippleFlag
)
486 intel_emit_post_sync_nonzero_flush(intel
);
489 OUT_BATCH(_3DSTATE_POLY_STIPPLE_PATTERN
<< 16 | (33 - 2));
491 /* Polygon stipple is provided in OpenGL order, i.e. bottom
492 * row first. If we're rendering to a window (i.e. the
493 * default frame buffer object, 0), then we need to invert
494 * it to match our pixel layout. But if we're rendering
495 * to a FBO (i.e. any named frame buffer object), we *don't*
496 * need to invert - we already match the layout.
498 if (ctx
->DrawBuffer
->Name
== 0) {
499 for (i
= 0; i
< 32; i
++)
500 OUT_BATCH(ctx
->PolygonStipple
[31 - i
]); /* invert */
503 for (i
= 0; i
< 32; i
++)
504 OUT_BATCH(ctx
->PolygonStipple
[i
]);
509 const struct brw_tracked_state brw_polygon_stipple
= {
511 .mesa
= (_NEW_POLYGONSTIPPLE
|
513 .brw
= BRW_NEW_CONTEXT
,
516 .emit
= upload_polygon_stipple
520 /***********************************************************************
521 * Polygon stipple offset packet
524 static void upload_polygon_stipple_offset(struct brw_context
*brw
)
526 struct intel_context
*intel
= &brw
->intel
;
527 struct gl_context
*ctx
= &brw
->intel
.ctx
;
530 if (!ctx
->Polygon
.StippleFlag
)
534 intel_emit_post_sync_nonzero_flush(intel
);
537 OUT_BATCH(_3DSTATE_POLY_STIPPLE_OFFSET
<< 16 | (2-2));
541 * If we're drawing to a system window (ctx->DrawBuffer->Name == 0),
542 * we have to invert the Y axis in order to match the OpenGL
543 * pixel coordinate system, and our offset must be matched
544 * to the window position. If we're drawing to a FBO
545 * (ctx->DrawBuffer->Name != 0), then our native pixel coordinate
546 * system works just fine, and there's no window system to
549 if (brw
->intel
.ctx
.DrawBuffer
->Name
== 0)
550 OUT_BATCH((32 - (ctx
->DrawBuffer
->Height
& 31)) & 31);
556 const struct brw_tracked_state brw_polygon_stipple_offset
= {
558 .mesa
= (_NEW_BUFFERS
|
560 .brw
= BRW_NEW_CONTEXT
,
563 .emit
= upload_polygon_stipple_offset
566 /**********************************************************************
569 static void upload_aa_line_parameters(struct brw_context
*brw
)
571 struct intel_context
*intel
= &brw
->intel
;
572 struct gl_context
*ctx
= &brw
->intel
.ctx
;
574 if (!ctx
->Line
.SmoothFlag
|| !brw
->has_aa_line_parameters
)
578 intel_emit_post_sync_nonzero_flush(intel
);
580 OUT_BATCH(_3DSTATE_AA_LINE_PARAMETERS
<< 16 | (3 - 2));
581 /* use legacy aa line coverage computation */
587 const struct brw_tracked_state brw_aa_line_parameters
= {
590 .brw
= BRW_NEW_CONTEXT
,
593 .emit
= upload_aa_line_parameters
596 /***********************************************************************
597 * Line stipple packet
600 static void upload_line_stipple(struct brw_context
*brw
)
602 struct intel_context
*intel
= &brw
->intel
;
603 struct gl_context
*ctx
= &brw
->intel
.ctx
;
607 if (!ctx
->Line
.StippleFlag
)
611 intel_emit_post_sync_nonzero_flush(intel
);
614 OUT_BATCH(_3DSTATE_LINE_STIPPLE_PATTERN
<< 16 | (3 - 2));
615 OUT_BATCH(ctx
->Line
.StipplePattern
);
616 tmp
= 1.0 / (GLfloat
) ctx
->Line
.StippleFactor
;
617 tmpi
= tmp
* (1<<13);
618 OUT_BATCH(tmpi
<< 16 | ctx
->Line
.StippleFactor
);
622 const struct brw_tracked_state brw_line_stipple
= {
625 .brw
= BRW_NEW_CONTEXT
,
628 .emit
= upload_line_stipple
632 /***********************************************************************
633 * Misc invarient state packets
636 static void upload_invarient_state( struct brw_context
*brw
)
638 struct intel_context
*intel
= &brw
->intel
;
640 /* 3DSTATE_SIP, 3DSTATE_MULTISAMPLE, etc. are nonpipelined. */
642 intel_emit_post_sync_nonzero_flush(intel
);
644 /* Select the 3D pipeline (as opposed to media) */
646 OUT_BATCH(brw
->CMD_PIPELINE_SELECT
<< 16 | 0);
649 if (intel
->gen
< 6) {
650 /* Disable depth offset clamping. */
652 OUT_BATCH(_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP
<< 16 | (2 - 2));
657 if (intel
->gen
>= 6) {
659 int len
= intel
->gen
>= 7 ? 4 : 3;
662 OUT_BATCH(_3DSTATE_MULTISAMPLE
<< 16 | (len
- 2));
663 OUT_BATCH(MS_PIXEL_LOCATION_CENTER
|
665 OUT_BATCH(0); /* positions for 4/8-sample */
671 OUT_BATCH(_3DSTATE_SAMPLE_MASK
<< 16 | (2 - 2));
675 if (intel
->gen
< 7) {
676 for (i
= 0; i
< 4; i
++) {
678 OUT_BATCH(_3DSTATE_GS_SVB_INDEX
<< 16 | (4 - 2));
679 OUT_BATCH(i
<< SVB_INDEX_SHIFT
);
681 OUT_BATCH(0xffffffff);
688 OUT_BATCH(CMD_STATE_SIP
<< 16 | (2 - 2));
693 OUT_BATCH(brw
->CMD_VF_STATISTICS
<< 16 |
694 (unlikely(INTEL_DEBUG
& DEBUG_STATS
) ? 1 : 0));
698 const struct brw_tracked_state brw_invarient_state
= {
701 .brw
= BRW_NEW_CONTEXT
,
704 .emit
= upload_invarient_state
708 * Define the base addresses which some state is referenced from.
710 * This allows us to avoid having to emit relocations for the objects,
711 * and is actually required for binding table pointers on gen6.
713 * Surface state base address covers binding table pointers and
714 * surface state objects, but not the surfaces that the surface state
717 static void upload_state_base_address( struct brw_context
*brw
)
719 struct intel_context
*intel
= &brw
->intel
;
721 /* FINISHME: According to section 3.6.1 "STATE_BASE_ADDRESS" of
722 * vol1a of the G45 PRM, MI_FLUSH with the ISC invalidate should be
723 * programmed prior to STATE_BASE_ADDRESS.
725 * However, given that the instruction SBA (general state base
726 * address) on this chipset is always set to 0 across X and GL,
727 * maybe this isn't required for us in particular.
730 if (intel
->gen
>= 6) {
732 intel_emit_post_sync_nonzero_flush(intel
);
735 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (10 - 2));
736 /* General state base address: stateless DP read/write requests */
738 /* Surface state base address:
739 * BINDING_TABLE_STATE
742 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0, 1);
743 /* Dynamic state base address:
745 * SAMPLER_BORDER_COLOR_STATE
746 * CLIP, SF, WM/CC viewport state
748 * DEPTH_STENCIL_STATE
750 * Push constants (when INSTPM: CONSTANT_BUFFER Address Offset
751 * Disable is clear, which we rely on)
753 OUT_RELOC(intel
->batch
.bo
, (I915_GEM_DOMAIN_RENDER
|
754 I915_GEM_DOMAIN_INSTRUCTION
), 0, 1);
756 OUT_BATCH(1); /* Indirect object base address: MEDIA_OBJECT data */
757 OUT_RELOC(brw
->cache
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
758 1); /* Instruction base address: shader kernels (incl. SIP) */
760 OUT_BATCH(1); /* General state upper bound */
761 OUT_BATCH(1); /* Dynamic state upper bound */
762 OUT_BATCH(1); /* Indirect object upper bound */
763 OUT_BATCH(1); /* Instruction access upper bound */
765 } else if (intel
->gen
== 5) {
767 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (8 - 2));
768 OUT_BATCH(1); /* General state base address */
769 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0,
770 1); /* Surface state base address */
771 OUT_BATCH(1); /* Indirect object base address */
772 OUT_RELOC(brw
->cache
.bo
, I915_GEM_DOMAIN_INSTRUCTION
, 0,
773 1); /* Instruction base address */
774 OUT_BATCH(1); /* General state upper bound */
775 OUT_BATCH(1); /* Indirect object upper bound */
776 OUT_BATCH(1); /* Instruction access upper bound */
780 OUT_BATCH(CMD_STATE_BASE_ADDRESS
<< 16 | (6 - 2));
781 OUT_BATCH(1); /* General state base address */
782 OUT_RELOC(intel
->batch
.bo
, I915_GEM_DOMAIN_SAMPLER
, 0,
783 1); /* Surface state base address */
784 OUT_BATCH(1); /* Indirect object base address */
785 OUT_BATCH(1); /* General state upper bound */
786 OUT_BATCH(1); /* Indirect object upper bound */
790 /* According to section 3.6.1 of VOL1 of the 965 PRM,
791 * STATE_BASE_ADDRESS updates require a reissue of:
793 * 3DSTATE_PIPELINE_POINTERS
794 * 3DSTATE_BINDING_TABLE_POINTERS
795 * MEDIA_STATE_POINTERS
797 * and this continues through Ironlake. The Sandy Bridge PRM, vol
798 * 1 part 1 says that the folowing packets must be reissued:
800 * 3DSTATE_CC_POINTERS
801 * 3DSTATE_BINDING_TABLE_POINTERS
802 * 3DSTATE_SAMPLER_STATE_POINTERS
803 * 3DSTATE_VIEWPORT_STATE_POINTERS
804 * MEDIA_STATE_POINTERS
806 * Those are always reissued following SBA updates anyway (new
807 * batch time), except in the case of the program cache BO
808 * changing. Having a separate state flag makes the sequence more
812 brw
->state
.dirty
.brw
|= BRW_NEW_STATE_BASE_ADDRESS
;
815 const struct brw_tracked_state brw_state_base_address
= {
818 .brw
= (BRW_NEW_BATCH
|
819 BRW_NEW_PROGRAM_CACHE
),
822 .emit
= upload_state_base_address