Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 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 | |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 29 | #include "genhw/genhw.h" |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 30 | #include "compiler/pipeline/pipeline_compiler_interface.h" |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 31 | #include "cmd.h" |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 32 | #include "format.h" |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 33 | #include "shader.h" |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 34 | #include "pipeline.h" |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 35 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 36 | static int translate_blend_func(VkBlendOp func) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 37 | { |
| 38 | switch (func) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 39 | case VK_BLEND_OP_ADD: return GEN6_BLENDFUNCTION_ADD; |
| 40 | case VK_BLEND_OP_SUBTRACT: return GEN6_BLENDFUNCTION_SUBTRACT; |
| 41 | case VK_BLEND_OP_REVERSE_SUBTRACT: return GEN6_BLENDFUNCTION_REVERSE_SUBTRACT; |
| 42 | case VK_BLEND_OP_MIN: return GEN6_BLENDFUNCTION_MIN; |
| 43 | case VK_BLEND_OP_MAX: return GEN6_BLENDFUNCTION_MAX; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 44 | default: |
| 45 | assert(!"unknown blend func"); |
| 46 | return GEN6_BLENDFUNCTION_ADD; |
| 47 | }; |
| 48 | } |
| 49 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 50 | static int translate_blend(VkBlend blend) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 51 | { |
| 52 | switch (blend) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 53 | case VK_BLEND_ZERO: return GEN6_BLENDFACTOR_ZERO; |
| 54 | case VK_BLEND_ONE: return GEN6_BLENDFACTOR_ONE; |
| 55 | case VK_BLEND_SRC_COLOR: return GEN6_BLENDFACTOR_SRC_COLOR; |
| 56 | case VK_BLEND_ONE_MINUS_SRC_COLOR: return GEN6_BLENDFACTOR_INV_SRC_COLOR; |
| 57 | case VK_BLEND_DEST_COLOR: return GEN6_BLENDFACTOR_DST_COLOR; |
| 58 | case VK_BLEND_ONE_MINUS_DEST_COLOR: return GEN6_BLENDFACTOR_INV_DST_COLOR; |
| 59 | case VK_BLEND_SRC_ALPHA: return GEN6_BLENDFACTOR_SRC_ALPHA; |
| 60 | case VK_BLEND_ONE_MINUS_SRC_ALPHA: return GEN6_BLENDFACTOR_INV_SRC_ALPHA; |
| 61 | case VK_BLEND_DEST_ALPHA: return GEN6_BLENDFACTOR_DST_ALPHA; |
| 62 | case VK_BLEND_ONE_MINUS_DEST_ALPHA: return GEN6_BLENDFACTOR_INV_DST_ALPHA; |
| 63 | case VK_BLEND_CONSTANT_COLOR: return GEN6_BLENDFACTOR_CONST_COLOR; |
| 64 | case VK_BLEND_ONE_MINUS_CONSTANT_COLOR: return GEN6_BLENDFACTOR_INV_CONST_COLOR; |
| 65 | case VK_BLEND_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_CONST_ALPHA; |
| 66 | case VK_BLEND_ONE_MINUS_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_INV_CONST_ALPHA; |
| 67 | case VK_BLEND_SRC_ALPHA_SATURATE: return GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE; |
| 68 | case VK_BLEND_SRC1_COLOR: return GEN6_BLENDFACTOR_SRC1_COLOR; |
| 69 | case VK_BLEND_ONE_MINUS_SRC1_COLOR: return GEN6_BLENDFACTOR_INV_SRC1_COLOR; |
| 70 | case VK_BLEND_SRC1_ALPHA: return GEN6_BLENDFACTOR_SRC1_ALPHA; |
| 71 | case VK_BLEND_ONE_MINUS_SRC1_ALPHA: return GEN6_BLENDFACTOR_INV_SRC1_ALPHA; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 72 | default: |
| 73 | assert(!"unknown blend factor"); |
| 74 | return GEN6_BLENDFACTOR_ONE; |
| 75 | }; |
| 76 | } |
| 77 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 78 | static int translate_compare_func(VkCompareOp func) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 79 | { |
| 80 | switch (func) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 81 | case VK_COMPARE_OP_NEVER: return GEN6_COMPAREFUNCTION_NEVER; |
| 82 | case VK_COMPARE_OP_LESS: return GEN6_COMPAREFUNCTION_LESS; |
| 83 | case VK_COMPARE_OP_EQUAL: return GEN6_COMPAREFUNCTION_EQUAL; |
| 84 | case VK_COMPARE_OP_LESS_EQUAL: return GEN6_COMPAREFUNCTION_LEQUAL; |
| 85 | case VK_COMPARE_OP_GREATER: return GEN6_COMPAREFUNCTION_GREATER; |
| 86 | case VK_COMPARE_OP_NOT_EQUAL: return GEN6_COMPAREFUNCTION_NOTEQUAL; |
| 87 | case VK_COMPARE_OP_GREATER_EQUAL: return GEN6_COMPAREFUNCTION_GEQUAL; |
| 88 | case VK_COMPARE_OP_ALWAYS: return GEN6_COMPAREFUNCTION_ALWAYS; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 89 | default: |
| 90 | assert(!"unknown compare_func"); |
| 91 | return GEN6_COMPAREFUNCTION_NEVER; |
| 92 | } |
| 93 | } |
| 94 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 95 | static int translate_stencil_op(VkStencilOp op) |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 96 | { |
| 97 | switch (op) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 98 | case VK_STENCIL_OP_KEEP: return GEN6_STENCILOP_KEEP; |
| 99 | case VK_STENCIL_OP_ZERO: return GEN6_STENCILOP_ZERO; |
| 100 | case VK_STENCIL_OP_REPLACE: return GEN6_STENCILOP_REPLACE; |
| 101 | case VK_STENCIL_OP_INC_CLAMP: return GEN6_STENCILOP_INCRSAT; |
| 102 | case VK_STENCIL_OP_DEC_CLAMP: return GEN6_STENCILOP_DECRSAT; |
| 103 | case VK_STENCIL_OP_INVERT: return GEN6_STENCILOP_INVERT; |
| 104 | case VK_STENCIL_OP_INC_WRAP: return GEN6_STENCILOP_INCR; |
| 105 | case VK_STENCIL_OP_DEC_WRAP: return GEN6_STENCILOP_DECR; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 106 | default: |
| 107 | assert(!"unknown stencil op"); |
| 108 | return GEN6_STENCILOP_KEEP; |
| 109 | } |
| 110 | } |
| 111 | |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 112 | struct intel_pipeline_create_info { |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 113 | VkGraphicsPipelineCreateInfo graphics; |
| 114 | VkPipelineVertexInputStateCreateInfo vi; |
| 115 | VkPipelineIaStateCreateInfo ia; |
| 116 | VkPipelineDsStateCreateInfo db; |
| 117 | VkPipelineCbStateCreateInfo cb; |
| 118 | VkPipelineRsStateCreateInfo rs; |
| 119 | VkPipelineTessStateCreateInfo tess; |
| 120 | VkPipelineMsStateCreateInfo ms; |
| 121 | VkPipelineVpStateCreateInfo vp; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 122 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 123 | VkComputePipelineCreateInfo compute; |
| 124 | |
| 125 | VkPipelineShaderStageCreateInfo vs; |
| 126 | VkPipelineShaderStageCreateInfo tcs; |
| 127 | VkPipelineShaderStageCreateInfo tes; |
| 128 | VkPipelineShaderStageCreateInfo gs; |
| 129 | VkPipelineShaderStageCreateInfo fs; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 130 | }; |
Chia-I Wu | 38d1ddf | 2015-03-02 10:51:39 -0700 | [diff] [blame] | 131 | |
| 132 | /* in S1.3 */ |
| 133 | struct intel_pipeline_sample_position { |
| 134 | int8_t x, y; |
| 135 | }; |
| 136 | |
| 137 | static uint8_t pack_sample_position(const struct intel_dev *dev, |
| 138 | const struct intel_pipeline_sample_position *pos) |
| 139 | { |
| 140 | return (pos->x + 8) << 4 | (pos->y + 8); |
| 141 | } |
| 142 | |
| 143 | void intel_pipeline_init_default_sample_patterns(const struct intel_dev *dev, |
| 144 | uint8_t *pat_1x, uint8_t *pat_2x, |
| 145 | uint8_t *pat_4x, uint8_t *pat_8x, |
| 146 | uint8_t *pat_16x) |
| 147 | { |
| 148 | static const struct intel_pipeline_sample_position default_1x[1] = { |
| 149 | { 0, 0 }, |
| 150 | }; |
| 151 | static const struct intel_pipeline_sample_position default_2x[2] = { |
| 152 | { -4, -4 }, |
| 153 | { 4, 4 }, |
| 154 | }; |
| 155 | static const struct intel_pipeline_sample_position default_4x[4] = { |
| 156 | { -2, -6 }, |
| 157 | { 6, -2 }, |
| 158 | { -6, 2 }, |
| 159 | { 2, 6 }, |
| 160 | }; |
| 161 | static const struct intel_pipeline_sample_position default_8x[8] = { |
| 162 | { -1, 1 }, |
| 163 | { 1, 5 }, |
| 164 | { 3, -5 }, |
| 165 | { 5, 3 }, |
| 166 | { -7, -1 }, |
| 167 | { -3, -7 }, |
| 168 | { 7, -3 }, |
| 169 | { -5, 7 }, |
| 170 | }; |
| 171 | static const struct intel_pipeline_sample_position default_16x[16] = { |
| 172 | { 0, 2 }, |
| 173 | { 3, 0 }, |
| 174 | { -3, -2 }, |
| 175 | { -2, -4 }, |
| 176 | { 4, 3 }, |
| 177 | { 5, 1 }, |
| 178 | { 6, -1 }, |
| 179 | { 2, -6 }, |
| 180 | { -4, 5 }, |
| 181 | { -5, -5 }, |
| 182 | { -1, -7 }, |
| 183 | { 7, -3 }, |
| 184 | { -7, 4 }, |
| 185 | { 1, -8 }, |
| 186 | { -6, 6 }, |
| 187 | { -8, 7 }, |
| 188 | }; |
| 189 | int i; |
| 190 | |
| 191 | pat_1x[0] = pack_sample_position(dev, default_1x); |
| 192 | for (i = 0; i < 2; i++) |
| 193 | pat_2x[i] = pack_sample_position(dev, &default_2x[i]); |
| 194 | for (i = 0; i < 4; i++) |
| 195 | pat_4x[i] = pack_sample_position(dev, &default_4x[i]); |
| 196 | for (i = 0; i < 8; i++) |
| 197 | pat_8x[i] = pack_sample_position(dev, &default_8x[i]); |
| 198 | for (i = 0; i < 16; i++) |
| 199 | pat_16x[i] = pack_sample_position(dev, &default_16x[i]); |
| 200 | } |
| 201 | |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 202 | struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev, |
| 203 | enum intel_dev_meta_shader id) |
| 204 | { |
| 205 | struct intel_pipeline_shader *sh; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 206 | VkResult ret; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 207 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 208 | sh = intel_alloc(dev, sizeof(*sh), 0, VK_SYSTEM_ALLOC_TYPE_INTERNAL); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 209 | if (!sh) |
| 210 | return NULL; |
| 211 | memset(sh, 0, sizeof(*sh)); |
| 212 | |
| 213 | ret = intel_pipeline_shader_compile_meta(sh, dev->gpu, id); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 214 | if (ret != VK_SUCCESS) { |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 215 | intel_free(dev, sh); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 216 | return NULL; |
| 217 | } |
| 218 | |
| 219 | switch (id) { |
| 220 | case INTEL_DEV_META_VS_FILL_MEM: |
| 221 | case INTEL_DEV_META_VS_COPY_MEM: |
| 222 | case INTEL_DEV_META_VS_COPY_MEM_UNALIGNED: |
| 223 | sh->max_threads = intel_gpu_get_max_threads(dev->gpu, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 224 | VK_SHADER_STAGE_VERTEX); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 225 | break; |
| 226 | default: |
| 227 | sh->max_threads = intel_gpu_get_max_threads(dev->gpu, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 228 | VK_SHADER_STAGE_FRAGMENT); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 229 | break; |
| 230 | } |
| 231 | |
| 232 | return sh; |
| 233 | } |
| 234 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 235 | void intel_pipeline_shader_destroy(struct intel_dev *dev, |
| 236 | struct intel_pipeline_shader *sh) |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 237 | { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 238 | intel_pipeline_shader_cleanup(sh, dev->gpu); |
| 239 | intel_free(dev, sh); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 240 | } |
| 241 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 242 | static VkResult pipeline_build_shader(struct intel_pipeline *pipeline, |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 243 | const VkPipelineShaderStageCreateInfo *sh_info, |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 244 | struct intel_pipeline_shader *sh) |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 245 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 246 | VkResult ret; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 247 | |
Cody Northrop | bc12f87 | 2015-04-29 13:22:07 -0600 | [diff] [blame] | 248 | const struct intel_ir* ir = intel_shader(sh_info->shader)->ir; |
| 249 | |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 250 | ret = intel_pipeline_shader_compile(sh, |
Cody Northrop | bc12f87 | 2015-04-29 13:22:07 -0600 | [diff] [blame] | 251 | pipeline->dev->gpu, pipeline->pipeline_layout, sh_info, ir); |
| 252 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 253 | if (ret != VK_SUCCESS) |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 254 | return ret; |
| 255 | |
| 256 | sh->max_threads = |
| 257 | intel_gpu_get_max_threads(pipeline->dev->gpu, sh_info->stage); |
| 258 | |
| 259 | /* 1KB aligned */ |
| 260 | sh->scratch_offset = u_align(pipeline->scratch_size, 1024); |
| 261 | pipeline->scratch_size = sh->scratch_offset + |
| 262 | sh->per_thread_scratch_size * sh->max_threads; |
| 263 | |
| 264 | pipeline->active_shaders |= 1 << sh_info->stage; |
| 265 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 266 | return VK_SUCCESS; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 267 | } |
| 268 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 269 | static VkResult pipeline_build_shaders(struct intel_pipeline *pipeline, |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 270 | const struct intel_pipeline_create_info *info) |
| 271 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 272 | VkResult ret = VK_SUCCESS; |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 273 | |
Chia-I Wu | df601c4 | 2015-04-17 01:58:07 +0800 | [diff] [blame] | 274 | if (ret == VK_SUCCESS && info->vs.shader) |
| 275 | ret = pipeline_build_shader(pipeline, &info->vs, &pipeline->vs); |
| 276 | if (ret == VK_SUCCESS && info->tcs.shader) |
| 277 | ret = pipeline_build_shader(pipeline, &info->tcs,&pipeline->tcs); |
| 278 | if (ret == VK_SUCCESS && info->tes.shader) |
| 279 | ret = pipeline_build_shader(pipeline, &info->tes,&pipeline->tes); |
| 280 | if (ret == VK_SUCCESS && info->gs.shader) |
| 281 | ret = pipeline_build_shader(pipeline, &info->gs, &pipeline->gs); |
| 282 | if (ret == VK_SUCCESS && info->fs.shader) |
| 283 | ret = pipeline_build_shader(pipeline, &info->fs, &pipeline->fs); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 284 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 285 | if (ret == VK_SUCCESS && info->compute.cs.shader) { |
Chia-I Wu | df601c4 | 2015-04-17 01:58:07 +0800 | [diff] [blame] | 286 | ret = pipeline_build_shader(pipeline, |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 287 | &info->compute.cs, &pipeline->cs); |
| 288 | } |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 289 | |
| 290 | return ret; |
| 291 | } |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 292 | static uint32_t *pipeline_cmd_ptr(struct intel_pipeline *pipeline, int cmd_len) |
| 293 | { |
| 294 | uint32_t *ptr; |
| 295 | |
| 296 | assert(pipeline->cmd_len + cmd_len < INTEL_PSO_CMD_ENTRIES); |
| 297 | ptr = &pipeline->cmds[pipeline->cmd_len]; |
| 298 | pipeline->cmd_len += cmd_len; |
| 299 | return ptr; |
| 300 | } |
| 301 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 302 | static VkResult pipeline_build_ia(struct intel_pipeline *pipeline, |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 303 | const struct intel_pipeline_create_info* info) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 304 | { |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 305 | pipeline->topology = info->ia.topology; |
| 306 | pipeline->disable_vs_cache = info->ia.disableVertexReuse; |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 307 | |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 308 | switch (info->ia.topology) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 309 | case VK_PRIMITIVE_TOPOLOGY_POINT_LIST: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 310 | pipeline->prim_type = GEN6_3DPRIM_POINTLIST; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 311 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 312 | case VK_PRIMITIVE_TOPOLOGY_LINE_LIST: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 313 | pipeline->prim_type = GEN6_3DPRIM_LINELIST; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 314 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 315 | case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 316 | pipeline->prim_type = GEN6_3DPRIM_LINESTRIP; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 317 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 318 | case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 319 | pipeline->prim_type = GEN6_3DPRIM_TRILIST; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 320 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 321 | case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 322 | pipeline->prim_type = GEN6_3DPRIM_TRISTRIP; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 323 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 324 | case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN: |
Courtney Goeltzenleuchter | 528781d | 2015-03-03 11:38:12 -0700 | [diff] [blame] | 325 | pipeline->prim_type = GEN6_3DPRIM_TRIFAN; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 326 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 327 | case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_ADJ: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 328 | pipeline->prim_type = GEN6_3DPRIM_LINELIST_ADJ; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 329 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 330 | case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 331 | pipeline->prim_type = GEN6_3DPRIM_LINESTRIP_ADJ; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 332 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 333 | case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_ADJ: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 334 | pipeline->prim_type = GEN6_3DPRIM_TRILIST_ADJ; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 335 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 336 | case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ: |
Courtney Goeltzenleuchter | 8a3de59 | 2014-08-22 09:09:46 -0600 | [diff] [blame] | 337 | pipeline->prim_type = GEN6_3DPRIM_TRISTRIP_ADJ; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 338 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 339 | case VK_PRIMITIVE_TOPOLOGY_PATCH: |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 340 | if (!info->tess.patchControlPoints || |
| 341 | info->tess.patchControlPoints > 32) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 342 | return VK_ERROR_BAD_PIPELINE_DATA; |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 343 | pipeline->prim_type = GEN7_3DPRIM_PATCHLIST_1 + |
| 344 | info->tess.patchControlPoints - 1; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 345 | break; |
| 346 | default: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 347 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 348 | } |
| 349 | |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 350 | if (info->ia.primitiveRestartEnable) { |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 351 | pipeline->primitive_restart = true; |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 352 | pipeline->primitive_restart_index = info->ia.primitiveRestartIndex; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 353 | } else { |
| 354 | pipeline->primitive_restart = false; |
| 355 | } |
| 356 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 357 | return VK_SUCCESS; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 358 | } |
| 359 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 360 | static VkResult pipeline_build_rs_state(struct intel_pipeline *pipeline, |
Chia-I Wu | 6abcb0e | 2015-03-24 14:38:14 +0800 | [diff] [blame] | 361 | const struct intel_pipeline_create_info* info) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 362 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 363 | const VkPipelineRsStateCreateInfo *rs_state = &info->rs; |
Chia-I Wu | 6abcb0e | 2015-03-24 14:38:14 +0800 | [diff] [blame] | 364 | bool ccw; |
| 365 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 366 | pipeline->depthClipEnable = rs_state->depthClipEnable; |
| 367 | pipeline->rasterizerDiscardEnable = rs_state->rasterizerDiscardEnable; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 368 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 369 | if (rs_state->provokingVertex == VK_PROVOKING_VERTEX_FIRST) { |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 370 | pipeline->provoking_vertex_tri = 0; |
| 371 | pipeline->provoking_vertex_trifan = 1; |
| 372 | pipeline->provoking_vertex_line = 0; |
| 373 | } else { |
| 374 | pipeline->provoking_vertex_tri = 2; |
| 375 | pipeline->provoking_vertex_trifan = 2; |
| 376 | pipeline->provoking_vertex_line = 1; |
| 377 | } |
| 378 | |
| 379 | switch (rs_state->fillMode) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 380 | case VK_FILL_MODE_POINTS: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 381 | pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT | |
| 382 | GEN7_SF_DW1_BACKFACE_POINT; |
| 383 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 384 | case VK_FILL_MODE_WIREFRAME: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 385 | pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME | |
| 386 | GEN7_SF_DW1_BACKFACE_WIREFRAME; |
| 387 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 388 | case VK_FILL_MODE_SOLID: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 389 | default: |
| 390 | pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID | |
| 391 | GEN7_SF_DW1_BACKFACE_SOLID; |
| 392 | break; |
| 393 | } |
| 394 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 395 | ccw = (rs_state->frontFace == VK_FRONT_FACE_CCW); |
Chia-I Wu | 6abcb0e | 2015-03-24 14:38:14 +0800 | [diff] [blame] | 396 | /* flip the winding order */ |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 397 | if (info->vp.clipOrigin == VK_COORDINATE_ORIGIN_LOWER_LEFT) |
Chia-I Wu | 6abcb0e | 2015-03-24 14:38:14 +0800 | [diff] [blame] | 398 | ccw = !ccw; |
| 399 | |
| 400 | if (ccw) { |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 401 | pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW; |
| 402 | pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW; |
| 403 | } |
| 404 | |
| 405 | switch (rs_state->cullMode) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 406 | case VK_CULL_MODE_NONE: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 407 | default: |
| 408 | pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE; |
| 409 | pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE; |
| 410 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 411 | case VK_CULL_MODE_FRONT: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 412 | pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT; |
| 413 | pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT; |
| 414 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 415 | case VK_CULL_MODE_BACK: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 416 | pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK; |
| 417 | pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK; |
| 418 | break; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 419 | case VK_CULL_MODE_FRONT_AND_BACK: |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 420 | pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH; |
| 421 | pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH; |
| 422 | break; |
| 423 | } |
| 424 | |
| 425 | /* only GEN7+ needs cull mode in 3DSTATE_CLIP */ |
| 426 | if (intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6)) |
| 427 | pipeline->cmd_clip_cull = 0; |
| 428 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 429 | return VK_SUCCESS; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 430 | } |
| 431 | |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 432 | static void pipeline_destroy(struct intel_obj *obj) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 433 | { |
| 434 | struct intel_pipeline *pipeline = intel_pipeline_from_obj(obj); |
| 435 | |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 436 | if (pipeline->active_shaders & SHADER_VERTEX_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 437 | intel_pipeline_shader_cleanup(&pipeline->vs, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 441 | intel_pipeline_shader_cleanup(&pipeline->tcs, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 445 | intel_pipeline_shader_cleanup(&pipeline->tes, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 449 | intel_pipeline_shader_cleanup(&pipeline->gs, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 453 | intel_pipeline_shader_cleanup(&pipeline->fs, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | if (pipeline->active_shaders & SHADER_COMPUTE_FLAG) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 457 | intel_pipeline_shader_cleanup(&pipeline->cs, pipeline->dev->gpu); |
Chia-I Wu | 3f23983 | 2014-12-11 22:57:18 +0800 | [diff] [blame] | 458 | } |
Chia-I Wu | ed83387 | 2014-08-23 17:00:35 +0800 | [diff] [blame] | 459 | |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 460 | intel_base_destroy(&pipeline->obj.base); |
| 461 | } |
| 462 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 463 | static VkResult pipeline_get_info(struct intel_base *base, int type, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 464 | size_t *size, void *data) |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 465 | { |
| 466 | struct intel_pipeline *pipeline = intel_pipeline_from_base(base); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 467 | VkResult ret = VK_SUCCESS; |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 468 | |
| 469 | switch (type) { |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 470 | case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS: |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 471 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 472 | VkMemoryRequirements *mem_req = data; |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 473 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 474 | *size = sizeof(VkMemoryRequirements); |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 475 | if (data) { |
| 476 | mem_req->size = pipeline->scratch_size; |
| 477 | mem_req->alignment = 1024; |
Jeremy Hayes | d02809a | 2015-04-15 14:17:56 -0600 | [diff] [blame] | 478 | mem_req->memPropsAllowed = INTEL_MEMORY_PROPERTY_ALL; |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | break; |
| 482 | default: |
| 483 | ret = intel_base_get_info(base, type, size, data); |
| 484 | break; |
| 485 | } |
| 486 | |
| 487 | return ret; |
| 488 | } |
| 489 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 490 | static VkResult pipeline_validate(struct intel_pipeline *pipeline) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 491 | { |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 492 | /* |
| 493 | * Validate required elements |
| 494 | */ |
| 495 | if (!(pipeline->active_shaders & SHADER_VERTEX_FLAG)) { |
| 496 | // TODO: Log debug message: Vertex Shader required. |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 497 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | /* |
| 501 | * Tessalation control and evaluation have to both have a shader defined or |
| 502 | * neither should have a shader defined. |
| 503 | */ |
| 504 | if (((pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) == 0) != |
| 505 | ((pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) == 0) ) { |
| 506 | // TODO: Log debug message: Both Tess control and Tess eval are required to use tessalation |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 507 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | if ((pipeline->active_shaders & SHADER_COMPUTE_FLAG) && |
| 511 | (pipeline->active_shaders & (SHADER_VERTEX_FLAG | SHADER_TESS_CONTROL_FLAG | |
| 512 | SHADER_TESS_EVAL_FLAG | SHADER_GEOMETRY_FLAG | |
| 513 | SHADER_FRAGMENT_FLAG))) { |
| 514 | // TODO: Log debug message: Can only specify compute shader when doing compute |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 515 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | /* |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 519 | * VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines. |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 520 | * Mismatching primitive topology and tessellation fails graphics pipeline creation. |
| 521 | */ |
| 522 | if (pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG) && |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 523 | (pipeline->topology != VK_PRIMITIVE_TOPOLOGY_PATCH)) { |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 524 | // TODO: Log debug message: Invalid topology used with tessalation shader. |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 525 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 526 | } |
| 527 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 528 | if ((pipeline->topology == VK_PRIMITIVE_TOPOLOGY_PATCH) && |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 529 | (pipeline->active_shaders & ~(SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG))) { |
| 530 | // TODO: Log debug message: Cannot use TOPOLOGY_PATCH on non-tessalation shader. |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 531 | return VK_ERROR_BAD_PIPELINE_DATA; |
Courtney Goeltzenleuchter | 4250999 | 2014-08-21 17:33:46 -0600 | [diff] [blame] | 532 | } |
| 533 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 534 | return VK_SUCCESS; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 535 | } |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 536 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 537 | static void pipeline_build_urb_alloc_gen6(struct intel_pipeline *pipeline, |
| 538 | const struct intel_pipeline_create_info *info) |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 539 | { |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 540 | const struct intel_gpu *gpu = pipeline->dev->gpu; |
| 541 | const int urb_size = ((gpu->gt == 2) ? 64 : 32) * 1024; |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 542 | const struct intel_pipeline_shader *vs = &pipeline->vs; |
| 543 | const struct intel_pipeline_shader *gs = &pipeline->gs; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 544 | int vs_entry_size, gs_entry_size; |
| 545 | int vs_size, gs_size; |
| 546 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 547 | INTEL_GPU_ASSERT(gpu, 6, 6); |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 548 | |
| 549 | vs_entry_size = ((vs->in_count >= vs->out_count) ? |
| 550 | vs->in_count : vs->out_count); |
| 551 | gs_entry_size = (gs) ? gs->out_count : 0; |
| 552 | |
| 553 | /* in bytes */ |
| 554 | vs_entry_size *= sizeof(float) * 4; |
| 555 | gs_entry_size *= sizeof(float) * 4; |
| 556 | |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 557 | if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) { |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 558 | vs_size = urb_size / 2; |
| 559 | gs_size = vs_size; |
| 560 | } else { |
| 561 | vs_size = urb_size; |
| 562 | gs_size = 0; |
| 563 | } |
| 564 | |
| 565 | /* 3DSTATE_URB */ |
| 566 | { |
| 567 | const uint8_t cmd_len = 3; |
| 568 | const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_URB) | |
| 569 | (cmd_len - 2); |
| 570 | int vs_alloc_size, gs_alloc_size; |
| 571 | int vs_entry_count, gs_entry_count; |
| 572 | uint32_t *dw; |
| 573 | |
| 574 | /* in 1024-bit rows */ |
| 575 | vs_alloc_size = (vs_entry_size + 128 - 1) / 128; |
| 576 | gs_alloc_size = (gs_entry_size + 128 - 1) / 128; |
| 577 | |
| 578 | /* valid range is [1, 5] */ |
| 579 | if (!vs_alloc_size) |
| 580 | vs_alloc_size = 1; |
| 581 | if (!gs_alloc_size) |
| 582 | gs_alloc_size = 1; |
| 583 | assert(vs_alloc_size <= 5 && gs_alloc_size <= 5); |
| 584 | |
| 585 | /* valid range is [24, 256], multiples of 4 */ |
| 586 | vs_entry_count = (vs_size / 128 / vs_alloc_size) & ~3; |
| 587 | if (vs_entry_count > 256) |
| 588 | vs_entry_count = 256; |
| 589 | assert(vs_entry_count >= 24); |
| 590 | |
| 591 | /* valid range is [0, 256], multiples of 4 */ |
| 592 | gs_entry_count = (gs_size / 128 / gs_alloc_size) & ~3; |
| 593 | if (gs_entry_count > 256) |
| 594 | gs_entry_count = 256; |
| 595 | |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 596 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 597 | |
| 598 | dw[0] = dw0; |
| 599 | dw[1] = (vs_alloc_size - 1) << GEN6_URB_DW1_VS_ENTRY_SIZE__SHIFT | |
| 600 | vs_entry_count << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT; |
| 601 | dw[2] = gs_entry_count << GEN6_URB_DW2_GS_ENTRY_COUNT__SHIFT | |
| 602 | (gs_alloc_size - 1) << GEN6_URB_DW2_GS_ENTRY_SIZE__SHIFT; |
| 603 | } |
| 604 | } |
| 605 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 606 | static void pipeline_build_urb_alloc_gen7(struct intel_pipeline *pipeline, |
| 607 | const struct intel_pipeline_create_info *info) |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 608 | { |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 609 | const struct intel_gpu *gpu = pipeline->dev->gpu; |
| 610 | const int urb_size = ((gpu->gt == 3) ? 512 : |
| 611 | (gpu->gt == 2) ? 256 : 128) * 1024; |
Cody Northrop | 306ec35 | 2014-10-06 15:11:45 -0600 | [diff] [blame] | 612 | const struct intel_pipeline_shader *vs = &pipeline->vs; |
| 613 | const struct intel_pipeline_shader *gs = &pipeline->gs; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 614 | /* some space is reserved for PCBs */ |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 615 | int urb_offset = ((gpu->gt == 3) ? 32 : 16) * 1024; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 616 | int vs_entry_size, gs_entry_size; |
| 617 | int vs_size, gs_size; |
| 618 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 619 | INTEL_GPU_ASSERT(gpu, 7, 7.5); |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 620 | |
| 621 | vs_entry_size = ((vs->in_count >= vs->out_count) ? |
| 622 | vs->in_count : vs->out_count); |
| 623 | gs_entry_size = (gs) ? gs->out_count : 0; |
| 624 | |
| 625 | /* in bytes */ |
| 626 | vs_entry_size *= sizeof(float) * 4; |
| 627 | gs_entry_size *= sizeof(float) * 4; |
| 628 | |
Chia-I Wu | a4d1b39 | 2014-10-10 13:57:29 +0800 | [diff] [blame] | 629 | if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) { |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 630 | vs_size = (urb_size - urb_offset) / 2; |
| 631 | gs_size = vs_size; |
| 632 | } else { |
| 633 | vs_size = urb_size - urb_offset; |
| 634 | gs_size = 0; |
| 635 | } |
| 636 | |
| 637 | /* 3DSTATE_URB_* */ |
| 638 | { |
| 639 | const uint8_t cmd_len = 2; |
| 640 | int vs_alloc_size, gs_alloc_size; |
| 641 | int vs_entry_count, gs_entry_count; |
| 642 | uint32_t *dw; |
| 643 | |
| 644 | /* in 512-bit rows */ |
| 645 | vs_alloc_size = (vs_entry_size + 64 - 1) / 64; |
| 646 | gs_alloc_size = (gs_entry_size + 64 - 1) / 64; |
| 647 | |
| 648 | if (!vs_alloc_size) |
| 649 | vs_alloc_size = 1; |
| 650 | if (!gs_alloc_size) |
| 651 | gs_alloc_size = 1; |
| 652 | |
| 653 | /* avoid performance decrease due to banking */ |
| 654 | if (vs_alloc_size == 5) |
| 655 | vs_alloc_size = 6; |
| 656 | |
| 657 | /* in multiples of 8 */ |
| 658 | vs_entry_count = (vs_size / 64 / vs_alloc_size) & ~7; |
| 659 | assert(vs_entry_count >= 32); |
| 660 | |
| 661 | gs_entry_count = (gs_size / 64 / gs_alloc_size) & ~7; |
| 662 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 663 | if (intel_gpu_gen(gpu) >= INTEL_GEN(7.5)) { |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 664 | const int max_vs_entry_count = |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 665 | (gpu->gt >= 2) ? 1664 : 640; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 666 | const int max_gs_entry_count = |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 667 | (gpu->gt >= 2) ? 640 : 256; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 668 | if (vs_entry_count >= max_vs_entry_count) |
| 669 | vs_entry_count = max_vs_entry_count; |
| 670 | if (gs_entry_count >= max_gs_entry_count) |
| 671 | gs_entry_count = max_gs_entry_count; |
| 672 | } else { |
| 673 | const int max_vs_entry_count = |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 674 | (gpu->gt == 2) ? 704 : 512; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 675 | const int max_gs_entry_count = |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 676 | (gpu->gt == 2) ? 320 : 192; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 677 | if (vs_entry_count >= max_vs_entry_count) |
| 678 | vs_entry_count = max_vs_entry_count; |
| 679 | if (gs_entry_count >= max_gs_entry_count) |
| 680 | gs_entry_count = max_gs_entry_count; |
| 681 | } |
| 682 | |
Courtney Goeltzenleuchter | 814cd29 | 2014-08-28 13:16:27 -0600 | [diff] [blame] | 683 | dw = pipeline_cmd_ptr(pipeline, cmd_len*4); |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 684 | dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_VS) | (cmd_len - 2); |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 685 | dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT | |
| 686 | (vs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT | |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 687 | vs_entry_count; |
| 688 | |
| 689 | dw += 2; |
| 690 | if (gs_size) |
| 691 | urb_offset += vs_size; |
| 692 | dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_GS) | (cmd_len - 2); |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 693 | dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT | |
| 694 | (gs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT | |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 695 | gs_entry_count; |
| 696 | |
| 697 | dw += 2; |
| 698 | dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_HS) | (cmd_len - 2); |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 699 | dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 700 | |
| 701 | dw += 2; |
| 702 | dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_DS) | (cmd_len - 2); |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 703 | dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 704 | } |
| 705 | } |
| 706 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 707 | static void pipeline_build_vertex_elements(struct intel_pipeline *pipeline, |
| 708 | const struct intel_pipeline_create_info *info) |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 709 | { |
Cody Northrop | 306ec35 | 2014-10-06 15:11:45 -0600 | [diff] [blame] | 710 | const struct intel_pipeline_shader *vs = &pipeline->vs; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 711 | uint8_t cmd_len; |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 712 | uint32_t *dw; |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 713 | uint32_t i, j; |
| 714 | uint32_t attr_count; |
| 715 | uint32_t attrs_processed; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 716 | int comps[4]; |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 717 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 718 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5); |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 719 | |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 720 | attr_count = u_popcountll(vs->inputs_read); |
| 721 | cmd_len = 1 + 2 * attr_count; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 722 | if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) |
| 723 | cmd_len += 2; |
| 724 | |
| 725 | if (cmd_len == 1) |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 726 | return; |
| 727 | |
| 728 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 729 | |
| 730 | dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) | |
| 731 | (cmd_len - 2); |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 732 | dw++; |
| 733 | |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 734 | /* VERTEX_ELEMENT_STATE */ |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 735 | for (i = 0, attrs_processed = 0; attrs_processed < attr_count; i++) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 736 | VkVertexInputAttributeDescription *attr = NULL; |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 737 | |
| 738 | /* |
| 739 | * The compiler will pack the shader references and then |
| 740 | * indicate which locations are used via the bitmask in |
| 741 | * vs->inputs_read. |
| 742 | */ |
| 743 | if (!(vs->inputs_read & (1L << i))) { |
GregF | 2dc4021 | 2014-10-31 17:31:47 -0600 | [diff] [blame] | 744 | continue; |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 745 | } |
| 746 | |
| 747 | /* |
| 748 | * For each bit set in the vs->inputs_read we'll need |
| 749 | * to find the corresponding attribute record and then |
| 750 | * set up the next HW vertex element based on that attribute. |
| 751 | */ |
| 752 | for (j = 0; j < info->vi.attributeCount; j++) { |
| 753 | if (info->vi.pVertexAttributeDescriptions[j].location == i) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 754 | attr = (VkVertexInputAttributeDescription *) &info->vi.pVertexAttributeDescriptions[j]; |
Courtney Goeltzenleuchter | f5cdad0 | 2015-03-31 16:36:30 -0600 | [diff] [blame] | 755 | attrs_processed++; |
| 756 | break; |
| 757 | } |
| 758 | } |
| 759 | assert(attr != NULL); |
| 760 | |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 761 | const int format = |
| 762 | intel_format_translate_color(pipeline->dev->gpu, attr->format); |
| 763 | |
| 764 | comps[0] = GEN6_VFCOMP_STORE_0; |
| 765 | comps[1] = GEN6_VFCOMP_STORE_0; |
| 766 | comps[2] = GEN6_VFCOMP_STORE_0; |
| 767 | comps[3] = icd_format_is_int(attr->format) ? |
| 768 | GEN6_VFCOMP_STORE_1_INT : GEN6_VFCOMP_STORE_1_FP; |
| 769 | |
| 770 | switch (icd_format_get_channel_count(attr->format)) { |
| 771 | case 4: comps[3] = GEN6_VFCOMP_STORE_SRC; /* fall through */ |
| 772 | case 3: comps[2] = GEN6_VFCOMP_STORE_SRC; /* fall through */ |
| 773 | case 2: comps[1] = GEN6_VFCOMP_STORE_SRC; /* fall through */ |
| 774 | case 1: comps[0] = GEN6_VFCOMP_STORE_SRC; break; |
| 775 | default: |
| 776 | break; |
| 777 | } |
| 778 | |
| 779 | assert(attr->offsetInBytes <= 2047); |
| 780 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 781 | dw[0] = attr->binding << GEN6_VE_DW0_VB_INDEX__SHIFT | |
| 782 | GEN6_VE_DW0_VALID | |
| 783 | format << GEN6_VE_DW0_FORMAT__SHIFT | |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 784 | attr->offsetInBytes; |
| 785 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 786 | dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT | |
| 787 | comps[1] << GEN6_VE_DW1_COMP1__SHIFT | |
| 788 | comps[2] << GEN6_VE_DW1_COMP2__SHIFT | |
| 789 | comps[3] << GEN6_VE_DW1_COMP3__SHIFT; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 790 | |
| 791 | dw += 2; |
| 792 | } |
GregF | 932fcf5 | 2014-10-29 17:02:11 -0600 | [diff] [blame] | 793 | |
| 794 | if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) { |
| 795 | comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ? |
| 796 | GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0; |
| 797 | comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ? |
| 798 | GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE; |
| 799 | comps[2] = GEN6_VFCOMP_NOSTORE; |
| 800 | comps[3] = GEN6_VFCOMP_NOSTORE; |
| 801 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 802 | dw[0] = GEN6_VE_DW0_VALID; |
| 803 | dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT | |
| 804 | comps[1] << GEN6_VE_DW1_COMP1__SHIFT | |
| 805 | comps[2] << GEN6_VE_DW1_COMP2__SHIFT | |
| 806 | comps[3] << GEN6_VE_DW1_COMP3__SHIFT; |
GregF | 932fcf5 | 2014-10-29 17:02:11 -0600 | [diff] [blame] | 807 | |
| 808 | dw += 2; |
| 809 | } |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 810 | } |
| 811 | |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 812 | static void pipeline_build_fragment_SBE(struct intel_pipeline *pipeline, |
| 813 | const struct intel_pipeline_create_info *info) |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 814 | { |
| 815 | const struct intel_pipeline_shader *fs = &pipeline->fs; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 816 | uint8_t cmd_len; |
| 817 | uint32_t *body; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 818 | uint32_t attr_skip, attr_count; |
| 819 | uint32_t vue_offset, vue_len; |
| 820 | uint32_t i; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 821 | |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 822 | // If GS is active, use its outputs |
| 823 | const struct intel_pipeline_shader *src = |
| 824 | (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) |
| 825 | ? &pipeline->gs |
| 826 | : &pipeline->vs; |
| 827 | |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 828 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5); |
| 829 | |
| 830 | cmd_len = 14; |
| 831 | |
Chia-I Wu | f85def4 | 2015-01-29 00:34:24 +0800 | [diff] [blame] | 832 | if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) |
| 833 | body = pipeline_cmd_ptr(pipeline, cmd_len); |
| 834 | else |
| 835 | body = pipeline->cmd_3dstate_sbe; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 836 | |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 837 | assert(!fs->reads_user_clip || src->enable_user_clip); |
| 838 | attr_skip = src->outputs_offset; |
| 839 | if (src->enable_user_clip != fs->reads_user_clip) { |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 840 | attr_skip += 2; |
| 841 | } |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 842 | assert(src->out_count >= attr_skip); |
| 843 | attr_count = src->out_count - attr_skip; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 844 | |
| 845 | // LUNARG TODO: We currently are only handling 16 attrs; |
| 846 | // ultimately, we need to handle 32 |
| 847 | assert(fs->in_count <= 16); |
| 848 | assert(attr_count <= 16); |
| 849 | |
| 850 | vue_offset = attr_skip / 2; |
| 851 | vue_len = (attr_count + 1) / 2; |
| 852 | if (!vue_len) |
| 853 | vue_len = 1; |
| 854 | |
| 855 | body[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) | |
| 856 | (cmd_len - 2); |
| 857 | |
| 858 | // LUNARG TODO: If the attrs needed by the FS are exactly |
| 859 | // what is written by the VS, we don't need to enable |
| 860 | // swizzling, improving performance. Even if we swizzle, |
| 861 | // we can improve performance by reducing vue_len to |
| 862 | // just include the values needed by the FS: |
| 863 | // vue_len = ceiling((max_vs_out + 1)/2) |
| 864 | |
| 865 | body[1] = GEN7_SBE_DW1_ATTR_SWIZZLE_ENABLE | |
| 866 | fs->in_count << GEN7_SBE_DW1_ATTR_COUNT__SHIFT | |
| 867 | vue_len << GEN7_SBE_DW1_URB_READ_LEN__SHIFT | |
| 868 | vue_offset << GEN7_SBE_DW1_URB_READ_OFFSET__SHIFT; |
| 869 | |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 870 | switch (info->rs.pointOrigin) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 871 | case VK_COORDINATE_ORIGIN_UPPER_LEFT: |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 872 | body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_UPPERLEFT; |
| 873 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 874 | case VK_COORDINATE_ORIGIN_LOWER_LEFT: |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 875 | body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_LOWERLEFT; |
| 876 | break; |
| 877 | default: |
| 878 | assert(!"unknown point origin"); |
| 879 | break; |
| 880 | } |
| 881 | |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 882 | uint16_t src_slot[fs->in_count]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 883 | int32_t fs_in = 0; |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 884 | int32_t src_out = - (vue_offset * 2 - src->outputs_offset); |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 885 | for (i=0; i < 64; i++) { |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 886 | bool srcWrites = src->outputs_written & (1L << i); |
| 887 | bool fsReads = fs->inputs_read & (1L << i); |
Cody Northrop | d75c13e | 2015-01-02 14:07:20 -0700 | [diff] [blame] | 888 | |
| 889 | if (fsReads) { |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 890 | assert(src_out >= 0); |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 891 | assert(fs_in < fs->in_count); |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 892 | src_slot[fs_in] = src_out; |
Cody Northrop | d75c13e | 2015-01-02 14:07:20 -0700 | [diff] [blame] | 893 | |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 894 | if (!srcWrites) { |
Cody Northrop | d75c13e | 2015-01-02 14:07:20 -0700 | [diff] [blame] | 895 | // If the vertex shader did not write this input, we cannot |
| 896 | // program the SBE to read it. Our choices are to allow it to |
| 897 | // read junk from a GRF, or get zero. We're choosing zero. |
| 898 | if (i >= fs->generic_input_start) { |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 899 | src_slot[fs_in] = GEN8_SBE_SWIZ_CONST_0000 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 900 | GEN8_SBE_SWIZ_OVERRIDE_X | |
| 901 | GEN8_SBE_SWIZ_OVERRIDE_Y | |
| 902 | GEN8_SBE_SWIZ_OVERRIDE_Z | |
| 903 | GEN8_SBE_SWIZ_OVERRIDE_W; |
Cody Northrop | d75c13e | 2015-01-02 14:07:20 -0700 | [diff] [blame] | 904 | } |
| 905 | } |
| 906 | |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 907 | fs_in += 1; |
| 908 | } |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 909 | if (srcWrites) { |
| 910 | src_out += 1; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | |
| 914 | for (i = 0; i < 8; i++) { |
| 915 | uint16_t hi, lo; |
| 916 | |
| 917 | /* no attr swizzles */ |
| 918 | if (i * 2 + 1 < fs->in_count) { |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 919 | lo = src_slot[i * 2]; |
| 920 | hi = src_slot[i * 2 + 1]; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 921 | } else if (i * 2 < fs->in_count) { |
Cody Northrop | 293d450 | 2015-05-05 09:38:03 -0600 | [diff] [blame] | 922 | lo = src_slot[i * 2]; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 923 | hi = 0; |
| 924 | } else { |
| 925 | hi = 0; |
| 926 | lo = 0; |
| 927 | } |
| 928 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 929 | body[2 + i] = hi << GEN8_SBE_SWIZ_HIGH__SHIFT | lo; |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 930 | } |
| 931 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 932 | if (info->ia.topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST) |
Chia-I Wu | 7f39056 | 2015-03-25 08:47:18 +0800 | [diff] [blame] | 933 | body[10] = fs->point_sprite_enables; |
| 934 | else |
| 935 | body[10] = 0; |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 936 | |
GregF | 8cd8183 | 2014-11-18 18:01:01 -0700 | [diff] [blame] | 937 | body[11] = 0; /* constant interpolation enables */ |
| 938 | body[12] = 0; /* WrapShortest enables */ |
| 939 | body[13] = 0; |
| 940 | } |
| 941 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 942 | static void pipeline_build_gs(struct intel_pipeline *pipeline, |
| 943 | const struct intel_pipeline_create_info *info) |
Courtney Goeltzenleuchter | b286770 | 2014-08-28 17:44:05 -0600 | [diff] [blame] | 944 | { |
Courtney Goeltzenleuchter | b286770 | 2014-08-28 17:44:05 -0600 | [diff] [blame] | 945 | // gen7_emit_3DSTATE_GS done by cmd_pipeline |
Courtney Goeltzenleuchter | b286770 | 2014-08-28 17:44:05 -0600 | [diff] [blame] | 946 | } |
| 947 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 948 | static void pipeline_build_hs(struct intel_pipeline *pipeline, |
| 949 | const struct intel_pipeline_create_info *info) |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 950 | { |
| 951 | const uint8_t cmd_len = 7; |
| 952 | const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2); |
| 953 | uint32_t *dw; |
| 954 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 955 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 956 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 957 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 958 | dw[0] = dw0; |
| 959 | dw[1] = 0; |
| 960 | dw[2] = 0; |
| 961 | dw[3] = 0; |
| 962 | dw[4] = 0; |
| 963 | dw[5] = 0; |
| 964 | dw[6] = 0; |
| 965 | } |
| 966 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 967 | static void pipeline_build_te(struct intel_pipeline *pipeline, |
| 968 | const struct intel_pipeline_create_info *info) |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 969 | { |
| 970 | const uint8_t cmd_len = 4; |
| 971 | const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2); |
| 972 | uint32_t *dw; |
| 973 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 974 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 975 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 976 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 977 | dw[0] = dw0; |
| 978 | dw[1] = 0; |
| 979 | dw[2] = 0; |
| 980 | dw[3] = 0; |
| 981 | } |
| 982 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 983 | static void pipeline_build_ds(struct intel_pipeline *pipeline, |
| 984 | const struct intel_pipeline_create_info *info) |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 985 | { |
| 986 | const uint8_t cmd_len = 6; |
| 987 | const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2); |
| 988 | uint32_t *dw; |
| 989 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 990 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 991 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 992 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Courtney Goeltzenleuchter | dee81a6 | 2014-08-28 18:05:24 -0600 | [diff] [blame] | 993 | dw[0] = dw0; |
| 994 | dw[1] = 0; |
| 995 | dw[2] = 0; |
| 996 | dw[3] = 0; |
| 997 | dw[4] = 0; |
| 998 | dw[5] = 0; |
| 999 | } |
| 1000 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1001 | static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline, |
| 1002 | const struct intel_pipeline_create_info *info) |
| 1003 | { |
| 1004 | pipeline->cmd_depth_stencil = 0; |
| 1005 | |
| 1006 | if (info->db.stencilTestEnable) { |
| 1007 | pipeline->cmd_depth_stencil = 1 << 31 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1008 | translate_compare_func(info->db.front.stencilCompareOp) << 28 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1009 | translate_stencil_op(info->db.front.stencilFailOp) << 25 | |
| 1010 | translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 | |
| 1011 | translate_stencil_op(info->db.front.stencilPassOp) << 19 | |
| 1012 | 1 << 15 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1013 | translate_compare_func(info->db.back.stencilCompareOp) << 12 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1014 | translate_stencil_op(info->db.back.stencilFailOp) << 9 | |
| 1015 | translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 | |
| 1016 | translate_stencil_op(info->db.back.stencilPassOp) << 3; |
| 1017 | } |
| 1018 | |
| 1019 | pipeline->stencilTestEnable = info->db.stencilTestEnable; |
| 1020 | |
| 1021 | /* |
| 1022 | * From the Sandy Bridge PRM, volume 2 part 1, page 360: |
| 1023 | * |
| 1024 | * "Enabling the Depth Test function without defining a Depth Buffer is |
| 1025 | * UNDEFINED." |
| 1026 | * |
| 1027 | * From the Sandy Bridge PRM, volume 2 part 1, page 375: |
| 1028 | * |
| 1029 | * "A Depth Buffer must be defined before enabling writes to it, or |
| 1030 | * operation is UNDEFINED." |
| 1031 | * |
| 1032 | * TODO We do not check these yet. |
| 1033 | */ |
| 1034 | if (info->db.depthTestEnable) { |
| 1035 | pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1036 | translate_compare_func(info->db.depthCompareOp) << 27; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1037 | } else { |
| 1038 | pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27; |
| 1039 | } |
| 1040 | |
| 1041 | if (info->db.depthWriteEnable) |
| 1042 | pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE; |
| 1043 | } |
| 1044 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1045 | static void pipeline_build_msaa(struct intel_pipeline *pipeline, |
| 1046 | const struct intel_pipeline_create_info *info) |
| 1047 | { |
| 1048 | uint32_t cmd, cmd_len; |
| 1049 | uint32_t *dw; |
| 1050 | |
| 1051 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5); |
| 1052 | |
Chia-I Wu | 8ada424 | 2015-03-02 11:19:33 -0700 | [diff] [blame] | 1053 | pipeline->sample_count = (info->ms.samples <= 1) ? 1 : info->ms.samples; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1054 | |
| 1055 | /* 3DSTATE_SAMPLE_MASK */ |
| 1056 | cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK); |
| 1057 | cmd_len = 2; |
| 1058 | |
Chia-I Wu | 8ada424 | 2015-03-02 11:19:33 -0700 | [diff] [blame] | 1059 | dw = pipeline_cmd_ptr(pipeline, cmd_len); |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1060 | dw[0] = cmd | (cmd_len - 2); |
| 1061 | dw[1] = info->ms.sampleMask & ((1 << pipeline->sample_count) - 1); |
| 1062 | pipeline->cmd_sample_mask = dw[1]; |
| 1063 | } |
| 1064 | |
| 1065 | static void pipeline_build_cb(struct intel_pipeline *pipeline, |
| 1066 | const struct intel_pipeline_create_info *info) |
| 1067 | { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1068 | uint32_t i; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1069 | |
| 1070 | INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5); |
| 1071 | STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2); |
| 1072 | assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS); |
| 1073 | |
| 1074 | uint32_t *dw = pipeline->cmd_cb; |
| 1075 | |
| 1076 | for (i = 0; i < info->cb.attachmentCount; i++) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1077 | const VkPipelineCbAttachmentState *att = &info->cb.pAttachments[i]; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1078 | uint32_t dw0, dw1; |
| 1079 | |
| 1080 | |
| 1081 | dw0 = 0; |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1082 | dw1 = GEN6_RT_DW1_COLORCLAMP_RTFORMAT | |
| 1083 | GEN6_RT_DW1_PRE_BLEND_CLAMP | |
| 1084 | GEN6_RT_DW1_POST_BLEND_CLAMP; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1085 | |
| 1086 | if (att->blendEnable) { |
| 1087 | dw0 = 1 << 31 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1088 | translate_blend_func(att->blendOpAlpha) << 26 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1089 | translate_blend(att->srcBlendAlpha) << 20 | |
| 1090 | translate_blend(att->destBlendAlpha) << 15 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1091 | translate_blend_func(att->blendOpColor) << 11 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1092 | translate_blend(att->srcBlendColor) << 5 | |
| 1093 | translate_blend(att->destBlendColor); |
| 1094 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1095 | if (att->blendOpAlpha != att->blendOpColor || |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1096 | att->srcBlendAlpha != att->srcBlendColor || |
| 1097 | att->destBlendAlpha != att->destBlendColor) |
| 1098 | dw0 |= 1 << 30; |
Courtney Goeltzenleuchter | df13a4d | 2015-02-11 14:14:45 -0700 | [diff] [blame] | 1099 | |
| 1100 | pipeline->dual_source_blend_enable = icd_pipeline_cb_att_needs_dual_source_blending(att); |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1101 | } |
| 1102 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1103 | if (info->cb.logicOp != VK_LOGIC_OP_COPY) { |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1104 | int logicop; |
| 1105 | |
| 1106 | switch (info->cb.logicOp) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1107 | case VK_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break; |
| 1108 | case VK_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break; |
| 1109 | case VK_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break; |
| 1110 | case VK_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break; |
| 1111 | case VK_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break; |
| 1112 | case VK_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break; |
| 1113 | case VK_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break; |
| 1114 | case VK_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break; |
| 1115 | case VK_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break; |
| 1116 | case VK_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break; |
| 1117 | case VK_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break; |
| 1118 | case VK_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break; |
| 1119 | case VK_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break; |
| 1120 | case VK_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break; |
| 1121 | case VK_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1122 | default: |
| 1123 | assert(!"unknown logic op"); |
| 1124 | logicop = GEN6_LOGICOP_CLEAR; |
| 1125 | break; |
| 1126 | } |
| 1127 | |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1128 | dw1 |= GEN6_RT_DW1_LOGICOP_ENABLE | |
| 1129 | logicop << GEN6_RT_DW1_LOGICOP_FUNC__SHIFT; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | if (!(att->channelWriteMask & 0x1)) |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1133 | dw1 |= GEN6_RT_DW1_WRITE_DISABLE_R; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1134 | if (!(att->channelWriteMask & 0x2)) |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1135 | dw1 |= GEN6_RT_DW1_WRITE_DISABLE_G; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1136 | if (!(att->channelWriteMask & 0x4)) |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1137 | dw1 |= GEN6_RT_DW1_WRITE_DISABLE_B; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1138 | if (!(att->channelWriteMask & 0x8)) |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1139 | dw1 |= GEN6_RT_DW1_WRITE_DISABLE_A; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1140 | |
| 1141 | dw[2 * i] = dw0; |
| 1142 | dw[2 * i + 1] = dw1; |
| 1143 | } |
| 1144 | |
| 1145 | for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++) |
| 1146 | { |
| 1147 | dw[2 * i] = 0; |
Chia-I Wu | 97aa4de | 2015-03-05 15:43:16 -0700 | [diff] [blame] | 1148 | dw[2 * i + 1] = GEN6_RT_DW1_COLORCLAMP_RTFORMAT | |
| 1149 | GEN6_RT_DW1_PRE_BLEND_CLAMP | |
| 1150 | GEN6_RT_DW1_POST_BLEND_CLAMP | |
| 1151 | GEN6_RT_DW1_WRITE_DISABLE_R | |
| 1152 | GEN6_RT_DW1_WRITE_DISABLE_G | |
| 1153 | GEN6_RT_DW1_WRITE_DISABLE_B | |
| 1154 | GEN6_RT_DW1_WRITE_DISABLE_A; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | } |
| 1158 | |
| 1159 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1160 | static VkResult pipeline_build_all(struct intel_pipeline *pipeline, |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1161 | const struct intel_pipeline_create_info *info) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1162 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1163 | VkResult ret; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1164 | |
Chia-I Wu | 9882459 | 2014-09-02 09:42:46 +0800 | [diff] [blame] | 1165 | ret = pipeline_build_shaders(pipeline, info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1166 | if (ret != VK_SUCCESS) |
Chia-I Wu | 9882459 | 2014-09-02 09:42:46 +0800 | [diff] [blame] | 1167 | return ret; |
| 1168 | |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 1169 | if (info->vi.bindingCount > ARRAY_SIZE(pipeline->vb) || |
| 1170 | info->vi.attributeCount > ARRAY_SIZE(pipeline->vb)) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1171 | return VK_ERROR_BAD_PIPELINE_DATA; |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 1172 | |
Chia-I Wu | 2f455af | 2015-04-22 15:54:06 +0800 | [diff] [blame] | 1173 | if (info->vp.clipOrigin != VK_COORDINATE_ORIGIN_UPPER_LEFT) { |
| 1174 | assert(!"only VK_COORDINATE_ORIGIN_UPPER_LEFT is supported"); |
| 1175 | return VK_ERROR_INVALID_VALUE; |
| 1176 | } |
| 1177 | |
Chia-I Wu | e2504cb | 2015-04-22 14:20:52 +0800 | [diff] [blame] | 1178 | if (info->vp.depthMode != VK_DEPTH_MODE_ZERO_TO_ONE) { |
| 1179 | assert(!"only VK_DEPTH_MODE_ZERO_TO_ONE is supported"); |
| 1180 | return VK_ERROR_INVALID_VALUE; |
| 1181 | } |
| 1182 | |
Chia-I Wu | 1d12509 | 2014-10-08 08:49:38 +0800 | [diff] [blame] | 1183 | pipeline->vb_count = info->vi.bindingCount; |
| 1184 | memcpy(pipeline->vb, info->vi.pVertexBindingDescriptions, |
| 1185 | sizeof(pipeline->vb[0]) * pipeline->vb_count); |
| 1186 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1187 | pipeline_build_vertex_elements(pipeline, info); |
Chia-I Wu | 86a5e0c | 2015-03-24 11:01:50 +0800 | [diff] [blame] | 1188 | pipeline_build_fragment_SBE(pipeline, info); |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1189 | pipeline_build_msaa(pipeline, info); |
Chia-I Wu | 5bdb096 | 2015-01-24 12:49:28 +0800 | [diff] [blame] | 1190 | pipeline_build_depth_stencil(pipeline, info); |
Chia-I Wu | 4d9ad91 | 2014-08-29 14:20:36 +0800 | [diff] [blame] | 1191 | |
Chia-I Wu | 509b3f2 | 2014-09-02 10:24:05 +0800 | [diff] [blame] | 1192 | if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) { |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1193 | pipeline_build_urb_alloc_gen7(pipeline, info); |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1194 | pipeline_build_gs(pipeline, info); |
| 1195 | pipeline_build_hs(pipeline, info); |
| 1196 | pipeline_build_te(pipeline, info); |
| 1197 | pipeline_build_ds(pipeline, info); |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 1198 | |
| 1199 | pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE | |
| 1200 | INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL | |
| 1201 | INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE | |
| 1202 | INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL | |
| 1203 | INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 1204 | } else { |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1205 | pipeline_build_urb_alloc_gen6(pipeline, info); |
Chia-I Wu | 8370b40 | 2014-08-29 12:28:37 +0800 | [diff] [blame] | 1206 | |
| 1207 | pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE | |
| 1208 | INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL; |
Chia-I Wu | bb2d8ca | 2014-08-28 23:15:48 +0800 | [diff] [blame] | 1209 | } |
| 1210 | |
Chia-I Wu | be0a3d9 | 2014-09-02 13:20:59 +0800 | [diff] [blame] | 1211 | ret = pipeline_build_ia(pipeline, info); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1212 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1213 | if (ret == VK_SUCCESS) |
Chia-I Wu | 6abcb0e | 2015-03-24 14:38:14 +0800 | [diff] [blame] | 1214 | ret = pipeline_build_rs_state(pipeline, info); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1215 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1216 | if (ret == VK_SUCCESS) { |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1217 | pipeline->db_format = info->db.format; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1218 | pipeline_build_cb(pipeline, info); |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1219 | pipeline->cb_state = info->cb; |
| 1220 | pipeline->tess_state = info->tess; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | return ret; |
| 1224 | } |
| 1225 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1226 | static VkResult pipeline_create_info_init(struct intel_pipeline_create_info *info, |
| 1227 | const VkGraphicsPipelineCreateInfo *vkinfo) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1228 | { |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1229 | memset(info, 0, sizeof(*info)); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1230 | |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1231 | /* |
| 1232 | * Do we need to set safe defaults in case the app doesn't provide all of |
| 1233 | * the necessary create infos? |
| 1234 | */ |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1235 | info->ms.samples = 1; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 1236 | info->ms.sampleMask = 1; |
| 1237 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1238 | memcpy(&info->graphics, vkinfo, sizeof (info->graphics)); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1239 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1240 | void *dst; |
| 1241 | for (uint32_t i = 0; i < vkinfo->stageCount; i++) { |
| 1242 | const VkPipelineShaderStageCreateInfo *thisStage = &vkinfo->pStages[i]; |
| 1243 | switch (thisStage->stage) { |
| 1244 | case VK_SHADER_STAGE_VERTEX: |
| 1245 | dst = &info->vs; |
| 1246 | break; |
| 1247 | case VK_SHADER_STAGE_TESS_CONTROL: |
| 1248 | dst = &info->tcs; |
| 1249 | break; |
| 1250 | case VK_SHADER_STAGE_TESS_EVALUATION: |
| 1251 | dst = &info->tes; |
| 1252 | break; |
| 1253 | case VK_SHADER_STAGE_GEOMETRY: |
| 1254 | dst = &info->gs; |
| 1255 | break; |
| 1256 | case VK_SHADER_STAGE_FRAGMENT: |
| 1257 | dst = &info->fs; |
| 1258 | break; |
| 1259 | case VK_SHADER_STAGE_COMPUTE: |
| 1260 | dst = &info->compute; |
| 1261 | break; |
| 1262 | default: |
| 1263 | return VK_ERROR_BAD_PIPELINE_DATA; |
| 1264 | break; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1265 | } |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1266 | memcpy(dst, thisStage, sizeof(VkPipelineShaderStageCreateInfo)); |
| 1267 | } |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1268 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1269 | if (vkinfo->pVertexInputState != NULL) { |
| 1270 | memcpy(&info->vi, vkinfo->pVertexInputState, sizeof (info->vi)); |
| 1271 | } |
| 1272 | if (vkinfo->pIaState != NULL) { |
| 1273 | memcpy(&info->ia, vkinfo->pIaState, sizeof (info->ia)); |
| 1274 | } |
| 1275 | if (vkinfo->pDsState != NULL) { |
| 1276 | memcpy(&info->db, vkinfo->pDsState, sizeof (info->db)); |
| 1277 | } |
| 1278 | if (vkinfo->pCbState != NULL) { |
| 1279 | memcpy(&info->cb, vkinfo->pCbState, sizeof (info->cb)); |
| 1280 | } |
| 1281 | if (vkinfo->pRsState != NULL) { |
| 1282 | memcpy(&info->rs, vkinfo->pRsState, sizeof (info->rs)); |
| 1283 | } |
| 1284 | if (vkinfo->pTessState != NULL) { |
| 1285 | memcpy(&info->tess, vkinfo->pTessState, sizeof (info->tess)); |
| 1286 | } |
| 1287 | if (vkinfo->pMsState != NULL) { |
| 1288 | memcpy(&info->ms, vkinfo->pMsState, sizeof (info->ms)); |
| 1289 | } |
| 1290 | if (vkinfo->pVpState != NULL) { |
| 1291 | memcpy(&info->vp, vkinfo->pVpState, sizeof (info->vp)); |
| 1292 | } |
| 1293 | if (vkinfo->pVpState != NULL) { |
| 1294 | memcpy(&info->vp, vkinfo->pVpState, sizeof (info->vp)); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1295 | } |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1296 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1297 | return VK_SUCCESS; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1298 | } |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1299 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1300 | static VkResult graphics_pipeline_create(struct intel_dev *dev, |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1301 | const VkGraphicsPipelineCreateInfo *info_, |
| 1302 | struct intel_pipeline **pipeline_ret) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1303 | { |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1304 | struct intel_pipeline_create_info info; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1305 | struct intel_pipeline *pipeline; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1306 | VkResult ret; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1307 | |
Mark Lobodzinski | 0e0fb5c | 2015-06-23 15:11:57 -0600 | [diff] [blame^] | 1308 | ret = pipeline_create_info_init(&info, info_); |
| 1309 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1310 | if (ret != VK_SUCCESS) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1311 | return ret; |
| 1312 | |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 1313 | pipeline = (struct intel_pipeline *) intel_base_create(&dev->base.handle, |
| 1314 | sizeof(*pipeline), dev->base.dbg, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 1315 | VK_OBJECT_TYPE_PIPELINE, info_, 0); |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1316 | if (!pipeline) |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 1317 | return VK_ERROR_OUT_OF_HOST_MEMORY; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1318 | |
| 1319 | pipeline->dev = dev; |
Mark Lobodzinski | 556f721 | 2015-04-17 14:11:39 -0500 | [diff] [blame] | 1320 | pipeline->pipeline_layout = |
| 1321 | intel_pipeline_layout(info.graphics.layout); |
Chia-I Wu | df601c4 | 2015-04-17 01:58:07 +0800 | [diff] [blame] | 1322 | |
Chia-I Wu | b102473 | 2014-12-19 13:00:29 +0800 | [diff] [blame] | 1323 | pipeline->obj.base.get_info = pipeline_get_info; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1324 | pipeline->obj.destroy = pipeline_destroy; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1325 | |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1326 | ret = pipeline_build_all(pipeline, &info); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1327 | if (ret == VK_SUCCESS) |
Chia-I Wu | f90ff0c | 2014-09-02 09:32:46 +0800 | [diff] [blame] | 1328 | ret = pipeline_validate(pipeline); |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1329 | if (ret != VK_SUCCESS) { |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1330 | pipeline_destroy(&pipeline->obj); |
| 1331 | return ret; |
| 1332 | } |
| 1333 | |
| 1334 | *pipeline_ret = pipeline; |
| 1335 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1336 | return VK_SUCCESS; |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1337 | } |
| 1338 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1339 | ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipeline( |
| 1340 | VkDevice device, |
| 1341 | const VkGraphicsPipelineCreateInfo* pCreateInfo, |
| 1342 | VkPipeline* pPipeline) |
Chia-I Wu | 3efef43 | 2014-08-28 15:00:16 +0800 | [diff] [blame] | 1343 | { |
| 1344 | struct intel_dev *dev = intel_dev(device); |
| 1345 | |
| 1346 | return graphics_pipeline_create(dev, pCreateInfo, |
| 1347 | (struct intel_pipeline **) pPipeline); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1348 | } |
| 1349 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1350 | ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative( |
| 1351 | VkDevice device, |
| 1352 | const VkGraphicsPipelineCreateInfo* pCreateInfo, |
| 1353 | VkPipeline basePipeline, |
| 1354 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 32876a1 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1355 | { |
| 1356 | struct intel_dev *dev = intel_dev(device); |
| 1357 | |
| 1358 | /* TODO: Use basePipeline to optimize creation of derivative */ |
| 1359 | |
| 1360 | return graphics_pipeline_create(dev, pCreateInfo, |
| 1361 | (struct intel_pipeline **) pPipeline); |
| 1362 | } |
| 1363 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1364 | ICD_EXPORT VkResult VKAPI vkCreateComputePipeline( |
| 1365 | VkDevice device, |
| 1366 | const VkComputePipelineCreateInfo* pCreateInfo, |
| 1367 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1368 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1369 | return VK_ERROR_UNAVAILABLE; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1370 | } |
| 1371 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1372 | ICD_EXPORT VkResult VKAPI vkStorePipeline( |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 1373 | VkDevice device, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1374 | VkPipeline pipeline, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1375 | size_t* pDataSize, |
| 1376 | void* pData) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1377 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1378 | return VK_ERROR_UNAVAILABLE; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1379 | } |
| 1380 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1381 | ICD_EXPORT VkResult VKAPI vkLoadPipeline( |
| 1382 | VkDevice device, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1383 | size_t dataSize, |
| 1384 | const void* pData, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1385 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1386 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1387 | return VK_ERROR_UNAVAILABLE; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1388 | } |
| 1389 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1390 | ICD_EXPORT VkResult VKAPI vkLoadPipelineDerivative( |
| 1391 | VkDevice device, |
Courtney Goeltzenleuchter | 32876a1 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1392 | size_t dataSize, |
| 1393 | const void* pData, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1394 | VkPipeline basePipeline, |
| 1395 | VkPipeline* pPipeline) |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1396 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1397 | return VK_ERROR_UNAVAILABLE; |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 1398 | } |