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. |
| 23 | */ |
| 24 | |
| 25 | #ifndef PIPELINE_H |
| 26 | #define PIPELINE_H |
| 27 | |
| 28 | #include "intel.h" |
| 29 | #include "obj.h" |
| 30 | #include "dev.h" |
| 31 | |
Chia-I Wu | 1f7540b | 2014-08-22 13:56:18 +0800 | [diff] [blame] | 32 | #define INTEL_RMAP_SLOT_RT ((XGL_UINT) -1) |
| 33 | #define INTEL_RMAP_SLOT_DYN ((XGL_UINT) -2) |
| 34 | struct intel_rmap_slot { |
| 35 | /* |
| 36 | * |
| 37 | * When path_len is 0, the slot is unused. |
| 38 | * When path_len is 1, the slot uses descriptor "index". |
| 39 | * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index". |
| 40 | * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view. |
| 41 | * Otherwise, the slot uses "path" to find the descriptor. |
| 42 | */ |
| 43 | XGL_UINT path_len; |
| 44 | |
| 45 | union { |
| 46 | XGL_UINT index; |
| 47 | XGL_UINT *path; |
| 48 | } u; |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * Shader resource mapping. |
| 53 | */ |
| 54 | struct intel_rmap { |
| 55 | /* this is not an intel_obj */ |
| 56 | |
| 57 | XGL_UINT rt_count; |
| 58 | XGL_UINT resource_count; |
| 59 | XGL_UINT uav_count; |
| 60 | XGL_UINT sampler_count; |
| 61 | |
| 62 | /* |
| 63 | * rt_count slots + |
| 64 | * resource_count slots + |
| 65 | * uav_count slots + |
| 66 | * sampler_count slots |
| 67 | */ |
| 68 | struct intel_rmap_slot *slots; |
| 69 | XGL_UINT slot_count; |
| 70 | }; |
| 71 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 72 | #define INTEL_MAX_DRAW_BUFFERS 8 |
| 73 | #define INTEL_MAX_CONST_BUFFERS (1 + 12) |
| 74 | #define INTEL_MAX_SAMPLER_VIEWS 16 |
| 75 | #define INTEL_MAX_SAMPLERS 16 |
| 76 | #define INTEL_MAX_SO_BINDINGS 64 |
| 77 | #define INTEL_MAX_SO_BUFFERS 4 |
| 78 | #define INTEL_MAX_VIEWPORTS 1 |
| 79 | |
| 80 | #define INTEL_MAX_VS_SURFACES (INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS) |
| 81 | #define INTEL_VS_CONST_SURFACE(i) (i) |
| 82 | #define INTEL_VS_TEXTURE_SURFACE(i) (INTEL_MAX_CONST_BUFFERS + i) |
| 83 | |
| 84 | #define INTEL_MAX_GS_SURFACES (INTEL_MAX_SO_BINDINGS) |
| 85 | #define INTEL_GS_SO_SURFACE(i) (i) |
| 86 | |
| 87 | #define INTEL_MAX_WM_SURFACES (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS) |
| 88 | #define INTEL_WM_DRAW_SURFACE(i) (i) |
| 89 | #define INTEL_WM_CONST_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + i) |
| 90 | #define INTEL_WM_TEXTURE_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + i) |
| 91 | |
| 92 | #define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX) |
| 93 | #define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL) |
| 94 | #define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION) |
| 95 | #define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY) |
| 96 | #define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT) |
| 97 | #define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE) |
| 98 | |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 99 | struct intel_pipe_shader { |
| 100 | void *pCode; |
| 101 | uint32_t codeSize; |
| 102 | }; |
| 103 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 104 | /** |
| 105 | * 3D pipeline. |
| 106 | */ |
| 107 | struct intel_pipeline { |
| 108 | struct intel_obj obj; |
| 109 | |
| 110 | struct intel_dev *dev; |
| 111 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 112 | bool has_gen6_wa_pipe_control; |
| 113 | |
| 114 | /* XGL IA_STATE */ |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 115 | XGL_PIPELINE_IA_STATE_CREATE_INFO ia_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 116 | int prim_type; |
| 117 | bool primitive_restart; |
| 118 | uint32_t primitive_restart_index; |
| 119 | |
| 120 | /* Index of provoking vertex for each prim type */ |
| 121 | int provoking_vertex_tri; |
| 122 | int provoking_vertex_trifan; |
| 123 | int provoking_vertex_line; |
| 124 | |
| 125 | // TODO: This should probably be Intel HW state, not XGL state. |
| 126 | /* Depth Buffer format */ |
| 127 | XGL_FORMAT db_format; |
| 128 | |
| 129 | XGL_PIPELINE_CB_STATE cb_state; |
| 130 | |
| 131 | // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state; |
| 132 | bool depthClipEnable; |
| 133 | bool rasterizerDiscardEnable; |
| 134 | float pointSize; |
| 135 | |
| 136 | XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 137 | |
| 138 | uint32_t active_shaders; |
| 139 | XGL_PIPELINE_SHADER vs; |
| 140 | XGL_PIPELINE_SHADER fs; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 141 | struct intel_pipe_shader intel_vs; |
| 142 | struct intel_rmap *vs_rmap; |
| 143 | struct intel_pipe_shader intel_fs; |
Chia-I Wu | ed83387 | 2014-08-23 17:00:35 +0800 | [diff] [blame] | 144 | struct intel_rmap *fs_rmap; |
Courtney Goeltzenleuchter | d85c1d6 | 2014-08-27 14:04:53 -0600 | [diff] [blame] | 145 | struct intel_pipe_shader gs; |
| 146 | struct intel_pipe_shader tess_control; |
| 147 | struct intel_pipe_shader tess_eval; |
| 148 | struct intel_pipe_shader compute; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 149 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 150 | XGL_SIZE total_size; // FB memory app needs to allocate for this pipeline |
| 151 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 152 | int reduced_prim; |
| 153 | int so_num_vertices, so_max_vertices; |
| 154 | |
| 155 | uint32_t SF_VIEWPORT; |
| 156 | uint32_t CLIP_VIEWPORT; |
| 157 | uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */ |
| 158 | uint32_t CC_VIEWPORT; |
| 159 | |
| 160 | uint32_t COLOR_CALC_STATE; |
| 161 | uint32_t BLEND_STATE; |
| 162 | uint32_t DEPTH_STENCIL_STATE; |
| 163 | |
| 164 | uint32_t SCISSOR_RECT; |
| 165 | |
| 166 | struct { |
| 167 | uint32_t BINDING_TABLE_STATE; |
| 168 | int BINDING_TABLE_STATE_size; |
| 169 | uint32_t SURFACE_STATE[INTEL_MAX_VS_SURFACES]; |
| 170 | uint32_t SAMPLER_STATE; |
| 171 | uint32_t SAMPLER_BORDER_COLOR_STATE[INTEL_MAX_SAMPLERS]; |
| 172 | uint32_t PUSH_CONSTANT_BUFFER; |
| 173 | int PUSH_CONSTANT_BUFFER_size; |
| 174 | } vs_state; |
| 175 | |
| 176 | struct { |
| 177 | uint32_t BINDING_TABLE_STATE; |
| 178 | int BINDING_TABLE_STATE_size; |
| 179 | uint32_t SURFACE_STATE[INTEL_MAX_GS_SURFACES]; |
| 180 | bool active; |
| 181 | } gs_state; |
| 182 | |
| 183 | struct { |
| 184 | uint32_t BINDING_TABLE_STATE; |
| 185 | int BINDING_TABLE_STATE_size; |
| 186 | uint32_t SURFACE_STATE[INTEL_MAX_WM_SURFACES]; |
| 187 | uint32_t SAMPLER_STATE; |
| 188 | uint32_t SAMPLER_BORDER_COLOR_STATE[INTEL_MAX_SAMPLERS]; |
| 189 | uint32_t PUSH_CONSTANT_BUFFER; |
| 190 | int PUSH_CONSTANT_BUFFER_size; |
| 191 | } wm_state; |
| 192 | }; |
| 193 | |
| 194 | static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline) |
| 195 | { |
| 196 | return (struct intel_pipeline *) pipeline; |
| 197 | } |
| 198 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 199 | static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base) |
| 200 | { |
| 201 | return (struct intel_pipeline *) base; |
| 202 | } |
| 203 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 204 | static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj) |
| 205 | { |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 206 | return intel_pipeline_from_base(&obj->base); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | XGL_RESULT XGLAPI intelCreateGraphicsPipeline( |
| 210 | XGL_DEVICE device, |
| 211 | const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, |
| 212 | XGL_PIPELINE* pPipeline); |
| 213 | |
| 214 | XGL_RESULT XGLAPI intelCreateComputePipeline( |
| 215 | XGL_DEVICE device, |
| 216 | const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, |
| 217 | XGL_PIPELINE* pPipeline); |
| 218 | |
| 219 | XGL_RESULT XGLAPI intelStorePipeline( |
| 220 | XGL_PIPELINE pipeline, |
| 221 | XGL_SIZE* pDataSize, |
| 222 | XGL_VOID* pData); |
| 223 | |
| 224 | XGL_RESULT XGLAPI intelLoadPipeline( |
| 225 | XGL_DEVICE device, |
| 226 | XGL_SIZE dataSize, |
| 227 | const XGL_VOID* pData, |
| 228 | XGL_PIPELINE* pPipeline); |
| 229 | |
| 230 | XGL_RESULT XGLAPI intelCreatePipelineDelta( |
| 231 | XGL_DEVICE device, |
| 232 | XGL_PIPELINE p1, |
| 233 | XGL_PIPELINE p2, |
| 234 | XGL_PIPELINE_DELTA* delta); |
| 235 | #endif // PIPELINE_H |