blob: da765bff0a32cb9f5ec29481ba9c805fedf3e846 [file] [log] [blame]
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06003 *
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 Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 * Chia-I Wu <olv@lunarg.com>
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060027 */
28
Chia-I Wu8370b402014-08-29 12:28:37 +080029#include "genhw/genhw.h"
Chia-I Wu3f239832014-12-11 22:57:18 +080030#include "compiler/pipeline/pipeline_compiler_interface.h"
Chia-I Wu8370b402014-08-29 12:28:37 +080031#include "cmd.h"
Chia-I Wu1d125092014-10-08 08:49:38 +080032#include "format.h"
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -060033#include "shader.h"
Chia-I Wu3f239832014-12-11 22:57:18 +080034#include "pipeline.h"
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060035
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060036static int translate_blend_func(VkBlendFunc func)
Tony Barbourfa6cac72015-01-16 14:27:35 -070037{
38 switch (func) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060039 case VK_BLEND_FUNC_ADD: return GEN6_BLENDFUNCTION_ADD;
40 case VK_BLEND_FUNC_SUBTRACT: return GEN6_BLENDFUNCTION_SUBTRACT;
41 case VK_BLEND_FUNC_REVERSE_SUBTRACT: return GEN6_BLENDFUNCTION_REVERSE_SUBTRACT;
42 case VK_BLEND_FUNC_MIN: return GEN6_BLENDFUNCTION_MIN;
43 case VK_BLEND_FUNC_MAX: return GEN6_BLENDFUNCTION_MAX;
Tony Barbourfa6cac72015-01-16 14:27:35 -070044 default:
45 assert(!"unknown blend func");
46 return GEN6_BLENDFUNCTION_ADD;
47 };
48}
49
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060050static int translate_blend(VkBlend blend)
Tony Barbourfa6cac72015-01-16 14:27:35 -070051{
52 switch (blend) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060053 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 Barbourfa6cac72015-01-16 14:27:35 -070072 default:
73 assert(!"unknown blend factor");
74 return GEN6_BLENDFACTOR_ONE;
75 };
76}
77
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060078static int translate_compare_func(VkCompareFunc func)
Tony Barbourfa6cac72015-01-16 14:27:35 -070079{
80 switch (func) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060081 case VK_COMPARE_NEVER: return GEN6_COMPAREFUNCTION_NEVER;
82 case VK_COMPARE_LESS: return GEN6_COMPAREFUNCTION_LESS;
83 case VK_COMPARE_EQUAL: return GEN6_COMPAREFUNCTION_EQUAL;
84 case VK_COMPARE_LESS_EQUAL: return GEN6_COMPAREFUNCTION_LEQUAL;
85 case VK_COMPARE_GREATER: return GEN6_COMPAREFUNCTION_GREATER;
86 case VK_COMPARE_NOT_EQUAL: return GEN6_COMPAREFUNCTION_NOTEQUAL;
87 case VK_COMPARE_GREATER_EQUAL: return GEN6_COMPAREFUNCTION_GEQUAL;
88 case VK_COMPARE_ALWAYS: return GEN6_COMPAREFUNCTION_ALWAYS;
Tony Barbourfa6cac72015-01-16 14:27:35 -070089 default:
90 assert(!"unknown compare_func");
91 return GEN6_COMPAREFUNCTION_NEVER;
92 }
93}
94
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060095static int translate_stencil_op(VkStencilOp op)
Tony Barbourfa6cac72015-01-16 14:27:35 -070096{
97 switch (op) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060098 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 Barbourfa6cac72015-01-16 14:27:35 -0700106 default:
107 assert(!"unknown stencil op");
108 return GEN6_STENCILOP_KEEP;
109 }
110}
111
Chia-I Wu3f239832014-12-11 22:57:18 +0800112struct intel_pipeline_create_info {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600113 VkGraphicsPipelineCreateInfo graphics;
114 VkPipelineVertexInputCreateInfo vi;
115 VkPipelineIaStateCreateInfo ia;
116 VkPipelineDsStateCreateInfo db;
117 VkPipelineCbStateCreateInfo cb;
118 VkPipelineRsStateCreateInfo rs;
119 VkPipelineTessStateCreateInfo tess;
120 VkPipelineMsStateCreateInfo ms;
121 VkPipelineVpStateCreateInfo vp;
122 VkPipelineShader vs;
123 VkPipelineShader tcs;
124 VkPipelineShader tes;
125 VkPipelineShader gs;
126 VkPipelineShader fs;
Chia-I Wu3f239832014-12-11 22:57:18 +0800127
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600128 VkComputePipelineCreateInfo compute;
Chia-I Wu3f239832014-12-11 22:57:18 +0800129};
Chia-I Wu38d1ddf2015-03-02 10:51:39 -0700130
131/* in S1.3 */
132struct intel_pipeline_sample_position {
133 int8_t x, y;
134};
135
136static uint8_t pack_sample_position(const struct intel_dev *dev,
137 const struct intel_pipeline_sample_position *pos)
138{
139 return (pos->x + 8) << 4 | (pos->y + 8);
140}
141
142void intel_pipeline_init_default_sample_patterns(const struct intel_dev *dev,
143 uint8_t *pat_1x, uint8_t *pat_2x,
144 uint8_t *pat_4x, uint8_t *pat_8x,
145 uint8_t *pat_16x)
146{
147 static const struct intel_pipeline_sample_position default_1x[1] = {
148 { 0, 0 },
149 };
150 static const struct intel_pipeline_sample_position default_2x[2] = {
151 { -4, -4 },
152 { 4, 4 },
153 };
154 static const struct intel_pipeline_sample_position default_4x[4] = {
155 { -2, -6 },
156 { 6, -2 },
157 { -6, 2 },
158 { 2, 6 },
159 };
160 static const struct intel_pipeline_sample_position default_8x[8] = {
161 { -1, 1 },
162 { 1, 5 },
163 { 3, -5 },
164 { 5, 3 },
165 { -7, -1 },
166 { -3, -7 },
167 { 7, -3 },
168 { -5, 7 },
169 };
170 static const struct intel_pipeline_sample_position default_16x[16] = {
171 { 0, 2 },
172 { 3, 0 },
173 { -3, -2 },
174 { -2, -4 },
175 { 4, 3 },
176 { 5, 1 },
177 { 6, -1 },
178 { 2, -6 },
179 { -4, 5 },
180 { -5, -5 },
181 { -1, -7 },
182 { 7, -3 },
183 { -7, 4 },
184 { 1, -8 },
185 { -6, 6 },
186 { -8, 7 },
187 };
188 int i;
189
190 pat_1x[0] = pack_sample_position(dev, default_1x);
191 for (i = 0; i < 2; i++)
192 pat_2x[i] = pack_sample_position(dev, &default_2x[i]);
193 for (i = 0; i < 4; i++)
194 pat_4x[i] = pack_sample_position(dev, &default_4x[i]);
195 for (i = 0; i < 8; i++)
196 pat_8x[i] = pack_sample_position(dev, &default_8x[i]);
197 for (i = 0; i < 16; i++)
198 pat_16x[i] = pack_sample_position(dev, &default_16x[i]);
199}
200
Chia-I Wu3f239832014-12-11 22:57:18 +0800201struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
202 enum intel_dev_meta_shader id)
203{
204 struct intel_pipeline_shader *sh;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600205 VkResult ret;
Chia-I Wu3f239832014-12-11 22:57:18 +0800206
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600207 sh = intel_alloc(dev, sizeof(*sh), 0, VK_SYSTEM_ALLOC_INTERNAL);
Chia-I Wu3f239832014-12-11 22:57:18 +0800208 if (!sh)
209 return NULL;
210 memset(sh, 0, sizeof(*sh));
211
212 ret = intel_pipeline_shader_compile_meta(sh, dev->gpu, id);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600213 if (ret != VK_SUCCESS) {
Chia-I Wuf9c81ef2015-02-22 13:49:15 +0800214 intel_free(dev, sh);
Chia-I Wu3f239832014-12-11 22:57:18 +0800215 return NULL;
216 }
217
218 switch (id) {
219 case INTEL_DEV_META_VS_FILL_MEM:
220 case INTEL_DEV_META_VS_COPY_MEM:
221 case INTEL_DEV_META_VS_COPY_MEM_UNALIGNED:
222 sh->max_threads = intel_gpu_get_max_threads(dev->gpu,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600223 VK_SHADER_STAGE_VERTEX);
Chia-I Wu3f239832014-12-11 22:57:18 +0800224 break;
225 default:
226 sh->max_threads = intel_gpu_get_max_threads(dev->gpu,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600227 VK_SHADER_STAGE_FRAGMENT);
Chia-I Wu3f239832014-12-11 22:57:18 +0800228 break;
229 }
230
231 return sh;
232}
233
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800234void intel_pipeline_shader_destroy(struct intel_dev *dev,
235 struct intel_pipeline_shader *sh)
Chia-I Wu3f239832014-12-11 22:57:18 +0800236{
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800237 intel_pipeline_shader_cleanup(sh, dev->gpu);
238 intel_free(dev, sh);
Chia-I Wu3f239832014-12-11 22:57:18 +0800239}
240
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600241static VkResult pipeline_build_shader(struct intel_pipeline *pipeline,
Chia-I Wu7732cb22015-03-26 15:27:55 +0800242 const struct intel_desc_layout_chain *chain,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600243 const VkPipelineShader *sh_info,
Chia-I Wuf8385062015-01-04 16:27:24 +0800244 struct intel_pipeline_shader *sh)
Chia-I Wu3f239832014-12-11 22:57:18 +0800245{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600246 VkResult ret;
Chia-I Wu3f239832014-12-11 22:57:18 +0800247
Chia-I Wuf8385062015-01-04 16:27:24 +0800248 ret = intel_pipeline_shader_compile(sh,
Chia-I Wu7732cb22015-03-26 15:27:55 +0800249 pipeline->dev->gpu, chain, sh_info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600250 if (ret != VK_SUCCESS)
Chia-I Wu3f239832014-12-11 22:57:18 +0800251 return ret;
252
253 sh->max_threads =
254 intel_gpu_get_max_threads(pipeline->dev->gpu, sh_info->stage);
255
256 /* 1KB aligned */
257 sh->scratch_offset = u_align(pipeline->scratch_size, 1024);
258 pipeline->scratch_size = sh->scratch_offset +
259 sh->per_thread_scratch_size * sh->max_threads;
260
261 pipeline->active_shaders |= 1 << sh_info->stage;
262
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600263 return VK_SUCCESS;
Chia-I Wu3f239832014-12-11 22:57:18 +0800264}
265
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600266static VkResult pipeline_build_shaders(struct intel_pipeline *pipeline,
Chia-I Wu3f239832014-12-11 22:57:18 +0800267 const struct intel_pipeline_create_info *info)
268{
Chia-I Wu7732cb22015-03-26 15:27:55 +0800269 const struct intel_desc_layout_chain *chain =
270 intel_desc_layout_chain(info->graphics.pSetLayoutChain);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600271 VkResult ret = VK_SUCCESS;
Chia-I Wu3f239832014-12-11 22:57:18 +0800272
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600273 if (ret == VK_SUCCESS && info->vs.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800274 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800275 &info->vs, &pipeline->vs);
276 }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600277 if (ret == VK_SUCCESS && info->tcs.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800278 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800279 &info->tcs,&pipeline->tcs);
280 }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600281 if (ret == VK_SUCCESS && info->tes.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800282 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800283 &info->tes,&pipeline->tes);
284 }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600285 if (ret == VK_SUCCESS && info->gs.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800286 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800287 &info->gs, &pipeline->gs);
288 }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600289 if (ret == VK_SUCCESS && info->fs.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800290 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800291 &info->fs, &pipeline->fs);
292 }
Chia-I Wu3f239832014-12-11 22:57:18 +0800293
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600294 if (ret == VK_SUCCESS && info->compute.cs.shader) {
Chia-I Wu7732cb22015-03-26 15:27:55 +0800295 chain = intel_desc_layout_chain(info->compute.setLayoutChain);
296 ret = pipeline_build_shader(pipeline, chain,
Chia-I Wuf8385062015-01-04 16:27:24 +0800297 &info->compute.cs, &pipeline->cs);
298 }
Chia-I Wu3f239832014-12-11 22:57:18 +0800299
300 return ret;
301}
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600302static uint32_t *pipeline_cmd_ptr(struct intel_pipeline *pipeline, int cmd_len)
303{
304 uint32_t *ptr;
305
306 assert(pipeline->cmd_len + cmd_len < INTEL_PSO_CMD_ENTRIES);
307 ptr = &pipeline->cmds[pipeline->cmd_len];
308 pipeline->cmd_len += cmd_len;
309 return ptr;
310}
311
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600312static VkResult pipeline_build_ia(struct intel_pipeline *pipeline,
Chia-I Wube0a3d92014-09-02 13:20:59 +0800313 const struct intel_pipeline_create_info* info)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600314{
Chia-I Wube0a3d92014-09-02 13:20:59 +0800315 pipeline->topology = info->ia.topology;
316 pipeline->disable_vs_cache = info->ia.disableVertexReuse;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600317
Chia-I Wube0a3d92014-09-02 13:20:59 +0800318 switch (info->ia.topology) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600319 case VK_TOPOLOGY_POINT_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600320 pipeline->prim_type = GEN6_3DPRIM_POINTLIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600321 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600322 case VK_TOPOLOGY_LINE_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600323 pipeline->prim_type = GEN6_3DPRIM_LINELIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600324 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600325 case VK_TOPOLOGY_LINE_STRIP:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600326 pipeline->prim_type = GEN6_3DPRIM_LINESTRIP;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600327 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328 case VK_TOPOLOGY_TRIANGLE_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600329 pipeline->prim_type = GEN6_3DPRIM_TRILIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600330 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331 case VK_TOPOLOGY_TRIANGLE_STRIP:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600332 pipeline->prim_type = GEN6_3DPRIM_TRISTRIP;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600333 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600334 case VK_TOPOLOGY_TRIANGLE_FAN:
Courtney Goeltzenleuchter528781d2015-03-03 11:38:12 -0700335 pipeline->prim_type = GEN6_3DPRIM_TRIFAN;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600336 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600337 case VK_TOPOLOGY_LINE_LIST_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600338 pipeline->prim_type = GEN6_3DPRIM_LINELIST_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600339 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600340 case VK_TOPOLOGY_LINE_STRIP_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600341 pipeline->prim_type = GEN6_3DPRIM_LINESTRIP_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600342 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600343 case VK_TOPOLOGY_TRIANGLE_LIST_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600344 pipeline->prim_type = GEN6_3DPRIM_TRILIST_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600345 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600346 case VK_TOPOLOGY_TRIANGLE_STRIP_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600347 pipeline->prim_type = GEN6_3DPRIM_TRISTRIP_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600348 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600349 case VK_TOPOLOGY_PATCH:
Chia-I Wube0a3d92014-09-02 13:20:59 +0800350 if (!info->tess.patchControlPoints ||
351 info->tess.patchControlPoints > 32)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600352 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800353 pipeline->prim_type = GEN7_3DPRIM_PATCHLIST_1 +
354 info->tess.patchControlPoints - 1;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600355 break;
356 default:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600357 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600358 }
359
Chia-I Wube0a3d92014-09-02 13:20:59 +0800360 if (info->ia.primitiveRestartEnable) {
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600361 pipeline->primitive_restart = true;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800362 pipeline->primitive_restart_index = info->ia.primitiveRestartIndex;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600363 } else {
364 pipeline->primitive_restart = false;
365 }
366
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600368}
369
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600370static VkResult pipeline_build_rs_state(struct intel_pipeline *pipeline,
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800371 const struct intel_pipeline_create_info* info)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600372{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600373 const VkPipelineRsStateCreateInfo *rs_state = &info->rs;
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800374 bool ccw;
375
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600376 pipeline->depthClipEnable = rs_state->depthClipEnable;
377 pipeline->rasterizerDiscardEnable = rs_state->rasterizerDiscardEnable;
Chia-I Wudb3fbc42015-03-24 10:55:40 +0800378 pipeline->use_rs_point_size = !rs_state->programPointSize;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700379
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600380 if (rs_state->provokingVertex == VK_PROVOKING_VERTEX_FIRST) {
Tony Barbourfa6cac72015-01-16 14:27:35 -0700381 pipeline->provoking_vertex_tri = 0;
382 pipeline->provoking_vertex_trifan = 1;
383 pipeline->provoking_vertex_line = 0;
384 } else {
385 pipeline->provoking_vertex_tri = 2;
386 pipeline->provoking_vertex_trifan = 2;
387 pipeline->provoking_vertex_line = 1;
388 }
389
390 switch (rs_state->fillMode) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600391 case VK_FILL_POINTS:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700392 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT |
393 GEN7_SF_DW1_BACKFACE_POINT;
394 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600395 case VK_FILL_WIREFRAME:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700396 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME |
397 GEN7_SF_DW1_BACKFACE_WIREFRAME;
398 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600399 case VK_FILL_SOLID:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700400 default:
401 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID |
402 GEN7_SF_DW1_BACKFACE_SOLID;
403 break;
404 }
405
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600406 ccw = (rs_state->frontFace == VK_FRONT_FACE_CCW);
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800407 /* flip the winding order */
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600408 if (info->vp.clipOrigin == VK_COORDINATE_ORIGIN_LOWER_LEFT)
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800409 ccw = !ccw;
410
411 if (ccw) {
Tony Barbourfa6cac72015-01-16 14:27:35 -0700412 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW;
413 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW;
414 }
415
416 switch (rs_state->cullMode) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600417 case VK_CULL_NONE:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700418 default:
419 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE;
420 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE;
421 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600422 case VK_CULL_FRONT:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700423 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT;
424 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT;
425 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600426 case VK_CULL_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700427 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK;
428 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK;
429 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600430 case VK_CULL_FRONT_AND_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700431 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH;
432 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH;
433 break;
434 }
435
436 /* only GEN7+ needs cull mode in 3DSTATE_CLIP */
437 if (intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6))
438 pipeline->cmd_clip_cull = 0;
439
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600440 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600441}
442
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600443static void pipeline_destroy(struct intel_obj *obj)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600444{
445 struct intel_pipeline *pipeline = intel_pipeline_from_obj(obj);
446
Chia-I Wu3f239832014-12-11 22:57:18 +0800447 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800448 intel_pipeline_shader_cleanup(&pipeline->vs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800449 }
450
451 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800452 intel_pipeline_shader_cleanup(&pipeline->tcs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800453 }
454
455 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800456 intel_pipeline_shader_cleanup(&pipeline->tes, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800457 }
458
459 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800460 intel_pipeline_shader_cleanup(&pipeline->gs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800461 }
462
463 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800464 intel_pipeline_shader_cleanup(&pipeline->fs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800465 }
466
467 if (pipeline->active_shaders & SHADER_COMPUTE_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800468 intel_pipeline_shader_cleanup(&pipeline->cs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800469 }
Chia-I Wued833872014-08-23 17:00:35 +0800470
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600471 intel_base_destroy(&pipeline->obj.base);
472}
473
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600474static VkResult pipeline_get_info(struct intel_base *base, int type,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600475 size_t *size, void *data)
Chia-I Wub1024732014-12-19 13:00:29 +0800476{
477 struct intel_pipeline *pipeline = intel_pipeline_from_base(base);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600478 VkResult ret = VK_SUCCESS;
Chia-I Wub1024732014-12-19 13:00:29 +0800479
480 switch (type) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600481 case VK_INFO_TYPE_MEMORY_REQUIREMENTS:
Chia-I Wub1024732014-12-19 13:00:29 +0800482 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600483 VkMemoryRequirements *mem_req = data;
Chia-I Wub1024732014-12-19 13:00:29 +0800484
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600485 *size = sizeof(VkMemoryRequirements);
Chia-I Wub1024732014-12-19 13:00:29 +0800486 if (data) {
487 mem_req->size = pipeline->scratch_size;
488 mem_req->alignment = 1024;
Chia-I Wub1024732014-12-19 13:00:29 +0800489 }
490 }
491 break;
492 default:
493 ret = intel_base_get_info(base, type, size, data);
494 break;
495 }
496
497 return ret;
498}
499
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600500static VkResult pipeline_validate(struct intel_pipeline *pipeline)
Chia-I Wu3efef432014-08-28 15:00:16 +0800501{
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600502 /*
503 * Validate required elements
504 */
505 if (!(pipeline->active_shaders & SHADER_VERTEX_FLAG)) {
506 // TODO: Log debug message: Vertex Shader required.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600507 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600508 }
509
510 /*
511 * Tessalation control and evaluation have to both have a shader defined or
512 * neither should have a shader defined.
513 */
514 if (((pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) == 0) !=
515 ((pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) == 0) ) {
516 // TODO: Log debug message: Both Tess control and Tess eval are required to use tessalation
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600517 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600518 }
519
520 if ((pipeline->active_shaders & SHADER_COMPUTE_FLAG) &&
521 (pipeline->active_shaders & (SHADER_VERTEX_FLAG | SHADER_TESS_CONTROL_FLAG |
522 SHADER_TESS_EVAL_FLAG | SHADER_GEOMETRY_FLAG |
523 SHADER_FRAGMENT_FLAG))) {
524 // TODO: Log debug message: Can only specify compute shader when doing compute
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600525 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600526 }
527
528 /*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600529 * VK_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines.
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600530 * Mismatching primitive topology and tessellation fails graphics pipeline creation.
531 */
532 if (pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG) &&
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600533 (pipeline->topology != VK_TOPOLOGY_PATCH)) {
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600534 // TODO: Log debug message: Invalid topology used with tessalation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600535 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600536 }
537
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600538 if ((pipeline->topology == VK_TOPOLOGY_PATCH) &&
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600539 (pipeline->active_shaders & ~(SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG))) {
540 // TODO: Log debug message: Cannot use TOPOLOGY_PATCH on non-tessalation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600541 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600542 }
543
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600544 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +0800545}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600546
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800547static void pipeline_build_urb_alloc_gen6(struct intel_pipeline *pipeline,
548 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800549{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800550 const struct intel_gpu *gpu = pipeline->dev->gpu;
551 const int urb_size = ((gpu->gt == 2) ? 64 : 32) * 1024;
Chia-I Wua4d1b392014-10-10 13:57:29 +0800552 const struct intel_pipeline_shader *vs = &pipeline->vs;
553 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800554 int vs_entry_size, gs_entry_size;
555 int vs_size, gs_size;
556
Chia-I Wu509b3f22014-09-02 10:24:05 +0800557 INTEL_GPU_ASSERT(gpu, 6, 6);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800558
559 vs_entry_size = ((vs->in_count >= vs->out_count) ?
560 vs->in_count : vs->out_count);
561 gs_entry_size = (gs) ? gs->out_count : 0;
562
563 /* in bytes */
564 vs_entry_size *= sizeof(float) * 4;
565 gs_entry_size *= sizeof(float) * 4;
566
Chia-I Wua4d1b392014-10-10 13:57:29 +0800567 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800568 vs_size = urb_size / 2;
569 gs_size = vs_size;
570 } else {
571 vs_size = urb_size;
572 gs_size = 0;
573 }
574
575 /* 3DSTATE_URB */
576 {
577 const uint8_t cmd_len = 3;
578 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_URB) |
579 (cmd_len - 2);
580 int vs_alloc_size, gs_alloc_size;
581 int vs_entry_count, gs_entry_count;
582 uint32_t *dw;
583
584 /* in 1024-bit rows */
585 vs_alloc_size = (vs_entry_size + 128 - 1) / 128;
586 gs_alloc_size = (gs_entry_size + 128 - 1) / 128;
587
588 /* valid range is [1, 5] */
589 if (!vs_alloc_size)
590 vs_alloc_size = 1;
591 if (!gs_alloc_size)
592 gs_alloc_size = 1;
593 assert(vs_alloc_size <= 5 && gs_alloc_size <= 5);
594
595 /* valid range is [24, 256], multiples of 4 */
596 vs_entry_count = (vs_size / 128 / vs_alloc_size) & ~3;
597 if (vs_entry_count > 256)
598 vs_entry_count = 256;
599 assert(vs_entry_count >= 24);
600
601 /* valid range is [0, 256], multiples of 4 */
602 gs_entry_count = (gs_size / 128 / gs_alloc_size) & ~3;
603 if (gs_entry_count > 256)
604 gs_entry_count = 256;
605
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600606 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800607
608 dw[0] = dw0;
609 dw[1] = (vs_alloc_size - 1) << GEN6_URB_DW1_VS_ENTRY_SIZE__SHIFT |
610 vs_entry_count << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT;
611 dw[2] = gs_entry_count << GEN6_URB_DW2_GS_ENTRY_COUNT__SHIFT |
612 (gs_alloc_size - 1) << GEN6_URB_DW2_GS_ENTRY_SIZE__SHIFT;
613 }
614}
615
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800616static void pipeline_build_urb_alloc_gen7(struct intel_pipeline *pipeline,
617 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800618{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800619 const struct intel_gpu *gpu = pipeline->dev->gpu;
620 const int urb_size = ((gpu->gt == 3) ? 512 :
621 (gpu->gt == 2) ? 256 : 128) * 1024;
Cody Northrop306ec352014-10-06 15:11:45 -0600622 const struct intel_pipeline_shader *vs = &pipeline->vs;
623 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800624 /* some space is reserved for PCBs */
Chia-I Wu509b3f22014-09-02 10:24:05 +0800625 int urb_offset = ((gpu->gt == 3) ? 32 : 16) * 1024;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800626 int vs_entry_size, gs_entry_size;
627 int vs_size, gs_size;
628
Chia-I Wu509b3f22014-09-02 10:24:05 +0800629 INTEL_GPU_ASSERT(gpu, 7, 7.5);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800630
631 vs_entry_size = ((vs->in_count >= vs->out_count) ?
632 vs->in_count : vs->out_count);
633 gs_entry_size = (gs) ? gs->out_count : 0;
634
635 /* in bytes */
636 vs_entry_size *= sizeof(float) * 4;
637 gs_entry_size *= sizeof(float) * 4;
638
Chia-I Wua4d1b392014-10-10 13:57:29 +0800639 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800640 vs_size = (urb_size - urb_offset) / 2;
641 gs_size = vs_size;
642 } else {
643 vs_size = urb_size - urb_offset;
644 gs_size = 0;
645 }
646
647 /* 3DSTATE_URB_* */
648 {
649 const uint8_t cmd_len = 2;
650 int vs_alloc_size, gs_alloc_size;
651 int vs_entry_count, gs_entry_count;
652 uint32_t *dw;
653
654 /* in 512-bit rows */
655 vs_alloc_size = (vs_entry_size + 64 - 1) / 64;
656 gs_alloc_size = (gs_entry_size + 64 - 1) / 64;
657
658 if (!vs_alloc_size)
659 vs_alloc_size = 1;
660 if (!gs_alloc_size)
661 gs_alloc_size = 1;
662
663 /* avoid performance decrease due to banking */
664 if (vs_alloc_size == 5)
665 vs_alloc_size = 6;
666
667 /* in multiples of 8 */
668 vs_entry_count = (vs_size / 64 / vs_alloc_size) & ~7;
669 assert(vs_entry_count >= 32);
670
671 gs_entry_count = (gs_size / 64 / gs_alloc_size) & ~7;
672
Chia-I Wu509b3f22014-09-02 10:24:05 +0800673 if (intel_gpu_gen(gpu) >= INTEL_GEN(7.5)) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800674 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800675 (gpu->gt >= 2) ? 1664 : 640;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800676 const int max_gs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800677 (gpu->gt >= 2) ? 640 : 256;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800678 if (vs_entry_count >= max_vs_entry_count)
679 vs_entry_count = max_vs_entry_count;
680 if (gs_entry_count >= max_gs_entry_count)
681 gs_entry_count = max_gs_entry_count;
682 } else {
683 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800684 (gpu->gt == 2) ? 704 : 512;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800685 const int max_gs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800686 (gpu->gt == 2) ? 320 : 192;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800687 if (vs_entry_count >= max_vs_entry_count)
688 vs_entry_count = max_vs_entry_count;
689 if (gs_entry_count >= max_gs_entry_count)
690 gs_entry_count = max_gs_entry_count;
691 }
692
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600693 dw = pipeline_cmd_ptr(pipeline, cmd_len*4);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800694 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_VS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700695 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
696 (vs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800697 vs_entry_count;
698
699 dw += 2;
700 if (gs_size)
701 urb_offset += vs_size;
702 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_GS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700703 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
704 (gs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800705 gs_entry_count;
706
707 dw += 2;
708 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_HS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700709 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800710
711 dw += 2;
712 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_DS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700713 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800714 }
715}
716
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800717static void pipeline_build_vertex_elements(struct intel_pipeline *pipeline,
718 const struct intel_pipeline_create_info *info)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800719{
Cody Northrop306ec352014-10-06 15:11:45 -0600720 const struct intel_pipeline_shader *vs = &pipeline->vs;
Chia-I Wu1d125092014-10-08 08:49:38 +0800721 uint8_t cmd_len;
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800722 uint32_t *dw;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600723 uint32_t i, j;
724 uint32_t attr_count;
725 uint32_t attrs_processed;
Chia-I Wu1d125092014-10-08 08:49:38 +0800726 int comps[4];
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800727
Chia-I Wu509b3f22014-09-02 10:24:05 +0800728 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800729
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600730 attr_count = u_popcountll(vs->inputs_read);
731 cmd_len = 1 + 2 * attr_count;
Chia-I Wu1d125092014-10-08 08:49:38 +0800732 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID))
733 cmd_len += 2;
734
735 if (cmd_len == 1)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800736 return;
737
738 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wu1d125092014-10-08 08:49:38 +0800739
740 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) |
741 (cmd_len - 2);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800742 dw++;
743
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800744 /* VERTEX_ELEMENT_STATE */
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600745 for (i = 0, attrs_processed = 0; attrs_processed < attr_count; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600746 VkVertexInputAttributeDescription *attr = NULL;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600747
748 /*
749 * The compiler will pack the shader references and then
750 * indicate which locations are used via the bitmask in
751 * vs->inputs_read.
752 */
753 if (!(vs->inputs_read & (1L << i))) {
GregF2dc40212014-10-31 17:31:47 -0600754 continue;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600755 }
756
757 /*
758 * For each bit set in the vs->inputs_read we'll need
759 * to find the corresponding attribute record and then
760 * set up the next HW vertex element based on that attribute.
761 */
762 for (j = 0; j < info->vi.attributeCount; j++) {
763 if (info->vi.pVertexAttributeDescriptions[j].location == i) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600764 attr = (VkVertexInputAttributeDescription *) &info->vi.pVertexAttributeDescriptions[j];
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600765 attrs_processed++;
766 break;
767 }
768 }
769 assert(attr != NULL);
770
Chia-I Wu1d125092014-10-08 08:49:38 +0800771 const int format =
772 intel_format_translate_color(pipeline->dev->gpu, attr->format);
773
774 comps[0] = GEN6_VFCOMP_STORE_0;
775 comps[1] = GEN6_VFCOMP_STORE_0;
776 comps[2] = GEN6_VFCOMP_STORE_0;
777 comps[3] = icd_format_is_int(attr->format) ?
778 GEN6_VFCOMP_STORE_1_INT : GEN6_VFCOMP_STORE_1_FP;
779
780 switch (icd_format_get_channel_count(attr->format)) {
781 case 4: comps[3] = GEN6_VFCOMP_STORE_SRC; /* fall through */
782 case 3: comps[2] = GEN6_VFCOMP_STORE_SRC; /* fall through */
783 case 2: comps[1] = GEN6_VFCOMP_STORE_SRC; /* fall through */
784 case 1: comps[0] = GEN6_VFCOMP_STORE_SRC; break;
785 default:
786 break;
787 }
788
789 assert(attr->offsetInBytes <= 2047);
790
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700791 dw[0] = attr->binding << GEN6_VE_DW0_VB_INDEX__SHIFT |
792 GEN6_VE_DW0_VALID |
793 format << GEN6_VE_DW0_FORMAT__SHIFT |
Chia-I Wu1d125092014-10-08 08:49:38 +0800794 attr->offsetInBytes;
795
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700796 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
797 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
798 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
799 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
Chia-I Wu1d125092014-10-08 08:49:38 +0800800
801 dw += 2;
802 }
GregF932fcf52014-10-29 17:02:11 -0600803
804 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) {
805 comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ?
806 GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0;
807 comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ?
808 GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE;
809 comps[2] = GEN6_VFCOMP_NOSTORE;
810 comps[3] = GEN6_VFCOMP_NOSTORE;
811
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700812 dw[0] = GEN6_VE_DW0_VALID;
813 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
814 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
815 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
816 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
GregF932fcf52014-10-29 17:02:11 -0600817
818 dw += 2;
819 }
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800820}
821
Chia-I Wub6386202015-03-24 11:13:06 +0800822static void pipeline_build_viewport(struct intel_pipeline *pipeline,
823 const struct intel_pipeline_create_info *info)
824{
825 switch (info->vp.depthMode) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600826 case VK_DEPTH_MODE_ZERO_TO_ONE:
Chia-I Wub6386202015-03-24 11:13:06 +0800827 pipeline->depth_zero_to_one = true;
828 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600829 case VK_DEPTH_MODE_NEGATIVE_ONE_TO_ONE:
Chia-I Wub6386202015-03-24 11:13:06 +0800830 default:
831 pipeline->depth_zero_to_one = false;
832 break;
833 }
834}
835
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800836static void pipeline_build_fragment_SBE(struct intel_pipeline *pipeline,
837 const struct intel_pipeline_create_info *info)
GregF8cd81832014-11-18 18:01:01 -0700838{
839 const struct intel_pipeline_shader *fs = &pipeline->fs;
840 const struct intel_pipeline_shader *vs = &pipeline->vs;
841 uint8_t cmd_len;
842 uint32_t *body;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600843 uint32_t attr_skip, attr_count;
844 uint32_t vue_offset, vue_len;
845 uint32_t i;
GregF8cd81832014-11-18 18:01:01 -0700846
847 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
848
849 cmd_len = 14;
850
Chia-I Wuf85def42015-01-29 00:34:24 +0800851 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7))
852 body = pipeline_cmd_ptr(pipeline, cmd_len);
853 else
854 body = pipeline->cmd_3dstate_sbe;
GregF8cd81832014-11-18 18:01:01 -0700855
GregF8cd81832014-11-18 18:01:01 -0700856 assert(!fs->reads_user_clip || vs->enable_user_clip);
857 attr_skip = vs->outputs_offset;
858 if (vs->enable_user_clip != fs->reads_user_clip) {
859 attr_skip += 2;
860 }
861 assert(vs->out_count >= attr_skip);
862 attr_count = vs->out_count - attr_skip;
863
864 // LUNARG TODO: We currently are only handling 16 attrs;
865 // ultimately, we need to handle 32
866 assert(fs->in_count <= 16);
867 assert(attr_count <= 16);
868
869 vue_offset = attr_skip / 2;
870 vue_len = (attr_count + 1) / 2;
871 if (!vue_len)
872 vue_len = 1;
873
874 body[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) |
875 (cmd_len - 2);
876
877 // LUNARG TODO: If the attrs needed by the FS are exactly
878 // what is written by the VS, we don't need to enable
879 // swizzling, improving performance. Even if we swizzle,
880 // we can improve performance by reducing vue_len to
881 // just include the values needed by the FS:
882 // vue_len = ceiling((max_vs_out + 1)/2)
883
884 body[1] = GEN7_SBE_DW1_ATTR_SWIZZLE_ENABLE |
885 fs->in_count << GEN7_SBE_DW1_ATTR_COUNT__SHIFT |
886 vue_len << GEN7_SBE_DW1_URB_READ_LEN__SHIFT |
887 vue_offset << GEN7_SBE_DW1_URB_READ_OFFSET__SHIFT;
888
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800889 switch (info->rs.pointOrigin) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600890 case VK_COORDINATE_ORIGIN_UPPER_LEFT:
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800891 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_UPPERLEFT;
892 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600893 case VK_COORDINATE_ORIGIN_LOWER_LEFT:
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800894 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_LOWERLEFT;
895 break;
896 default:
897 assert(!"unknown point origin");
898 break;
899 }
900
GregF8cd81832014-11-18 18:01:01 -0700901 uint16_t vs_slot[fs->in_count];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600902 int32_t fs_in = 0;
903 int32_t vs_out = - (vue_offset * 2 - vs->outputs_offset);
GregF8cd81832014-11-18 18:01:01 -0700904 for (i=0; i < 64; i++) {
Cody Northropd75c13e2015-01-02 14:07:20 -0700905 bool vsWrites = vs->outputs_written & (1L << i);
906 bool fsReads = fs->inputs_read & (1L << i);
907
908 if (fsReads) {
GregF8cd81832014-11-18 18:01:01 -0700909 assert(vs_out >= 0);
910 assert(fs_in < fs->in_count);
911 vs_slot[fs_in] = vs_out;
Cody Northropd75c13e2015-01-02 14:07:20 -0700912
913 if (!vsWrites) {
914 // If the vertex shader did not write this input, we cannot
915 // program the SBE to read it. Our choices are to allow it to
916 // read junk from a GRF, or get zero. We're choosing zero.
917 if (i >= fs->generic_input_start) {
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700918 vs_slot[fs_in] = GEN8_SBE_SWIZ_CONST_0000 |
919 GEN8_SBE_SWIZ_OVERRIDE_X |
920 GEN8_SBE_SWIZ_OVERRIDE_Y |
921 GEN8_SBE_SWIZ_OVERRIDE_Z |
922 GEN8_SBE_SWIZ_OVERRIDE_W;
Cody Northropd75c13e2015-01-02 14:07:20 -0700923 }
924 }
925
GregF8cd81832014-11-18 18:01:01 -0700926 fs_in += 1;
927 }
Cody Northropd75c13e2015-01-02 14:07:20 -0700928 if (vsWrites) {
GregF8cd81832014-11-18 18:01:01 -0700929 vs_out += 1;
930 }
931 }
932
933 for (i = 0; i < 8; i++) {
934 uint16_t hi, lo;
935
936 /* no attr swizzles */
937 if (i * 2 + 1 < fs->in_count) {
938 lo = vs_slot[i * 2];
939 hi = vs_slot[i * 2 + 1];
940 } else if (i * 2 < fs->in_count) {
941 lo = vs_slot[i * 2];
942 hi = 0;
943 } else {
944 hi = 0;
945 lo = 0;
946 }
947
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700948 body[2 + i] = hi << GEN8_SBE_SWIZ_HIGH__SHIFT | lo;
GregF8cd81832014-11-18 18:01:01 -0700949 }
950
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600951 if (info->ia.topology == VK_TOPOLOGY_POINT_LIST)
Chia-I Wu7f390562015-03-25 08:47:18 +0800952 body[10] = fs->point_sprite_enables;
953 else
954 body[10] = 0;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800955
GregF8cd81832014-11-18 18:01:01 -0700956 body[11] = 0; /* constant interpolation enables */
957 body[12] = 0; /* WrapShortest enables */
958 body[13] = 0;
959}
960
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800961static void pipeline_build_gs(struct intel_pipeline *pipeline,
962 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600963{
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600964 // gen7_emit_3DSTATE_GS done by cmd_pipeline
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600965}
966
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800967static void pipeline_build_hs(struct intel_pipeline *pipeline,
968 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600969{
970 const uint8_t cmd_len = 7;
971 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2);
972 uint32_t *dw;
973
Chia-I Wu509b3f22014-09-02 10:24:05 +0800974 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600975
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800976 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600977 dw[0] = dw0;
978 dw[1] = 0;
979 dw[2] = 0;
980 dw[3] = 0;
981 dw[4] = 0;
982 dw[5] = 0;
983 dw[6] = 0;
984}
985
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800986static void pipeline_build_te(struct intel_pipeline *pipeline,
987 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600988{
989 const uint8_t cmd_len = 4;
990 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2);
991 uint32_t *dw;
992
Chia-I Wu509b3f22014-09-02 10:24:05 +0800993 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600994
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800995 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600996 dw[0] = dw0;
997 dw[1] = 0;
998 dw[2] = 0;
999 dw[3] = 0;
1000}
1001
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001002static void pipeline_build_ds(struct intel_pipeline *pipeline,
1003 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -06001004{
1005 const uint8_t cmd_len = 6;
1006 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2);
1007 uint32_t *dw;
1008
Chia-I Wu509b3f22014-09-02 10:24:05 +08001009 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -06001010
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001011 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -06001012 dw[0] = dw0;
1013 dw[1] = 0;
1014 dw[2] = 0;
1015 dw[3] = 0;
1016 dw[4] = 0;
1017 dw[5] = 0;
1018}
1019
Tony Barbourfa6cac72015-01-16 14:27:35 -07001020static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline,
1021 const struct intel_pipeline_create_info *info)
1022{
1023 pipeline->cmd_depth_stencil = 0;
1024
1025 if (info->db.stencilTestEnable) {
1026 pipeline->cmd_depth_stencil = 1 << 31 |
1027 translate_compare_func(info->db.front.stencilFunc) << 28 |
1028 translate_stencil_op(info->db.front.stencilFailOp) << 25 |
1029 translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 |
1030 translate_stencil_op(info->db.front.stencilPassOp) << 19 |
1031 1 << 15 |
1032 translate_compare_func(info->db.back.stencilFunc) << 12 |
1033 translate_stencil_op(info->db.back.stencilFailOp) << 9 |
1034 translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 |
1035 translate_stencil_op(info->db.back.stencilPassOp) << 3;
1036 }
1037
1038 pipeline->stencilTestEnable = info->db.stencilTestEnable;
1039
1040 /*
1041 * From the Sandy Bridge PRM, volume 2 part 1, page 360:
1042 *
1043 * "Enabling the Depth Test function without defining a Depth Buffer is
1044 * UNDEFINED."
1045 *
1046 * From the Sandy Bridge PRM, volume 2 part 1, page 375:
1047 *
1048 * "A Depth Buffer must be defined before enabling writes to it, or
1049 * operation is UNDEFINED."
1050 *
1051 * TODO We do not check these yet.
1052 */
1053 if (info->db.depthTestEnable) {
1054 pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
1055 translate_compare_func(info->db.depthFunc) << 27;
1056 } else {
1057 pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27;
1058 }
1059
1060 if (info->db.depthWriteEnable)
1061 pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
1062}
1063
Tony Barbourfa6cac72015-01-16 14:27:35 -07001064static void pipeline_build_msaa(struct intel_pipeline *pipeline,
1065 const struct intel_pipeline_create_info *info)
1066{
1067 uint32_t cmd, cmd_len;
1068 uint32_t *dw;
1069
1070 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1071
Chia-I Wu8ada4242015-03-02 11:19:33 -07001072 pipeline->sample_count = (info->ms.samples <= 1) ? 1 : info->ms.samples;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001073
1074 /* 3DSTATE_SAMPLE_MASK */
1075 cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
1076 cmd_len = 2;
1077
Chia-I Wu8ada4242015-03-02 11:19:33 -07001078 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001079 dw[0] = cmd | (cmd_len - 2);
1080 dw[1] = info->ms.sampleMask & ((1 << pipeline->sample_count) - 1);
1081 pipeline->cmd_sample_mask = dw[1];
1082}
1083
1084static void pipeline_build_cb(struct intel_pipeline *pipeline,
1085 const struct intel_pipeline_create_info *info)
1086{
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001087 uint32_t i;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001088
1089 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1090 STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2);
1091 assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS);
1092
1093 uint32_t *dw = pipeline->cmd_cb;
1094
1095 for (i = 0; i < info->cb.attachmentCount; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001096 const VkPipelineCbAttachmentState *att = &info->cb.pAttachments[i];
Tony Barbourfa6cac72015-01-16 14:27:35 -07001097 uint32_t dw0, dw1;
1098
1099
1100 dw0 = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001101 dw1 = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1102 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1103 GEN6_RT_DW1_POST_BLEND_CLAMP;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001104
1105 if (att->blendEnable) {
1106 dw0 = 1 << 31 |
1107 translate_blend_func(att->blendFuncAlpha) << 26 |
1108 translate_blend(att->srcBlendAlpha) << 20 |
1109 translate_blend(att->destBlendAlpha) << 15 |
1110 translate_blend_func(att->blendFuncColor) << 11 |
1111 translate_blend(att->srcBlendColor) << 5 |
1112 translate_blend(att->destBlendColor);
1113
1114 if (att->blendFuncAlpha != att->blendFuncColor ||
1115 att->srcBlendAlpha != att->srcBlendColor ||
1116 att->destBlendAlpha != att->destBlendColor)
1117 dw0 |= 1 << 30;
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -07001118
1119 pipeline->dual_source_blend_enable = icd_pipeline_cb_att_needs_dual_source_blending(att);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001120 }
1121
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001122 if (info->cb.logicOp != VK_LOGIC_OP_COPY) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001123 int logicop;
1124
1125 switch (info->cb.logicOp) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001126 case VK_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
1127 case VK_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
1128 case VK_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
1129 case VK_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
1130 case VK_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
1131 case VK_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
1132 case VK_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
1133 case VK_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
1134 case VK_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
1135 case VK_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
1136 case VK_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
1137 case VK_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
1138 case VK_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
1139 case VK_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
1140 case VK_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001141 default:
1142 assert(!"unknown logic op");
1143 logicop = GEN6_LOGICOP_CLEAR;
1144 break;
1145 }
1146
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001147 dw1 |= GEN6_RT_DW1_LOGICOP_ENABLE |
1148 logicop << GEN6_RT_DW1_LOGICOP_FUNC__SHIFT;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001149 }
1150
1151 if (!(att->channelWriteMask & 0x1))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001152 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_R;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001153 if (!(att->channelWriteMask & 0x2))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001154 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_G;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001155 if (!(att->channelWriteMask & 0x4))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001156 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_B;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001157 if (!(att->channelWriteMask & 0x8))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001158 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001159
1160 dw[2 * i] = dw0;
1161 dw[2 * i + 1] = dw1;
1162 }
1163
1164 for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++)
1165 {
1166 dw[2 * i] = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001167 dw[2 * i + 1] = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1168 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1169 GEN6_RT_DW1_POST_BLEND_CLAMP |
1170 GEN6_RT_DW1_WRITE_DISABLE_R |
1171 GEN6_RT_DW1_WRITE_DISABLE_G |
1172 GEN6_RT_DW1_WRITE_DISABLE_B |
1173 GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001174 }
1175
1176}
1177
1178
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001179static VkResult pipeline_build_all(struct intel_pipeline *pipeline,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001180 const struct intel_pipeline_create_info *info)
Chia-I Wu3efef432014-08-28 15:00:16 +08001181{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001182 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001183
Chia-I Wu98824592014-09-02 09:42:46 +08001184 ret = pipeline_build_shaders(pipeline, info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001185 if (ret != VK_SUCCESS)
Chia-I Wu98824592014-09-02 09:42:46 +08001186 return ret;
1187
Chia-I Wu1d125092014-10-08 08:49:38 +08001188 if (info->vi.bindingCount > ARRAY_SIZE(pipeline->vb) ||
1189 info->vi.attributeCount > ARRAY_SIZE(pipeline->vb))
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001190 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu1d125092014-10-08 08:49:38 +08001191
1192 pipeline->vb_count = info->vi.bindingCount;
1193 memcpy(pipeline->vb, info->vi.pVertexBindingDescriptions,
1194 sizeof(pipeline->vb[0]) * pipeline->vb_count);
1195
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001196 pipeline_build_vertex_elements(pipeline, info);
Chia-I Wub6386202015-03-24 11:13:06 +08001197 pipeline_build_viewport(pipeline, info);
Chia-I Wu86a5e0c2015-03-24 11:01:50 +08001198 pipeline_build_fragment_SBE(pipeline, info);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001199 pipeline_build_msaa(pipeline, info);
Chia-I Wu5bdb0962015-01-24 12:49:28 +08001200 pipeline_build_depth_stencil(pipeline, info);
Chia-I Wu4d9ad912014-08-29 14:20:36 +08001201
Chia-I Wu509b3f22014-09-02 10:24:05 +08001202 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001203 pipeline_build_urb_alloc_gen7(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001204 pipeline_build_gs(pipeline, info);
1205 pipeline_build_hs(pipeline, info);
1206 pipeline_build_te(pipeline, info);
1207 pipeline_build_ds(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001208
1209 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1210 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL |
1211 INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE |
1212 INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL |
1213 INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001214 } else {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001215 pipeline_build_urb_alloc_gen6(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001216
1217 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1218 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001219 }
1220
Chia-I Wube0a3d92014-09-02 13:20:59 +08001221 ret = pipeline_build_ia(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001222
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001223 if (ret == VK_SUCCESS)
Chia-I Wu6abcb0e2015-03-24 14:38:14 +08001224 ret = pipeline_build_rs_state(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001225
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001226 if (ret == VK_SUCCESS) {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001227 pipeline->db_format = info->db.format;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001228 pipeline_build_cb(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001229 pipeline->cb_state = info->cb;
1230 pipeline->tess_state = info->tess;
Chia-I Wu3efef432014-08-28 15:00:16 +08001231 }
1232
1233 return ret;
1234}
1235
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001236struct intel_pipeline_create_info_header {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001237 VkStructureType struct_type;
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001238 const struct intel_pipeline_create_info_header *next;
1239};
1240
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001241static VkResult pipeline_create_info_init(struct intel_pipeline_create_info *info,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001242 const struct intel_pipeline_create_info_header *header)
Chia-I Wu3efef432014-08-28 15:00:16 +08001243{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001244 memset(info, 0, sizeof(*info));
Chia-I Wu3efef432014-08-28 15:00:16 +08001245
Tony Barbourfa6cac72015-01-16 14:27:35 -07001246
1247 /*
1248 * Do we need to set safe defaults in case the app doesn't provide all of
1249 * the necessary create infos?
1250 */
1251 info->ms.samples = 1;
1252 info->ms.sampleMask = 1;
1253
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001254 while (header) {
1255 const void *src = (const void *) header;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001256 size_t size;
Chia-I Wu3efef432014-08-28 15:00:16 +08001257 void *dst;
1258
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001259 switch (header->struct_type) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001260 case VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001261 size = sizeof(info->graphics);
1262 dst = &info->graphics;
Chia-I Wu3efef432014-08-28 15:00:16 +08001263 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001264 case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:
Chia-I Wu1d125092014-10-08 08:49:38 +08001265 size = sizeof(info->vi);
1266 dst = &info->vi;
1267 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001268 case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001269 size = sizeof(info->ia);
1270 dst = &info->ia;
Chia-I Wu3efef432014-08-28 15:00:16 +08001271 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001272 case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001273 size = sizeof(info->db);
1274 dst = &info->db;
Chia-I Wu3efef432014-08-28 15:00:16 +08001275 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001276 case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001277 size = sizeof(info->cb);
1278 dst = &info->cb;
Chia-I Wu3efef432014-08-28 15:00:16 +08001279 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001280 case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001281 size = sizeof(info->rs);
1282 dst = &info->rs;
Chia-I Wu3efef432014-08-28 15:00:16 +08001283 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001284 case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001285 size = sizeof(info->tess);
1286 dst = &info->tess;
Chia-I Wu3efef432014-08-28 15:00:16 +08001287 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001288 case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:
Tony Barbourfa6cac72015-01-16 14:27:35 -07001289 size = sizeof(info->ms);
1290 dst = &info->ms;
1291 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001292 case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:
Tony Barbourfa6cac72015-01-16 14:27:35 -07001293 size = sizeof(info->vp);
1294 dst = &info->vp;
1295 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001296 case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:
Chia-I Wu3efef432014-08-28 15:00:16 +08001297 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001298 const VkPipelineShader *shader =
1299 (const VkPipelineShader *) (header + 1);
Chia-I Wu3efef432014-08-28 15:00:16 +08001300
1301 src = (const void *) shader;
1302 size = sizeof(*shader);
1303
1304 switch (shader->stage) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001305 case VK_SHADER_STAGE_VERTEX:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001306 dst = &info->vs;
Chia-I Wu3efef432014-08-28 15:00:16 +08001307 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001308 case VK_SHADER_STAGE_TESS_CONTROL:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001309 dst = &info->tcs;
Chia-I Wu3efef432014-08-28 15:00:16 +08001310 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001311 case VK_SHADER_STAGE_TESS_EVALUATION:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001312 dst = &info->tes;
Chia-I Wu3efef432014-08-28 15:00:16 +08001313 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001314 case VK_SHADER_STAGE_GEOMETRY:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001315 dst = &info->gs;
Chia-I Wu3efef432014-08-28 15:00:16 +08001316 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001317 case VK_SHADER_STAGE_FRAGMENT:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001318 dst = &info->fs;
Chia-I Wu3efef432014-08-28 15:00:16 +08001319 break;
Chia-I Wu3efef432014-08-28 15:00:16 +08001320 default:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001321 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu3efef432014-08-28 15:00:16 +08001322 break;
1323 }
1324 }
1325 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001326 case VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO:
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001327 size = sizeof(info->compute);
1328 dst = &info->compute;
Chia-I Wu3efef432014-08-28 15:00:16 +08001329 break;
1330 default:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001331 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu3efef432014-08-28 15:00:16 +08001332 break;
1333 }
1334
1335 memcpy(dst, src, size);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001336 header = header->next;
Chia-I Wu3efef432014-08-28 15:00:16 +08001337 }
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001338
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001339 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001340}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001341
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001342static VkResult graphics_pipeline_create(struct intel_dev *dev,
1343 const VkGraphicsPipelineCreateInfo *info_,
Chia-I Wu3efef432014-08-28 15:00:16 +08001344 struct intel_pipeline **pipeline_ret)
1345{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001346 struct intel_pipeline_create_info info;
Chia-I Wu3efef432014-08-28 15:00:16 +08001347 struct intel_pipeline *pipeline;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001348 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001349
Chia-I Wu509b3f22014-09-02 10:24:05 +08001350 ret = pipeline_create_info_init(&info,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001351 (const struct intel_pipeline_create_info_header *) info_);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001352 if (ret != VK_SUCCESS)
Chia-I Wu3efef432014-08-28 15:00:16 +08001353 return ret;
1354
Chia-I Wu545c2e12015-02-22 13:19:54 +08001355 pipeline = (struct intel_pipeline *) intel_base_create(&dev->base.handle,
1356 sizeof(*pipeline), dev->base.dbg,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001357 VK_DBG_OBJECT_GRAPHICS_PIPELINE, info_, 0);
Chia-I Wu3efef432014-08-28 15:00:16 +08001358 if (!pipeline)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001359 return VK_ERROR_OUT_OF_MEMORY;
Chia-I Wu3efef432014-08-28 15:00:16 +08001360
1361 pipeline->dev = dev;
Chia-I Wub1024732014-12-19 13:00:29 +08001362 pipeline->obj.base.get_info = pipeline_get_info;
Chia-I Wu3efef432014-08-28 15:00:16 +08001363 pipeline->obj.destroy = pipeline_destroy;
Chia-I Wu3efef432014-08-28 15:00:16 +08001364
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001365 ret = pipeline_build_all(pipeline, &info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001366 if (ret == VK_SUCCESS)
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001367 ret = pipeline_validate(pipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001368 if (ret != VK_SUCCESS) {
Chia-I Wu3efef432014-08-28 15:00:16 +08001369 pipeline_destroy(&pipeline->obj);
1370 return ret;
1371 }
1372
1373 *pipeline_ret = pipeline;
1374
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001375 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001376}
1377
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001378ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(
1379 VkDevice device,
1380 const VkGraphicsPipelineCreateInfo* pCreateInfo,
1381 VkPipeline* pPipeline)
Chia-I Wu3efef432014-08-28 15:00:16 +08001382{
1383 struct intel_dev *dev = intel_dev(device);
1384
1385 return graphics_pipeline_create(dev, pCreateInfo,
1386 (struct intel_pipeline **) pPipeline);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001387}
1388
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001389ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(
1390 VkDevice device,
1391 const VkGraphicsPipelineCreateInfo* pCreateInfo,
1392 VkPipeline basePipeline,
1393 VkPipeline* pPipeline)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001394{
1395 struct intel_dev *dev = intel_dev(device);
1396
1397 /* TODO: Use basePipeline to optimize creation of derivative */
1398
1399 return graphics_pipeline_create(dev, pCreateInfo,
1400 (struct intel_pipeline **) pPipeline);
1401}
1402
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001403ICD_EXPORT VkResult VKAPI vkCreateComputePipeline(
1404 VkDevice device,
1405 const VkComputePipelineCreateInfo* pCreateInfo,
1406 VkPipeline* pPipeline)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001407{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001408 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001409}
1410
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001411ICD_EXPORT VkResult VKAPI vkStorePipeline(
1412 VkPipeline pipeline,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001413 size_t* pDataSize,
1414 void* pData)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001415{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001416 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001417}
1418
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001419ICD_EXPORT VkResult VKAPI vkLoadPipeline(
1420 VkDevice device,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001421 size_t dataSize,
1422 const void* pData,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001423 VkPipeline* pPipeline)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001424{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001425 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001426}
1427
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001428ICD_EXPORT VkResult VKAPI vkLoadPipelineDerivative(
1429 VkDevice device,
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001430 size_t dataSize,
1431 const void* pData,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001432 VkPipeline basePipeline,
1433 VkPipeline* pPipeline)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001434{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001435 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001436}