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 | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 36 | #define INTEL_RMAP_SLOT_RT ((XGL_UINT) -1) |
| 37 | #define INTEL_RMAP_SLOT_DYN ((XGL_UINT) -2) |
| 38 | struct intel_rmap_slot { |
| 39 | /* |
| 40 | * |
| 41 | * When path_len is 0, the slot is unused. |
| 42 | * When path_len is 1, the slot uses descriptor "index". |
| 43 | * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index". |
| 44 | * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view. |
| 45 | * Otherwise, the slot uses "path" to find the descriptor. |
| 46 | */ |
| 47 | XGL_UINT path_len; |
| 48 | |
| 49 | union { |
| 50 | XGL_UINT index; |
| 51 | XGL_UINT *path; |
| 52 | } u; |
| 53 | }; |
| 54 | |
| 55 | /** |
| 56 | * Shader resource mapping. |
| 57 | */ |
| 58 | struct intel_rmap { |
| 59 | /* this is not an intel_obj */ |
| 60 | |
| 61 | XGL_UINT rt_count; |
| 62 | XGL_UINT resource_count; |
| 63 | XGL_UINT uav_count; |
| 64 | XGL_UINT sampler_count; |
| 65 | |
| 66 | /* |
| 67 | * rt_count slots + |
| 68 | * resource_count slots + |
| 69 | * uav_count slots + |
| 70 | * sampler_count slots |
| 71 | */ |
| 72 | struct intel_rmap_slot *slots; |
| 73 | XGL_UINT slot_count; |
| 74 | }; |
| 75 | |
Courtney Goeltzenleuchter | f21aaab | 2014-08-28 17:38:09 -0600 | [diff] [blame] | 76 | /** |
| 77 | * Implementation limits |
| 78 | */ |
| 79 | #define INTEL_MAX_ATTRIBS 32 |
| 80 | #define INTEL_MAX_CLIP_PLANES 8 |
| 81 | #define INTEL_MAX_COLOR_BUFS 8 |
| 82 | #define INTEL_MAX_SHADER_INPUTS 32 |
| 83 | #define INTEL_MAX_SHADER_OUTPUTS 48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */ |
| 84 | #define INTEL_MAX_SHADER_SAMPLER_VIEWS 32 |
| 85 | #define INTEL_MAX_SHADER_RESOURCES 32 |
| 86 | #define INTEL_MAX_TEXTURE_LEVELS 16 |
| 87 | #define INTEL_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8 |
| 88 | #define INTEL_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2 |
| 89 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 90 | #define INTEL_MAX_DRAW_BUFFERS 8 |
| 91 | #define INTEL_MAX_CONST_BUFFERS (1 + 12) |
| 92 | #define INTEL_MAX_SAMPLER_VIEWS 16 |
| 93 | #define INTEL_MAX_SAMPLERS 16 |
| 94 | #define INTEL_MAX_SO_BINDINGS 64 |
| 95 | #define INTEL_MAX_SO_BUFFERS 4 |
Courtney Goeltzenleuchter | f21aaab | 2014-08-28 17:38:09 -0600 | [diff] [blame] | 96 | #define INTEL_MAX_SO_OUTPUTS 64 |
| 97 | #define INTEL_MAX_VIEWPORTS 1 // TODO: Should this be 16 to match XGL_MAX_VIEWPORTS? |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 98 | |
| 99 | #define INTEL_MAX_VS_SURFACES (INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS) |
| 100 | #define INTEL_VS_CONST_SURFACE(i) (i) |
| 101 | #define INTEL_VS_TEXTURE_SURFACE(i) (INTEL_MAX_CONST_BUFFERS + i) |
| 102 | |
| 103 | #define INTEL_MAX_GS_SURFACES (INTEL_MAX_SO_BINDINGS) |
| 104 | #define INTEL_GS_SO_SURFACE(i) (i) |
| 105 | |
| 106 | #define INTEL_MAX_WM_SURFACES (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS) |
| 107 | #define INTEL_WM_DRAW_SURFACE(i) (i) |
| 108 | #define INTEL_WM_CONST_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + i) |
| 109 | #define INTEL_WM_TEXTURE_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + i) |
| 110 | |
| 111 | #define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX) |
| 112 | #define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL) |
| 113 | #define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION) |
| 114 | #define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY) |
| 115 | #define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT) |
| 116 | #define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE) |
| 117 | |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 118 | struct intel_pipe_shader { |
| 119 | void *pCode; |
| 120 | uint32_t codeSize; |
Courtney Goeltzenleuchter | c4ef614 | 2014-08-29 16:25:30 -0600 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * must grab everything we need from shader object as that |
| 124 | * can go away after the pipeline is created |
| 125 | */ |
| 126 | XGL_FLAGS uses; |
| 127 | |
| 128 | XGL_UINT in_count; |
| 129 | XGL_UINT out_count; |
| 130 | |
| 131 | XGL_UINT sampler_count; |
| 132 | XGL_UINT surface_count; |
| 133 | |
| 134 | /* |
| 135 | * Used by 3DSTATE_VS command |
| 136 | */ |
| 137 | XGL_UINT urb_grf_start; |
| 138 | XGL_UINT urb_read_length; |
| 139 | |
| 140 | XGL_FLAGS barycentric_interps; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 141 | }; |
| 142 | |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 143 | /* |
| 144 | * On GEN6, there are |
| 145 | * |
| 146 | * - 3DSTATE_URB (3) |
Chia-I Wu | 4f3612b | 2014-08-29 15:40:39 +0800 | [diff] [blame] | 147 | * - 3DSTATE_VERTEX_ELEMENTS (3) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 148 | * |
| 149 | * On GEN7, there are |
| 150 | * |
| 151 | * - 3DSTATE_URB_x (2*4) |
| 152 | * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5) |
Chia-I Wu | 4f3612b | 2014-08-29 15:40:39 +0800 | [diff] [blame] | 153 | * - 3DSTATE_VERTEX_ELEMENTS (3) |
Chia-I Wu | 1638c1c | 2014-08-29 14:01:16 +0800 | [diff] [blame] | 154 | * - 3DSTATE_HS (7) |
| 155 | * - 3DSTATE_TE (4) |
| 156 | * - 3DSTATE_DS (6) |
| 157 | */ |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 158 | #define INTEL_PSO_CMD_ENTRIES 64 |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 159 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 160 | /** |
| 161 | * 3D pipeline. |
| 162 | */ |
| 163 | struct intel_pipeline { |
| 164 | struct intel_obj obj; |
| 165 | |
| 166 | struct intel_dev *dev; |
| 167 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 168 | /* XGL IA_STATE */ |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 169 | XGL_PIPELINE_IA_STATE_CREATE_INFO ia_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 170 | int prim_type; |
| 171 | bool primitive_restart; |
| 172 | uint32_t primitive_restart_index; |
| 173 | |
| 174 | /* Index of provoking vertex for each prim type */ |
| 175 | int provoking_vertex_tri; |
| 176 | int provoking_vertex_trifan; |
| 177 | int provoking_vertex_line; |
| 178 | |
| 179 | // TODO: This should probably be Intel HW state, not XGL state. |
| 180 | /* Depth Buffer format */ |
| 181 | XGL_FORMAT db_format; |
| 182 | |
| 183 | XGL_PIPELINE_CB_STATE cb_state; |
| 184 | |
| 185 | // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state; |
| 186 | bool depthClipEnable; |
| 187 | bool rasterizerDiscardEnable; |
| 188 | float pointSize; |
| 189 | |
| 190 | XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 191 | |
| 192 | uint32_t active_shaders; |
| 193 | XGL_PIPELINE_SHADER vs; |
| 194 | XGL_PIPELINE_SHADER fs; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 195 | struct intel_pipe_shader intel_vs; |
| 196 | struct intel_rmap *vs_rmap; |
| 197 | struct intel_pipe_shader intel_fs; |
Chia-I Wu | ed83387 | 2014-08-23 17:00:35 +0800 | [diff] [blame] | 198 | struct intel_rmap *fs_rmap; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 199 | struct intel_pipe_shader gs; |
| 200 | struct intel_pipe_shader tess_control; |
| 201 | struct intel_pipe_shader tess_eval; |
| 202 | struct intel_pipe_shader compute; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 203 | |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 204 | uint32_t wa_flags; |
| 205 | |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 206 | uint32_t cmds[INTEL_PSO_CMD_ENTRIES]; |
| 207 | XGL_UINT cmd_len; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline) |
| 211 | { |
| 212 | return (struct intel_pipeline *) pipeline; |
| 213 | } |
| 214 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 215 | static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base) |
| 216 | { |
| 217 | return (struct intel_pipeline *) base; |
| 218 | } |
| 219 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 220 | static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj) |
| 221 | { |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 222 | return intel_pipeline_from_base(&obj->base); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | XGL_RESULT XGLAPI intelCreateGraphicsPipeline( |
| 226 | XGL_DEVICE device, |
| 227 | const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, |
| 228 | XGL_PIPELINE* pPipeline); |
| 229 | |
| 230 | XGL_RESULT XGLAPI intelCreateComputePipeline( |
| 231 | XGL_DEVICE device, |
| 232 | const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, |
| 233 | XGL_PIPELINE* pPipeline); |
| 234 | |
| 235 | XGL_RESULT XGLAPI intelStorePipeline( |
| 236 | XGL_PIPELINE pipeline, |
| 237 | XGL_SIZE* pDataSize, |
| 238 | XGL_VOID* pData); |
| 239 | |
| 240 | XGL_RESULT XGLAPI intelLoadPipeline( |
| 241 | XGL_DEVICE device, |
| 242 | XGL_SIZE dataSize, |
| 243 | const XGL_VOID* pData, |
| 244 | XGL_PIPELINE* pPipeline); |
| 245 | |
| 246 | XGL_RESULT XGLAPI intelCreatePipelineDelta( |
| 247 | XGL_DEVICE device, |
| 248 | XGL_PIPELINE p1, |
| 249 | XGL_PIPELINE p2, |
| 250 | XGL_PIPELINE_DELTA* delta); |
| 251 | #endif // PIPELINE_H |