1 #ifndef GEN7_RENDER_H 2 #define GEN7_RENDER_H 3 4 #include <stdint.h> 5 #include "surfaceformat.h" 6 #include "gen6_render.h" 7 8 #define INTEL_MASK(high, low) (((1 << ((high) - (low) + 1)) - 1) << (low)) 9 10 11 /* GEN7_3DSTATE_WM */ 12 /* DW1 */ 13 # define GEN7_WM_STATISTICS_ENABLE (1 << 31) 14 # define GEN7_WM_DEPTH_CLEAR (1 << 30) 15 # define GEN7_WM_DISPATCH_ENABLE (1 << 29) 16 # define GEN7_WM_DEPTH_RESOLVE (1 << 28) 17 # define GEN7_WM_HIERARCHICAL_DEPTH_RESOLVE (1 << 27) 18 # define GEN7_WM_KILL_ENABLE (1 << 25) 19 # define GEN7_WM_PSCDEPTH_OFF (0 << 23) 20 # define GEN7_WM_PSCDEPTH_ON (1 << 23) 21 # define GEN7_WM_PSCDEPTH_ON_GE (2 << 23) 22 # define GEN7_WM_PSCDEPTH_ON_LE (3 << 23) 23 # define GEN7_WM_USES_SOURCE_DEPTH (1 << 20) 24 # define GEN7_WM_USES_SOURCE_W (1 << 19) 25 # define GEN7_WM_POSITION_ZW_PIXEL (0 << 17) 26 # define GEN7_WM_POSITION_ZW_CENTROID (2 << 17) 27 # define GEN7_WM_POSITION_ZW_SAMPLE (3 << 17) 28 # define GEN7_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC (1 << 16) 29 # define GEN7_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC (1 << 15) 30 # define GEN7_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC (1 << 14) 31 # define GEN7_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC (1 << 13) 32 # define GEN7_WM_PERSPECTIVE_CENTROID_BARYCENTRIC (1 << 12) 33 # define GEN7_WM_PERSPECTIVE_PIXEL_BARYCENTRIC (1 << 11) 34 # define GEN7_WM_USES_INPUT_COVERAGE_MASK (1 << 10) 35 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_0_5 (0 << 8) 36 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0 (1 << 8) 37 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_2_0 (2 << 8) 38 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_4_0 (3 << 8) 39 # define GEN7_WM_LINE_AA_WIDTH_0_5 (0 << 6) 40 # define GEN7_WM_LINE_AA_WIDTH_1_0 (1 << 6) 41 # define GEN7_WM_LINE_AA_WIDTH_2_0 (2 << 6) 42 # define GEN7_WM_LINE_AA_WIDTH_4_0 (3 << 6) 43 # define GEN7_WM_POLYGON_STIPPLE_ENABLE (1 << 4) 44 # define GEN7_WM_LINE_STIPPLE_ENABLE (1 << 3) 45 # define GEN7_WM_POINT_RASTRULE_UPPER_RIGHT (1 << 2) 46 # define GEN7_WM_MSRAST_OFF_PIXEL (0 << 0) 47 # define GEN7_WM_MSRAST_OFF_PATTERN (1 << 0) 48 # define GEN7_WM_MSRAST_ON_PIXEL (2 << 0) 49 # define GEN7_WM_MSRAST_ON_PATTERN (3 << 0) 50 /* DW2 */ 51 # define GEN7_WM_MSDISPMODE_PERPIXEL (1 << 31) 52 53 /* Surface state DW0 */ 54 #define GEN7_SURFACE_RC_READ_WRITE (1 << 8) 55 #define GEN7_SURFACE_TILED (1 << 14) 56 #define GEN7_SURFACE_TILED_Y (1 << 13) 57 #define GEN7_SURFACE_FORMAT_SHIFT 18 58 #define GEN7_SURFACE_TYPE_SHIFT 29 59 60 /* Surface state DW2 */ 61 #define GEN7_SURFACE_HEIGHT_SHIFT 16 62 #define GEN7_SURFACE_WIDTH_SHIFT 0 63 64 /* Surface state DW3 */ 65 #define GEN7_SURFACE_DEPTH_SHIFT 21 66 #define GEN7_SURFACE_PITCH_SHIFT 0 67 68 #define HSW_SWIZZLE_ZERO 0 69 #define HSW_SWIZZLE_ONE 1 70 #define HSW_SWIZZLE_RED 4 71 #define HSW_SWIZZLE_GREEN 5 72 #define HSW_SWIZZLE_BLUE 6 73 #define HSW_SWIZZLE_ALPHA 7 74 #define __HSW_SURFACE_SWIZZLE(r,g,b,a) \ 75 ((a) << 16 | (b) << 19 | (g) << 22 | (r) << 25) 76 #define HSW_SURFACE_SWIZZLE(r,g,b,a) \ 77 __HSW_SURFACE_SWIZZLE(HSW_SWIZZLE_##r, HSW_SWIZZLE_##g, HSW_SWIZZLE_##b, HSW_SWIZZLE_##a) 78 79 /* _3DSTATE_VERTEX_BUFFERS on GEN7*/ 80 /* DW1 */ 81 #define GEN7_VB0_ADDRESS_MODIFYENABLE (1 << 14) 82 83 /* _3DPRIMITIVE on GEN7 */ 84 /* DW1 */ 85 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 8) 86 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM (1 << 8) 87 88 #define GEN7_3DSTATE_CLEAR_PARAMS GEN4_3D(3, 0, 0x04) 89 #define GEN7_3DSTATE_DEPTH_BUFFER GEN4_3D(3, 0, 0x05) 90 # define GEN7_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT 29 91 # define GEN7_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT 18 92 /* DW1 */ 93 # define GEN7_3DSTATE_DEPTH_CLEAR_VALID (1 << 15) 94 95 #define GEN7_3DSTATE_CONSTANT_HS GEN4_3D(3, 0, 0x19) 96 #define GEN7_3DSTATE_CONSTANT_DS GEN4_3D(3, 0, 0x1a) 97 98 #define GEN7_3DSTATE_HS GEN4_3D(3, 0, 0x1b) 99 #define GEN7_3DSTATE_TE GEN4_3D(3, 0, 0x1c) 100 #define GEN7_3DSTATE_DS GEN4_3D(3, 0, 0x1d) 101 #define GEN7_3DSTATE_STREAMOUT GEN4_3D(3, 0, 0x1e) 102 #define GEN7_3DSTATE_SBE GEN4_3D(3, 0, 0x1f) 103 104 /* DW1 */ 105 # define GEN7_SBE_SWIZZLE_CONTROL_MODE (1 << 28) 106 # define GEN7_SBE_NUM_OUTPUTS_SHIFT 22 107 # define GEN7_SBE_SWIZZLE_ENABLE (1 << 21) 108 # define GEN7_SBE_POINT_SPRITE_LOWERLEFT (1 << 20) 109 # define GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT 11 110 # define GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT 4 111 112 #define GEN7_3DSTATE_PS GEN4_3D(3, 0, 0x20) 113 /* DW1: kernel pointer */ 114 /* DW2 */ 115 # define GEN7_PS_SPF_MODE (1 << 31) 116 # define GEN7_PS_VECTOR_MASK_ENABLE (1 << 30) 117 # define GEN7_PS_SAMPLER_COUNT_SHIFT 27 118 # define GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18 119 # define GEN7_PS_FLOATING_POINT_MODE_IEEE_754 (0 << 16) 120 # define GEN7_PS_FLOATING_POINT_MODE_ALT (1 << 16) 121 /* DW3: scratch space */ 122 /* DW4 */ 123 # define IVB_PS_MAX_THREADS_SHIFT 24 124 # define HSW_PS_MAX_THREADS_SHIFT 23 125 # define HSW_PS_SAMPLE_MASK_SHIFT 12 126 # define GEN7_PS_PUSH_CONSTANT_ENABLE (1 << 11) 127 # define GEN7_PS_ATTRIBUTE_ENABLE (1 << 10) 128 # define GEN7_PS_OMASK_TO_RENDER_TARGET (1 << 9) 129 # define GEN7_PS_DUAL_SOURCE_BLEND_ENABLE (1 << 7) 130 # define GEN7_PS_POSOFFSET_NONE (0 << 3) 131 # define GEN7_PS_POSOFFSET_CENTROID (2 << 3) 132 # define GEN7_PS_POSOFFSET_SAMPLE (3 << 3) 133 # define GEN7_PS_32_DISPATCH_ENABLE (1 << 2) 134 # define GEN7_PS_16_DISPATCH_ENABLE (1 << 1) 135 # define GEN7_PS_8_DISPATCH_ENABLE (1 << 0) 136 /* DW5 */ 137 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_0 16 138 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_1 8 139 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_2 0 140 /* DW6: kernel 1 pointer */ 141 /* DW7: kernel 2 pointer */ 142 143 #define GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL GEN4_3D(3, 0, 0x21) 144 #define GEN7_3DSTATE_VIEWPORT_STATE_POINTERS_CC GEN4_3D(3, 0, 0x23) 145 146 #define GEN7_3DSTATE_BLEND_STATE_POINTERS GEN4_3D(3, 0, 0x24) 147 #define GEN7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS GEN4_3D(3, 0, 0x25) 148 149 #define GEN7_3DSTATE_BINDING_TABLE_POINTERS_VS GEN4_3D(3, 0, 0x26) 150 #define GEN7_3DSTATE_BINDING_TABLE_POINTERS_HS GEN4_3D(3, 0, 0x27) 151 #define GEN7_3DSTATE_BINDING_TABLE_POINTERS_DS GEN4_3D(3, 0, 0x28) 152 #define GEN7_3DSTATE_BINDING_TABLE_POINTERS_GS GEN4_3D(3, 0, 0x29) 153 #define GEN7_3DSTATE_BINDING_TABLE_POINTERS_PS GEN4_3D(3, 0, 0x2a) 154 155 #define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_VS GEN4_3D(3, 0, 0x2b) 156 #define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_GS GEN4_3D(3, 0, 0x2e) 157 #define GEN7_3DSTATE_SAMPLER_STATE_POINTERS_PS GEN4_3D(3, 0, 0x2f) 158 159 #define GEN7_3DSTATE_URB_VS GEN4_3D(3, 0, 0x30) 160 #define GEN7_3DSTATE_URB_HS GEN4_3D(3, 0, 0x31) 161 #define GEN7_3DSTATE_URB_DS GEN4_3D(3, 0, 0x32) 162 #define GEN7_3DSTATE_URB_GS GEN4_3D(3, 0, 0x33) 163 /* DW1 */ 164 # define GEN7_URB_ENTRY_NUMBER_SHIFT 0 165 # define GEN7_URB_ENTRY_SIZE_SHIFT 16 166 # define GEN7_URB_STARTING_ADDRESS_SHIFT 25 167 168 #define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_VS GEN4_3D(3, 1, 0x12) 169 #define GEN7_3DSTATE_PUSH_CONSTANT_ALLOC_PS GEN4_3D(3, 1, 0x16) 170 /* DW1 */ 171 # define GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT 16 172 173 /* for GEN7_STATE_BASE_ADDRESS */ 174 #define BASE_ADDRESS_MODIFY (1 << 0) 175 176 /* for GEN7_PIPE_CONTROL */ 177 #define GEN7_PIPE_CONTROL_CS_STALL (1 << 20) 178 #define GEN7_PIPE_CONTROL_STALL_AT_SCOREBOARD (1 << 1) 179 180 /* VERTEX_BUFFER_STATE Structure */ 181 #define GEN7_VB0_ADDRESS_MODIFY_ENABLE (1 << 14) 182 183 #define GEN7_TD_CTL 0x8000 184 185 /* Execution Unit (EU) defines */ 186 187 #define GEN7_ARF_IP 0xA0 188 189 #define VLV_MOCS_SNOOP (2 << 1) 190 #define VLV_MOCS_L3 (1 << 0) 191 192 #define IVB_MOCS_GFDT (1 << 2) 193 #define IVB_MOCS_PTE (0 << 1) 194 #define IVB_MOCS_LLC (1 << 1) 195 #define IVB_MOCS_L3 (1 << 0) 196 197 /* The hardware supports two different modes for border color. The 198 * default (OpenGL) mode uses floating-point color channels, while the 199 * legacy mode uses 4 bytes. 200 * 201 * More significantly, the legacy mode respects the components of the 202 * border color for channels not present in the source, (whereas the 203 * default mode will ignore the border color's alpha channel and use 204 * alpha==1 for an RGB source, for example). 205 * 206 * The legacy mode matches the semantics specified by the Render 207 * extension. 208 */ 209 struct gen7_surface_state { 210 struct { 211 unsigned int cube_pos_z:1; 212 unsigned int cube_neg_z:1; 213 unsigned int cube_pos_y:1; 214 unsigned int cube_neg_y:1; 215 unsigned int cube_pos_x:1; 216 unsigned int cube_neg_x:1; 217 unsigned int pad2:2; 218 unsigned int render_cache_read_write:1; 219 unsigned int pad1:1; 220 unsigned int surface_array_spacing:1; 221 unsigned int vert_line_stride_ofs:1; 222 unsigned int vert_line_stride:1; 223 unsigned int tile_walk:1; 224 unsigned int tiled_surface:1; 225 unsigned int horizontal_alignment:1; 226 unsigned int vertical_alignment:2; 227 unsigned int surface_format:9; /**< BRW_SURFACEFORMAT_x */ 228 unsigned int pad0:1; 229 unsigned int is_array:1; 230 unsigned int surface_type:3; /**< BRW_SURFACE_1D/2D/3D/CUBE */ 231 } ss0; 232 233 struct { 234 unsigned int base_addr; 235 } ss1; 236 237 struct { 238 unsigned int width:14; 239 unsigned int pad1:2; 240 unsigned int height:14; 241 unsigned int pad0:2; 242 } ss2; 243 244 struct { 245 unsigned int pitch:18; 246 unsigned int pad:3; 247 unsigned int depth:11; 248 } ss3; 249 250 struct { 251 unsigned int multisample_position_palette_index:3; 252 unsigned int num_multisamples:3; 253 unsigned int multisampled_surface_storage_format:1; 254 unsigned int render_target_view_extent:11; 255 unsigned int min_array_elt:11; 256 unsigned int rotation:2; 257 unsigned int pad0:1; 258 } ss4; 259 260 struct { 261 unsigned int mip_count:4; 262 unsigned int min_lod:4; 263 unsigned int pad1:8; 264 unsigned int memory_object_control:4; 265 unsigned int y_offset:4; 266 unsigned int pad0:1; 267 unsigned int x_offset:7; 268 } ss5; 269 270 struct { 271 unsigned int pad; /* Multisample Control Surface stuff */ 272 } ss6; 273 274 struct { 275 unsigned int resource_min_lod:12; 276 unsigned int pad0:16; 277 unsigned int alpha_clear_color:1; 278 unsigned int blue_clear_color:1; 279 unsigned int green_clear_color:1; 280 unsigned int red_clear_color:1; 281 } ss7; 282 }; 283 284 struct gen7_sampler_state { 285 struct { 286 unsigned int aniso_algorithm:1; 287 unsigned int lod_bias:13; 288 unsigned int min_filter:3; 289 unsigned int mag_filter:3; 290 unsigned int mip_filter:2; 291 unsigned int base_level:5; 292 unsigned int pad1:1; 293 unsigned int lod_preclamp:1; 294 unsigned int default_color_mode:1; 295 unsigned int pad0:1; 296 unsigned int disable:1; 297 } ss0; 298 299 struct { 300 unsigned int cube_control_mode:1; 301 unsigned int shadow_function:3; 302 unsigned int pad:4; 303 unsigned int max_lod:12; 304 unsigned int min_lod:12; 305 } ss1; 306 307 struct { 308 unsigned int pad:5; 309 unsigned int default_color_pointer:27; 310 } ss2; 311 312 struct { 313 unsigned int r_wrap_mode:3; 314 unsigned int t_wrap_mode:3; 315 unsigned int s_wrap_mode:3; 316 unsigned int pad:1; 317 unsigned int non_normalized_coord:1; 318 unsigned int trilinear_quality:2; 319 unsigned int address_round:6; 320 unsigned int max_aniso:3; 321 unsigned int chroma_key_mode:1; 322 unsigned int chroma_key_index:2; 323 unsigned int chroma_key_enable:1; 324 unsigned int pad0:6; 325 } ss3; 326 }; 327 328 #endif 329