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" |
| 34 | #include "dev.h" |
| 35 | |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 36 | enum intel_pipeline_shader_use { |
| 37 | INTEL_SHADER_USE_VID = (1 << 0), |
| 38 | INTEL_SHADER_USE_IID = (1 << 1), |
| 39 | |
| 40 | INTEL_SHADER_USE_KILL = (1 << 2), |
| 41 | INTEL_SHADER_USE_COMPUTED_DEPTH = (1 << 3), |
| 42 | INTEL_SHADER_USE_DEPTH = (1 << 4), |
| 43 | INTEL_SHADER_USE_W = (1 << 5), |
| 44 | }; |
| 45 | |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 46 | #define INTEL_PIPELINE_RMAP_SLOT_RT ((XGL_UINT) -1) |
| 47 | #define INTEL_PIPELINE_RMAP_SLOT_DYN ((XGL_UINT) -2) |
| 48 | struct intel_pipeline_rmap_slot { |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 49 | /* |
| 50 | * |
| 51 | * When path_len is 0, the slot is unused. |
| 52 | * When path_len is 1, the slot uses descriptor "index". |
| 53 | * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index". |
| 54 | * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view. |
| 55 | * Otherwise, the slot uses "path" to find the descriptor. |
| 56 | */ |
| 57 | XGL_UINT path_len; |
| 58 | |
| 59 | union { |
| 60 | XGL_UINT index; |
| 61 | XGL_UINT *path; |
| 62 | } u; |
| 63 | }; |
| 64 | |
| 65 | /** |
| 66 | * Shader resource mapping. |
| 67 | */ |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 68 | struct intel_pipeline_rmap { |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 69 | /* this is not an intel_obj */ |
| 70 | |
| 71 | XGL_UINT rt_count; |
Cody Northrop | 40316a3 | 2014-12-09 19:08:33 -0700 | [diff] [blame] | 72 | XGL_UINT texture_resource_count; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 73 | XGL_UINT resource_count; |
| 74 | XGL_UINT uav_count; |
| 75 | XGL_UINT sampler_count; |
| 76 | |
| 77 | /* |
| 78 | * rt_count slots + |
| 79 | * resource_count slots + |
| 80 | * uav_count slots + |
Chia-I Wu | 3b04af5 | 2014-11-08 10:48:20 +0800 | [diff] [blame] | 81 | * sampler_count slots |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 82 | */ |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 83 | struct intel_pipeline_rmap_slot *slots; |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 84 | XGL_UINT slot_count; |
| 85 | }; |
| 86 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 87 | #define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX) |
| 88 | #define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL) |
| 89 | #define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION) |
| 90 | #define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY) |
| 91 | #define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT) |
| 92 | #define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE) |
| 93 | |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 94 | struct intel_pipeline_shader { |
| 95 | /* this is not an intel_obj */ |
| 96 | |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 97 | void *pCode; |
| 98 | uint32_t codeSize; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * must grab everything we need from shader object as that |
| 102 | * can go away after the pipeline is created |
| 103 | */ |
| 104 | XGL_FLAGS uses; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 105 | uint64_t inputs_read; |
| 106 | uint64_t outputs_written; |
| 107 | XGL_UINT outputs_offset; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 108 | |
GregF | fd4c1f9 | 2014-11-07 15:32:52 -0700 | [diff] [blame] | 109 | XGL_BOOL enable_user_clip; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 110 | XGL_BOOL reads_user_clip; |
GregF | fd4c1f9 | 2014-11-07 15:32:52 -0700 | [diff] [blame] | 111 | |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 112 | XGL_UINT in_count; |
| 113 | XGL_UINT out_count; |
| 114 | |
| 115 | XGL_UINT sampler_count; |
| 116 | XGL_UINT surface_count; |
| 117 | |
Cody Northrop | 37c4705 | 2014-12-11 09:58:50 -0700 | [diff] [blame] | 118 | XGL_UINT ubo_start; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 119 | XGL_UINT urb_grf_start; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 120 | |
| 121 | XGL_FLAGS barycentric_interps; |
Chia-I Wu | 39026c9 | 2014-09-02 10:03:19 +0800 | [diff] [blame] | 122 | |
Chia-I Wu | 3f4bd10 | 2014-12-19 13:14:42 +0800 | [diff] [blame^] | 123 | /* these are set up by the driver */ |
Chia-I Wu | 2098376 | 2014-09-02 12:07:28 +0800 | [diff] [blame] | 124 | struct intel_pipeline_rmap *rmap; |
Chia-I Wu | 3f4bd10 | 2014-12-19 13:14:42 +0800 | [diff] [blame^] | 125 | XGL_UINT max_threads; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 126 | }; |
| 127 | |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 128 | /* |
| 129 | * On GEN6, there are |
| 130 | * |
| 131 | * - 3DSTATE_URB (3) |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 132 | * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 133 | * |
| 134 | * On GEN7, there are |
| 135 | * |
| 136 | * - 3DSTATE_URB_x (2*4) |
| 137 | * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5) |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 138 | * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 139 | * - 3DSTATE_HS (7) |
| 140 | * - 3DSTATE_TE (4) |
| 141 | * - 3DSTATE_DS (6) |
| 142 | */ |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 143 | #define INTEL_PSO_CMD_ENTRIES 128 |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 144 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 145 | /** |
| 146 | * 3D pipeline. |
| 147 | */ |
| 148 | struct intel_pipeline { |
| 149 | struct intel_obj obj; |
| 150 | |
| 151 | struct intel_dev *dev; |
| 152 | |
Chia-I Wu | 2469371 | 2014-11-08 11:54:47 +0800 | [diff] [blame] | 153 | XGL_VERTEX_INPUT_BINDING_DESCRIPTION vb[INTEL_MAX_VERTEX_BINDING_COUNT]; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 154 | XGL_UINT vb_count; |
| 155 | |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 156 | /* XGL_PIPELINE_IA_STATE_CREATE_INFO */ |
| 157 | XGL_PRIMITIVE_TOPOLOGY topology; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 158 | int prim_type; |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 159 | bool disable_vs_cache; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 160 | bool primitive_restart; |
| 161 | uint32_t primitive_restart_index; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 162 | /* Index of provoking vertex for each prim type */ |
| 163 | int provoking_vertex_tri; |
| 164 | int provoking_vertex_trifan; |
| 165 | int provoking_vertex_line; |
| 166 | |
| 167 | // TODO: This should probably be Intel HW state, not XGL state. |
| 168 | /* Depth Buffer format */ |
| 169 | XGL_FORMAT db_format; |
| 170 | |
| 171 | XGL_PIPELINE_CB_STATE cb_state; |
| 172 | |
| 173 | // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state; |
| 174 | bool depthClipEnable; |
| 175 | bool rasterizerDiscardEnable; |
| 176 | float pointSize; |
| 177 | |
| 178 | XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 179 | |
| 180 | uint32_t active_shaders; |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 181 | struct intel_pipeline_shader vs; |
Chia-I Wu | 95959fb | 2014-09-02 11:01:03 +0800 | [diff] [blame] | 182 | struct intel_pipeline_shader tcs; |
| 183 | struct intel_pipeline_shader tes; |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 184 | struct intel_pipeline_shader gs; |
| 185 | struct intel_pipeline_shader fs; |
Chia-I Wu | 95959fb | 2014-09-02 11:01:03 +0800 | [diff] [blame] | 186 | struct intel_pipeline_shader cs; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 187 | |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 188 | uint32_t wa_flags; |
| 189 | |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 190 | uint32_t cmds[INTEL_PSO_CMD_ENTRIES]; |
| 191 | XGL_UINT cmd_len; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 192 | XGL_UINT cmd_sbe_body_offset; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline) |
| 196 | { |
| 197 | return (struct intel_pipeline *) pipeline; |
| 198 | } |
| 199 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 200 | static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base) |
| 201 | { |
| 202 | return (struct intel_pipeline *) base; |
| 203 | } |
| 204 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 205 | static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj) |
| 206 | { |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 207 | return intel_pipeline_from_base(&obj->base); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 208 | } |
| 209 | |
Chia-I Wu | 9fe3ec4 | 2014-10-17 09:49:16 +0800 | [diff] [blame] | 210 | struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev, |
| 211 | enum intel_dev_meta_shader id); |
| 212 | void intel_pipeline_shader_destroy(struct intel_pipeline_shader *sh); |
| 213 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 214 | XGL_RESULT XGLAPI intelCreateGraphicsPipeline( |
| 215 | XGL_DEVICE device, |
| 216 | const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, |
| 217 | XGL_PIPELINE* pPipeline); |
| 218 | |
| 219 | XGL_RESULT XGLAPI intelCreateComputePipeline( |
| 220 | XGL_DEVICE device, |
| 221 | const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, |
| 222 | XGL_PIPELINE* pPipeline); |
| 223 | |
| 224 | XGL_RESULT XGLAPI intelStorePipeline( |
| 225 | XGL_PIPELINE pipeline, |
| 226 | XGL_SIZE* pDataSize, |
| 227 | XGL_VOID* pData); |
| 228 | |
| 229 | XGL_RESULT XGLAPI intelLoadPipeline( |
| 230 | XGL_DEVICE device, |
| 231 | XGL_SIZE dataSize, |
| 232 | const XGL_VOID* pData, |
| 233 | XGL_PIPELINE* pPipeline); |
| 234 | |
| 235 | XGL_RESULT XGLAPI intelCreatePipelineDelta( |
| 236 | XGL_DEVICE device, |
| 237 | XGL_PIPELINE p1, |
| 238 | XGL_PIPELINE p2, |
| 239 | XGL_PIPELINE_DELTA* delta); |
Chia-I Wu | f2b6d72 | 2014-09-02 08:52:27 +0800 | [diff] [blame] | 240 | |
| 241 | #endif /* PIPELINE_H */ |