Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Courtney Goeltzenleuchter <courtney@lunarg.com> |
| 26 | * Chia-I Wu <olv@lunarg.com> |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 27 | */ |
| 28 | |
| 29 | #ifndef PIPELINE_H |
| 30 | #define PIPELINE_H |
| 31 | |
| 32 | #include "intel.h" |
| 33 | #include "obj.h" |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 34 | #include "desc.h" |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 35 | #include "dev.h" |
| 36 | |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 37 | enum intel_pipeline_shader_use { |
| 38 | INTEL_SHADER_USE_VID = (1 << 0), |
| 39 | INTEL_SHADER_USE_IID = (1 << 1), |
| 40 | |
| 41 | INTEL_SHADER_USE_KILL = (1 << 2), |
Cody Northrop | e238deb | 2015-01-26 14:41:36 -0700 | [diff] [blame] | 42 | INTEL_SHADER_USE_DEPTH = (1 << 3), |
| 43 | INTEL_SHADER_USE_W = (1 << 4), |
| 44 | }; |
| 45 | |
| 46 | /* This order must match Pixel Shader Computed Depth Mode in 3DSTATE_WM */ |
| 47 | enum intel_computed_depth_mode { |
| 48 | INTEL_COMPUTED_DEPTH_MODE_NONE, |
| 49 | INTEL_COMPUTED_DEPTH_MODE_ON, |
| 50 | INTEL_COMPUTED_DEPTH_MODE_ON_GE, |
| 51 | INTEL_COMPUTED_DEPTH_MODE_ON_LE |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 52 | }; |
| 53 | |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 54 | enum intel_pipeline_rmap_slot_type { |
| 55 | INTEL_PIPELINE_RMAP_UNUSED, |
| 56 | INTEL_PIPELINE_RMAP_RT, |
| 57 | INTEL_PIPELINE_RMAP_SURFACE, |
| 58 | INTEL_PIPELINE_RMAP_SAMPLER, |
| 59 | }; |
| 60 | |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 61 | struct intel_pipeline_rmap_slot { |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 62 | enum intel_pipeline_rmap_slot_type type; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 63 | |
| 64 | union { |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 65 | uint32_t rt; |
| 66 | struct { |
| 67 | struct intel_desc_offset offset; |
| 68 | int dynamic_offset_index; |
| 69 | } surface; |
| 70 | struct intel_desc_offset sampler; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 71 | } u; |
| 72 | }; |
| 73 | |
| 74 | /** |
| 75 | * Shader resource mapping. |
| 76 | */ |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 77 | struct intel_pipeline_rmap { |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 78 | /* this is not an intel_obj */ |
| 79 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 80 | uint32_t rt_count; |
| 81 | uint32_t texture_resource_count; |
| 82 | uint32_t resource_count; |
| 83 | uint32_t uav_count; |
| 84 | uint32_t sampler_count; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 85 | |
| 86 | /* |
| 87 | * rt_count slots + |
| 88 | * resource_count slots + |
| 89 | * uav_count slots + |
Chia-I Wu | 3b04af5 | 2014-11-08 10:48:20 +0800 | [diff] [blame] | 90 | * sampler_count slots |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 91 | */ |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 92 | struct intel_pipeline_rmap_slot *slots; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 93 | uint32_t slot_count; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 94 | }; |
| 95 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 96 | #define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX) |
| 97 | #define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL) |
| 98 | #define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION) |
| 99 | #define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY) |
| 100 | #define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT) |
| 101 | #define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE) |
| 102 | |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 103 | struct intel_pipeline_shader { |
| 104 | /* this is not an intel_obj */ |
| 105 | |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 106 | void *pCode; |
| 107 | uint32_t codeSize; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 108 | |
| 109 | /* |
| 110 | * must grab everything we need from shader object as that |
| 111 | * can go away after the pipeline is created |
| 112 | */ |
| 113 | XGL_FLAGS uses; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 114 | uint64_t inputs_read; |
| 115 | uint64_t outputs_written; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 116 | uint32_t outputs_offset; |
| 117 | uint32_t generic_input_start; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 118 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 119 | bool32_t enable_user_clip; |
| 120 | bool32_t reads_user_clip; |
GregF | fd4c1f9 | 2014-11-07 15:32:52 -0700 | [diff] [blame] | 121 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 122 | uint32_t in_count; |
| 123 | uint32_t out_count; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 124 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 125 | uint32_t sampler_count; |
| 126 | uint32_t surface_count; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 127 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 128 | uint32_t ubo_start; |
| 129 | uint32_t urb_grf_start; |
Cody Northrop | e86574e | 2015-02-24 14:15:29 -0700 | [diff] [blame] | 130 | uint32_t urb_grf_start_16; |
| 131 | |
| 132 | /* If present, where does the SIMD16 kernel start? */ |
| 133 | uint32_t offset_16; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 134 | |
| 135 | XGL_FLAGS barycentric_interps; |
Chia-I Wu | 7f39056 | 2015-03-25 08:47:18 +0800 | [diff] [blame] | 136 | XGL_FLAGS point_sprite_enables; |
Chia-I Wu | 39026c9 | 2014-09-02 10:03:19 +0800 | [diff] [blame] | 137 | |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 138 | XGL_GPU_SIZE per_thread_scratch_size; |
| 139 | |
Cody Northrop | e238deb | 2015-01-26 14:41:36 -0700 | [diff] [blame] | 140 | enum intel_computed_depth_mode computed_depth_mode; |
| 141 | |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 142 | struct intel_pipeline_rmap *rmap; |
Chia-I Wu | 5667d6f | 2014-12-11 22:37:37 +0800 | [diff] [blame] | 143 | |
| 144 | /* these are set up by the driver */ |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 145 | uint32_t max_threads; |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 146 | XGL_GPU_SIZE scratch_offset; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 147 | }; |
| 148 | |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 149 | /* |
| 150 | * On GEN6, there are |
| 151 | * |
| 152 | * - 3DSTATE_URB (3) |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 153 | * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 154 | * - 3DSTATE_SAMPLE_MASK (2) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 155 | * |
| 156 | * On GEN7, there are |
| 157 | * |
| 158 | * - 3DSTATE_URB_x (2*4) |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 159 | * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 160 | * - 3DSTATE_SBE (14) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 161 | * - 3DSTATE_HS (7) |
| 162 | * - 3DSTATE_TE (4) |
| 163 | * - 3DSTATE_DS (6) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 164 | * - 3DSTATE_SAMPLE_MASK (2) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 165 | */ |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 166 | #define INTEL_PSO_CMD_ENTRIES 128 |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 167 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 168 | /** |
| 169 | * 3D pipeline. |
| 170 | */ |
| 171 | struct intel_pipeline { |
| 172 | struct intel_obj obj; |
| 173 | |
| 174 | struct intel_dev *dev; |
| 175 | |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 176 | XGL_VERTEX_INPUT_BINDING_DESCRIPTION vb[INTEL_MAX_VERTEX_BINDING_COUNT]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 177 | uint32_t vb_count; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 178 | |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 179 | /* XGL_PIPELINE_IA_STATE_CREATE_INFO */ |
| 180 | XGL_PRIMITIVE_TOPOLOGY topology; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 181 | int prim_type; |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 182 | bool disable_vs_cache; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 183 | bool primitive_restart; |
| 184 | uint32_t primitive_restart_index; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 185 | /* Index of provoking vertex for each prim type */ |
| 186 | int provoking_vertex_tri; |
| 187 | int provoking_vertex_trifan; |
| 188 | int provoking_vertex_line; |
| 189 | |
| 190 | // TODO: This should probably be Intel HW state, not XGL state. |
| 191 | /* Depth Buffer format */ |
| 192 | XGL_FORMAT db_format; |
| 193 | |
Chia-I Wu | b638620 | 2015-03-24 11:13:06 +0800 | [diff] [blame] | 194 | bool depth_zero_to_one; |
| 195 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 196 | XGL_PIPELINE_CB_STATE_CREATE_INFO cb_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 197 | |
| 198 | // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state; |
| 199 | bool depthClipEnable; |
| 200 | bool rasterizerDiscardEnable; |
Chia-I Wu | db3fbc4 | 2015-03-24 10:55:40 +0800 | [diff] [blame] | 201 | bool use_rs_point_size; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 202 | |
| 203 | XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 204 | |
| 205 | uint32_t active_shaders; |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 206 | struct intel_pipeline_shader vs; |
Chia-I Wu | 95959fb | 2014-09-02 11:01:03 +0800 | [diff] [blame] | 207 | struct intel_pipeline_shader tcs; |
| 208 | struct intel_pipeline_shader tes; |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 209 | struct intel_pipeline_shader gs; |
| 210 | struct intel_pipeline_shader fs; |
Chia-I Wu | 95959fb | 2014-09-02 11:01:03 +0800 | [diff] [blame] | 211 | struct intel_pipeline_shader cs; |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 212 | XGL_GPU_SIZE scratch_size; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 213 | |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 214 | uint32_t wa_flags; |
| 215 | |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 216 | uint32_t cmds[INTEL_PSO_CMD_ENTRIES]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 217 | uint32_t cmd_len; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 218 | |
Courtney Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame] | 219 | bool dual_source_blend_enable; |
| 220 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 221 | /* The following are only partial HW commands that will need |
| 222 | * more processing before sending to the HW |
| 223 | */ |
| 224 | // XGL_PIPELINE_DS_STATE_CREATE_INFO ds_state |
| 225 | bool stencilTestEnable; |
| 226 | uint32_t cmd_depth_stencil; |
| 227 | uint32_t cmd_depth_test; |
| 228 | |
| 229 | uint32_t cmd_sf_fill; |
| 230 | uint32_t cmd_clip_cull; |
| 231 | uint32_t cmd_sf_cull; |
| 232 | uint32_t cmd_cb[2 * INTEL_MAX_RENDER_TARGETS]; |
| 233 | uint32_t sample_count; |
| 234 | uint32_t cmd_sample_mask; |
Chia-I Wu | f85def4 | 2015-01-29 00:34:24 +0800 | [diff] [blame] | 235 | |
| 236 | uint32_t cmd_3dstate_sbe[14]; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline) |
| 240 | { |
| 241 | return (struct intel_pipeline *) pipeline; |
| 242 | } |
| 243 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 244 | static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base) |
| 245 | { |
| 246 | return (struct intel_pipeline *) base; |
| 247 | } |
| 248 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 249 | static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj) |
| 250 | { |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 251 | return intel_pipeline_from_base(&obj->base); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 252 | } |
| 253 | |
Chia-I Wu | 9fe3ec4 | 2014-10-17 09:49:16 +0800 | [diff] [blame] | 254 | struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev, |
| 255 | enum intel_dev_meta_shader id); |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 256 | void intel_pipeline_shader_destroy(struct intel_dev *dev, |
| 257 | struct intel_pipeline_shader *sh); |
Chia-I Wu | 9fe3ec4 | 2014-10-17 09:49:16 +0800 | [diff] [blame] | 258 | |
Chia-I Wu | 38d1ddf | 2015-03-02 10:51:39 -0700 | [diff] [blame] | 259 | void intel_pipeline_init_default_sample_patterns(const struct intel_dev *dev, |
| 260 | uint8_t *pat_1x, uint8_t *pat_2x, |
| 261 | uint8_t *pat_4x, uint8_t *pat_8x, |
| 262 | uint8_t *pat_16x); |
| 263 | |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 264 | #endif /* PIPELINE_H */ |