2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
36 #include "pipe/p_compiler.h"
58 unsigned notify_enable
:1;
60 unsigned wc_flush_enable
:1;
61 unsigned depth_stall_enable
:1;
69 unsigned dest_addr_type
:1;
70 unsigned dest_addr
:29;
78 struct brw_3d_primitive
89 unsigned verts_per_instance
;
90 unsigned start_vert_location
;
91 unsigned instance_count
;
92 unsigned start_instance_location
;
93 unsigned base_vert_location
;
96 /* These seem to be passed around as function args, so it works out
97 * better to keep them as #defines:
99 #define BRW_FLUSH_READ_CACHE 0x1
100 #define BRW_FLUSH_STATE_CACHE 0x2
101 #define BRW_INHIBIT_FLUSH_RENDER_CACHE 0x4
102 #define BRW_FLUSH_SNAPSHOT_COUNTERS 0x8
111 struct brw_vf_statistics
113 unsigned statistics_enable
:1;
120 struct brw_binding_table_pointers
122 struct header header
;
131 struct brw_blend_constant_color
133 struct header header
;
134 float blend_constant_color
[4];
138 struct brw_depthbuffer
140 union header_union header
;
147 unsigned depth_offset_disable
:1;
148 unsigned tile_walk
:1;
149 unsigned tiled_surface
:1;
151 unsigned surface_type
:3;
156 unsigned dword2_base_addr
;
161 unsigned mipmap_layout
:1;
172 unsigned min_array_element
:9;
181 struct header header
;
193 struct brw_global_depth_offset_clamp
195 struct header header
;
196 float depth_offset_clamp
;
199 struct brw_indexbuffer
205 unsigned index_format
:2;
206 unsigned cut_index_enable
:1;
214 unsigned buffer_start
;
219 struct brw_line_stipple
221 struct header header
;
231 unsigned repeat_count
:9;
233 unsigned inverse_repeat_count
:16;
238 struct brw_pipelined_state_pointers
240 struct header header
;
276 unsigned offset
:27; /* KW: check me! */
281 struct brw_polygon_stipple_offset
283 struct header header
;
295 struct brw_polygon_stipple
297 struct header header
;
298 unsigned stipple
[32];
303 struct brw_pipeline_select
307 unsigned pipeline_select
:1;
314 struct brw_pipe_control
319 unsigned notify_enable
:1;
321 unsigned instruction_state_cache_flush_enable
:1;
322 unsigned write_cache_flush_enable
:1;
323 unsigned depth_stall_enable
:1;
324 unsigned post_sync_operation
:2;
332 unsigned dest_addr_type
:1;
333 unsigned dest_addr
:29;
346 unsigned vs_realloc
:1;
347 unsigned gs_realloc
:1;
348 unsigned clp_realloc
:1;
349 unsigned sf_realloc
:1;
350 unsigned vfe_realloc
:1;
351 unsigned cs_realloc
:1;
358 unsigned vs_fence
:10;
359 unsigned gs_fence
:10;
360 unsigned clp_fence
:10;
366 unsigned sf_fence
:10;
367 unsigned vf_fence
:10;
368 unsigned cs_fence
:10;
373 struct brw_constant_buffer_state
/* previously brw_command_streamer */
375 struct header header
;
379 unsigned nr_urb_entries
:3;
381 unsigned urb_entry_size
:5;
386 struct brw_constant_buffer
398 unsigned buffer_length
:6;
399 unsigned buffer_address
:26;
403 struct brw_state_base_address
405 struct header header
;
409 unsigned modify_enable
:1;
411 unsigned general_state_address
:27;
416 unsigned modify_enable
:1;
418 unsigned surface_state_address
:27;
423 unsigned modify_enable
:1;
425 unsigned indirect_object_state_address
:27;
430 unsigned modify_enable
:1;
432 unsigned general_state_upper_bound
:20;
437 unsigned modify_enable
:1;
439 unsigned indirect_object_state_upper_bound
:20;
443 struct brw_state_prefetch
445 struct header header
;
449 unsigned prefetch_count
:3;
451 unsigned prefetch_pointer
:26;
455 struct brw_system_instruction_pointer
457 struct header header
;
462 unsigned system_instruction_pointer
:28;
469 /* State structs for the various fixed function units:
476 unsigned grf_reg_count
:3;
478 unsigned kernel_start_pointer
:26;
483 unsigned ext_halt_exception_enable
:1;
484 unsigned sw_exception_enable
:1;
485 unsigned mask_stack_exception_enable
:1;
486 unsigned timeout_exception_enable
:1;
487 unsigned illegal_op_exception_enable
:1;
489 unsigned depth_coef_urb_read_offset
:6; /* WM only */
491 unsigned floating_point_mode
:1;
492 unsigned thread_priority
:1;
493 unsigned binding_table_entry_count
:8;
495 unsigned single_program_flow
:1;
500 unsigned per_thread_scratch_space
:4;
502 unsigned scratch_space_base_pointer
:22;
508 unsigned dispatch_grf_start_reg
:4;
509 unsigned urb_entry_read_offset
:6;
511 unsigned urb_entry_read_length
:6;
513 unsigned const_urb_entry_read_offset
:6;
515 unsigned const_urb_entry_read_length
:6;
521 struct brw_clip_unit_state
523 struct thread0 thread0
;
527 unsigned sw_exception_enable
:1;
529 unsigned mask_stack_exception_enable
:1;
531 unsigned illegal_op_exception_enable
:1;
533 unsigned floating_point_mode
:1;
534 unsigned thread_priority
:1;
535 unsigned binding_table_entry_count
:8;
537 unsigned single_program_flow
:1;
540 struct thread2 thread2
;
541 struct thread3 thread3
;
546 unsigned gs_output_stats
:1; /* not always */
547 unsigned stats_enable
:1;
548 unsigned nr_urb_entries
:7;
550 unsigned urb_entry_allocation_size
:5;
552 unsigned max_threads
:1; /* may be less */
559 unsigned clip_mode
:3;
560 unsigned userclip_enable_flags
:8;
561 unsigned userclip_must_clip
:1;
563 unsigned guard_band_enable
:1;
564 unsigned viewport_z_clip_enable
:1;
565 unsigned viewport_xy_clip_enable
:1;
566 unsigned vertex_position_space
:1;
574 unsigned clipper_viewport_state_ptr
:27;
586 struct brw_cc_unit_state
591 unsigned bf_stencil_pass_depth_pass_op
:3;
592 unsigned bf_stencil_pass_depth_fail_op
:3;
593 unsigned bf_stencil_fail_op
:3;
594 unsigned bf_stencil_func
:3;
595 unsigned bf_stencil_enable
:1;
597 unsigned stencil_write_enable
:1;
598 unsigned stencil_pass_depth_pass_op
:3;
599 unsigned stencil_pass_depth_fail_op
:3;
600 unsigned stencil_fail_op
:3;
601 unsigned stencil_func
:3;
602 unsigned stencil_enable
:1;
608 unsigned bf_stencil_ref
:8;
609 unsigned stencil_write_mask
:8;
610 unsigned stencil_test_mask
:8;
611 unsigned stencil_ref
:8;
617 unsigned logicop_enable
:1;
619 unsigned depth_write_enable
:1;
620 unsigned depth_test_function
:3;
621 unsigned depth_test
:1;
622 unsigned bf_stencil_write_mask
:8;
623 unsigned bf_stencil_test_mask
:8;
630 unsigned alpha_test_func
:3;
631 unsigned alpha_test
:1;
632 unsigned blend_enable
:1;
633 unsigned ia_blend_enable
:1;
635 unsigned alpha_test_format
:1;
642 unsigned cc_viewport_state_offset
:27;
648 unsigned ia_dest_blend_factor
:5;
649 unsigned ia_src_blend_factor
:5;
650 unsigned ia_blend_function
:3;
651 unsigned statistics_enable
:1;
652 unsigned logicop_func
:4;
654 unsigned dither_enable
:1;
659 unsigned clamp_post_alpha_blend
:1;
660 unsigned clamp_pre_alpha_blend
:1;
661 unsigned clamp_range
:2;
663 unsigned y_dither_offset
:2;
664 unsigned x_dither_offset
:2;
665 unsigned dest_blend_factor
:5;
666 unsigned src_blend_factor
:5;
667 unsigned blend_function
:3;
680 struct brw_sf_unit_state
682 struct thread0 thread0
;
683 struct thread1 thread1
;
684 struct thread2 thread2
;
685 struct thread3 thread3
;
690 unsigned stats_enable
:1;
691 unsigned nr_urb_entries
:7;
693 unsigned urb_entry_allocation_size
:5;
695 unsigned max_threads
:6;
701 unsigned front_winding
:1;
702 unsigned viewport_transform
:1;
704 unsigned sf_viewport_state_offset
:27;
710 unsigned dest_org_vbias
:4;
711 unsigned dest_org_hbias
:4;
713 unsigned disable_2x2_trifilter
:1;
714 unsigned disable_zero_pix_trifilter
:1;
715 unsigned point_rast_rule
:2;
716 unsigned line_endcap_aa_region_width
:2;
717 unsigned line_width
:4;
718 unsigned fast_scissor_disable
:1;
719 unsigned cull_mode
:2;
720 unsigned aa_enable
:1;
725 unsigned point_size
:11;
726 unsigned use_point_size_state
:1;
727 unsigned subpixel_precision
:1;
728 unsigned sprite_point
:1;
730 unsigned trifan_pv
:2;
731 unsigned linestrip_pv
:2;
732 unsigned tristrip_pv
:2;
733 unsigned line_last_pixel_enable
:1;
739 struct brw_gs_unit_state
741 struct thread0 thread0
;
742 struct thread1 thread1
;
743 struct thread2 thread2
;
744 struct thread3 thread3
;
749 unsigned stats_enable
:1;
750 unsigned nr_urb_entries
:7;
752 unsigned urb_entry_allocation_size
:5;
754 unsigned max_threads
:1;
760 unsigned sampler_count
:3;
762 unsigned sampler_state_pointer
:27;
768 unsigned max_vp_index
:4;
770 unsigned reorder_enable
:1;
776 struct brw_vs_unit_state
778 struct thread0 thread0
;
779 struct thread1 thread1
;
780 struct thread2 thread2
;
781 struct thread3 thread3
;
786 unsigned stats_enable
:1;
787 unsigned nr_urb_entries
:7;
789 unsigned urb_entry_allocation_size
:5;
791 unsigned max_threads
:4;
797 unsigned sampler_count
:3;
799 unsigned sampler_state_pointer
:27;
804 unsigned vs_enable
:1;
805 unsigned vert_cache_disable
:1;
811 struct brw_wm_unit_state
813 struct thread0 thread0
;
814 struct thread1 thread1
;
815 struct thread2 thread2
;
816 struct thread3 thread3
;
819 unsigned stats_enable
:1;
821 unsigned sampler_count
:3;
822 unsigned sampler_state_pointer
:27;
827 unsigned enable_8_pix
:1;
828 unsigned enable_16_pix
:1;
829 unsigned enable_32_pix
:1;
831 unsigned legacy_global_depth_bias
:1;
832 unsigned line_stipple
:1;
833 unsigned depth_offset
:1;
834 unsigned polygon_stipple
:1;
835 unsigned line_aa_region_width
:2;
836 unsigned line_endcap_aa_region_width
:2;
837 unsigned early_depth_test
:1;
838 unsigned thread_dispatch_enable
:1;
839 unsigned program_uses_depth
:1;
840 unsigned program_computes_depth
:1;
841 unsigned program_uses_killpixel
:1;
842 unsigned legacy_line_rast
: 1;
844 unsigned max_threads
:6;
848 float global_depth_offset_constant
;
849 float global_depth_offset_scale
;
852 struct brw_sampler_default_color
{
856 struct brw_sampler_state
861 unsigned shadow_function
:3;
862 unsigned lod_bias
:11;
863 unsigned min_filter
:3;
864 unsigned mag_filter
:3;
865 unsigned mip_filter
:2;
866 unsigned base_level
:5;
868 unsigned lod_preclamp
:1;
869 unsigned default_color_mode
:1;
876 unsigned r_wrap_mode
:3;
877 unsigned t_wrap_mode
:3;
878 unsigned s_wrap_mode
:3;
888 unsigned default_color_pointer
:27;
894 unsigned max_aniso
:3;
895 unsigned chroma_key_mode
:1;
896 unsigned chroma_key_index
:2;
897 unsigned chroma_key_enable
:1;
898 unsigned monochrome_filter_width
:3;
899 unsigned monochrome_filter_height
:3;
904 struct brw_clipper_viewport
912 struct brw_cc_viewport
918 struct brw_sf_viewport
937 /* Documented in the subsystem/shared-functions/sampler chapter...
939 struct brw_surface_state
942 unsigned cube_pos_z
:1;
943 unsigned cube_neg_z
:1;
944 unsigned cube_pos_y
:1;
945 unsigned cube_neg_y
:1;
946 unsigned cube_pos_x
:1;
947 unsigned cube_neg_x
:1;
949 unsigned mipmap_layout_mode
:1;
950 unsigned vert_line_stride_ofs
:1;
951 unsigned vert_line_stride
:1;
952 unsigned color_blend
:1;
953 unsigned writedisable_blue
:1;
954 unsigned writedisable_green
:1;
955 unsigned writedisable_red
:1;
956 unsigned writedisable_alpha
:1;
957 unsigned surface_format
:9;
958 unsigned data_return_format
:1;
960 unsigned surface_type
:3;
969 unsigned mip_count
:4;
975 unsigned tile_walk
:1;
976 unsigned tiled_surface
:1;
984 unsigned min_array_elt
:9;
991 struct brw_vertex_buffer_state
996 unsigned access_type
:1;
1000 unsigned start_addr
;
1003 unsigned instance_data_step_rate
; /* not included for sequential/random vertices? */
1007 #define BRW_VBP_MAX 17
1009 struct brw_vb_array_state
{
1010 struct header header
;
1011 struct brw_vertex_buffer_state vb
[BRW_VBP_MAX
];
1015 struct brw_vertex_element_state
1019 unsigned src_offset
:11;
1021 unsigned src_format
:9;
1024 unsigned vertex_buffer_index
:5;
1029 unsigned dst_offset
:8;
1031 unsigned vfcomponent3
:4;
1032 unsigned vfcomponent2
:4;
1033 unsigned vfcomponent1
:4;
1034 unsigned vfcomponent0
:4;
1038 #define BRW_VEP_MAX 18
1040 struct brw_vertex_element_packet
{
1041 struct header header
;
1042 struct brw_vertex_element_state ve
[BRW_VEP_MAX
]; /* note: less than _TNL_ATTRIB_MAX */
1046 struct brw_urb_immediate
{
1049 unsigned swizzle_control
:2;
1051 unsigned allocate
:1;
1053 unsigned complete
:1;
1054 unsigned response_length
:4;
1055 unsigned msg_length
:4;
1056 unsigned msg_target
:4;
1058 unsigned end_of_thread
:1;
1061 /* Instruction format for the execution units:
1064 struct brw_instruction
1070 unsigned access_mode
:1;
1071 unsigned mask_control
:1;
1072 unsigned dependency_control
:2;
1073 unsigned compression_control
:2;
1074 unsigned thread_control
:2;
1075 unsigned predicate_control
:4;
1076 unsigned predicate_inverse
:1;
1077 unsigned execution_size
:3;
1078 unsigned destreg__conditonalmod
:4; /* destreg - send, conditionalmod - others */
1080 unsigned debug_control
:1;
1081 unsigned saturate
:1;
1087 unsigned dest_reg_file
:2;
1088 unsigned dest_reg_type
:3;
1089 unsigned src0_reg_file
:2;
1090 unsigned src0_reg_type
:3;
1091 unsigned src1_reg_file
:2;
1092 unsigned src1_reg_type
:3;
1094 unsigned dest_subreg_nr
:5;
1095 unsigned dest_reg_nr
:8;
1096 unsigned dest_horiz_stride
:2;
1097 unsigned dest_address_mode
:1;
1102 unsigned dest_reg_file
:2;
1103 unsigned dest_reg_type
:3;
1104 unsigned src0_reg_file
:2;
1105 unsigned src0_reg_type
:3;
1107 int dest_indirect_offset
:10; /* offset against the deref'd address reg */
1108 unsigned dest_subreg_nr
:3; /* subnr for the address reg a0.x */
1109 unsigned dest_horiz_stride
:2;
1110 unsigned dest_address_mode
:1;
1115 unsigned dest_reg_file
:2;
1116 unsigned dest_reg_type
:3;
1117 unsigned src0_reg_file
:2;
1118 unsigned src0_reg_type
:3;
1119 unsigned src1_reg_file
:2;
1120 unsigned src1_reg_type
:3;
1122 unsigned dest_writemask
:4;
1123 unsigned dest_subreg_nr
:1;
1124 unsigned dest_reg_nr
:8;
1126 unsigned dest_address_mode
:1;
1131 unsigned dest_reg_file
:2;
1132 unsigned dest_reg_type
:3;
1133 unsigned src0_reg_file
:2;
1134 unsigned src0_reg_type
:3;
1136 unsigned dest_writemask
:4;
1137 int dest_indirect_offset
:6;
1138 unsigned dest_subreg_nr
:3;
1140 unsigned dest_address_mode
:1;
1148 unsigned src0_subreg_nr
:5;
1149 unsigned src0_reg_nr
:8;
1150 unsigned src0_abs
:1;
1151 unsigned src0_negate
:1;
1152 unsigned src0_address_mode
:1;
1153 unsigned src0_horiz_stride
:2;
1154 unsigned src0_width
:3;
1155 unsigned src0_vert_stride
:4;
1156 unsigned flag_reg_nr
:1;
1162 int src0_indirect_offset
:10;
1163 unsigned src0_subreg_nr
:3;
1164 unsigned src0_abs
:1;
1165 unsigned src0_negate
:1;
1166 unsigned src0_address_mode
:1;
1167 unsigned src0_horiz_stride
:2;
1168 unsigned src0_width
:3;
1169 unsigned src0_vert_stride
:4;
1170 unsigned flag_reg_nr
:1;
1176 unsigned src0_swz_x
:2;
1177 unsigned src0_swz_y
:2;
1178 unsigned src0_subreg_nr
:1;
1179 unsigned src0_reg_nr
:8;
1180 unsigned src0_abs
:1;
1181 unsigned src0_negate
:1;
1182 unsigned src0_address_mode
:1;
1183 unsigned src0_swz_z
:2;
1184 unsigned src0_swz_w
:2;
1186 unsigned src0_vert_stride
:4;
1187 unsigned flag_reg_nr
:1;
1193 unsigned src0_swz_x
:2;
1194 unsigned src0_swz_y
:2;
1195 int src0_indirect_offset
:6;
1196 unsigned src0_subreg_nr
:3;
1197 unsigned src0_abs
:1;
1198 unsigned src0_negate
:1;
1199 unsigned src0_address_mode
:1;
1200 unsigned src0_swz_z
:2;
1201 unsigned src0_swz_w
:2;
1203 unsigned src0_vert_stride
:4;
1204 unsigned flag_reg_nr
:1;
1214 unsigned src1_subreg_nr
:5;
1215 unsigned src1_reg_nr
:8;
1216 unsigned src1_abs
:1;
1217 unsigned src1_negate
:1;
1219 unsigned src1_horiz_stride
:2;
1220 unsigned src1_width
:3;
1221 unsigned src1_vert_stride
:4;
1227 unsigned src1_swz_x
:2;
1228 unsigned src1_swz_y
:2;
1229 unsigned src1_subreg_nr
:1;
1230 unsigned src1_reg_nr
:8;
1231 unsigned src1_abs
:1;
1232 unsigned src1_negate
:1;
1234 unsigned src1_swz_z
:2;
1235 unsigned src1_swz_w
:2;
1237 unsigned src1_vert_stride
:4;
1243 int src1_indirect_offset
:10;
1244 unsigned src1_subreg_nr
:3;
1245 unsigned src1_abs
:1;
1246 unsigned src1_negate
:1;
1248 unsigned src1_horiz_stride
:2;
1249 unsigned src1_width
:3;
1250 unsigned src1_vert_stride
:4;
1251 unsigned flag_reg_nr
:1;
1257 unsigned src1_swz_x
:2;
1258 unsigned src1_swz_y
:2;
1259 int src1_indirect_offset
:6;
1260 unsigned src1_subreg_nr
:3;
1261 unsigned src1_abs
:1;
1262 unsigned src1_negate
:1;
1264 unsigned src1_swz_z
:2;
1265 unsigned src1_swz_w
:2;
1267 unsigned src1_vert_stride
:4;
1268 unsigned flag_reg_nr
:1;
1275 int jump_count
:16; /* note: signed */
1276 unsigned pop_count
:4;
1281 unsigned function
:4;
1282 unsigned int_type
:1;
1283 unsigned precision
:1;
1284 unsigned saturate
:1;
1285 unsigned data_type
:1;
1287 unsigned response_length
:4;
1288 unsigned msg_length
:4;
1289 unsigned msg_target
:4;
1291 unsigned end_of_thread
:1;
1295 unsigned binding_table_index
:8;
1297 unsigned return_format
:2;
1298 unsigned msg_type
:2;
1299 unsigned response_length
:4;
1300 unsigned msg_length
:4;
1301 unsigned msg_target
:4;
1303 unsigned end_of_thread
:1;
1306 struct brw_urb_immediate urb
;
1309 unsigned binding_table_index
:8;
1310 unsigned msg_control
:4;
1311 unsigned msg_type
:2;
1312 unsigned target_cache
:2;
1313 unsigned response_length
:4;
1314 unsigned msg_length
:4;
1315 unsigned msg_target
:4;
1317 unsigned end_of_thread
:1;
1321 unsigned binding_table_index
:8;
1322 unsigned msg_control
:3;
1323 unsigned pixel_scoreboard_clear
:1;
1324 unsigned msg_type
:3;
1325 unsigned send_commit_msg
:1;
1326 unsigned response_length
:4;
1327 unsigned msg_length
:4;
1328 unsigned msg_target
:4;
1330 unsigned end_of_thread
:1;
1335 unsigned response_length
:4;
1336 unsigned msg_length
:4;
1337 unsigned msg_target
:4;
1339 unsigned end_of_thread
:1;