freedreno/a3xx: add blend state
[mesa.git] / src / gallium / drivers / ilo / include / brw_structs.h
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
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:
13
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.
17
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.
25
26 **********************************************************************/
27 /*
28 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32
33 #ifndef BRW_STRUCTS_H
34 #define BRW_STRUCTS_H
35
36 /* These seem to be passed around as function args, so it works out
37 * better to keep them as #defines:
38 */
39 #define BRW_FLUSH_READ_CACHE 0x1
40 #define BRW_FLUSH_STATE_CACHE 0x2
41 #define BRW_INHIBIT_FLUSH_RENDER_CACHE 0x4
42 #define BRW_FLUSH_SNAPSHOT_COUNTERS 0x8
43
44 struct brw_urb_fence
45 {
46 struct
47 {
48 GLuint length:8;
49 GLuint vs_realloc:1;
50 GLuint gs_realloc:1;
51 GLuint clp_realloc:1;
52 GLuint sf_realloc:1;
53 GLuint vfe_realloc:1;
54 GLuint cs_realloc:1;
55 GLuint pad:2;
56 GLuint opcode:16;
57 } header;
58
59 struct
60 {
61 GLuint vs_fence:10;
62 GLuint gs_fence:10;
63 GLuint clp_fence:10;
64 GLuint pad:2;
65 } bits0;
66
67 struct
68 {
69 GLuint sf_fence:10;
70 GLuint vf_fence:10;
71 GLuint cs_fence:11;
72 GLuint pad:1;
73 } bits1;
74 };
75
76 /* State structs for the various fixed function units:
77 */
78
79
80 struct thread0
81 {
82 GLuint pad0:1;
83 GLuint grf_reg_count:3;
84 GLuint pad1:2;
85 GLuint kernel_start_pointer:26; /* Offset from GENERAL_STATE_BASE */
86 };
87
88 struct thread1
89 {
90 GLuint ext_halt_exception_enable:1;
91 GLuint sw_exception_enable:1;
92 GLuint mask_stack_exception_enable:1;
93 GLuint timeout_exception_enable:1;
94 GLuint illegal_op_exception_enable:1;
95 GLuint pad0:3;
96 GLuint depth_coef_urb_read_offset:6; /* WM only */
97 GLuint pad1:2;
98 GLuint floating_point_mode:1;
99 GLuint thread_priority:1;
100 GLuint binding_table_entry_count:8;
101 GLuint pad3:5;
102 GLuint single_program_flow:1;
103 };
104
105 struct thread2
106 {
107 GLuint per_thread_scratch_space:4;
108 GLuint pad0:6;
109 GLuint scratch_space_base_pointer:22;
110 };
111
112
113 struct thread3
114 {
115 GLuint dispatch_grf_start_reg:4;
116 GLuint urb_entry_read_offset:6;
117 GLuint pad0:1;
118 GLuint urb_entry_read_length:6;
119 GLuint pad1:1;
120 GLuint const_urb_entry_read_offset:6;
121 GLuint pad2:1;
122 GLuint const_urb_entry_read_length:6;
123 GLuint pad3:1;
124 };
125
126
127
128 struct brw_clip_unit_state
129 {
130 struct thread0 thread0;
131 struct
132 {
133 GLuint pad0:7;
134 GLuint sw_exception_enable:1;
135 GLuint pad1:3;
136 GLuint mask_stack_exception_enable:1;
137 GLuint pad2:1;
138 GLuint illegal_op_exception_enable:1;
139 GLuint pad3:2;
140 GLuint floating_point_mode:1;
141 GLuint thread_priority:1;
142 GLuint binding_table_entry_count:8;
143 GLuint pad4:5;
144 GLuint single_program_flow:1;
145 } thread1;
146
147 struct thread2 thread2;
148 struct thread3 thread3;
149
150 struct
151 {
152 GLuint pad0:9;
153 GLuint gs_output_stats:1; /* not always */
154 GLuint stats_enable:1;
155 GLuint nr_urb_entries:7;
156 GLuint pad1:1;
157 GLuint urb_entry_allocation_size:5;
158 GLuint pad2:1;
159 GLuint max_threads:5; /* may be less */
160 GLuint pad3:2;
161 } thread4;
162
163 struct
164 {
165 GLuint pad0:13;
166 GLuint clip_mode:3;
167 GLuint userclip_enable_flags:8;
168 GLuint userclip_must_clip:1;
169 GLuint negative_w_clip_test:1;
170 GLuint guard_band_enable:1;
171 GLuint viewport_z_clip_enable:1;
172 GLuint viewport_xy_clip_enable:1;
173 GLuint vertex_position_space:1;
174 GLuint api_mode:1;
175 GLuint pad2:1;
176 } clip5;
177
178 struct
179 {
180 GLuint pad0:5;
181 GLuint clipper_viewport_state_ptr:27;
182 } clip6;
183
184
185 GLfloat viewport_xmin;
186 GLfloat viewport_xmax;
187 GLfloat viewport_ymin;
188 GLfloat viewport_ymax;
189 };
190
191 struct gen6_blend_state
192 {
193 struct {
194 GLuint dest_blend_factor:5;
195 GLuint source_blend_factor:5;
196 GLuint pad3:1;
197 GLuint blend_func:3;
198 GLuint pad2:1;
199 GLuint ia_dest_blend_factor:5;
200 GLuint ia_source_blend_factor:5;
201 GLuint pad1:1;
202 GLuint ia_blend_func:3;
203 GLuint pad0:1;
204 GLuint ia_blend_enable:1;
205 GLuint blend_enable:1;
206 } blend0;
207
208 struct {
209 GLuint post_blend_clamp_enable:1;
210 GLuint pre_blend_clamp_enable:1;
211 GLuint clamp_range:2;
212 GLuint pad0:4;
213 GLuint x_dither_offset:2;
214 GLuint y_dither_offset:2;
215 GLuint dither_enable:1;
216 GLuint alpha_test_func:3;
217 GLuint alpha_test_enable:1;
218 GLuint pad1:1;
219 GLuint logic_op_func:4;
220 GLuint logic_op_enable:1;
221 GLuint pad2:1;
222 GLuint write_disable_b:1;
223 GLuint write_disable_g:1;
224 GLuint write_disable_r:1;
225 GLuint write_disable_a:1;
226 GLuint pad3:1;
227 GLuint alpha_to_coverage_dither:1;
228 GLuint alpha_to_one:1;
229 GLuint alpha_to_coverage:1;
230 } blend1;
231 };
232
233 struct gen6_color_calc_state
234 {
235 struct {
236 GLuint alpha_test_format:1;
237 GLuint pad0:14;
238 GLuint round_disable:1;
239 GLuint bf_stencil_ref:8;
240 GLuint stencil_ref:8;
241 } cc0;
242
243 union {
244 GLfloat alpha_ref_f;
245 struct {
246 GLuint ui:8;
247 GLuint pad0:24;
248 } alpha_ref_fi;
249 } cc1;
250
251 GLfloat constant_r;
252 GLfloat constant_g;
253 GLfloat constant_b;
254 GLfloat constant_a;
255 };
256
257 struct gen6_depth_stencil_state
258 {
259 struct {
260 GLuint pad0:3;
261 GLuint bf_stencil_pass_depth_pass_op:3;
262 GLuint bf_stencil_pass_depth_fail_op:3;
263 GLuint bf_stencil_fail_op:3;
264 GLuint bf_stencil_func:3;
265 GLuint bf_stencil_enable:1;
266 GLuint pad1:2;
267 GLuint stencil_write_enable:1;
268 GLuint stencil_pass_depth_pass_op:3;
269 GLuint stencil_pass_depth_fail_op:3;
270 GLuint stencil_fail_op:3;
271 GLuint stencil_func:3;
272 GLuint stencil_enable:1;
273 } ds0;
274
275 struct {
276 GLuint bf_stencil_write_mask:8;
277 GLuint bf_stencil_test_mask:8;
278 GLuint stencil_write_mask:8;
279 GLuint stencil_test_mask:8;
280 } ds1;
281
282 struct {
283 GLuint pad0:26;
284 GLuint depth_write_enable:1;
285 GLuint depth_test_func:3;
286 GLuint pad1:1;
287 GLuint depth_test_enable:1;
288 } ds2;
289 };
290
291 struct brw_cc_unit_state
292 {
293 struct
294 {
295 GLuint pad0:3;
296 GLuint bf_stencil_pass_depth_pass_op:3;
297 GLuint bf_stencil_pass_depth_fail_op:3;
298 GLuint bf_stencil_fail_op:3;
299 GLuint bf_stencil_func:3;
300 GLuint bf_stencil_enable:1;
301 GLuint pad1:2;
302 GLuint stencil_write_enable:1;
303 GLuint stencil_pass_depth_pass_op:3;
304 GLuint stencil_pass_depth_fail_op:3;
305 GLuint stencil_fail_op:3;
306 GLuint stencil_func:3;
307 GLuint stencil_enable:1;
308 } cc0;
309
310
311 struct
312 {
313 GLuint bf_stencil_ref:8;
314 GLuint stencil_write_mask:8;
315 GLuint stencil_test_mask:8;
316 GLuint stencil_ref:8;
317 } cc1;
318
319
320 struct
321 {
322 GLuint logicop_enable:1;
323 GLuint pad0:10;
324 GLuint depth_write_enable:1;
325 GLuint depth_test_function:3;
326 GLuint depth_test:1;
327 GLuint bf_stencil_write_mask:8;
328 GLuint bf_stencil_test_mask:8;
329 } cc2;
330
331
332 struct
333 {
334 GLuint pad0:8;
335 GLuint alpha_test_func:3;
336 GLuint alpha_test:1;
337 GLuint blend_enable:1;
338 GLuint ia_blend_enable:1;
339 GLuint pad1:1;
340 GLuint alpha_test_format:1;
341 GLuint pad2:16;
342 } cc3;
343
344 struct
345 {
346 GLuint pad0:5;
347 GLuint cc_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
348 } cc4;
349
350 struct
351 {
352 GLuint pad0:2;
353 GLuint ia_dest_blend_factor:5;
354 GLuint ia_src_blend_factor:5;
355 GLuint ia_blend_function:3;
356 GLuint statistics_enable:1;
357 GLuint logicop_func:4;
358 GLuint pad1:11;
359 GLuint dither_enable:1;
360 } cc5;
361
362 struct
363 {
364 GLuint clamp_post_alpha_blend:1;
365 GLuint clamp_pre_alpha_blend:1;
366 GLuint clamp_range:2;
367 GLuint pad0:11;
368 GLuint y_dither_offset:2;
369 GLuint x_dither_offset:2;
370 GLuint dest_blend_factor:5;
371 GLuint src_blend_factor:5;
372 GLuint blend_function:3;
373 } cc6;
374
375 struct {
376 union {
377 GLfloat f;
378 GLubyte ub[4];
379 } alpha_ref;
380 } cc7;
381 };
382
383 struct brw_sf_unit_state
384 {
385 struct thread0 thread0;
386 struct thread1 thread1;
387 struct thread2 thread2;
388 struct thread3 thread3;
389
390 struct
391 {
392 GLuint pad0:10;
393 GLuint stats_enable:1;
394 GLuint nr_urb_entries:7;
395 GLuint pad1:1;
396 GLuint urb_entry_allocation_size:5;
397 GLuint pad2:1;
398 GLuint max_threads:6;
399 GLuint pad3:1;
400 } thread4;
401
402 struct
403 {
404 GLuint front_winding:1;
405 GLuint viewport_transform:1;
406 GLuint pad0:3;
407 GLuint sf_viewport_state_offset:27; /* Offset from GENERAL_STATE_BASE */
408 } sf5;
409
410 struct
411 {
412 GLuint pad0:9;
413 GLuint dest_org_vbias:4;
414 GLuint dest_org_hbias:4;
415 GLuint scissor:1;
416 GLuint disable_2x2_trifilter:1;
417 GLuint disable_zero_pix_trifilter:1;
418 GLuint point_rast_rule:2;
419 GLuint line_endcap_aa_region_width:2;
420 GLuint line_width:4;
421 GLuint fast_scissor_disable:1;
422 GLuint cull_mode:2;
423 GLuint aa_enable:1;
424 } sf6;
425
426 struct
427 {
428 GLuint point_size:11;
429 GLuint use_point_size_state:1;
430 GLuint subpixel_precision:1;
431 GLuint sprite_point:1;
432 GLuint pad0:10;
433 GLuint aa_line_distance_mode:1;
434 GLuint trifan_pv:2;
435 GLuint linestrip_pv:2;
436 GLuint tristrip_pv:2;
437 GLuint line_last_pixel_enable:1;
438 } sf7;
439
440 };
441
442 struct gen6_scissor_rect
443 {
444 GLuint xmin:16;
445 GLuint ymin:16;
446 GLuint xmax:16;
447 GLuint ymax:16;
448 };
449
450 struct brw_gs_unit_state
451 {
452 struct thread0 thread0;
453 struct thread1 thread1;
454 struct thread2 thread2;
455 struct thread3 thread3;
456
457 struct
458 {
459 GLuint pad0:8;
460 GLuint rendering_enable:1; /* for Ironlake */
461 GLuint pad4:1;
462 GLuint stats_enable:1;
463 GLuint nr_urb_entries:7;
464 GLuint pad1:1;
465 GLuint urb_entry_allocation_size:5;
466 GLuint pad2:1;
467 GLuint max_threads:5;
468 GLuint pad3:2;
469 } thread4;
470
471 struct
472 {
473 GLuint sampler_count:3;
474 GLuint pad0:2;
475 GLuint sampler_state_pointer:27;
476 } gs5;
477
478
479 struct
480 {
481 GLuint max_vp_index:4;
482 GLuint pad0:12;
483 GLuint svbi_post_inc_value:10;
484 GLuint pad1:1;
485 GLuint svbi_post_inc_enable:1;
486 GLuint svbi_payload:1;
487 GLuint discard_adjaceny:1;
488 GLuint reorder_enable:1;
489 GLuint pad2:1;
490 } gs6;
491 };
492
493
494 struct brw_vs_unit_state
495 {
496 struct thread0 thread0;
497 struct thread1 thread1;
498 struct thread2 thread2;
499 struct thread3 thread3;
500
501 struct
502 {
503 GLuint pad0:10;
504 GLuint stats_enable:1;
505 GLuint nr_urb_entries:7;
506 GLuint pad1:1;
507 GLuint urb_entry_allocation_size:5;
508 GLuint pad2:1;
509 GLuint max_threads:6;
510 GLuint pad3:1;
511 } thread4;
512
513 struct
514 {
515 GLuint sampler_count:3;
516 GLuint pad0:2;
517 GLuint sampler_state_pointer:27;
518 } vs5;
519
520 struct
521 {
522 GLuint vs_enable:1;
523 GLuint vert_cache_disable:1;
524 GLuint pad0:30;
525 } vs6;
526 };
527
528
529 struct brw_wm_unit_state
530 {
531 struct thread0 thread0;
532 struct thread1 thread1;
533 struct thread2 thread2;
534 struct thread3 thread3;
535
536 struct {
537 GLuint stats_enable:1;
538 GLuint depth_buffer_clear:1;
539 GLuint sampler_count:3;
540 GLuint sampler_state_pointer:27;
541 } wm4;
542
543 struct
544 {
545 GLuint enable_8_pix:1;
546 GLuint enable_16_pix:1;
547 GLuint enable_32_pix:1;
548 GLuint enable_con_32_pix:1;
549 GLuint enable_con_64_pix:1;
550 GLuint pad0:1;
551
552 /* These next four bits are for Ironlake+ */
553 GLuint fast_span_coverage_enable:1;
554 GLuint depth_buffer_clear:1;
555 GLuint depth_buffer_resolve_enable:1;
556 GLuint hierarchical_depth_buffer_resolve_enable:1;
557
558 GLuint legacy_global_depth_bias:1;
559 GLuint line_stipple:1;
560 GLuint depth_offset:1;
561 GLuint polygon_stipple:1;
562 GLuint line_aa_region_width:2;
563 GLuint line_endcap_aa_region_width:2;
564 GLuint early_depth_test:1;
565 GLuint thread_dispatch_enable:1;
566 GLuint program_uses_depth:1;
567 GLuint program_computes_depth:1;
568 GLuint program_uses_killpixel:1;
569 GLuint legacy_line_rast: 1;
570 GLuint transposed_urb_read_enable:1;
571 GLuint max_threads:7;
572 } wm5;
573
574 GLfloat global_depth_offset_constant;
575 GLfloat global_depth_offset_scale;
576
577 /* for Ironlake only */
578 struct {
579 GLuint pad0:1;
580 GLuint grf_reg_count_1:3;
581 GLuint pad1:2;
582 GLuint kernel_start_pointer_1:26;
583 } wm8;
584
585 struct {
586 GLuint pad0:1;
587 GLuint grf_reg_count_2:3;
588 GLuint pad1:2;
589 GLuint kernel_start_pointer_2:26;
590 } wm9;
591
592 struct {
593 GLuint pad0:1;
594 GLuint grf_reg_count_3:3;
595 GLuint pad1:2;
596 GLuint kernel_start_pointer_3:26;
597 } wm10;
598 };
599
600 struct brw_sampler_default_color {
601 GLfloat color[4];
602 };
603
604 struct gen5_sampler_default_color {
605 uint8_t ub[4];
606 float f[4];
607 uint16_t hf[4];
608 uint16_t us[4];
609 int16_t s[4];
610 uint8_t b[4];
611 };
612
613 struct brw_sampler_state
614 {
615
616 struct
617 {
618 GLuint shadow_function:3;
619 GLuint lod_bias:11;
620 GLuint min_filter:3;
621 GLuint mag_filter:3;
622 GLuint mip_filter:2;
623 GLuint base_level:5;
624 GLuint min_mag_neq:1;
625 GLuint lod_preclamp:1;
626 GLuint default_color_mode:1;
627 GLuint pad0:1;
628 GLuint disable:1;
629 } ss0;
630
631 struct
632 {
633 GLuint r_wrap_mode:3;
634 GLuint t_wrap_mode:3;
635 GLuint s_wrap_mode:3;
636 GLuint cube_control_mode:1;
637 GLuint pad:2;
638 GLuint max_lod:10;
639 GLuint min_lod:10;
640 } ss1;
641
642
643 struct
644 {
645 GLuint pad:5;
646 GLuint default_color_pointer:27;
647 } ss2;
648
649 struct
650 {
651 GLuint non_normalized_coord:1;
652 GLuint pad:12;
653 GLuint address_round:6;
654 GLuint max_aniso:3;
655 GLuint chroma_key_mode:1;
656 GLuint chroma_key_index:2;
657 GLuint chroma_key_enable:1;
658 GLuint monochrome_filter_width:3;
659 GLuint monochrome_filter_height:3;
660 } ss3;
661 };
662
663 struct gen7_sampler_state
664 {
665 struct
666 {
667 GLuint aniso_algorithm:1;
668 GLuint lod_bias:13;
669 GLuint min_filter:3;
670 GLuint mag_filter:3;
671 GLuint mip_filter:2;
672 GLuint base_level:5;
673 GLuint pad1:1;
674 GLuint lod_preclamp:1;
675 GLuint default_color_mode:1;
676 GLuint pad0:1;
677 GLuint disable:1;
678 } ss0;
679
680 struct
681 {
682 GLuint cube_control_mode:1;
683 GLuint shadow_function:3;
684 GLuint pad:4;
685 GLuint max_lod:12;
686 GLuint min_lod:12;
687 } ss1;
688
689 struct
690 {
691 GLuint pad:5;
692 GLuint default_color_pointer:27;
693 } ss2;
694
695 struct
696 {
697 GLuint r_wrap_mode:3;
698 GLuint t_wrap_mode:3;
699 GLuint s_wrap_mode:3;
700 GLuint pad:1;
701 GLuint non_normalized_coord:1;
702 GLuint trilinear_quality:2;
703 GLuint address_round:6;
704 GLuint max_aniso:3;
705 GLuint chroma_key_mode:1;
706 GLuint chroma_key_index:2;
707 GLuint chroma_key_enable:1;
708 GLuint pad0:6;
709 } ss3;
710 };
711
712 struct brw_clipper_viewport
713 {
714 GLfloat xmin;
715 GLfloat xmax;
716 GLfloat ymin;
717 GLfloat ymax;
718 };
719
720 struct brw_cc_viewport
721 {
722 GLfloat min_depth;
723 GLfloat max_depth;
724 };
725
726 struct brw_sf_viewport
727 {
728 struct {
729 GLfloat m00;
730 GLfloat m11;
731 GLfloat m22;
732 GLfloat m30;
733 GLfloat m31;
734 GLfloat m32;
735 } viewport;
736
737 /* scissor coordinates are inclusive */
738 struct {
739 GLshort xmin;
740 GLshort ymin;
741 GLshort xmax;
742 GLshort ymax;
743 } scissor;
744 };
745
746 struct gen6_sf_viewport {
747 GLfloat m00;
748 GLfloat m11;
749 GLfloat m22;
750 GLfloat m30;
751 GLfloat m31;
752 GLfloat m32;
753 };
754
755 struct gen7_sf_clip_viewport {
756 struct {
757 GLfloat m00;
758 GLfloat m11;
759 GLfloat m22;
760 GLfloat m30;
761 GLfloat m31;
762 GLfloat m32;
763 } viewport;
764
765 GLuint pad0[2];
766
767 struct {
768 GLfloat xmin;
769 GLfloat xmax;
770 GLfloat ymin;
771 GLfloat ymax;
772 } guardband;
773
774 GLfloat pad1[4];
775 };
776
777 struct brw_vertex_element_state
778 {
779 struct
780 {
781 GLuint src_offset:11;
782 GLuint pad:5;
783 GLuint src_format:9;
784 GLuint pad0:1;
785 GLuint valid:1;
786 GLuint vertex_buffer_index:5;
787 } ve0;
788
789 struct
790 {
791 GLuint dst_offset:8;
792 GLuint pad:8;
793 GLuint vfcomponent3:4;
794 GLuint vfcomponent2:4;
795 GLuint vfcomponent1:4;
796 GLuint vfcomponent0:4;
797 } ve1;
798 };
799
800 struct brw_urb_immediate {
801 GLuint opcode:4;
802 GLuint offset:6;
803 GLuint swizzle_control:2;
804 GLuint pad:1;
805 GLuint allocate:1;
806 GLuint used:1;
807 GLuint complete:1;
808 GLuint response_length:4;
809 GLuint msg_length:4;
810 GLuint msg_target:4;
811 GLuint pad1:3;
812 GLuint end_of_thread:1;
813 };
814
815 /* Instruction format for the execution units:
816 */
817
818 struct brw_instruction
819 {
820 struct
821 {
822 GLuint opcode:7;
823 GLuint pad:1;
824 GLuint access_mode:1;
825 GLuint mask_control:1;
826 GLuint dependency_control:2;
827 GLuint compression_control:2; /* gen6: quarter control */
828 GLuint thread_control:2;
829 GLuint predicate_control:4;
830 GLuint predicate_inverse:1;
831 GLuint execution_size:3;
832 /**
833 * Conditional Modifier for most instructions. On Gen6+, this is also
834 * used for the SEND instruction's Message Target/SFID.
835 */
836 GLuint destreg__conditionalmod:4;
837 GLuint acc_wr_control:1;
838 GLuint cmpt_control:1;
839 GLuint debug_control:1;
840 GLuint saturate:1;
841 } header;
842
843 union {
844 struct
845 {
846 GLuint dest_reg_file:2;
847 GLuint dest_reg_type:3;
848 GLuint src0_reg_file:2;
849 GLuint src0_reg_type:3;
850 GLuint src1_reg_file:2;
851 GLuint src1_reg_type:3;
852 GLuint nibctrl:1; /* gen7+ */
853 GLuint dest_subreg_nr:5;
854 GLuint dest_reg_nr:8;
855 GLuint dest_horiz_stride:2;
856 GLuint dest_address_mode:1;
857 } da1;
858
859 struct
860 {
861 GLuint dest_reg_file:2;
862 GLuint dest_reg_type:3;
863 GLuint src0_reg_file:2;
864 GLuint src0_reg_type:3;
865 GLuint src1_reg_file:2; /* 0x00000c00 */
866 GLuint src1_reg_type:3; /* 0x00007000 */
867 GLuint nibctrl:1; /* gen7+ */
868 GLint dest_indirect_offset:10; /* offset against the deref'd address reg */
869 GLuint dest_subreg_nr:3; /* subnr for the address reg a0.x */
870 GLuint dest_horiz_stride:2;
871 GLuint dest_address_mode:1;
872 } ia1;
873
874 struct
875 {
876 GLuint dest_reg_file:2;
877 GLuint dest_reg_type:3;
878 GLuint src0_reg_file:2;
879 GLuint src0_reg_type:3;
880 GLuint src1_reg_file:2;
881 GLuint src1_reg_type:3;
882 GLuint nibctrl:1; /* gen7+ */
883 GLuint dest_writemask:4;
884 GLuint dest_subreg_nr:1;
885 GLuint dest_reg_nr:8;
886 GLuint dest_horiz_stride:2;
887 GLuint dest_address_mode:1;
888 } da16;
889
890 struct
891 {
892 GLuint dest_reg_file:2;
893 GLuint dest_reg_type:3;
894 GLuint src0_reg_file:2;
895 GLuint src0_reg_type:3;
896 GLuint src1_reg_file:2;
897 GLuint src1_reg_type:3;
898 GLuint nibctrl:1; /* gen7+ */
899 GLuint dest_writemask:4;
900 GLint dest_indirect_offset:6;
901 GLuint dest_subreg_nr:3;
902 GLuint dest_horiz_stride:2;
903 GLuint dest_address_mode:1;
904 } ia16;
905
906 struct {
907 GLuint dest_reg_file:2;
908 GLuint dest_reg_type:3;
909 GLuint src0_reg_file:2;
910 GLuint src0_reg_type:3;
911 GLuint src1_reg_file:2;
912 GLuint src1_reg_type:3;
913 GLuint pad:1;
914
915 GLint jump_count:16;
916 } branch_gen6;
917
918 struct {
919 GLuint dest_reg_file:1; /* gen6, not gen7+ */
920 GLuint flag_subreg_num:1;
921 GLuint flag_reg_nr:1; /* gen7+ */
922 GLuint pad0:1;
923 GLuint src0_abs:1;
924 GLuint src0_negate:1;
925 GLuint src1_abs:1;
926 GLuint src1_negate:1;
927 GLuint src2_abs:1;
928 GLuint src2_negate:1;
929 GLuint src_type:2; /* gen7+ */
930 GLuint dst_type:2; /* gen7+ */
931 GLuint pad1:1;
932 GLuint nibctrl:1; /* gen7+ */
933 GLuint pad2:1;
934 GLuint dest_writemask:4;
935 GLuint dest_subreg_nr:3;
936 GLuint dest_reg_nr:8;
937 } da3src;
938
939 uint32_t ud;
940 } bits1;
941
942
943 union {
944 struct
945 {
946 GLuint src0_subreg_nr:5;
947 GLuint src0_reg_nr:8;
948 GLuint src0_abs:1;
949 GLuint src0_negate:1;
950 GLuint src0_address_mode:1;
951 GLuint src0_horiz_stride:2;
952 GLuint src0_width:3;
953 GLuint src0_vert_stride:4;
954 GLuint flag_subreg_nr:1;
955 GLuint flag_reg_nr:1; /* gen7+ */
956 GLuint pad:5;
957 } da1;
958
959 struct
960 {
961 GLint src0_indirect_offset:10;
962 GLuint src0_subreg_nr:3;
963 GLuint src0_abs:1;
964 GLuint src0_negate:1;
965 GLuint src0_address_mode:1;
966 GLuint src0_horiz_stride:2;
967 GLuint src0_width:3;
968 GLuint src0_vert_stride:4;
969 GLuint flag_subreg_nr:1;
970 GLuint flag_reg_nr:1; /* gen7+ */
971 GLuint pad:5;
972 } ia1;
973
974 struct
975 {
976 GLuint src0_swz_x:2;
977 GLuint src0_swz_y:2;
978 GLuint src0_subreg_nr:1;
979 GLuint src0_reg_nr:8;
980 GLuint src0_abs:1;
981 GLuint src0_negate:1;
982 GLuint src0_address_mode:1;
983 GLuint src0_swz_z:2;
984 GLuint src0_swz_w:2;
985 GLuint pad0:1;
986 GLuint src0_vert_stride:4;
987 GLuint flag_subreg_nr:1;
988 GLuint flag_reg_nr:1; /* gen7+ */
989 GLuint pad1:5;
990 } da16;
991
992 struct
993 {
994 GLuint src0_swz_x:2;
995 GLuint src0_swz_y:2;
996 GLint src0_indirect_offset:6;
997 GLuint src0_subreg_nr:3;
998 GLuint src0_abs:1;
999 GLuint src0_negate:1;
1000 GLuint src0_address_mode:1;
1001 GLuint src0_swz_z:2;
1002 GLuint src0_swz_w:2;
1003 GLuint pad0:1;
1004 GLuint src0_vert_stride:4;
1005 GLuint flag_subreg_nr:1;
1006 GLuint flag_reg_nr:1; /* gen7+ */
1007 GLuint pad1:5;
1008 } ia16;
1009
1010 /* Extended Message Descriptor for Ironlake (Gen5) SEND instruction.
1011 *
1012 * Does not apply to Gen6+. The SFID/message target moved to bits
1013 * 27:24 of the header (destreg__conditionalmod); EOT is in bits3.
1014 */
1015 struct
1016 {
1017 GLuint pad:26;
1018 GLuint end_of_thread:1;
1019 GLuint pad1:1;
1020 GLuint sfid:4;
1021 } send_gen5; /* for Ironlake only */
1022
1023 struct {
1024 GLuint src0_rep_ctrl:1;
1025 GLuint src0_swizzle:8;
1026 GLuint src0_subreg_nr:3;
1027 GLuint src0_reg_nr:8;
1028 GLuint pad0:1;
1029 GLuint src1_rep_ctrl:1;
1030 GLuint src1_swizzle:8;
1031 GLuint src1_subreg_nr_low:2;
1032 } da3src;
1033
1034 uint32_t ud;
1035 } bits2;
1036
1037 union
1038 {
1039 struct
1040 {
1041 GLuint src1_subreg_nr:5;
1042 GLuint src1_reg_nr:8;
1043 GLuint src1_abs:1;
1044 GLuint src1_negate:1;
1045 GLuint src1_address_mode:1;
1046 GLuint src1_horiz_stride:2;
1047 GLuint src1_width:3;
1048 GLuint src1_vert_stride:4;
1049 GLuint pad0:7;
1050 } da1;
1051
1052 struct
1053 {
1054 GLuint src1_swz_x:2;
1055 GLuint src1_swz_y:2;
1056 GLuint src1_subreg_nr:1;
1057 GLuint src1_reg_nr:8;
1058 GLuint src1_abs:1;
1059 GLuint src1_negate:1;
1060 GLuint src1_address_mode:1;
1061 GLuint src1_swz_z:2;
1062 GLuint src1_swz_w:2;
1063 GLuint pad1:1;
1064 GLuint src1_vert_stride:4;
1065 GLuint pad2:7;
1066 } da16;
1067
1068 struct
1069 {
1070 GLint src1_indirect_offset:10;
1071 GLuint src1_subreg_nr:3;
1072 GLuint src1_abs:1;
1073 GLuint src1_negate:1;
1074 GLuint src1_address_mode:1;
1075 GLuint src1_horiz_stride:2;
1076 GLuint src1_width:3;
1077 GLuint src1_vert_stride:4;
1078 GLuint pad1:7;
1079 } ia1;
1080
1081 struct
1082 {
1083 GLuint src1_swz_x:2;
1084 GLuint src1_swz_y:2;
1085 GLint src1_indirect_offset:6;
1086 GLuint src1_subreg_nr:3;
1087 GLuint src1_abs:1;
1088 GLuint src1_negate:1;
1089 GLuint pad0:1;
1090 GLuint src1_swz_z:2;
1091 GLuint src1_swz_w:2;
1092 GLuint pad1:1;
1093 GLuint src1_vert_stride:4;
1094 GLuint pad2:7;
1095 } ia16;
1096
1097
1098 struct
1099 {
1100 GLint jump_count:16; /* note: signed */
1101 GLuint pop_count:4;
1102 GLuint pad0:12;
1103 } if_else;
1104
1105 /* This is also used for gen7 IF/ELSE instructions */
1106 struct
1107 {
1108 /* Signed jump distance to the ip to jump to if all channels
1109 * are disabled after the break or continue. It should point
1110 * to the end of the innermost control flow block, as that's
1111 * where some channel could get re-enabled.
1112 */
1113 int jip:16;
1114
1115 /* Signed jump distance to the location to resume execution
1116 * of this channel if it's enabled for the break or continue.
1117 */
1118 int uip:16;
1119 } break_cont;
1120
1121 /**
1122 * \defgroup SEND instructions / Message Descriptors
1123 *
1124 * @{
1125 */
1126
1127 /**
1128 * Generic Message Descriptor for Gen4 SEND instructions. The structs
1129 * below expand function_control to something specific for their
1130 * message. Due to struct packing issues, they duplicate these bits.
1131 *
1132 * See the G45 PRM, Volume 4, Table 14-15.
1133 */
1134 struct {
1135 GLuint function_control:16;
1136 GLuint response_length:4;
1137 GLuint msg_length:4;
1138 GLuint msg_target:4;
1139 GLuint pad1:3;
1140 GLuint end_of_thread:1;
1141 } generic;
1142
1143 /**
1144 * Generic Message Descriptor for Gen5-7 SEND instructions.
1145 *
1146 * See the Sandybridge PRM, Volume 2 Part 2, Table 8-15. (Sadly, most
1147 * of the information on the SEND instruction is missing from the public
1148 * Ironlake PRM.)
1149 *
1150 * The table claims that bit 31 is reserved/MBZ on Gen6+, but it lies.
1151 * According to the SEND instruction description:
1152 * "The MSb of the message description, the EOT field, always comes from
1153 * bit 127 of the instruction word"...which is bit 31 of this field.
1154 */
1155 struct {
1156 GLuint function_control:19;
1157 GLuint header_present:1;
1158 GLuint response_length:5;
1159 GLuint msg_length:4;
1160 GLuint pad1:2;
1161 GLuint end_of_thread:1;
1162 } generic_gen5;
1163
1164 /** G45 PRM, Volume 4, Section 6.1.1.1 */
1165 struct {
1166 GLuint function:4;
1167 GLuint int_type:1;
1168 GLuint precision:1;
1169 GLuint saturate:1;
1170 GLuint data_type:1;
1171 GLuint pad0:8;
1172 GLuint response_length:4;
1173 GLuint msg_length:4;
1174 GLuint msg_target:4;
1175 GLuint pad1:3;
1176 GLuint end_of_thread:1;
1177 } math;
1178
1179 /** Ironlake PRM, Volume 4 Part 1, Section 6.1.1.1 */
1180 struct {
1181 GLuint function:4;
1182 GLuint int_type:1;
1183 GLuint precision:1;
1184 GLuint saturate:1;
1185 GLuint data_type:1;
1186 GLuint snapshot:1;
1187 GLuint pad0:10;
1188 GLuint header_present:1;
1189 GLuint response_length:5;
1190 GLuint msg_length:4;
1191 GLuint pad1:2;
1192 GLuint end_of_thread:1;
1193 } math_gen5;
1194
1195 /** G45 PRM, Volume 4, Section 4.8.1.1.1 [DevBW] and [DevCL] */
1196 struct {
1197 GLuint binding_table_index:8;
1198 GLuint sampler:4;
1199 GLuint return_format:2;
1200 GLuint msg_type:2;
1201 GLuint response_length:4;
1202 GLuint msg_length:4;
1203 GLuint msg_target:4;
1204 GLuint pad1:3;
1205 GLuint end_of_thread:1;
1206 } sampler;
1207
1208 /** G45 PRM, Volume 4, Section 4.8.1.1.2 [DevCTG] */
1209 struct {
1210 GLuint binding_table_index:8;
1211 GLuint sampler:4;
1212 GLuint msg_type:4;
1213 GLuint response_length:4;
1214 GLuint msg_length:4;
1215 GLuint msg_target:4;
1216 GLuint pad1:3;
1217 GLuint end_of_thread:1;
1218 } sampler_g4x;
1219
1220 /** Ironlake PRM, Volume 4 Part 1, Section 4.11.1.1.3 */
1221 struct {
1222 GLuint binding_table_index:8;
1223 GLuint sampler:4;
1224 GLuint msg_type:4;
1225 GLuint simd_mode:2;
1226 GLuint pad0:1;
1227 GLuint header_present:1;
1228 GLuint response_length:5;
1229 GLuint msg_length:4;
1230 GLuint pad1:2;
1231 GLuint end_of_thread:1;
1232 } sampler_gen5;
1233
1234 struct {
1235 GLuint binding_table_index:8;
1236 GLuint sampler:4;
1237 GLuint msg_type:5;
1238 GLuint simd_mode:2;
1239 GLuint header_present:1;
1240 GLuint response_length:5;
1241 GLuint msg_length:4;
1242 GLuint pad1:2;
1243 GLuint end_of_thread:1;
1244 } sampler_gen7;
1245
1246 struct brw_urb_immediate urb;
1247
1248 struct {
1249 GLuint opcode:4;
1250 GLuint offset:6;
1251 GLuint swizzle_control:2;
1252 GLuint pad:1;
1253 GLuint allocate:1;
1254 GLuint used:1;
1255 GLuint complete:1;
1256 GLuint pad0:3;
1257 GLuint header_present:1;
1258 GLuint response_length:5;
1259 GLuint msg_length:4;
1260 GLuint pad1:2;
1261 GLuint end_of_thread:1;
1262 } urb_gen5;
1263
1264 struct {
1265 GLuint opcode:3;
1266 GLuint offset:11;
1267 GLuint swizzle_control:1;
1268 GLuint complete:1;
1269 GLuint per_slot_offset:1;
1270 GLuint pad0:2;
1271 GLuint header_present:1;
1272 GLuint response_length:5;
1273 GLuint msg_length:4;
1274 GLuint pad1:2;
1275 GLuint end_of_thread:1;
1276 } urb_gen7;
1277
1278 /** 965 PRM, Volume 4, Section 5.10.1.1: Message Descriptor */
1279 struct {
1280 GLuint binding_table_index:8;
1281 GLuint msg_control:4;
1282 GLuint msg_type:2;
1283 GLuint target_cache:2;
1284 GLuint response_length:4;
1285 GLuint msg_length:4;
1286 GLuint msg_target:4;
1287 GLuint pad1:3;
1288 GLuint end_of_thread:1;
1289 } dp_read;
1290
1291 /** G45 PRM, Volume 4, Section 5.10.1.1.2 */
1292 struct {
1293 GLuint binding_table_index:8;
1294 GLuint msg_control:3;
1295 GLuint msg_type:3;
1296 GLuint target_cache:2;
1297 GLuint response_length:4;
1298 GLuint msg_length:4;
1299 GLuint msg_target:4;
1300 GLuint pad1:3;
1301 GLuint end_of_thread:1;
1302 } dp_read_g4x;
1303
1304 /** Ironlake PRM, Volume 4 Part 1, Section 5.10.2.1.2. */
1305 struct {
1306 GLuint binding_table_index:8;
1307 GLuint msg_control:3;
1308 GLuint msg_type:3;
1309 GLuint target_cache:2;
1310 GLuint pad0:3;
1311 GLuint header_present:1;
1312 GLuint response_length:5;
1313 GLuint msg_length:4;
1314 GLuint pad1:2;
1315 GLuint end_of_thread:1;
1316 } dp_read_gen5;
1317
1318 /** G45 PRM, Volume 4, Section 5.10.1.1.2. For both Gen4 and G45. */
1319 struct {
1320 GLuint binding_table_index:8;
1321 GLuint msg_control:3;
1322 GLuint last_render_target:1;
1323 GLuint msg_type:3;
1324 GLuint send_commit_msg:1;
1325 GLuint response_length:4;
1326 GLuint msg_length:4;
1327 GLuint msg_target:4;
1328 GLuint pad1:3;
1329 GLuint end_of_thread:1;
1330 } dp_write;
1331
1332 /** Ironlake PRM, Volume 4 Part 1, Section 5.10.2.1.2. */
1333 struct {
1334 GLuint binding_table_index:8;
1335 GLuint msg_control:3;
1336 GLuint last_render_target:1;
1337 GLuint msg_type:3;
1338 GLuint send_commit_msg:1;
1339 GLuint pad0:3;
1340 GLuint header_present:1;
1341 GLuint response_length:5;
1342 GLuint msg_length:4;
1343 GLuint pad1:2;
1344 GLuint end_of_thread:1;
1345 } dp_write_gen5;
1346
1347 /**
1348 * Message for the Sandybridge Sampler Cache or Constant Cache Data Port.
1349 *
1350 * See the Sandybridge PRM, Volume 4 Part 1, Section 3.9.2.1.1.
1351 **/
1352 struct {
1353 GLuint binding_table_index:8;
1354 GLuint msg_control:5;
1355 GLuint msg_type:3;
1356 GLuint pad0:3;
1357 GLuint header_present:1;
1358 GLuint response_length:5;
1359 GLuint msg_length:4;
1360 GLuint pad1:2;
1361 GLuint end_of_thread:1;
1362 } gen6_dp_sampler_const_cache;
1363
1364 /**
1365 * Message for the Sandybridge Render Cache Data Port.
1366 *
1367 * Most fields are defined in the Sandybridge PRM, Volume 4 Part 1,
1368 * Section 3.9.2.1.1: Message Descriptor.
1369 *
1370 * "Slot Group Select" and "Last Render Target" are part of the
1371 * 5-bit message control for Render Target Write messages. See
1372 * Section 3.9.9.2.1 of the same volume.
1373 */
1374 struct {
1375 GLuint binding_table_index:8;
1376 GLuint msg_control:3;
1377 GLuint slot_group_select:1;
1378 GLuint last_render_target:1;
1379 GLuint msg_type:4;
1380 GLuint send_commit_msg:1;
1381 GLuint pad0:1;
1382 GLuint header_present:1;
1383 GLuint response_length:5;
1384 GLuint msg_length:4;
1385 GLuint pad1:2;
1386 GLuint end_of_thread:1;
1387 } gen6_dp;
1388
1389 /**
1390 * Message for any of the Gen7 Data Port caches.
1391 *
1392 * Most fields are defined in BSpec volume 5c.2 Data Port / Messages /
1393 * Data Port Messages / Message Descriptor. Once again, "Slot Group
1394 * Select" and "Last Render Target" are part of the 6-bit message
1395 * control for Render Target Writes.
1396 */
1397 struct {
1398 GLuint binding_table_index:8;
1399 GLuint msg_control:3;
1400 GLuint slot_group_select:1;
1401 GLuint last_render_target:1;
1402 GLuint msg_control_pad:1;
1403 GLuint msg_type:4;
1404 GLuint pad1:1;
1405 GLuint header_present:1;
1406 GLuint response_length:5;
1407 GLuint msg_length:4;
1408 GLuint pad2:2;
1409 GLuint end_of_thread:1;
1410 } gen7_dp;
1411 /** @} */
1412
1413 struct {
1414 GLuint src1_subreg_nr_high:1;
1415 GLuint src1_reg_nr:8;
1416 GLuint pad0:1;
1417 GLuint src2_rep_ctrl:1;
1418 GLuint src2_swizzle:8;
1419 GLuint src2_subreg_nr:3;
1420 GLuint src2_reg_nr:8;
1421 GLuint pad1:2;
1422 } da3src;
1423
1424 GLint d;
1425 GLuint ud;
1426 float f;
1427 } bits3;
1428 };
1429
1430 struct brw_compact_instruction {
1431 struct {
1432 unsigned opcode:7; /* 0- 6 */
1433 unsigned debug_control:1; /* 7- 7 */
1434 unsigned control_index:5; /* 8-12 */
1435 unsigned data_type_index:5; /* 13-17 */
1436 unsigned sub_reg_index:5; /* 18-22 */
1437 unsigned acc_wr_control:1; /* 23-23 */
1438 unsigned conditionalmod:4; /* 24-27 */
1439 unsigned flag_subreg_nr:1; /* 28-28 */
1440 unsigned cmpt_ctrl:1; /* 29-29 */
1441 unsigned src0_index:2; /* 30-31 */
1442 } dw0;
1443
1444 struct {
1445 unsigned src0_index:3; /* 32-24 */
1446 unsigned src1_index:5; /* 35-39 */
1447 unsigned dst_reg_nr:8; /* 40-47 */
1448 unsigned src0_reg_nr:8; /* 48-55 */
1449 unsigned src1_reg_nr:8; /* 56-63 */
1450 } dw1;
1451 };
1452
1453 #endif