103b705cfSriastradh/*
203b705cfSriastradh * Copyright � 2011 Intel Corporation
303b705cfSriastradh *
403b705cfSriastradh * Permission is hereby granted, free of charge, to any person obtaining a
503b705cfSriastradh * copy of this software and associated documentation files (the "Software"),
603b705cfSriastradh * to deal in the Software without restriction, including without limitation
703b705cfSriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
803b705cfSriastradh * and/or sell copies of the Software, and to permit persons to whom the
903b705cfSriastradh * Software is furnished to do so, subject to the following conditions:
1003b705cfSriastradh *
1103b705cfSriastradh * The above copyright notice and this permission notice (including the next
1203b705cfSriastradh * paragraph) shall be included in all copies or substantial portions of the
1303b705cfSriastradh * Software.
1403b705cfSriastradh *
1503b705cfSriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1603b705cfSriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1703b705cfSriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1803b705cfSriastradh * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1903b705cfSriastradh * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2003b705cfSriastradh * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2103b705cfSriastradh * DEALINGS IN THE SOFTWARE.
2203b705cfSriastradh */
2303b705cfSriastradh
2403b705cfSriastradh#ifdef HAVE_CONFIG_H
2503b705cfSriastradh#include "config.h"
2603b705cfSriastradh#endif
2703b705cfSriastradh
2803b705cfSriastradh#include <string.h>
2903b705cfSriastradh
3003b705cfSriastradh#include "intel.h"
3113496ba1Ssnj#include "intel_uxa.h"
3203b705cfSriastradh#include "i965_reg.h"
3303b705cfSriastradh#include "brw_defines.h"
3403b705cfSriastradh
3503b705cfSriastradhvoid
3603b705cfSriastradhgen6_upload_invariant_states(intel_screen_private *intel)
3703b705cfSriastradh{
3803b705cfSriastradh	Bool ivb = INTEL_INFO(intel)->gen >= 070;
3903b705cfSriastradh
4003b705cfSriastradh	OUT_BATCH(BRW_PIPE_CONTROL | (4 - 2));
4103b705cfSriastradh	OUT_BATCH(BRW_PIPE_CONTROL_IS_FLUSH |
4203b705cfSriastradh		BRW_PIPE_CONTROL_WC_FLUSH |
4303b705cfSriastradh		BRW_PIPE_CONTROL_DEPTH_CACHE_FLUSH |
4403b705cfSriastradh		BRW_PIPE_CONTROL_NOWRITE);
4503b705cfSriastradh	OUT_BATCH(0); /* write address */
4603b705cfSriastradh	OUT_BATCH(0); /* write data */
4703b705cfSriastradh
4803b705cfSriastradh	OUT_BATCH(NEW_PIPELINE_SELECT | PIPELINE_SELECT_3D);
4903b705cfSriastradh
5003b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE | ((ivb ? 4 : 3) - 2));
5103b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER |
5203b705cfSriastradh		GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1); /* 1 sample/pixel */
5303b705cfSriastradh	OUT_BATCH(0);
5403b705cfSriastradh	if (ivb)
5503b705cfSriastradh		OUT_BATCH(0);
5603b705cfSriastradh
5703b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SAMPLE_MASK | (2 - 2));
5803b705cfSriastradh	OUT_BATCH(1);
5903b705cfSriastradh
6003b705cfSriastradh	/* Set system instruction pointer */
6103b705cfSriastradh	OUT_BATCH(BRW_STATE_SIP | 0);
6203b705cfSriastradh	OUT_BATCH(0);
6303b705cfSriastradh}
6403b705cfSriastradh
6503b705cfSriastradhvoid
6603b705cfSriastradhgen6_upload_viewport_state_pointers(intel_screen_private *intel,
6703b705cfSriastradh				    drm_intel_bo *cc_vp_bo)
6803b705cfSriastradh{
6903b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_VIEWPORT_STATE_POINTERS |
7003b705cfSriastradh		GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC |
7103b705cfSriastradh		(4 - 2));
7203b705cfSriastradh	OUT_BATCH(0);
7303b705cfSriastradh	OUT_BATCH(0);
7403b705cfSriastradh	OUT_RELOC(cc_vp_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
7503b705cfSriastradh}
7603b705cfSriastradh
7703b705cfSriastradhvoid
7803b705cfSriastradhgen7_upload_viewport_state_pointers(intel_screen_private *intel,
7903b705cfSriastradh				    drm_intel_bo *cc_vp_bo)
8003b705cfSriastradh{
8103b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC | (2 - 2));
8203b705cfSriastradh	OUT_RELOC(cc_vp_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
8303b705cfSriastradh
8403b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL | (2 - 2));
8503b705cfSriastradh	OUT_BATCH(0);
8603b705cfSriastradh}
8703b705cfSriastradh
8803b705cfSriastradhvoid
8903b705cfSriastradhgen6_upload_urb(intel_screen_private *intel)
9003b705cfSriastradh{
9103b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_URB | (3 - 2));
9203b705cfSriastradh	OUT_BATCH(((1 - 1) << GEN6_3DSTATE_URB_VS_SIZE_SHIFT) |
9303b705cfSriastradh		(24 << GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT)); /* at least 24 on GEN6 */
9403b705cfSriastradh	OUT_BATCH((0 << GEN6_3DSTATE_URB_GS_SIZE_SHIFT) |
9503b705cfSriastradh		(0 << GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT)); /* no GS thread */
9603b705cfSriastradh}
9703b705cfSriastradh
9803b705cfSriastradh/*
9903b705cfSriastradh * URB layout on GEN7
10003b705cfSriastradh * ----------------------------------------
10103b705cfSriastradh * | PS Push Constants (8KB) | VS entries |
10203b705cfSriastradh * ----------------------------------------
10303b705cfSriastradh */
10403b705cfSriastradhvoid
10503b705cfSriastradhgen7_upload_urb(intel_screen_private *intel)
10603b705cfSriastradh{
10703b705cfSriastradh	unsigned int num_urb_entries = 32;
10803b705cfSriastradh
10903b705cfSriastradh	if (IS_HSW(intel))
11003b705cfSriastradh		num_urb_entries = 64;
11103b705cfSriastradh
11203b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS | (2 - 2));
11303b705cfSriastradh	OUT_BATCH(8); /* in 1KBs */
11403b705cfSriastradh
11503b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_URB_VS | (2 - 2));
11603b705cfSriastradh	OUT_BATCH(
11703b705cfSriastradh		(num_urb_entries << GEN7_URB_ENTRY_NUMBER_SHIFT) |
11803b705cfSriastradh		(2 - 1) << GEN7_URB_ENTRY_SIZE_SHIFT |
11903b705cfSriastradh		(1 << GEN7_URB_STARTING_ADDRESS_SHIFT));
12003b705cfSriastradh
12103b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_URB_GS | (2 - 2));
12203b705cfSriastradh	OUT_BATCH((0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
12303b705cfSriastradh		(1 << GEN7_URB_STARTING_ADDRESS_SHIFT));
12403b705cfSriastradh
12503b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_URB_HS | (2 - 2));
12603b705cfSriastradh	OUT_BATCH((0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
12703b705cfSriastradh		(2 << GEN7_URB_STARTING_ADDRESS_SHIFT));
12803b705cfSriastradh
12903b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_URB_DS | (2 - 2));
13003b705cfSriastradh	OUT_BATCH((0 << GEN7_URB_ENTRY_SIZE_SHIFT) |
13103b705cfSriastradh		(2 << GEN7_URB_STARTING_ADDRESS_SHIFT));
13203b705cfSriastradh}
13303b705cfSriastradh
13403b705cfSriastradhvoid
13503b705cfSriastradhgen6_upload_cc_state_pointers(intel_screen_private *intel,
13603b705cfSriastradh			      drm_intel_bo *blend_bo,
13703b705cfSriastradh			      drm_intel_bo *cc_bo,
13803b705cfSriastradh			      drm_intel_bo *depth_stencil_bo,
13903b705cfSriastradh			      uint32_t blend_offset)
14003b705cfSriastradh{
14103b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CC_STATE_POINTERS | (4 - 2));
14203b705cfSriastradh	if (blend_bo)
14303b705cfSriastradh		OUT_RELOC(blend_bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
14403b705cfSriastradh			  blend_offset | 1);
14503b705cfSriastradh	else
14603b705cfSriastradh		OUT_BATCH(0);
14703b705cfSriastradh
14803b705cfSriastradh	if (depth_stencil_bo)
14903b705cfSriastradh		OUT_RELOC(depth_stencil_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
15003b705cfSriastradh	else
15103b705cfSriastradh		OUT_BATCH(0);
15203b705cfSriastradh
15303b705cfSriastradh	if (cc_bo)
15403b705cfSriastradh		OUT_RELOC(cc_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
15503b705cfSriastradh	else
15603b705cfSriastradh		OUT_BATCH(0);
15703b705cfSriastradh}
15803b705cfSriastradh
15903b705cfSriastradhvoid
16003b705cfSriastradhgen7_upload_cc_state_pointers(intel_screen_private *intel,
16103b705cfSriastradh			      drm_intel_bo *blend_bo,
16203b705cfSriastradh			      drm_intel_bo *cc_bo,
16303b705cfSriastradh			      drm_intel_bo *depth_stencil_bo,
16403b705cfSriastradh			      uint32_t blend_offset)
16503b705cfSriastradh{
16603b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_BLEND_STATE_POINTERS | (2 - 2));
16703b705cfSriastradh	if (blend_bo)
16803b705cfSriastradh		OUT_RELOC(blend_bo, I915_GEM_DOMAIN_INSTRUCTION, 0,
16903b705cfSriastradh			  blend_offset | 1);
17003b705cfSriastradh	else
17103b705cfSriastradh		OUT_BATCH(0);
17203b705cfSriastradh
17303b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CC_STATE_POINTERS | (2 - 2));
17403b705cfSriastradh	if (cc_bo)
17503b705cfSriastradh		OUT_RELOC(cc_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
17603b705cfSriastradh	else
17703b705cfSriastradh		OUT_BATCH(0);
17803b705cfSriastradh
17903b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS | (2 - 2));
18003b705cfSriastradh	if (depth_stencil_bo)
18103b705cfSriastradh		OUT_RELOC(depth_stencil_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
18203b705cfSriastradh	else
18303b705cfSriastradh		OUT_BATCH(0);
18403b705cfSriastradh}
18503b705cfSriastradh
18603b705cfSriastradhvoid
18703b705cfSriastradhgen6_upload_sampler_state_pointers(intel_screen_private *intel,
18803b705cfSriastradh				   drm_intel_bo *sampler_bo)
18903b705cfSriastradh{
19003b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SAMPLER_STATE_POINTERS |
19103b705cfSriastradh		GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS |
19203b705cfSriastradh		(4 - 2));
19303b705cfSriastradh	OUT_BATCH(0); /* VS */
19403b705cfSriastradh	OUT_BATCH(0); /* GS */
19503b705cfSriastradh	OUT_RELOC(sampler_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
19603b705cfSriastradh}
19703b705cfSriastradh
19803b705cfSriastradhvoid
19903b705cfSriastradhgen7_upload_sampler_state_pointers(intel_screen_private *intel,
20003b705cfSriastradh				   drm_intel_bo *sampler_bo)
20103b705cfSriastradh{
20203b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS | (2 - 2));
20303b705cfSriastradh	OUT_RELOC(sampler_bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
20403b705cfSriastradh}
20503b705cfSriastradh
20603b705cfSriastradhvoid
20703b705cfSriastradhgen7_upload_bypass_states(intel_screen_private *intel)
20803b705cfSriastradh{
20903b705cfSriastradh	/* bypass GS */
21003b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CONSTANT_GS | (7 - 2));
21103b705cfSriastradh	OUT_BATCH(0);
21203b705cfSriastradh	OUT_BATCH(0);
21303b705cfSriastradh	OUT_BATCH(0);
21403b705cfSriastradh	OUT_BATCH(0);
21503b705cfSriastradh	OUT_BATCH(0);
21603b705cfSriastradh	OUT_BATCH(0);
21703b705cfSriastradh
21803b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_GS | (7 - 2));
21903b705cfSriastradh	OUT_BATCH(0); /* without GS kernel */
22003b705cfSriastradh	OUT_BATCH(0);
22103b705cfSriastradh	OUT_BATCH(0);
22203b705cfSriastradh	OUT_BATCH(0);
22303b705cfSriastradh	OUT_BATCH(0);
22403b705cfSriastradh	OUT_BATCH(0); /* pass-through */
22503b705cfSriastradh
22603b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS | (2 - 2));
22703b705cfSriastradh	OUT_BATCH(0);
22803b705cfSriastradh
22903b705cfSriastradh	/* disable HS */
23003b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_CONSTANT_HS | (7 - 2));
23103b705cfSriastradh	OUT_BATCH(0);
23203b705cfSriastradh	OUT_BATCH(0);
23303b705cfSriastradh	OUT_BATCH(0);
23403b705cfSriastradh	OUT_BATCH(0);
23503b705cfSriastradh	OUT_BATCH(0);
23603b705cfSriastradh	OUT_BATCH(0);
23703b705cfSriastradh
23803b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_HS | (7 - 2));
23903b705cfSriastradh	OUT_BATCH(0);
24003b705cfSriastradh	OUT_BATCH(0);
24103b705cfSriastradh	OUT_BATCH(0);
24203b705cfSriastradh	OUT_BATCH(0);
24303b705cfSriastradh	OUT_BATCH(0);
24403b705cfSriastradh	OUT_BATCH(0);
24503b705cfSriastradh
24603b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS | (2 - 2));
24703b705cfSriastradh	OUT_BATCH(0);
24803b705cfSriastradh
24903b705cfSriastradh	/* Disable TE */
25003b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_TE | (4 - 2));
25103b705cfSriastradh	OUT_BATCH(0);
25203b705cfSriastradh	OUT_BATCH(0);
25303b705cfSriastradh	OUT_BATCH(0);
25403b705cfSriastradh
25503b705cfSriastradh	/* Disable DS */
25603b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_CONSTANT_DS | (7 - 2));
25703b705cfSriastradh	OUT_BATCH(0);
25803b705cfSriastradh	OUT_BATCH(0);
25903b705cfSriastradh	OUT_BATCH(0);
26003b705cfSriastradh	OUT_BATCH(0);
26103b705cfSriastradh	OUT_BATCH(0);
26203b705cfSriastradh	OUT_BATCH(0);
26303b705cfSriastradh
26403b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_DS | (6 - 2));
26503b705cfSriastradh	OUT_BATCH(0);
26603b705cfSriastradh	OUT_BATCH(0);
26703b705cfSriastradh	OUT_BATCH(0);
26803b705cfSriastradh	OUT_BATCH(0);
26903b705cfSriastradh	OUT_BATCH(0);
27003b705cfSriastradh
27103b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS | (2 - 2));
27203b705cfSriastradh	OUT_BATCH(0);
27303b705cfSriastradh
27403b705cfSriastradh	/* Disable STREAMOUT */
27503b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_STREAMOUT | (3 - 2));
27603b705cfSriastradh	OUT_BATCH(0);
27703b705cfSriastradh	OUT_BATCH(0);
27803b705cfSriastradh}
27903b705cfSriastradh
28003b705cfSriastradhvoid
28103b705cfSriastradhgen6_upload_vs_state(intel_screen_private *intel)
28203b705cfSriastradh{
28303b705cfSriastradh	Bool ivb = INTEL_INFO(intel)->gen >= 070;
28403b705cfSriastradh	/* disable VS constant buffer */
28503b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CONSTANT_VS | ((ivb ? 7 : 5) - 2));
28603b705cfSriastradh	OUT_BATCH(0);
28703b705cfSriastradh	OUT_BATCH(0);
28803b705cfSriastradh	OUT_BATCH(0);
28903b705cfSriastradh	OUT_BATCH(0);
29003b705cfSriastradh	if (ivb) {
29103b705cfSriastradh		OUT_BATCH(0);
29203b705cfSriastradh		OUT_BATCH(0);
29303b705cfSriastradh	}
29403b705cfSriastradh
29503b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_VS | (6 - 2));
29603b705cfSriastradh	OUT_BATCH(0); /* without VS kernel */
29703b705cfSriastradh	OUT_BATCH(0);
29803b705cfSriastradh	OUT_BATCH(0);
29903b705cfSriastradh	OUT_BATCH(0);
30003b705cfSriastradh	OUT_BATCH(0); /* pass-through */
30103b705cfSriastradh}
30203b705cfSriastradh
30303b705cfSriastradhvoid
30403b705cfSriastradhgen6_upload_gs_state(intel_screen_private *intel)
30503b705cfSriastradh{
30603b705cfSriastradh	/* disable GS constant buffer */
30703b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CONSTANT_GS | (5 - 2));
30803b705cfSriastradh	OUT_BATCH(0);
30903b705cfSriastradh	OUT_BATCH(0);
31003b705cfSriastradh	OUT_BATCH(0);
31103b705cfSriastradh	OUT_BATCH(0);
31203b705cfSriastradh
31303b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_GS | (7 - 2));
31403b705cfSriastradh	OUT_BATCH(0); /* without GS kernel */
31503b705cfSriastradh	OUT_BATCH(0);
31603b705cfSriastradh	OUT_BATCH(0);
31703b705cfSriastradh	OUT_BATCH(0);
31803b705cfSriastradh	OUT_BATCH(0);
31903b705cfSriastradh	OUT_BATCH(0); /* pass-through */
32003b705cfSriastradh}
32103b705cfSriastradh
32203b705cfSriastradhvoid
32303b705cfSriastradhgen6_upload_clip_state(intel_screen_private *intel)
32403b705cfSriastradh{
32503b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_CLIP | (4 - 2));
32603b705cfSriastradh	OUT_BATCH(0);
32703b705cfSriastradh	OUT_BATCH(0); /* pass-through */
32803b705cfSriastradh	OUT_BATCH(0);
32903b705cfSriastradh}
33003b705cfSriastradh
33103b705cfSriastradhvoid
33203b705cfSriastradhgen6_upload_sf_state(intel_screen_private *intel,
33303b705cfSriastradh		     int num_sf_outputs,
33403b705cfSriastradh		     int read_offset)
33503b705cfSriastradh{
33603b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SF | (20 - 2));
33703b705cfSriastradh	OUT_BATCH((num_sf_outputs << GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT) |
33803b705cfSriastradh		(1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT) |
33903b705cfSriastradh		(read_offset << GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT));
34003b705cfSriastradh	OUT_BATCH(0);
34103b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SF_CULL_NONE);
34203b705cfSriastradh	OUT_BATCH(2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT); /* DW4 */
34303b705cfSriastradh	OUT_BATCH(0);
34403b705cfSriastradh	OUT_BATCH(0);
34503b705cfSriastradh	OUT_BATCH(0);
34603b705cfSriastradh	OUT_BATCH(0);
34703b705cfSriastradh	OUT_BATCH(0); /* DW9 */
34803b705cfSriastradh	OUT_BATCH(0);
34903b705cfSriastradh	OUT_BATCH(0);
35003b705cfSriastradh	OUT_BATCH(0);
35103b705cfSriastradh	OUT_BATCH(0);
35203b705cfSriastradh	OUT_BATCH(0); /* DW14 */
35303b705cfSriastradh	OUT_BATCH(0);
35403b705cfSriastradh	OUT_BATCH(0);
35503b705cfSriastradh	OUT_BATCH(0);
35603b705cfSriastradh	OUT_BATCH(0);
35703b705cfSriastradh	OUT_BATCH(0); /* DW19 */
35803b705cfSriastradh}
35903b705cfSriastradh
36003b705cfSriastradhvoid
36103b705cfSriastradhgen7_upload_sf_state(intel_screen_private *intel,
36203b705cfSriastradh		     int num_sf_outputs,
36303b705cfSriastradh		     int read_offset)
36403b705cfSriastradh{
36503b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_SBE | (14 - 2));
36603b705cfSriastradh	OUT_BATCH((num_sf_outputs << GEN7_SBE_NUM_OUTPUTS_SHIFT) |
36703b705cfSriastradh		(1 << GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT) |
36803b705cfSriastradh		(read_offset << GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT));
36903b705cfSriastradh	OUT_BATCH(0);
37003b705cfSriastradh	OUT_BATCH(0);
37103b705cfSriastradh	OUT_BATCH(0); /* DW4 */
37203b705cfSriastradh	OUT_BATCH(0);
37303b705cfSriastradh	OUT_BATCH(0);
37403b705cfSriastradh	OUT_BATCH(0);
37503b705cfSriastradh	OUT_BATCH(0);
37603b705cfSriastradh	OUT_BATCH(0); /* DW9 */
37703b705cfSriastradh	OUT_BATCH(0);
37803b705cfSriastradh	OUT_BATCH(0);
37903b705cfSriastradh	OUT_BATCH(0);
38003b705cfSriastradh	OUT_BATCH(0);
38103b705cfSriastradh
38203b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SF | (7 - 2));
38303b705cfSriastradh	OUT_BATCH(0);
38403b705cfSriastradh	OUT_BATCH(GEN6_3DSTATE_SF_CULL_NONE);
38503b705cfSriastradh	OUT_BATCH(2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT);
38603b705cfSriastradh	OUT_BATCH(0);
38703b705cfSriastradh	OUT_BATCH(0);
38803b705cfSriastradh	OUT_BATCH(0);
38903b705cfSriastradh}
39003b705cfSriastradh
39103b705cfSriastradhvoid
39203b705cfSriastradhgen6_upload_binding_table(intel_screen_private *intel,
39303b705cfSriastradh			  uint32_t ps_binding_table_offset)
39403b705cfSriastradh{
39503b705cfSriastradh	/* Binding table pointers */
39603b705cfSriastradh	OUT_BATCH(BRW_3DSTATE_BINDING_TABLE_POINTERS |
39703b705cfSriastradh		  GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS |
39803b705cfSriastradh		  (4 - 2));
39903b705cfSriastradh	OUT_BATCH(0); /* VS */
40003b705cfSriastradh	OUT_BATCH(0); /* GS */
40103b705cfSriastradh	/* Only the PS uses the binding table */
40203b705cfSriastradh	OUT_BATCH(ps_binding_table_offset);
40303b705cfSriastradh}
40403b705cfSriastradh
40503b705cfSriastradhvoid
40603b705cfSriastradhgen7_upload_binding_table(intel_screen_private *intel,
40703b705cfSriastradh			  uint32_t ps_binding_table_offset)
40803b705cfSriastradh{
40903b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS | (2 - 2));
41003b705cfSriastradh	OUT_BATCH(ps_binding_table_offset);
41103b705cfSriastradh}
41203b705cfSriastradh
41303b705cfSriastradhvoid
41403b705cfSriastradhgen6_upload_depth_buffer_state(intel_screen_private *intel)
41503b705cfSriastradh{
41603b705cfSriastradh	OUT_BATCH(BRW_3DSTATE_DEPTH_BUFFER | (7 - 2));
41703b705cfSriastradh	OUT_BATCH((BRW_SURFACE_NULL << BRW_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT) |
41803b705cfSriastradh		  (BRW_DEPTHFORMAT_D32_FLOAT << BRW_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT));
41903b705cfSriastradh	OUT_BATCH(0);
42003b705cfSriastradh	OUT_BATCH(0);
42103b705cfSriastradh	OUT_BATCH(0);
42203b705cfSriastradh	OUT_BATCH(0);
42303b705cfSriastradh	OUT_BATCH(0);
42403b705cfSriastradh
42503b705cfSriastradh	OUT_BATCH(BRW_3DSTATE_CLEAR_PARAMS | (2 - 2));
42603b705cfSriastradh	OUT_BATCH(0);
42703b705cfSriastradh}
42803b705cfSriastradh
42903b705cfSriastradhvoid
43003b705cfSriastradhgen7_upload_depth_buffer_state(intel_screen_private *intel)
43103b705cfSriastradh{
43203b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER | (7 - 2));
43303b705cfSriastradh	OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) | (BRW_SURFACE_NULL << 29));
43403b705cfSriastradh	OUT_BATCH(0);
43503b705cfSriastradh	OUT_BATCH(0);
43603b705cfSriastradh	OUT_BATCH(0);
43703b705cfSriastradh	OUT_BATCH(0);
43803b705cfSriastradh	OUT_BATCH(0);
43903b705cfSriastradh
44003b705cfSriastradh	OUT_BATCH(GEN7_3DSTATE_CLEAR_PARAMS | (3 - 2));
44103b705cfSriastradh	OUT_BATCH(0);
44203b705cfSriastradh	OUT_BATCH(0);
44303b705cfSriastradh}
444