i965: Port Gen7+ 3DSTATE_SBE state to genxml.
[mesa.git] / src / mesa / drivers / dri / i965 / genX_state_upload.c
1 /*
2 * Copyright © 2017 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 #include <assert.h>
25
26 #include "common/gen_device_info.h"
27 #include "genxml/gen_macros.h"
28
29 #include "brw_context.h"
30 #include "brw_state.h"
31 #include "brw_util.h"
32
33 #include "intel_batchbuffer.h"
34 #include "intel_fbo.h"
35
36 #include "main/fbobject.h"
37 #include "main/framebuffer.h"
38 #include "main/stencil.h"
39
40 UNUSED static void *
41 emit_dwords(struct brw_context *brw, unsigned n)
42 {
43 intel_batchbuffer_begin(brw, n, RENDER_RING);
44 uint32_t *map = brw->batch.map_next;
45 brw->batch.map_next += n;
46 intel_batchbuffer_advance(brw);
47 return map;
48 }
49
50 struct brw_address {
51 struct brw_bo *bo;
52 uint32_t read_domains;
53 uint32_t write_domain;
54 uint32_t offset;
55 };
56
57 static uint64_t
58 emit_reloc(struct brw_context *brw,
59 void *location, struct brw_address address, uint32_t delta)
60 {
61 uint32_t offset = (char *) location - (char *) brw->batch.map;
62
63 return brw_emit_reloc(&brw->batch, offset, address.bo,
64 address.offset + delta,
65 address.read_domains,
66 address.write_domain);
67 }
68
69 #define __gen_address_type struct brw_address
70 #define __gen_user_data struct brw_context
71
72 static uint64_t
73 __gen_combine_address(struct brw_context *brw, void *location,
74 struct brw_address address, uint32_t delta)
75 {
76 if (address.bo == NULL) {
77 return address.offset + delta;
78 } else {
79 return emit_reloc(brw, location, address, delta);
80 }
81 }
82
83 #include "genxml/genX_pack.h"
84
85 #define _brw_cmd_length(cmd) cmd ## _length
86 #define _brw_cmd_length_bias(cmd) cmd ## _length_bias
87 #define _brw_cmd_header(cmd) cmd ## _header
88 #define _brw_cmd_pack(cmd) cmd ## _pack
89
90 #define brw_batch_emit(brw, cmd, name) \
91 for (struct cmd name = { _brw_cmd_header(cmd) }, \
92 *_dst = emit_dwords(brw, _brw_cmd_length(cmd)); \
93 __builtin_expect(_dst != NULL, 1); \
94 _brw_cmd_pack(cmd)(brw, (void *)_dst, &name), \
95 _dst = NULL)
96
97 #define brw_batch_emitn(brw, cmd, n) ({ \
98 uint32_t *_dw = emit_dwords(brw, n); \
99 struct cmd template = { \
100 _brw_cmd_header(cmd), \
101 .DWordLength = n - _brw_cmd_length_bias(cmd), \
102 }; \
103 _brw_cmd_pack(cmd)(brw, _dw, &template); \
104 _dw + 1; /* Array starts at dw[1] */ \
105 })
106
107 #define brw_state_emit(brw, cmd, align, offset, name) \
108 for (struct cmd name = { 0, }, \
109 *_dst = brw_state_batch(brw, _brw_cmd_length(cmd) * 4, \
110 align, offset); \
111 __builtin_expect(_dst != NULL, 1); \
112 _brw_cmd_pack(cmd)(brw, (void *)_dst, &name), \
113 _dst = NULL)
114
115 #if GEN_GEN >= 6
116 /**
117 * Determine the appropriate attribute override value to store into the
118 * 3DSTATE_SF structure for a given fragment shader attribute. The attribute
119 * override value contains two pieces of information: the location of the
120 * attribute in the VUE (relative to urb_entry_read_offset, see below), and a
121 * flag indicating whether to "swizzle" the attribute based on the direction
122 * the triangle is facing.
123 *
124 * If an attribute is "swizzled", then the given VUE location is used for
125 * front-facing triangles, and the VUE location that immediately follows is
126 * used for back-facing triangles. We use this to implement the mapping from
127 * gl_FrontColor/gl_BackColor to gl_Color.
128 *
129 * urb_entry_read_offset is the offset into the VUE at which the SF unit is
130 * being instructed to begin reading attribute data. It can be set to a
131 * nonzero value to prevent the SF unit from wasting time reading elements of
132 * the VUE that are not needed by the fragment shader. It is measured in
133 * 256-bit increments.
134 */
135 static void
136 genX(get_attr_override)(struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) *attr,
137 const struct brw_vue_map *vue_map,
138 int urb_entry_read_offset, int fs_attr,
139 bool two_side_color, uint32_t *max_source_attr)
140 {
141 /* Find the VUE slot for this attribute. */
142 int slot = vue_map->varying_to_slot[fs_attr];
143
144 /* Viewport and Layer are stored in the VUE header. We need to override
145 * them to zero if earlier stages didn't write them, as GL requires that
146 * they read back as zero when not explicitly set.
147 */
148 if (fs_attr == VARYING_SLOT_VIEWPORT || fs_attr == VARYING_SLOT_LAYER) {
149 attr->ComponentOverrideX = true;
150 attr->ComponentOverrideW = true;
151 attr->ConstantSource = CONST_0000;
152
153 if (!(vue_map->slots_valid & VARYING_BIT_LAYER))
154 attr->ComponentOverrideY = true;
155 if (!(vue_map->slots_valid & VARYING_BIT_VIEWPORT))
156 attr->ComponentOverrideZ = true;
157
158 return;
159 }
160
161 /* If there was only a back color written but not front, use back
162 * as the color instead of undefined
163 */
164 if (slot == -1 && fs_attr == VARYING_SLOT_COL0)
165 slot = vue_map->varying_to_slot[VARYING_SLOT_BFC0];
166 if (slot == -1 && fs_attr == VARYING_SLOT_COL1)
167 slot = vue_map->varying_to_slot[VARYING_SLOT_BFC1];
168
169 if (slot == -1) {
170 /* This attribute does not exist in the VUE--that means that the vertex
171 * shader did not write to it. This means that either:
172 *
173 * (a) This attribute is a texture coordinate, and it is going to be
174 * replaced with point coordinates (as a consequence of a call to
175 * glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)), so the
176 * hardware will ignore whatever attribute override we supply.
177 *
178 * (b) This attribute is read by the fragment shader but not written by
179 * the vertex shader, so its value is undefined. Therefore the
180 * attribute override we supply doesn't matter.
181 *
182 * (c) This attribute is gl_PrimitiveID, and it wasn't written by the
183 * previous shader stage.
184 *
185 * Note that we don't have to worry about the cases where the attribute
186 * is gl_PointCoord or is undergoing point sprite coordinate
187 * replacement, because in those cases, this function isn't called.
188 *
189 * In case (c), we need to program the attribute overrides so that the
190 * primitive ID will be stored in this slot. In every other case, the
191 * attribute override we supply doesn't matter. So just go ahead and
192 * program primitive ID in every case.
193 */
194 attr->ComponentOverrideW = true;
195 attr->ComponentOverrideX = true;
196 attr->ComponentOverrideY = true;
197 attr->ComponentOverrideZ = true;
198 attr->ConstantSource = PRIM_ID;
199 return;
200 }
201
202 /* Compute the location of the attribute relative to urb_entry_read_offset.
203 * Each increment of urb_entry_read_offset represents a 256-bit value, so
204 * it counts for two 128-bit VUE slots.
205 */
206 int source_attr = slot - 2 * urb_entry_read_offset;
207 assert(source_attr >= 0 && source_attr < 32);
208
209 /* If we are doing two-sided color, and the VUE slot following this one
210 * represents a back-facing color, then we need to instruct the SF unit to
211 * do back-facing swizzling.
212 */
213 bool swizzling = two_side_color &&
214 ((vue_map->slot_to_varying[slot] == VARYING_SLOT_COL0 &&
215 vue_map->slot_to_varying[slot+1] == VARYING_SLOT_BFC0) ||
216 (vue_map->slot_to_varying[slot] == VARYING_SLOT_COL1 &&
217 vue_map->slot_to_varying[slot+1] == VARYING_SLOT_BFC1));
218
219 /* Update max_source_attr. If swizzling, the SF will read this slot + 1. */
220 if (*max_source_attr < source_attr + swizzling)
221 *max_source_attr = source_attr + swizzling;
222
223 attr->SourceAttribute = source_attr;
224 if (swizzling)
225 attr->SwizzleSelect = INPUTATTR_FACING;
226 }
227
228
229 static void
230 genX(calculate_attr_overrides)(const struct brw_context *brw,
231 struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) *attr_overrides,
232 uint32_t *point_sprite_enables,
233 uint32_t *urb_entry_read_length,
234 uint32_t *urb_entry_read_offset)
235 {
236 const struct gl_context *ctx = &brw->ctx;
237
238 /* _NEW_POINT */
239 const struct gl_point_attrib *point = &ctx->Point;
240
241 /* BRW_NEW_FS_PROG_DATA */
242 const struct brw_wm_prog_data *wm_prog_data =
243 brw_wm_prog_data(brw->wm.base.prog_data);
244 uint32_t max_source_attr = 0;
245
246 *point_sprite_enables = 0;
247
248 /* BRW_NEW_FRAGMENT_PROGRAM
249 *
250 * If the fragment shader reads VARYING_SLOT_LAYER, then we need to pass in
251 * the full vertex header. Otherwise, we can program the SF to start
252 * reading at an offset of 1 (2 varying slots) to skip unnecessary data:
253 * - VARYING_SLOT_PSIZ and BRW_VARYING_SLOT_NDC on gen4-5
254 * - VARYING_SLOT_{PSIZ,LAYER} and VARYING_SLOT_POS on gen6+
255 */
256
257 bool fs_needs_vue_header = brw->fragment_program->info.inputs_read &
258 (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT);
259
260 *urb_entry_read_offset = fs_needs_vue_header ? 0 : 1;
261
262 /* From the Ivybridge PRM, Vol 2 Part 1, 3DSTATE_SBE,
263 * description of dw10 Point Sprite Texture Coordinate Enable:
264 *
265 * "This field must be programmed to zero when non-point primitives
266 * are rendered."
267 *
268 * The SandyBridge PRM doesn't explicitly say that point sprite enables
269 * must be programmed to zero when rendering non-point primitives, but
270 * the IvyBridge PRM does, and if we don't, we get garbage.
271 *
272 * This is not required on Haswell, as the hardware ignores this state
273 * when drawing non-points -- although we do still need to be careful to
274 * correctly set the attr overrides.
275 *
276 * _NEW_POLYGON
277 * BRW_NEW_PRIMITIVE | BRW_NEW_GS_PROG_DATA | BRW_NEW_TES_PROG_DATA
278 */
279 bool drawing_points = brw_is_drawing_points(brw);
280
281 for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
282 int input_index = wm_prog_data->urb_setup[attr];
283
284 if (input_index < 0)
285 continue;
286
287 /* _NEW_POINT */
288 bool point_sprite = false;
289 if (drawing_points) {
290 if (point->PointSprite &&
291 (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) &&
292 (point->CoordReplace & (1u << (attr - VARYING_SLOT_TEX0)))) {
293 point_sprite = true;
294 }
295
296 if (attr == VARYING_SLOT_PNTC)
297 point_sprite = true;
298
299 if (point_sprite)
300 *point_sprite_enables |= (1 << input_index);
301 }
302
303 /* BRW_NEW_VUE_MAP_GEOM_OUT | _NEW_LIGHT | _NEW_PROGRAM */
304 struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) attribute = { 0 };
305
306 if (!point_sprite) {
307 genX(get_attr_override)(&attribute,
308 &brw->vue_map_geom_out,
309 *urb_entry_read_offset, attr,
310 brw->ctx.VertexProgram._TwoSideEnabled,
311 &max_source_attr);
312 }
313
314 /* The hardware can only do the overrides on 16 overrides at a
315 * time, and the other up to 16 have to be lined up so that the
316 * input index = the output index. We'll need to do some
317 * tweaking to make sure that's the case.
318 */
319 if (input_index < 16)
320 attr_overrides[input_index] = attribute;
321 else
322 assert(attribute.SourceAttribute == input_index);
323 }
324
325 /* From the Sandy Bridge PRM, Volume 2, Part 1, documentation for
326 * 3DSTATE_SF DWord 1 bits 15:11, "Vertex URB Entry Read Length":
327 *
328 * "This field should be set to the minimum length required to read the
329 * maximum source attribute. The maximum source attribute is indicated
330 * by the maximum value of the enabled Attribute # Source Attribute if
331 * Attribute Swizzle Enable is set, Number of Output Attributes-1 if
332 * enable is not set.
333 * read_length = ceiling((max_source_attr + 1) / 2)
334 *
335 * [errata] Corruption/Hang possible if length programmed larger than
336 * recommended"
337 *
338 * Similar text exists for Ivy Bridge.
339 */
340 *urb_entry_read_length = DIV_ROUND_UP(max_source_attr + 1, 2);
341 }
342
343 /* ---------------------------------------------------------------------- */
344
345 static void
346 genX(upload_depth_stencil_state)(struct brw_context *brw)
347 {
348 struct gl_context *ctx = &brw->ctx;
349
350 /* _NEW_BUFFERS */
351 struct intel_renderbuffer *depth_irb =
352 intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
353
354 /* _NEW_DEPTH */
355 struct gl_depthbuffer_attrib *depth = &ctx->Depth;
356
357 /* _NEW_STENCIL */
358 struct gl_stencil_attrib *stencil = &ctx->Stencil;
359 const int b = stencil->_BackFace;
360
361 #if GEN_GEN >= 8
362 brw_batch_emit(brw, GENX(3DSTATE_WM_DEPTH_STENCIL), wmds) {
363 #else
364 uint32_t ds_offset;
365 brw_state_emit(brw, GENX(DEPTH_STENCIL_STATE), 64, &ds_offset, wmds) {
366 #endif
367 if (depth->Test && depth_irb) {
368 wmds.DepthTestEnable = true;
369 wmds.DepthBufferWriteEnable = brw_depth_writes_enabled(brw);
370 wmds.DepthTestFunction = intel_translate_compare_func(depth->Func);
371 }
372
373 if (stencil->_Enabled) {
374 wmds.StencilTestEnable = true;
375 wmds.StencilWriteMask = stencil->WriteMask[0] & 0xff;
376 wmds.StencilTestMask = stencil->ValueMask[0] & 0xff;
377
378 wmds.StencilTestFunction =
379 intel_translate_compare_func(stencil->Function[0]);
380 wmds.StencilFailOp =
381 intel_translate_stencil_op(stencil->FailFunc[0]);
382 wmds.StencilPassDepthPassOp =
383 intel_translate_stencil_op(stencil->ZPassFunc[0]);
384 wmds.StencilPassDepthFailOp =
385 intel_translate_stencil_op(stencil->ZFailFunc[0]);
386
387 wmds.StencilBufferWriteEnable = stencil->_WriteEnabled;
388
389 if (stencil->_TestTwoSide) {
390 wmds.DoubleSidedStencilEnable = true;
391 wmds.BackfaceStencilWriteMask = stencil->WriteMask[b] & 0xff;
392 wmds.BackfaceStencilTestMask = stencil->ValueMask[b] & 0xff;
393
394 wmds.BackfaceStencilTestFunction =
395 intel_translate_compare_func(stencil->Function[b]);
396 wmds.BackfaceStencilFailOp =
397 intel_translate_stencil_op(stencil->FailFunc[b]);
398 wmds.BackfaceStencilPassDepthPassOp =
399 intel_translate_stencil_op(stencil->ZPassFunc[b]);
400 wmds.BackfaceStencilPassDepthFailOp =
401 intel_translate_stencil_op(stencil->ZFailFunc[b]);
402 }
403
404 #if GEN_GEN >= 9
405 wmds.StencilReferenceValue = _mesa_get_stencil_ref(ctx, 0);
406 wmds.BackfaceStencilReferenceValue = _mesa_get_stencil_ref(ctx, b);
407 #endif
408 }
409 }
410
411 #if GEN_GEN == 6
412 brw_batch_emit(brw, GENX(3DSTATE_CC_STATE_POINTERS), ptr) {
413 ptr.PointertoDEPTH_STENCIL_STATE = ds_offset;
414 ptr.DEPTH_STENCIL_STATEChange = true;
415 }
416 #elif GEN_GEN == 7
417 brw_batch_emit(brw, GENX(3DSTATE_DEPTH_STENCIL_STATE_POINTERS), ptr) {
418 ptr.PointertoDEPTH_STENCIL_STATE = ds_offset;
419 }
420 #endif
421 }
422
423 static const struct brw_tracked_state genX(depth_stencil_state) = {
424 .dirty = {
425 .mesa = _NEW_BUFFERS |
426 _NEW_DEPTH |
427 _NEW_STENCIL,
428 .brw = BRW_NEW_BLORP |
429 (GEN_GEN >= 8 ? BRW_NEW_CONTEXT
430 : BRW_NEW_BATCH |
431 BRW_NEW_STATE_BASE_ADDRESS),
432 },
433 .emit = genX(upload_depth_stencil_state),
434 };
435
436 /* ---------------------------------------------------------------------- */
437
438 static void
439 genX(upload_clip_state)(struct brw_context *brw)
440 {
441 struct gl_context *ctx = &brw->ctx;
442
443 /* _NEW_BUFFERS */
444 struct gl_framebuffer *fb = ctx->DrawBuffer;
445
446 /* BRW_NEW_FS_PROG_DATA */
447 struct brw_wm_prog_data *wm_prog_data =
448 brw_wm_prog_data(brw->wm.base.prog_data);
449
450 brw_batch_emit(brw, GENX(3DSTATE_CLIP), clip) {
451 clip.StatisticsEnable = !brw->meta_in_progress;
452
453 if (wm_prog_data->barycentric_interp_modes &
454 BRW_BARYCENTRIC_NONPERSPECTIVE_BITS)
455 clip.NonPerspectiveBarycentricEnable = true;
456
457 #if GEN_GEN >= 7
458 clip.EarlyCullEnable = true;
459 #endif
460
461 #if GEN_GEN == 7
462 clip.FrontWinding = ctx->Polygon._FrontBit == _mesa_is_user_fbo(fb);
463
464 if (ctx->Polygon.CullFlag) {
465 switch (ctx->Polygon.CullFaceMode) {
466 case GL_FRONT:
467 clip.CullMode = CULLMODE_FRONT;
468 break;
469 case GL_BACK:
470 clip.CullMode = CULLMODE_BACK;
471 break;
472 case GL_FRONT_AND_BACK:
473 clip.CullMode = CULLMODE_BOTH;
474 break;
475 default:
476 unreachable("Should not get here: invalid CullFlag");
477 }
478 } else {
479 clip.CullMode = CULLMODE_NONE;
480 }
481 #endif
482
483 #if GEN_GEN < 8
484 clip.UserClipDistanceCullTestEnableBitmask =
485 brw_vue_prog_data(brw->vs.base.prog_data)->cull_distance_mask;
486
487 clip.ViewportZClipTestEnable = !ctx->Transform.DepthClamp;
488 #endif
489
490 /* _NEW_LIGHT */
491 if (ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
492 clip.TriangleStripListProvokingVertexSelect = 0;
493 clip.TriangleFanProvokingVertexSelect = 1;
494 clip.LineStripListProvokingVertexSelect = 0;
495 } else {
496 clip.TriangleStripListProvokingVertexSelect = 2;
497 clip.TriangleFanProvokingVertexSelect = 2;
498 clip.LineStripListProvokingVertexSelect = 1;
499 }
500
501 /* _NEW_TRANSFORM */
502 clip.UserClipDistanceClipTestEnableBitmask =
503 ctx->Transform.ClipPlanesEnabled;
504
505 #if GEN_GEN >= 8
506 clip.ForceUserClipDistanceClipTestEnableBitmask = true;
507 #endif
508
509 if (ctx->Transform.ClipDepthMode == GL_ZERO_TO_ONE)
510 clip.APIMode = APIMODE_D3D;
511 else
512 clip.APIMode = APIMODE_OGL;
513
514 clip.GuardbandClipTestEnable = true;
515
516 /* BRW_NEW_VIEWPORT_COUNT */
517 const unsigned viewport_count = brw->clip.viewport_count;
518
519 if (ctx->RasterDiscard) {
520 clip.ClipMode = CLIPMODE_REJECT_ALL;
521 #if GEN_GEN == 6
522 perf_debug("Rasterizer discard is currently implemented via the "
523 "clipper; having the GS not write primitives would "
524 "likely be faster.\n");
525 #endif
526 } else {
527 clip.ClipMode = CLIPMODE_NORMAL;
528 }
529
530 clip.ClipEnable = brw->primitive != _3DPRIM_RECTLIST;
531
532 /* _NEW_POLYGON,
533 * BRW_NEW_GEOMETRY_PROGRAM | BRW_NEW_TES_PROG_DATA | BRW_NEW_PRIMITIVE
534 */
535 if (!brw_is_drawing_points(brw) && !brw_is_drawing_lines(brw))
536 clip.ViewportXYClipTestEnable = true;
537
538 clip.MinimumPointWidth = 0.125;
539 clip.MaximumPointWidth = 255.875;
540 clip.MaximumVPIndex = viewport_count - 1;
541 if (_mesa_geometric_layers(fb) == 0)
542 clip.ForceZeroRTAIndexEnable = true;
543 }
544 }
545
546 static const struct brw_tracked_state genX(clip_state) = {
547 .dirty = {
548 .mesa = _NEW_BUFFERS |
549 _NEW_LIGHT |
550 _NEW_POLYGON |
551 _NEW_TRANSFORM,
552 .brw = BRW_NEW_BLORP |
553 BRW_NEW_CONTEXT |
554 BRW_NEW_FS_PROG_DATA |
555 BRW_NEW_GS_PROG_DATA |
556 BRW_NEW_VS_PROG_DATA |
557 BRW_NEW_META_IN_PROGRESS |
558 BRW_NEW_PRIMITIVE |
559 BRW_NEW_RASTERIZER_DISCARD |
560 BRW_NEW_TES_PROG_DATA |
561 BRW_NEW_VIEWPORT_COUNT,
562 },
563 .emit = genX(upload_clip_state),
564 };
565
566 /* ---------------------------------------------------------------------- */
567
568 static void
569 genX(upload_sf)(struct brw_context *brw)
570 {
571 struct gl_context *ctx = &brw->ctx;
572 float point_size;
573
574 #if GEN_GEN <= 7
575 /* _NEW_BUFFERS */
576 bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
577 const bool multisampled_fbo = _mesa_geometric_samples(ctx->DrawBuffer) > 1;
578 #endif
579
580 brw_batch_emit(brw, GENX(3DSTATE_SF), sf) {
581 sf.StatisticsEnable = true;
582 sf.ViewportTransformEnable = brw->sf.viewport_transform_enable;
583
584 #if GEN_GEN == 7
585 /* _NEW_BUFFERS */
586 sf.DepthBufferSurfaceFormat = brw_depthbuffer_format(brw);
587 #endif
588
589 #if GEN_GEN <= 7
590 /* _NEW_POLYGON */
591 sf.FrontWinding = ctx->Polygon._FrontBit == render_to_fbo;
592 sf.GlobalDepthOffsetEnableSolid = ctx->Polygon.OffsetFill;
593 sf.GlobalDepthOffsetEnableWireframe = ctx->Polygon.OffsetLine;
594 sf.GlobalDepthOffsetEnablePoint = ctx->Polygon.OffsetPoint;
595
596 switch (ctx->Polygon.FrontMode) {
597 case GL_FILL:
598 sf.FrontFaceFillMode = FILL_MODE_SOLID;
599 break;
600 case GL_LINE:
601 sf.FrontFaceFillMode = FILL_MODE_WIREFRAME;
602 break;
603 case GL_POINT:
604 sf.FrontFaceFillMode = FILL_MODE_POINT;
605 break;
606 default:
607 unreachable("not reached");
608 }
609
610 switch (ctx->Polygon.BackMode) {
611 case GL_FILL:
612 sf.BackFaceFillMode = FILL_MODE_SOLID;
613 break;
614 case GL_LINE:
615 sf.BackFaceFillMode = FILL_MODE_WIREFRAME;
616 break;
617 case GL_POINT:
618 sf.BackFaceFillMode = FILL_MODE_POINT;
619 break;
620 default:
621 unreachable("not reached");
622 }
623
624 sf.ScissorRectangleEnable = true;
625
626 if (ctx->Polygon.CullFlag) {
627 switch (ctx->Polygon.CullFaceMode) {
628 case GL_FRONT:
629 sf.CullMode = CULLMODE_FRONT;
630 break;
631 case GL_BACK:
632 sf.CullMode = CULLMODE_BACK;
633 break;
634 case GL_FRONT_AND_BACK:
635 sf.CullMode = CULLMODE_BOTH;
636 break;
637 default:
638 unreachable("not reached");
639 }
640 } else {
641 sf.CullMode = CULLMODE_NONE;
642 }
643
644 #if GEN_IS_HASWELL
645 sf.LineStippleEnable = ctx->Line.StippleFlag;
646 #endif
647
648 if (multisampled_fbo && ctx->Multisample.Enabled)
649 sf.MultisampleRasterizationMode = MSRASTMODE_ON_PATTERN;
650
651 sf.GlobalDepthOffsetConstant = ctx->Polygon.OffsetUnits * 2;
652 sf.GlobalDepthOffsetScale = ctx->Polygon.OffsetFactor;
653 sf.GlobalDepthOffsetClamp = ctx->Polygon.OffsetClamp;
654 #endif
655
656 /* _NEW_LINE */
657 sf.LineWidth = brw_get_line_width_float(brw);
658
659 if (ctx->Line.SmoothFlag) {
660 sf.LineEndCapAntialiasingRegionWidth = _10pixels;
661 #if GEN_GEN <= 7
662 sf.AntiAliasingEnable = true;
663 #endif
664 }
665
666 /* _NEW_POINT - Clamp to ARB_point_parameters user limits */
667 point_size = CLAMP(ctx->Point.Size, ctx->Point.MinSize, ctx->Point.MaxSize);
668 /* Clamp to the hardware limits */
669 sf.PointWidth = CLAMP(point_size, 0.125f, 255.875f);
670
671 /* _NEW_PROGRAM | _NEW_POINT, BRW_NEW_VUE_MAP_GEOM_OUT */
672 if (use_state_point_size(brw))
673 sf.PointWidthSource = State;
674
675 #if GEN_GEN >= 8
676 /* _NEW_POINT | _NEW_MULTISAMPLE */
677 if ((ctx->Point.SmoothFlag || _mesa_is_multisample_enabled(ctx)) &&
678 !ctx->Point.PointSprite)
679 sf.SmoothPointEnable = true;
680 #endif
681
682 sf.AALineDistanceMode = AALINEDISTANCE_TRUE;
683
684 /* _NEW_LIGHT */
685 if (ctx->Light.ProvokingVertex != GL_FIRST_VERTEX_CONVENTION) {
686 sf.TriangleStripListProvokingVertexSelect = 2;
687 sf.TriangleFanProvokingVertexSelect = 2;
688 sf.LineStripListProvokingVertexSelect = 1;
689 } else {
690 sf.TriangleFanProvokingVertexSelect = 1;
691 }
692
693 #if GEN_GEN == 6
694 /* BRW_NEW_FS_PROG_DATA */
695 const struct brw_wm_prog_data *wm_prog_data =
696 brw_wm_prog_data(brw->wm.base.prog_data);
697
698 sf.AttributeSwizzleEnable = true;
699 sf.NumberofSFOutputAttributes = wm_prog_data->num_varying_inputs;
700
701 /*
702 * Window coordinates in an FBO are inverted, which means point
703 * sprite origin must be inverted, too.
704 */
705 if ((ctx->Point.SpriteOrigin == GL_LOWER_LEFT) != render_to_fbo) {
706 sf.PointSpriteTextureCoordinateOrigin = LOWERLEFT;
707 } else {
708 sf.PointSpriteTextureCoordinateOrigin = UPPERLEFT;
709 }
710
711 /* BRW_NEW_VUE_MAP_GEOM_OUT | BRW_NEW_FRAGMENT_PROGRAM |
712 * _NEW_POINT | _NEW_LIGHT | _NEW_PROGRAM | BRW_NEW_FS_PROG_DATA
713 */
714 uint32_t urb_entry_read_length;
715 uint32_t urb_entry_read_offset;
716 uint32_t point_sprite_enables;
717 genX(calculate_attr_overrides)(brw, sf.Attribute, &point_sprite_enables,
718 &urb_entry_read_length,
719 &urb_entry_read_offset);
720 sf.VertexURBEntryReadLength = urb_entry_read_length;
721 sf.VertexURBEntryReadOffset = urb_entry_read_offset;
722 sf.PointSpriteTextureCoordinateEnable = point_sprite_enables;
723 sf.ConstantInterpolationEnable = wm_prog_data->flat_inputs;
724 #endif
725 }
726 }
727
728 static const struct brw_tracked_state genX(sf_state) = {
729 .dirty = {
730 .mesa = _NEW_LIGHT |
731 _NEW_LINE |
732 _NEW_MULTISAMPLE |
733 _NEW_POINT |
734 _NEW_PROGRAM |
735 (GEN_GEN <= 7 ? _NEW_BUFFERS | _NEW_POLYGON : 0),
736 .brw = BRW_NEW_BLORP |
737 BRW_NEW_CONTEXT |
738 BRW_NEW_VUE_MAP_GEOM_OUT |
739 (GEN_GEN <= 7 ? BRW_NEW_GS_PROG_DATA |
740 BRW_NEW_PRIMITIVE |
741 BRW_NEW_TES_PROG_DATA
742 : 0) |
743 (GEN_GEN == 6 ? BRW_NEW_FS_PROG_DATA |
744 BRW_NEW_FRAGMENT_PROGRAM
745 : 0),
746 },
747 .emit = genX(upload_sf),
748 };
749
750 #endif
751
752 /* ---------------------------------------------------------------------- */
753
754 #if GEN_GEN >= 7
755 static void
756 genX(upload_sbe)(struct brw_context *brw)
757 {
758 struct gl_context *ctx = &brw->ctx;
759 /* BRW_NEW_FS_PROG_DATA */
760 const struct brw_wm_prog_data *wm_prog_data =
761 brw_wm_prog_data(brw->wm.base.prog_data);
762 #if GEN_GEN >= 8
763 struct GENX(SF_OUTPUT_ATTRIBUTE_DETAIL) attr_overrides[16] = { { 0 } };
764 #else
765 #define attr_overrides sbe.Attribute
766 #endif
767 uint32_t urb_entry_read_length;
768 uint32_t urb_entry_read_offset;
769 uint32_t point_sprite_enables;
770
771 brw_batch_emit(brw, GENX(3DSTATE_SBE), sbe) {
772 sbe.AttributeSwizzleEnable = true;
773 sbe.NumberofSFOutputAttributes = wm_prog_data->num_varying_inputs;
774
775 /* _NEW_BUFFERS */
776 bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
777
778 /* _NEW_POINT
779 *
780 * Window coordinates in an FBO are inverted, which means point
781 * sprite origin must be inverted.
782 */
783 if ((ctx->Point.SpriteOrigin == GL_LOWER_LEFT) != render_to_fbo)
784 sbe.PointSpriteTextureCoordinateOrigin = LOWERLEFT;
785 else
786 sbe.PointSpriteTextureCoordinateOrigin = UPPERLEFT;
787
788 /* _NEW_POINT | _NEW_LIGHT | _NEW_PROGRAM,
789 * BRW_NEW_FS_PROG_DATA | BRW_NEW_FRAGMENT_PROGRAM |
790 * BRW_NEW_GS_PROG_DATA | BRW_NEW_PRIMITIVE | BRW_NEW_TES_PROG_DATA |
791 * BRW_NEW_VUE_MAP_GEOM_OUT
792 */
793 genX(calculate_attr_overrides)(brw,
794 attr_overrides,
795 &point_sprite_enables,
796 &urb_entry_read_length,
797 &urb_entry_read_offset);
798
799 /* Typically, the URB entry read length and offset should be programmed
800 * in 3DSTATE_VS and 3DSTATE_GS; SBE inherits it from the last active
801 * stage which produces geometry. However, we don't know the proper
802 * value until we call calculate_attr_overrides().
803 *
804 * To fit with our existing code, we override the inherited values and
805 * specify it here directly, as we did on previous generations.
806 */
807 sbe.VertexURBEntryReadLength = urb_entry_read_length;
808 sbe.VertexURBEntryReadOffset = urb_entry_read_offset;
809 sbe.PointSpriteTextureCoordinateEnable = point_sprite_enables;
810 sbe.ConstantInterpolationEnable = wm_prog_data->flat_inputs;
811
812 #if GEN_GEN >= 8
813 sbe.ForceVertexURBEntryReadLength = true;
814 sbe.ForceVertexURBEntryReadOffset = true;
815 #endif
816
817 #if GEN_GEN >= 9
818 /* prepare the active component dwords */
819 int input_index = 0;
820 for (int attr = 0; attr < VARYING_SLOT_MAX; attr++) {
821 if (!(brw->fragment_program->info.inputs_read &
822 BITFIELD64_BIT(attr))) {
823 continue;
824 }
825
826 assert(input_index < 32);
827
828 sbe.AttributeActiveComponentFormat[input_index] = ACTIVE_COMPONENT_XYZW;
829 ++input_index;
830 }
831 #endif
832 }
833
834 #if GEN_GEN >= 8
835 brw_batch_emit(brw, GENX(3DSTATE_SBE_SWIZ), sbes) {
836 for (int i = 0; i < 16; i++)
837 sbes.Attribute[i] = attr_overrides[i];
838 }
839 #endif
840
841 #undef attr_overrides
842 }
843
844 static const struct brw_tracked_state genX(sbe_state) = {
845 .dirty = {
846 .mesa = _NEW_BUFFERS |
847 _NEW_LIGHT |
848 _NEW_POINT |
849 _NEW_POLYGON |
850 _NEW_PROGRAM,
851 .brw = BRW_NEW_BLORP |
852 BRW_NEW_CONTEXT |
853 BRW_NEW_FRAGMENT_PROGRAM |
854 BRW_NEW_FS_PROG_DATA |
855 BRW_NEW_GS_PROG_DATA |
856 BRW_NEW_TES_PROG_DATA |
857 BRW_NEW_VUE_MAP_GEOM_OUT |
858 (GEN_GEN == 7 ? BRW_NEW_PRIMITIVE
859 : 0),
860 },
861 .emit = genX(upload_sbe),
862 };
863 #endif
864
865 /* ---------------------------------------------------------------------- */
866
867 #if GEN_GEN >= 8
868 static void
869 genX(upload_raster)(struct brw_context *brw)
870 {
871 struct gl_context *ctx = &brw->ctx;
872
873 /* _NEW_BUFFERS */
874 bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
875
876 /* _NEW_POLYGON */
877 struct gl_polygon_attrib *polygon = &ctx->Polygon;
878
879 /* _NEW_POINT */
880 struct gl_point_attrib *point = &ctx->Point;
881
882 brw_batch_emit(brw, GENX(3DSTATE_RASTER), raster) {
883 if (polygon->_FrontBit == render_to_fbo)
884 raster.FrontWinding = CounterClockwise;
885
886 if (polygon->CullFlag) {
887 switch (polygon->CullFaceMode) {
888 case GL_FRONT:
889 raster.CullMode = CULLMODE_FRONT;
890 break;
891 case GL_BACK:
892 raster.CullMode = CULLMODE_BACK;
893 break;
894 case GL_FRONT_AND_BACK:
895 raster.CullMode = CULLMODE_BOTH;
896 break;
897 default:
898 unreachable("not reached");
899 }
900 } else {
901 raster.CullMode = CULLMODE_NONE;
902 }
903
904 point->SmoothFlag = raster.SmoothPointEnable;
905
906 raster.DXMultisampleRasterizationEnable =
907 _mesa_is_multisample_enabled(ctx);
908
909 raster.GlobalDepthOffsetEnableSolid = polygon->OffsetFill;
910 raster.GlobalDepthOffsetEnableWireframe = polygon->OffsetLine;
911 raster.GlobalDepthOffsetEnablePoint = polygon->OffsetPoint;
912
913 switch (polygon->FrontMode) {
914 case GL_FILL:
915 raster.FrontFaceFillMode = FILL_MODE_SOLID;
916 break;
917 case GL_LINE:
918 raster.FrontFaceFillMode = FILL_MODE_WIREFRAME;
919 break;
920 case GL_POINT:
921 raster.FrontFaceFillMode = FILL_MODE_POINT;
922 break;
923 default:
924 unreachable("not reached");
925 }
926
927 switch (polygon->BackMode) {
928 case GL_FILL:
929 raster.BackFaceFillMode = FILL_MODE_SOLID;
930 break;
931 case GL_LINE:
932 raster.BackFaceFillMode = FILL_MODE_WIREFRAME;
933 break;
934 case GL_POINT:
935 raster.BackFaceFillMode = FILL_MODE_POINT;
936 break;
937 default:
938 unreachable("not reached");
939 }
940
941 /* _NEW_LINE */
942 raster.AntialiasingEnable = ctx->Line.SmoothFlag;
943
944 /* _NEW_SCISSOR */
945 raster.ScissorRectangleEnable = ctx->Scissor.EnableFlags;
946
947 /* _NEW_TRANSFORM */
948 if (!ctx->Transform.DepthClamp) {
949 #if GEN_GEN >= 9
950 raster.ViewportZFarClipTestEnable = true;
951 raster.ViewportZNearClipTestEnable = true;
952 #else
953 raster.ViewportZClipTestEnable = true;
954 #endif
955 }
956
957 /* BRW_NEW_CONSERVATIVE_RASTERIZATION */
958 #if GEN_GEN >= 9
959 raster.ConservativeRasterizationEnable =
960 ctx->IntelConservativeRasterization;
961 #endif
962
963 raster.GlobalDepthOffsetClamp = polygon->OffsetClamp;
964 raster.GlobalDepthOffsetScale = polygon->OffsetFactor;
965
966 raster.GlobalDepthOffsetConstant = polygon->OffsetUnits * 2;
967 }
968 }
969
970 static const struct brw_tracked_state genX(raster_state) = {
971 .dirty = {
972 .mesa = _NEW_BUFFERS |
973 _NEW_LINE |
974 _NEW_MULTISAMPLE |
975 _NEW_POINT |
976 _NEW_POLYGON |
977 _NEW_SCISSOR |
978 _NEW_TRANSFORM,
979 .brw = BRW_NEW_BLORP |
980 BRW_NEW_CONTEXT |
981 BRW_NEW_CONSERVATIVE_RASTERIZATION,
982 },
983 .emit = genX(upload_raster),
984 };
985 #endif
986
987 /* ---------------------------------------------------------------------- */
988
989 void
990 genX(init_atoms)(struct brw_context *brw)
991 {
992 #if GEN_GEN < 6
993 static const struct brw_tracked_state *render_atoms[] =
994 {
995 /* Once all the programs are done, we know how large urb entry
996 * sizes need to be and can decide if we need to change the urb
997 * layout.
998 */
999 &brw_curbe_offsets,
1000 &brw_recalculate_urb_fence,
1001
1002 &brw_cc_vp,
1003 &brw_cc_unit,
1004
1005 /* Surface state setup. Must come before the VS/WM unit. The binding
1006 * table upload must be last.
1007 */
1008 &brw_vs_pull_constants,
1009 &brw_wm_pull_constants,
1010 &brw_renderbuffer_surfaces,
1011 &brw_renderbuffer_read_surfaces,
1012 &brw_texture_surfaces,
1013 &brw_vs_binding_table,
1014 &brw_wm_binding_table,
1015
1016 &brw_fs_samplers,
1017 &brw_vs_samplers,
1018
1019 /* These set up state for brw_psp_urb_cbs */
1020 &brw_wm_unit,
1021 &brw_sf_vp,
1022 &brw_sf_unit,
1023 &brw_vs_unit, /* always required, enabled or not */
1024 &brw_clip_unit,
1025 &brw_gs_unit,
1026
1027 /* Command packets:
1028 */
1029 &brw_invariant_state,
1030
1031 &brw_binding_table_pointers,
1032 &brw_blend_constant_color,
1033
1034 &brw_depthbuffer,
1035
1036 &brw_polygon_stipple,
1037 &brw_polygon_stipple_offset,
1038
1039 &brw_line_stipple,
1040
1041 &brw_psp_urb_cbs,
1042
1043 &brw_drawing_rect,
1044 &brw_indices, /* must come before brw_vertices */
1045 &brw_index_buffer,
1046 &brw_vertices,
1047
1048 &brw_constant_buffer
1049 };
1050 #elif GEN_GEN == 6
1051 static const struct brw_tracked_state *render_atoms[] =
1052 {
1053 &gen6_sf_and_clip_viewports,
1054
1055 /* Command packets: */
1056
1057 &brw_cc_vp,
1058 &gen6_viewport_state, /* must do after *_vp stages */
1059
1060 &gen6_urb,
1061 &gen6_blend_state, /* must do before cc unit */
1062 &gen6_color_calc_state, /* must do before cc unit */
1063 &gen6_depth_stencil_state, /* must do before cc unit */
1064
1065 &gen6_vs_push_constants, /* Before vs_state */
1066 &gen6_gs_push_constants, /* Before gs_state */
1067 &gen6_wm_push_constants, /* Before wm_state */
1068
1069 /* Surface state setup. Must come before the VS/WM unit. The binding
1070 * table upload must be last.
1071 */
1072 &brw_vs_pull_constants,
1073 &brw_vs_ubo_surfaces,
1074 &brw_gs_pull_constants,
1075 &brw_gs_ubo_surfaces,
1076 &brw_wm_pull_constants,
1077 &brw_wm_ubo_surfaces,
1078 &gen6_renderbuffer_surfaces,
1079 &brw_renderbuffer_read_surfaces,
1080 &brw_texture_surfaces,
1081 &gen6_sol_surface,
1082 &brw_vs_binding_table,
1083 &gen6_gs_binding_table,
1084 &brw_wm_binding_table,
1085
1086 &brw_fs_samplers,
1087 &brw_vs_samplers,
1088 &brw_gs_samplers,
1089 &gen6_sampler_state,
1090 &gen6_multisample_state,
1091
1092 &gen6_vs_state,
1093 &gen6_gs_state,
1094 &genX(clip_state),
1095 &genX(sf_state),
1096 &gen6_wm_state,
1097
1098 &gen6_scissor_state,
1099
1100 &gen6_binding_table_pointers,
1101
1102 &brw_depthbuffer,
1103
1104 &brw_polygon_stipple,
1105 &brw_polygon_stipple_offset,
1106
1107 &brw_line_stipple,
1108
1109 &brw_drawing_rect,
1110
1111 &brw_indices, /* must come before brw_vertices */
1112 &brw_index_buffer,
1113 &brw_vertices,
1114 };
1115 #elif GEN_GEN == 7
1116 static const struct brw_tracked_state *render_atoms[] =
1117 {
1118 /* Command packets: */
1119
1120 &brw_cc_vp,
1121 &gen7_sf_clip_viewport,
1122
1123 &gen7_l3_state,
1124 &gen7_push_constant_space,
1125 &gen7_urb,
1126 &gen6_blend_state, /* must do before cc unit */
1127 &gen6_color_calc_state, /* must do before cc unit */
1128 &genX(depth_stencil_state), /* must do before cc unit */
1129
1130 &brw_vs_image_surfaces, /* Before vs push/pull constants and binding table */
1131 &brw_tcs_image_surfaces, /* Before tcs push/pull constants and binding table */
1132 &brw_tes_image_surfaces, /* Before tes push/pull constants and binding table */
1133 &brw_gs_image_surfaces, /* Before gs push/pull constants and binding table */
1134 &brw_wm_image_surfaces, /* Before wm push/pull constants and binding table */
1135
1136 &gen6_vs_push_constants, /* Before vs_state */
1137 &gen7_tcs_push_constants,
1138 &gen7_tes_push_constants,
1139 &gen6_gs_push_constants, /* Before gs_state */
1140 &gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */
1141
1142 /* Surface state setup. Must come before the VS/WM unit. The binding
1143 * table upload must be last.
1144 */
1145 &brw_vs_pull_constants,
1146 &brw_vs_ubo_surfaces,
1147 &brw_vs_abo_surfaces,
1148 &brw_tcs_pull_constants,
1149 &brw_tcs_ubo_surfaces,
1150 &brw_tcs_abo_surfaces,
1151 &brw_tes_pull_constants,
1152 &brw_tes_ubo_surfaces,
1153 &brw_tes_abo_surfaces,
1154 &brw_gs_pull_constants,
1155 &brw_gs_ubo_surfaces,
1156 &brw_gs_abo_surfaces,
1157 &brw_wm_pull_constants,
1158 &brw_wm_ubo_surfaces,
1159 &brw_wm_abo_surfaces,
1160 &gen6_renderbuffer_surfaces,
1161 &brw_renderbuffer_read_surfaces,
1162 &brw_texture_surfaces,
1163 &brw_vs_binding_table,
1164 &brw_tcs_binding_table,
1165 &brw_tes_binding_table,
1166 &brw_gs_binding_table,
1167 &brw_wm_binding_table,
1168
1169 &brw_fs_samplers,
1170 &brw_vs_samplers,
1171 &brw_tcs_samplers,
1172 &brw_tes_samplers,
1173 &brw_gs_samplers,
1174 &gen6_multisample_state,
1175
1176 &gen7_vs_state,
1177 &gen7_hs_state,
1178 &gen7_te_state,
1179 &gen7_ds_state,
1180 &gen7_gs_state,
1181 &gen7_sol_state,
1182 &genX(clip_state),
1183 &genX(sbe_state),
1184 &genX(sf_state),
1185 &gen7_wm_state,
1186 &gen7_ps_state,
1187
1188 &gen6_scissor_state,
1189
1190 &gen7_depthbuffer,
1191
1192 &brw_polygon_stipple,
1193 &brw_polygon_stipple_offset,
1194
1195 &brw_line_stipple,
1196
1197 &brw_drawing_rect,
1198
1199 &brw_indices, /* must come before brw_vertices */
1200 &brw_index_buffer,
1201 &brw_vertices,
1202
1203 &haswell_cut_index,
1204 };
1205 #elif GEN_GEN >= 8
1206 static const struct brw_tracked_state *render_atoms[] =
1207 {
1208 &brw_cc_vp,
1209 &gen8_sf_clip_viewport,
1210
1211 &gen7_l3_state,
1212 &gen7_push_constant_space,
1213 &gen7_urb,
1214 &gen8_blend_state,
1215 &gen6_color_calc_state,
1216
1217 &brw_vs_image_surfaces, /* Before vs push/pull constants and binding table */
1218 &brw_tcs_image_surfaces, /* Before tcs push/pull constants and binding table */
1219 &brw_tes_image_surfaces, /* Before tes push/pull constants and binding table */
1220 &brw_gs_image_surfaces, /* Before gs push/pull constants and binding table */
1221 &brw_wm_image_surfaces, /* Before wm push/pull constants and binding table */
1222
1223 &gen6_vs_push_constants, /* Before vs_state */
1224 &gen7_tcs_push_constants,
1225 &gen7_tes_push_constants,
1226 &gen6_gs_push_constants, /* Before gs_state */
1227 &gen6_wm_push_constants, /* Before wm_surfaces and constant_buffer */
1228
1229 /* Surface state setup. Must come before the VS/WM unit. The binding
1230 * table upload must be last.
1231 */
1232 &brw_vs_pull_constants,
1233 &brw_vs_ubo_surfaces,
1234 &brw_vs_abo_surfaces,
1235 &brw_tcs_pull_constants,
1236 &brw_tcs_ubo_surfaces,
1237 &brw_tcs_abo_surfaces,
1238 &brw_tes_pull_constants,
1239 &brw_tes_ubo_surfaces,
1240 &brw_tes_abo_surfaces,
1241 &brw_gs_pull_constants,
1242 &brw_gs_ubo_surfaces,
1243 &brw_gs_abo_surfaces,
1244 &brw_wm_pull_constants,
1245 &brw_wm_ubo_surfaces,
1246 &brw_wm_abo_surfaces,
1247 &gen6_renderbuffer_surfaces,
1248 &brw_renderbuffer_read_surfaces,
1249 &brw_texture_surfaces,
1250 &brw_vs_binding_table,
1251 &brw_tcs_binding_table,
1252 &brw_tes_binding_table,
1253 &brw_gs_binding_table,
1254 &brw_wm_binding_table,
1255
1256 &brw_fs_samplers,
1257 &brw_vs_samplers,
1258 &brw_tcs_samplers,
1259 &brw_tes_samplers,
1260 &brw_gs_samplers,
1261 &gen8_multisample_state,
1262
1263 &gen8_vs_state,
1264 &gen8_hs_state,
1265 &gen7_te_state,
1266 &gen8_ds_state,
1267 &gen8_gs_state,
1268 &gen7_sol_state,
1269 &genX(clip_state),
1270 &genX(raster_state),
1271 &genX(sbe_state),
1272 &genX(sf_state),
1273 &gen8_ps_blend,
1274 &gen8_ps_extra,
1275 &gen8_ps_state,
1276 &genX(depth_stencil_state),
1277 &gen8_wm_state,
1278
1279 &gen6_scissor_state,
1280
1281 &gen7_depthbuffer,
1282
1283 &brw_polygon_stipple,
1284 &brw_polygon_stipple_offset,
1285
1286 &brw_line_stipple,
1287
1288 &brw_drawing_rect,
1289
1290 &gen8_vf_topology,
1291
1292 &brw_indices,
1293 &gen8_index_buffer,
1294 &gen8_vertices,
1295
1296 &haswell_cut_index,
1297 &gen8_pma_fix,
1298 };
1299 #endif
1300
1301 STATIC_ASSERT(ARRAY_SIZE(render_atoms) <= ARRAY_SIZE(brw->render_atoms));
1302 brw_copy_pipeline_atoms(brw, BRW_RENDER_PIPELINE,
1303 render_atoms, ARRAY_SIZE(render_atoms));
1304
1305 #if GEN_GEN >= 7
1306 static const struct brw_tracked_state *compute_atoms[] =
1307 {
1308 &gen7_l3_state,
1309 &brw_cs_image_surfaces,
1310 &gen7_cs_push_constants,
1311 &brw_cs_pull_constants,
1312 &brw_cs_ubo_surfaces,
1313 &brw_cs_abo_surfaces,
1314 &brw_cs_texture_surfaces,
1315 &brw_cs_work_groups_surface,
1316 &brw_cs_samplers,
1317 &brw_cs_state,
1318 };
1319
1320 STATIC_ASSERT(ARRAY_SIZE(compute_atoms) <= ARRAY_SIZE(brw->compute_atoms));
1321 brw_copy_pipeline_atoms(brw, BRW_COMPUTE_PIPELINE,
1322 compute_atoms, ARRAY_SIZE(compute_atoms));
1323 #endif
1324 }