blob: cc65743e32f0cfc82f41b5e47f2b1ca57f6b6a4d [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"
Tony Barbour2094dc72015-07-09 15:26:32 -060035#include "mem.h"
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060036
Tony Barbour8205d902015-04-16 15:59:00 -060037static int translate_blend_func(VkBlendOp func)
Tony Barbourfa6cac72015-01-16 14:27:35 -070038{
39 switch (func) {
Tony Barbour8205d902015-04-16 15:59:00 -060040 case VK_BLEND_OP_ADD: return GEN6_BLENDFUNCTION_ADD;
41 case VK_BLEND_OP_SUBTRACT: return GEN6_BLENDFUNCTION_SUBTRACT;
42 case VK_BLEND_OP_REVERSE_SUBTRACT: return GEN6_BLENDFUNCTION_REVERSE_SUBTRACT;
43 case VK_BLEND_OP_MIN: return GEN6_BLENDFUNCTION_MIN;
44 case VK_BLEND_OP_MAX: return GEN6_BLENDFUNCTION_MAX;
Tony Barbourfa6cac72015-01-16 14:27:35 -070045 default:
46 assert(!"unknown blend func");
47 return GEN6_BLENDFUNCTION_ADD;
48 };
49}
50
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060051static int translate_blend(VkBlend blend)
Tony Barbourfa6cac72015-01-16 14:27:35 -070052{
53 switch (blend) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060054 case VK_BLEND_ZERO: return GEN6_BLENDFACTOR_ZERO;
55 case VK_BLEND_ONE: return GEN6_BLENDFACTOR_ONE;
56 case VK_BLEND_SRC_COLOR: return GEN6_BLENDFACTOR_SRC_COLOR;
57 case VK_BLEND_ONE_MINUS_SRC_COLOR: return GEN6_BLENDFACTOR_INV_SRC_COLOR;
58 case VK_BLEND_DEST_COLOR: return GEN6_BLENDFACTOR_DST_COLOR;
59 case VK_BLEND_ONE_MINUS_DEST_COLOR: return GEN6_BLENDFACTOR_INV_DST_COLOR;
60 case VK_BLEND_SRC_ALPHA: return GEN6_BLENDFACTOR_SRC_ALPHA;
61 case VK_BLEND_ONE_MINUS_SRC_ALPHA: return GEN6_BLENDFACTOR_INV_SRC_ALPHA;
62 case VK_BLEND_DEST_ALPHA: return GEN6_BLENDFACTOR_DST_ALPHA;
63 case VK_BLEND_ONE_MINUS_DEST_ALPHA: return GEN6_BLENDFACTOR_INV_DST_ALPHA;
64 case VK_BLEND_CONSTANT_COLOR: return GEN6_BLENDFACTOR_CONST_COLOR;
65 case VK_BLEND_ONE_MINUS_CONSTANT_COLOR: return GEN6_BLENDFACTOR_INV_CONST_COLOR;
66 case VK_BLEND_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_CONST_ALPHA;
67 case VK_BLEND_ONE_MINUS_CONSTANT_ALPHA: return GEN6_BLENDFACTOR_INV_CONST_ALPHA;
68 case VK_BLEND_SRC_ALPHA_SATURATE: return GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE;
69 case VK_BLEND_SRC1_COLOR: return GEN6_BLENDFACTOR_SRC1_COLOR;
70 case VK_BLEND_ONE_MINUS_SRC1_COLOR: return GEN6_BLENDFACTOR_INV_SRC1_COLOR;
71 case VK_BLEND_SRC1_ALPHA: return GEN6_BLENDFACTOR_SRC1_ALPHA;
72 case VK_BLEND_ONE_MINUS_SRC1_ALPHA: return GEN6_BLENDFACTOR_INV_SRC1_ALPHA;
Tony Barbourfa6cac72015-01-16 14:27:35 -070073 default:
74 assert(!"unknown blend factor");
75 return GEN6_BLENDFACTOR_ONE;
76 };
77}
78
Tony Barbour8205d902015-04-16 15:59:00 -060079static int translate_compare_func(VkCompareOp func)
Tony Barbourfa6cac72015-01-16 14:27:35 -070080{
81 switch (func) {
Tony Barbour8205d902015-04-16 15:59:00 -060082 case VK_COMPARE_OP_NEVER: return GEN6_COMPAREFUNCTION_NEVER;
83 case VK_COMPARE_OP_LESS: return GEN6_COMPAREFUNCTION_LESS;
84 case VK_COMPARE_OP_EQUAL: return GEN6_COMPAREFUNCTION_EQUAL;
85 case VK_COMPARE_OP_LESS_EQUAL: return GEN6_COMPAREFUNCTION_LEQUAL;
86 case VK_COMPARE_OP_GREATER: return GEN6_COMPAREFUNCTION_GREATER;
87 case VK_COMPARE_OP_NOT_EQUAL: return GEN6_COMPAREFUNCTION_NOTEQUAL;
88 case VK_COMPARE_OP_GREATER_EQUAL: return GEN6_COMPAREFUNCTION_GEQUAL;
89 case VK_COMPARE_OP_ALWAYS: return GEN6_COMPAREFUNCTION_ALWAYS;
Tony Barbourfa6cac72015-01-16 14:27:35 -070090 default:
91 assert(!"unknown compare_func");
92 return GEN6_COMPAREFUNCTION_NEVER;
93 }
94}
95
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060096static int translate_stencil_op(VkStencilOp op)
Tony Barbourfa6cac72015-01-16 14:27:35 -070097{
98 switch (op) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060099 case VK_STENCIL_OP_KEEP: return GEN6_STENCILOP_KEEP;
100 case VK_STENCIL_OP_ZERO: return GEN6_STENCILOP_ZERO;
101 case VK_STENCIL_OP_REPLACE: return GEN6_STENCILOP_REPLACE;
102 case VK_STENCIL_OP_INC_CLAMP: return GEN6_STENCILOP_INCRSAT;
103 case VK_STENCIL_OP_DEC_CLAMP: return GEN6_STENCILOP_DECRSAT;
104 case VK_STENCIL_OP_INVERT: return GEN6_STENCILOP_INVERT;
105 case VK_STENCIL_OP_INC_WRAP: return GEN6_STENCILOP_INCR;
106 case VK_STENCIL_OP_DEC_WRAP: return GEN6_STENCILOP_DECR;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700107 default:
108 assert(!"unknown stencil op");
109 return GEN6_STENCILOP_KEEP;
110 }
111}
112
Chia-I Wu3f239832014-12-11 22:57:18 +0800113struct intel_pipeline_create_info {
Tony Barboure307f582015-07-10 15:29:03 -0600114 VkGraphicsPipelineCreateInfo graphics;
115 VkPipelineVertexInputStateCreateInfo vi;
116 VkPipelineInputAssemblyStateCreateInfo ia;
117 VkPipelineDepthStencilStateCreateInfo db;
118 VkPipelineColorBlendStateCreateInfo cb;
119 VkPipelineRasterStateCreateInfo rs;
120 VkPipelineTessellationStateCreateInfo tess;
121 VkPipelineMultisampleStateCreateInfo ms;
122 VkPipelineViewportStateCreateInfo vp;
Chia-I Wu3f239832014-12-11 22:57:18 +0800123
Tony Barboure307f582015-07-10 15:29:03 -0600124 VkComputePipelineCreateInfo compute;
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -0600125
Tony Barboure307f582015-07-10 15:29:03 -0600126 VkPipelineShaderStageCreateInfo vs;
127 VkPipelineShaderStageCreateInfo tcs;
128 VkPipelineShaderStageCreateInfo tes;
129 VkPipelineShaderStageCreateInfo gs;
130 VkPipelineShaderStageCreateInfo fs;
Chia-I Wu3f239832014-12-11 22:57:18 +0800131};
Chia-I Wu38d1ddf2015-03-02 10:51:39 -0700132
133/* in S1.3 */
134struct intel_pipeline_sample_position {
135 int8_t x, y;
136};
137
138static uint8_t pack_sample_position(const struct intel_dev *dev,
139 const struct intel_pipeline_sample_position *pos)
140{
141 return (pos->x + 8) << 4 | (pos->y + 8);
142}
143
144void intel_pipeline_init_default_sample_patterns(const struct intel_dev *dev,
145 uint8_t *pat_1x, uint8_t *pat_2x,
146 uint8_t *pat_4x, uint8_t *pat_8x,
147 uint8_t *pat_16x)
148{
149 static const struct intel_pipeline_sample_position default_1x[1] = {
150 { 0, 0 },
151 };
152 static const struct intel_pipeline_sample_position default_2x[2] = {
153 { -4, -4 },
154 { 4, 4 },
155 };
156 static const struct intel_pipeline_sample_position default_4x[4] = {
157 { -2, -6 },
158 { 6, -2 },
159 { -6, 2 },
160 { 2, 6 },
161 };
162 static const struct intel_pipeline_sample_position default_8x[8] = {
163 { -1, 1 },
164 { 1, 5 },
165 { 3, -5 },
166 { 5, 3 },
167 { -7, -1 },
168 { -3, -7 },
169 { 7, -3 },
170 { -5, 7 },
171 };
172 static const struct intel_pipeline_sample_position default_16x[16] = {
173 { 0, 2 },
174 { 3, 0 },
175 { -3, -2 },
176 { -2, -4 },
177 { 4, 3 },
178 { 5, 1 },
179 { 6, -1 },
180 { 2, -6 },
181 { -4, 5 },
182 { -5, -5 },
183 { -1, -7 },
184 { 7, -3 },
185 { -7, 4 },
186 { 1, -8 },
187 { -6, 6 },
188 { -8, 7 },
189 };
190 int i;
191
192 pat_1x[0] = pack_sample_position(dev, default_1x);
193 for (i = 0; i < 2; i++)
194 pat_2x[i] = pack_sample_position(dev, &default_2x[i]);
195 for (i = 0; i < 4; i++)
196 pat_4x[i] = pack_sample_position(dev, &default_4x[i]);
197 for (i = 0; i < 8; i++)
198 pat_8x[i] = pack_sample_position(dev, &default_8x[i]);
199 for (i = 0; i < 16; i++)
200 pat_16x[i] = pack_sample_position(dev, &default_16x[i]);
201}
202
Chia-I Wu3f239832014-12-11 22:57:18 +0800203struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
204 enum intel_dev_meta_shader id)
205{
206 struct intel_pipeline_shader *sh;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600207 VkResult ret;
Chia-I Wu3f239832014-12-11 22:57:18 +0800208
Tony Barbour8205d902015-04-16 15:59:00 -0600209 sh = intel_alloc(dev, sizeof(*sh), 0, VK_SYSTEM_ALLOC_TYPE_INTERNAL);
Chia-I Wu3f239832014-12-11 22:57:18 +0800210 if (!sh)
211 return NULL;
212 memset(sh, 0, sizeof(*sh));
213
214 ret = intel_pipeline_shader_compile_meta(sh, dev->gpu, id);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600215 if (ret != VK_SUCCESS) {
Chia-I Wuf9c81ef2015-02-22 13:49:15 +0800216 intel_free(dev, sh);
Chia-I Wu3f239832014-12-11 22:57:18 +0800217 return NULL;
218 }
219
220 switch (id) {
221 case INTEL_DEV_META_VS_FILL_MEM:
222 case INTEL_DEV_META_VS_COPY_MEM:
223 case INTEL_DEV_META_VS_COPY_MEM_UNALIGNED:
224 sh->max_threads = intel_gpu_get_max_threads(dev->gpu,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600225 VK_SHADER_STAGE_VERTEX);
Chia-I Wu3f239832014-12-11 22:57:18 +0800226 break;
227 default:
228 sh->max_threads = intel_gpu_get_max_threads(dev->gpu,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600229 VK_SHADER_STAGE_FRAGMENT);
Chia-I Wu3f239832014-12-11 22:57:18 +0800230 break;
231 }
232
233 return sh;
234}
235
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800236void intel_pipeline_shader_destroy(struct intel_dev *dev,
237 struct intel_pipeline_shader *sh)
Chia-I Wu3f239832014-12-11 22:57:18 +0800238{
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800239 intel_pipeline_shader_cleanup(sh, dev->gpu);
240 intel_free(dev, sh);
Chia-I Wu3f239832014-12-11 22:57:18 +0800241}
242
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600243static VkResult pipeline_build_shader(struct intel_pipeline *pipeline,
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -0600244 const VkPipelineShaderStageCreateInfo *sh_info,
Chia-I Wuf8385062015-01-04 16:27:24 +0800245 struct intel_pipeline_shader *sh)
Chia-I Wu3f239832014-12-11 22:57:18 +0800246{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600247 VkResult ret;
Chia-I Wu3f239832014-12-11 22:57:18 +0800248
Cody Northropbc12f872015-04-29 13:22:07 -0600249 const struct intel_ir* ir = intel_shader(sh_info->shader)->ir;
250
Chia-I Wuf8385062015-01-04 16:27:24 +0800251 ret = intel_pipeline_shader_compile(sh,
Cody Northropbc12f872015-04-29 13:22:07 -0600252 pipeline->dev->gpu, pipeline->pipeline_layout, sh_info, ir);
253
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600254 if (ret != VK_SUCCESS)
Chia-I Wu3f239832014-12-11 22:57:18 +0800255 return ret;
256
257 sh->max_threads =
258 intel_gpu_get_max_threads(pipeline->dev->gpu, sh_info->stage);
259
260 /* 1KB aligned */
261 sh->scratch_offset = u_align(pipeline->scratch_size, 1024);
262 pipeline->scratch_size = sh->scratch_offset +
263 sh->per_thread_scratch_size * sh->max_threads;
264
265 pipeline->active_shaders |= 1 << sh_info->stage;
266
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600267 return VK_SUCCESS;
Chia-I Wu3f239832014-12-11 22:57:18 +0800268}
269
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600270static VkResult pipeline_build_shaders(struct intel_pipeline *pipeline,
Chia-I Wu3f239832014-12-11 22:57:18 +0800271 const struct intel_pipeline_create_info *info)
272{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600273 VkResult ret = VK_SUCCESS;
Chia-I Wu3f239832014-12-11 22:57:18 +0800274
Tony Barbourde4124d2015-07-03 10:33:54 -0600275 if (ret == VK_SUCCESS && info->vs.shader.handle)
Chia-I Wudf601c42015-04-17 01:58:07 +0800276 ret = pipeline_build_shader(pipeline, &info->vs, &pipeline->vs);
Tony Barbourde4124d2015-07-03 10:33:54 -0600277 if (ret == VK_SUCCESS && info->tcs.shader.handle)
Chia-I Wudf601c42015-04-17 01:58:07 +0800278 ret = pipeline_build_shader(pipeline, &info->tcs,&pipeline->tcs);
Tony Barbourde4124d2015-07-03 10:33:54 -0600279 if (ret == VK_SUCCESS && info->tes.shader.handle)
Chia-I Wudf601c42015-04-17 01:58:07 +0800280 ret = pipeline_build_shader(pipeline, &info->tes,&pipeline->tes);
Tony Barbourde4124d2015-07-03 10:33:54 -0600281 if (ret == VK_SUCCESS && info->gs.shader.handle)
Chia-I Wudf601c42015-04-17 01:58:07 +0800282 ret = pipeline_build_shader(pipeline, &info->gs, &pipeline->gs);
Tony Barbourde4124d2015-07-03 10:33:54 -0600283 if (ret == VK_SUCCESS && info->fs.shader.handle)
Chia-I Wudf601c42015-04-17 01:58:07 +0800284 ret = pipeline_build_shader(pipeline, &info->fs, &pipeline->fs);
Chia-I Wu3f239832014-12-11 22:57:18 +0800285
Tony Barbourde4124d2015-07-03 10:33:54 -0600286 if (ret == VK_SUCCESS && info->compute.cs.shader.handle) {
Chia-I Wudf601c42015-04-17 01:58:07 +0800287 ret = pipeline_build_shader(pipeline,
Chia-I Wuf8385062015-01-04 16:27:24 +0800288 &info->compute.cs, &pipeline->cs);
289 }
Chia-I Wu3f239832014-12-11 22:57:18 +0800290
291 return ret;
292}
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600293static uint32_t *pipeline_cmd_ptr(struct intel_pipeline *pipeline, int cmd_len)
294{
295 uint32_t *ptr;
296
297 assert(pipeline->cmd_len + cmd_len < INTEL_PSO_CMD_ENTRIES);
298 ptr = &pipeline->cmds[pipeline->cmd_len];
299 pipeline->cmd_len += cmd_len;
300 return ptr;
301}
302
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600303static VkResult pipeline_build_ia(struct intel_pipeline *pipeline,
Chia-I Wube0a3d92014-09-02 13:20:59 +0800304 const struct intel_pipeline_create_info* info)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600305{
Chia-I Wube0a3d92014-09-02 13:20:59 +0800306 pipeline->topology = info->ia.topology;
307 pipeline->disable_vs_cache = info->ia.disableVertexReuse;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600308
Chia-I Wube0a3d92014-09-02 13:20:59 +0800309 switch (info->ia.topology) {
Tony Barbour8205d902015-04-16 15:59:00 -0600310 case VK_PRIMITIVE_TOPOLOGY_POINT_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600311 pipeline->prim_type = GEN6_3DPRIM_POINTLIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600312 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600313 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600314 pipeline->prim_type = GEN6_3DPRIM_LINELIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600315 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600316 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600317 pipeline->prim_type = GEN6_3DPRIM_LINESTRIP;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600318 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600319 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600320 pipeline->prim_type = GEN6_3DPRIM_TRILIST;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600321 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600322 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600323 pipeline->prim_type = GEN6_3DPRIM_TRISTRIP;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600324 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600325 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN:
Courtney Goeltzenleuchter528781d2015-03-03 11:38:12 -0700326 pipeline->prim_type = GEN6_3DPRIM_TRIFAN;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600327 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600328 case VK_PRIMITIVE_TOPOLOGY_LINE_LIST_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600329 pipeline->prim_type = GEN6_3DPRIM_LINELIST_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600330 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600331 case VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600332 pipeline->prim_type = GEN6_3DPRIM_LINESTRIP_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600333 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600334 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600335 pipeline->prim_type = GEN6_3DPRIM_TRILIST_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600336 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600337 case VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ:
Courtney Goeltzenleuchter8a3de592014-08-22 09:09:46 -0600338 pipeline->prim_type = GEN6_3DPRIM_TRISTRIP_ADJ;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600339 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600340 case VK_PRIMITIVE_TOPOLOGY_PATCH:
Chia-I Wube0a3d92014-09-02 13:20:59 +0800341 if (!info->tess.patchControlPoints ||
342 info->tess.patchControlPoints > 32)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600343 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800344 pipeline->prim_type = GEN7_3DPRIM_PATCHLIST_1 +
345 info->tess.patchControlPoints - 1;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600346 break;
347 default:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600348 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600349 }
350
Chia-I Wube0a3d92014-09-02 13:20:59 +0800351 if (info->ia.primitiveRestartEnable) {
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600352 pipeline->primitive_restart = true;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800353 pipeline->primitive_restart_index = info->ia.primitiveRestartIndex;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600354 } else {
355 pipeline->primitive_restart = false;
356 }
357
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600358 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600359}
360
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600361static VkResult pipeline_build_rs_state(struct intel_pipeline *pipeline,
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800362 const struct intel_pipeline_create_info* info)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600363{
Tony Barboure307f582015-07-10 15:29:03 -0600364 const VkPipelineRasterStateCreateInfo *rs_state = &info->rs;
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800365 bool ccw;
366
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600367 pipeline->depthClipEnable = rs_state->depthClipEnable;
368 pipeline->rasterizerDiscardEnable = rs_state->rasterizerDiscardEnable;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700369
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370 if (rs_state->provokingVertex == VK_PROVOKING_VERTEX_FIRST) {
Tony Barbourfa6cac72015-01-16 14:27:35 -0700371 pipeline->provoking_vertex_tri = 0;
372 pipeline->provoking_vertex_trifan = 1;
373 pipeline->provoking_vertex_line = 0;
374 } else {
375 pipeline->provoking_vertex_tri = 2;
376 pipeline->provoking_vertex_trifan = 2;
377 pipeline->provoking_vertex_line = 1;
378 }
379
380 switch (rs_state->fillMode) {
Tony Barbour8205d902015-04-16 15:59:00 -0600381 case VK_FILL_MODE_POINTS:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700382 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT |
383 GEN7_SF_DW1_BACKFACE_POINT;
384 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600385 case VK_FILL_MODE_WIREFRAME:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700386 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME |
387 GEN7_SF_DW1_BACKFACE_WIREFRAME;
388 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600389 case VK_FILL_MODE_SOLID:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700390 default:
391 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID |
392 GEN7_SF_DW1_BACKFACE_SOLID;
393 break;
394 }
395
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600396 ccw = (rs_state->frontFace == VK_FRONT_FACE_CCW);
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800397 /* flip the winding order */
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800398
399 if (ccw) {
Tony Barbourfa6cac72015-01-16 14:27:35 -0700400 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW;
401 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW;
402 }
403
404 switch (rs_state->cullMode) {
Tony Barbour8205d902015-04-16 15:59:00 -0600405 case VK_CULL_MODE_NONE:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700406 default:
407 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE;
408 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE;
409 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600410 case VK_CULL_MODE_FRONT:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700411 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT;
412 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT;
413 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600414 case VK_CULL_MODE_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700415 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK;
416 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK;
417 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600418 case VK_CULL_MODE_FRONT_AND_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700419 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH;
420 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH;
421 break;
422 }
423
424 /* only GEN7+ needs cull mode in 3DSTATE_CLIP */
425 if (intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6))
426 pipeline->cmd_clip_cull = 0;
427
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600428 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600429}
430
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600431static void pipeline_destroy(struct intel_obj *obj)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600432{
433 struct intel_pipeline *pipeline = intel_pipeline_from_obj(obj);
434
Chia-I Wu3f239832014-12-11 22:57:18 +0800435 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800436 intel_pipeline_shader_cleanup(&pipeline->vs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800437 }
438
439 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800440 intel_pipeline_shader_cleanup(&pipeline->tcs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800441 }
442
443 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800444 intel_pipeline_shader_cleanup(&pipeline->tes, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800445 }
446
447 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800448 intel_pipeline_shader_cleanup(&pipeline->gs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800449 }
450
451 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800452 intel_pipeline_shader_cleanup(&pipeline->fs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800453 }
454
455 if (pipeline->active_shaders & SHADER_COMPUTE_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800456 intel_pipeline_shader_cleanup(&pipeline->cs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800457 }
Chia-I Wued833872014-08-23 17:00:35 +0800458
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600459 intel_base_destroy(&pipeline->obj.base);
460}
461
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600462static VkResult pipeline_validate(struct intel_pipeline *pipeline)
Chia-I Wu3efef432014-08-28 15:00:16 +0800463{
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600464 /*
465 * Validate required elements
466 */
467 if (!(pipeline->active_shaders & SHADER_VERTEX_FLAG)) {
468 // TODO: Log debug message: Vertex Shader required.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600469 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600470 }
471
472 /*
473 * Tessalation control and evaluation have to both have a shader defined or
474 * neither should have a shader defined.
475 */
476 if (((pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) == 0) !=
477 ((pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) == 0) ) {
478 // TODO: Log debug message: Both Tess control and Tess eval are required to use tessalation
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600479 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600480 }
481
482 if ((pipeline->active_shaders & SHADER_COMPUTE_FLAG) &&
483 (pipeline->active_shaders & (SHADER_VERTEX_FLAG | SHADER_TESS_CONTROL_FLAG |
484 SHADER_TESS_EVAL_FLAG | SHADER_GEOMETRY_FLAG |
485 SHADER_FRAGMENT_FLAG))) {
486 // TODO: Log debug message: Can only specify compute shader when doing compute
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600487 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600488 }
489
490 /*
Tony Barbour8205d902015-04-16 15:59:00 -0600491 * VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines.
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600492 * Mismatching primitive topology and tessellation fails graphics pipeline creation.
493 */
494 if (pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG) &&
Tony Barbour8205d902015-04-16 15:59:00 -0600495 (pipeline->topology != VK_PRIMITIVE_TOPOLOGY_PATCH)) {
Tobin Ehlis43c973b2015-06-22 11:31:09 -0600496 // TODO: Log debug message: Invalid topology used with tessellation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600497 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600498 }
499
Tony Barbour8205d902015-04-16 15:59:00 -0600500 if ((pipeline->topology == VK_PRIMITIVE_TOPOLOGY_PATCH) &&
Tobin Ehlis43c973b2015-06-22 11:31:09 -0600501 (~pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG))) {
502 // TODO: Log debug message: Cannot use TOPOLOGY_PATCH on non-tessellation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600503 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600504 }
505
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600506 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +0800507}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600508
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800509static void pipeline_build_urb_alloc_gen6(struct intel_pipeline *pipeline,
510 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800511{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800512 const struct intel_gpu *gpu = pipeline->dev->gpu;
513 const int urb_size = ((gpu->gt == 2) ? 64 : 32) * 1024;
Chia-I Wua4d1b392014-10-10 13:57:29 +0800514 const struct intel_pipeline_shader *vs = &pipeline->vs;
515 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800516 int vs_entry_size, gs_entry_size;
517 int vs_size, gs_size;
518
Chia-I Wu509b3f22014-09-02 10:24:05 +0800519 INTEL_GPU_ASSERT(gpu, 6, 6);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800520
521 vs_entry_size = ((vs->in_count >= vs->out_count) ?
522 vs->in_count : vs->out_count);
523 gs_entry_size = (gs) ? gs->out_count : 0;
524
525 /* in bytes */
526 vs_entry_size *= sizeof(float) * 4;
527 gs_entry_size *= sizeof(float) * 4;
528
Chia-I Wua4d1b392014-10-10 13:57:29 +0800529 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800530 vs_size = urb_size / 2;
531 gs_size = vs_size;
532 } else {
533 vs_size = urb_size;
534 gs_size = 0;
535 }
536
537 /* 3DSTATE_URB */
538 {
539 const uint8_t cmd_len = 3;
540 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_URB) |
541 (cmd_len - 2);
542 int vs_alloc_size, gs_alloc_size;
543 int vs_entry_count, gs_entry_count;
544 uint32_t *dw;
545
546 /* in 1024-bit rows */
547 vs_alloc_size = (vs_entry_size + 128 - 1) / 128;
548 gs_alloc_size = (gs_entry_size + 128 - 1) / 128;
549
550 /* valid range is [1, 5] */
551 if (!vs_alloc_size)
552 vs_alloc_size = 1;
553 if (!gs_alloc_size)
554 gs_alloc_size = 1;
555 assert(vs_alloc_size <= 5 && gs_alloc_size <= 5);
556
557 /* valid range is [24, 256], multiples of 4 */
558 vs_entry_count = (vs_size / 128 / vs_alloc_size) & ~3;
559 if (vs_entry_count > 256)
560 vs_entry_count = 256;
561 assert(vs_entry_count >= 24);
562
563 /* valid range is [0, 256], multiples of 4 */
564 gs_entry_count = (gs_size / 128 / gs_alloc_size) & ~3;
565 if (gs_entry_count > 256)
566 gs_entry_count = 256;
567
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600568 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800569
570 dw[0] = dw0;
571 dw[1] = (vs_alloc_size - 1) << GEN6_URB_DW1_VS_ENTRY_SIZE__SHIFT |
572 vs_entry_count << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT;
573 dw[2] = gs_entry_count << GEN6_URB_DW2_GS_ENTRY_COUNT__SHIFT |
574 (gs_alloc_size - 1) << GEN6_URB_DW2_GS_ENTRY_SIZE__SHIFT;
575 }
576}
577
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800578static void pipeline_build_urb_alloc_gen7(struct intel_pipeline *pipeline,
579 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800580{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800581 const struct intel_gpu *gpu = pipeline->dev->gpu;
582 const int urb_size = ((gpu->gt == 3) ? 512 :
583 (gpu->gt == 2) ? 256 : 128) * 1024;
Cody Northrop306ec352014-10-06 15:11:45 -0600584 const struct intel_pipeline_shader *vs = &pipeline->vs;
585 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800586 /* some space is reserved for PCBs */
Chia-I Wu509b3f22014-09-02 10:24:05 +0800587 int urb_offset = ((gpu->gt == 3) ? 32 : 16) * 1024;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800588 int vs_entry_size, gs_entry_size;
589 int vs_size, gs_size;
590
Chia-I Wu509b3f22014-09-02 10:24:05 +0800591 INTEL_GPU_ASSERT(gpu, 7, 7.5);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800592
593 vs_entry_size = ((vs->in_count >= vs->out_count) ?
594 vs->in_count : vs->out_count);
595 gs_entry_size = (gs) ? gs->out_count : 0;
596
597 /* in bytes */
598 vs_entry_size *= sizeof(float) * 4;
599 gs_entry_size *= sizeof(float) * 4;
600
Chia-I Wua4d1b392014-10-10 13:57:29 +0800601 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800602 vs_size = (urb_size - urb_offset) / 2;
603 gs_size = vs_size;
604 } else {
605 vs_size = urb_size - urb_offset;
606 gs_size = 0;
607 }
608
609 /* 3DSTATE_URB_* */
610 {
611 const uint8_t cmd_len = 2;
612 int vs_alloc_size, gs_alloc_size;
613 int vs_entry_count, gs_entry_count;
614 uint32_t *dw;
615
616 /* in 512-bit rows */
617 vs_alloc_size = (vs_entry_size + 64 - 1) / 64;
618 gs_alloc_size = (gs_entry_size + 64 - 1) / 64;
619
620 if (!vs_alloc_size)
621 vs_alloc_size = 1;
622 if (!gs_alloc_size)
623 gs_alloc_size = 1;
624
625 /* avoid performance decrease due to banking */
626 if (vs_alloc_size == 5)
627 vs_alloc_size = 6;
628
629 /* in multiples of 8 */
630 vs_entry_count = (vs_size / 64 / vs_alloc_size) & ~7;
631 assert(vs_entry_count >= 32);
632
633 gs_entry_count = (gs_size / 64 / gs_alloc_size) & ~7;
634
Chia-I Wu509b3f22014-09-02 10:24:05 +0800635 if (intel_gpu_gen(gpu) >= INTEL_GEN(7.5)) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800636 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800637 (gpu->gt >= 2) ? 1664 : 640;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800638 const int max_gs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800639 (gpu->gt >= 2) ? 640 : 256;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800640 if (vs_entry_count >= max_vs_entry_count)
641 vs_entry_count = max_vs_entry_count;
642 if (gs_entry_count >= max_gs_entry_count)
643 gs_entry_count = max_gs_entry_count;
644 } else {
645 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800646 (gpu->gt == 2) ? 704 : 512;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800647 const int max_gs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800648 (gpu->gt == 2) ? 320 : 192;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800649 if (vs_entry_count >= max_vs_entry_count)
650 vs_entry_count = max_vs_entry_count;
651 if (gs_entry_count >= max_gs_entry_count)
652 gs_entry_count = max_gs_entry_count;
653 }
654
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600655 dw = pipeline_cmd_ptr(pipeline, cmd_len*4);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800656 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_VS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700657 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
658 (vs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800659 vs_entry_count;
660
661 dw += 2;
662 if (gs_size)
663 urb_offset += vs_size;
664 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_GS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700665 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
666 (gs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800667 gs_entry_count;
668
669 dw += 2;
670 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_HS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700671 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800672
673 dw += 2;
674 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_DS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700675 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800676 }
677}
678
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800679static void pipeline_build_vertex_elements(struct intel_pipeline *pipeline,
680 const struct intel_pipeline_create_info *info)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800681{
Cody Northrop306ec352014-10-06 15:11:45 -0600682 const struct intel_pipeline_shader *vs = &pipeline->vs;
Chia-I Wu1d125092014-10-08 08:49:38 +0800683 uint8_t cmd_len;
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800684 uint32_t *dw;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600685 uint32_t i, j;
686 uint32_t attr_count;
687 uint32_t attrs_processed;
Chia-I Wu1d125092014-10-08 08:49:38 +0800688 int comps[4];
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800689
Chia-I Wu509b3f22014-09-02 10:24:05 +0800690 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800691
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600692 attr_count = u_popcountll(vs->inputs_read);
693 cmd_len = 1 + 2 * attr_count;
Chia-I Wu1d125092014-10-08 08:49:38 +0800694 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID))
695 cmd_len += 2;
696
697 if (cmd_len == 1)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800698 return;
699
700 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wu1d125092014-10-08 08:49:38 +0800701
702 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) |
703 (cmd_len - 2);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800704 dw++;
705
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800706 /* VERTEX_ELEMENT_STATE */
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600707 for (i = 0, attrs_processed = 0; attrs_processed < attr_count; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600708 VkVertexInputAttributeDescription *attr = NULL;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600709
710 /*
711 * The compiler will pack the shader references and then
712 * indicate which locations are used via the bitmask in
713 * vs->inputs_read.
714 */
715 if (!(vs->inputs_read & (1L << i))) {
GregF2dc40212014-10-31 17:31:47 -0600716 continue;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600717 }
718
719 /*
720 * For each bit set in the vs->inputs_read we'll need
721 * to find the corresponding attribute record and then
722 * set up the next HW vertex element based on that attribute.
723 */
724 for (j = 0; j < info->vi.attributeCount; j++) {
725 if (info->vi.pVertexAttributeDescriptions[j].location == i) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600726 attr = (VkVertexInputAttributeDescription *) &info->vi.pVertexAttributeDescriptions[j];
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600727 attrs_processed++;
728 break;
729 }
730 }
731 assert(attr != NULL);
732
Chia-I Wu1d125092014-10-08 08:49:38 +0800733 const int format =
734 intel_format_translate_color(pipeline->dev->gpu, attr->format);
735
736 comps[0] = GEN6_VFCOMP_STORE_0;
737 comps[1] = GEN6_VFCOMP_STORE_0;
738 comps[2] = GEN6_VFCOMP_STORE_0;
739 comps[3] = icd_format_is_int(attr->format) ?
740 GEN6_VFCOMP_STORE_1_INT : GEN6_VFCOMP_STORE_1_FP;
741
742 switch (icd_format_get_channel_count(attr->format)) {
743 case 4: comps[3] = GEN6_VFCOMP_STORE_SRC; /* fall through */
744 case 3: comps[2] = GEN6_VFCOMP_STORE_SRC; /* fall through */
745 case 2: comps[1] = GEN6_VFCOMP_STORE_SRC; /* fall through */
746 case 1: comps[0] = GEN6_VFCOMP_STORE_SRC; break;
747 default:
748 break;
749 }
750
751 assert(attr->offsetInBytes <= 2047);
752
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700753 dw[0] = attr->binding << GEN6_VE_DW0_VB_INDEX__SHIFT |
754 GEN6_VE_DW0_VALID |
755 format << GEN6_VE_DW0_FORMAT__SHIFT |
Chia-I Wu1d125092014-10-08 08:49:38 +0800756 attr->offsetInBytes;
757
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700758 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
759 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
760 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
761 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
Chia-I Wu1d125092014-10-08 08:49:38 +0800762
763 dw += 2;
764 }
GregF932fcf52014-10-29 17:02:11 -0600765
766 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) {
767 comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ?
768 GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0;
769 comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ?
770 GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE;
771 comps[2] = GEN6_VFCOMP_NOSTORE;
772 comps[3] = GEN6_VFCOMP_NOSTORE;
773
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700774 dw[0] = GEN6_VE_DW0_VALID;
775 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
776 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
777 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
778 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
GregF932fcf52014-10-29 17:02:11 -0600779
780 dw += 2;
781 }
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800782}
783
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800784static void pipeline_build_fragment_SBE(struct intel_pipeline *pipeline,
785 const struct intel_pipeline_create_info *info)
GregF8cd81832014-11-18 18:01:01 -0700786{
787 const struct intel_pipeline_shader *fs = &pipeline->fs;
GregF8cd81832014-11-18 18:01:01 -0700788 uint8_t cmd_len;
789 uint32_t *body;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600790 uint32_t attr_skip, attr_count;
791 uint32_t vue_offset, vue_len;
792 uint32_t i;
GregF8cd81832014-11-18 18:01:01 -0700793
Cody Northrop293d4502015-05-05 09:38:03 -0600794 // If GS is active, use its outputs
795 const struct intel_pipeline_shader *src =
796 (pipeline->active_shaders & SHADER_GEOMETRY_FLAG)
797 ? &pipeline->gs
798 : &pipeline->vs;
799
GregF8cd81832014-11-18 18:01:01 -0700800 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
801
802 cmd_len = 14;
803
Chia-I Wuf85def42015-01-29 00:34:24 +0800804 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7))
805 body = pipeline_cmd_ptr(pipeline, cmd_len);
806 else
807 body = pipeline->cmd_3dstate_sbe;
GregF8cd81832014-11-18 18:01:01 -0700808
Cody Northrop293d4502015-05-05 09:38:03 -0600809 assert(!fs->reads_user_clip || src->enable_user_clip);
810 attr_skip = src->outputs_offset;
811 if (src->enable_user_clip != fs->reads_user_clip) {
GregF8cd81832014-11-18 18:01:01 -0700812 attr_skip += 2;
813 }
Cody Northrop293d4502015-05-05 09:38:03 -0600814 assert(src->out_count >= attr_skip);
815 attr_count = src->out_count - attr_skip;
GregF8cd81832014-11-18 18:01:01 -0700816
817 // LUNARG TODO: We currently are only handling 16 attrs;
818 // ultimately, we need to handle 32
819 assert(fs->in_count <= 16);
820 assert(attr_count <= 16);
821
822 vue_offset = attr_skip / 2;
823 vue_len = (attr_count + 1) / 2;
824 if (!vue_len)
825 vue_len = 1;
826
827 body[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) |
828 (cmd_len - 2);
829
830 // LUNARG TODO: If the attrs needed by the FS are exactly
831 // what is written by the VS, we don't need to enable
832 // swizzling, improving performance. Even if we swizzle,
833 // we can improve performance by reducing vue_len to
834 // just include the values needed by the FS:
835 // vue_len = ceiling((max_vs_out + 1)/2)
836
837 body[1] = GEN7_SBE_DW1_ATTR_SWIZZLE_ENABLE |
838 fs->in_count << GEN7_SBE_DW1_ATTR_COUNT__SHIFT |
839 vue_len << GEN7_SBE_DW1_URB_READ_LEN__SHIFT |
840 vue_offset << GEN7_SBE_DW1_URB_READ_OFFSET__SHIFT;
841
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800842 switch (info->rs.pointOrigin) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600843 case VK_COORDINATE_ORIGIN_UPPER_LEFT:
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800844 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_UPPERLEFT;
845 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600846 case VK_COORDINATE_ORIGIN_LOWER_LEFT:
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800847 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_LOWERLEFT;
848 break;
849 default:
850 assert(!"unknown point origin");
851 break;
852 }
853
Cody Northrop293d4502015-05-05 09:38:03 -0600854 uint16_t src_slot[fs->in_count];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600855 int32_t fs_in = 0;
Cody Northrop293d4502015-05-05 09:38:03 -0600856 int32_t src_out = - (vue_offset * 2 - src->outputs_offset);
GregF8cd81832014-11-18 18:01:01 -0700857 for (i=0; i < 64; i++) {
Cody Northrop293d4502015-05-05 09:38:03 -0600858 bool srcWrites = src->outputs_written & (1L << i);
859 bool fsReads = fs->inputs_read & (1L << i);
Cody Northropd75c13e2015-01-02 14:07:20 -0700860
861 if (fsReads) {
Cody Northrop293d4502015-05-05 09:38:03 -0600862 assert(src_out >= 0);
GregF8cd81832014-11-18 18:01:01 -0700863 assert(fs_in < fs->in_count);
Cody Northrop293d4502015-05-05 09:38:03 -0600864 src_slot[fs_in] = src_out;
Cody Northropd75c13e2015-01-02 14:07:20 -0700865
Cody Northrop293d4502015-05-05 09:38:03 -0600866 if (!srcWrites) {
Cody Northropd75c13e2015-01-02 14:07:20 -0700867 // If the vertex shader did not write this input, we cannot
868 // program the SBE to read it. Our choices are to allow it to
869 // read junk from a GRF, or get zero. We're choosing zero.
870 if (i >= fs->generic_input_start) {
Cody Northrop293d4502015-05-05 09:38:03 -0600871 src_slot[fs_in] = GEN8_SBE_SWIZ_CONST_0000 |
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700872 GEN8_SBE_SWIZ_OVERRIDE_X |
873 GEN8_SBE_SWIZ_OVERRIDE_Y |
874 GEN8_SBE_SWIZ_OVERRIDE_Z |
875 GEN8_SBE_SWIZ_OVERRIDE_W;
Cody Northropd75c13e2015-01-02 14:07:20 -0700876 }
877 }
878
GregF8cd81832014-11-18 18:01:01 -0700879 fs_in += 1;
880 }
Cody Northrop293d4502015-05-05 09:38:03 -0600881 if (srcWrites) {
882 src_out += 1;
GregF8cd81832014-11-18 18:01:01 -0700883 }
884 }
885
886 for (i = 0; i < 8; i++) {
887 uint16_t hi, lo;
888
889 /* no attr swizzles */
890 if (i * 2 + 1 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600891 lo = src_slot[i * 2];
892 hi = src_slot[i * 2 + 1];
GregF8cd81832014-11-18 18:01:01 -0700893 } else if (i * 2 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600894 lo = src_slot[i * 2];
GregF8cd81832014-11-18 18:01:01 -0700895 hi = 0;
896 } else {
897 hi = 0;
898 lo = 0;
899 }
900
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700901 body[2 + i] = hi << GEN8_SBE_SWIZ_HIGH__SHIFT | lo;
GregF8cd81832014-11-18 18:01:01 -0700902 }
903
Tony Barbour8205d902015-04-16 15:59:00 -0600904 if (info->ia.topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
Chia-I Wu7f390562015-03-25 08:47:18 +0800905 body[10] = fs->point_sprite_enables;
906 else
907 body[10] = 0;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800908
GregF8cd81832014-11-18 18:01:01 -0700909 body[11] = 0; /* constant interpolation enables */
910 body[12] = 0; /* WrapShortest enables */
911 body[13] = 0;
912}
913
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800914static void pipeline_build_gs(struct intel_pipeline *pipeline,
915 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600916{
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600917 // gen7_emit_3DSTATE_GS done by cmd_pipeline
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600918}
919
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800920static void pipeline_build_hs(struct intel_pipeline *pipeline,
921 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600922{
923 const uint8_t cmd_len = 7;
924 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2);
925 uint32_t *dw;
926
Chia-I Wu509b3f22014-09-02 10:24:05 +0800927 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600928
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800929 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600930 dw[0] = dw0;
931 dw[1] = 0;
932 dw[2] = 0;
933 dw[3] = 0;
934 dw[4] = 0;
935 dw[5] = 0;
936 dw[6] = 0;
937}
938
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800939static void pipeline_build_te(struct intel_pipeline *pipeline,
940 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600941{
942 const uint8_t cmd_len = 4;
943 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2);
944 uint32_t *dw;
945
Chia-I Wu509b3f22014-09-02 10:24:05 +0800946 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600947
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800948 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600949 dw[0] = dw0;
950 dw[1] = 0;
951 dw[2] = 0;
952 dw[3] = 0;
953}
954
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800955static void pipeline_build_ds(struct intel_pipeline *pipeline,
956 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600957{
958 const uint8_t cmd_len = 6;
959 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2);
960 uint32_t *dw;
961
Chia-I Wu509b3f22014-09-02 10:24:05 +0800962 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600963
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800964 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600965 dw[0] = dw0;
966 dw[1] = 0;
967 dw[2] = 0;
968 dw[3] = 0;
969 dw[4] = 0;
970 dw[5] = 0;
971}
972
Tony Barbourfa6cac72015-01-16 14:27:35 -0700973static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline,
974 const struct intel_pipeline_create_info *info)
975{
976 pipeline->cmd_depth_stencil = 0;
977
978 if (info->db.stencilTestEnable) {
979 pipeline->cmd_depth_stencil = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -0600980 translate_compare_func(info->db.front.stencilCompareOp) << 28 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700981 translate_stencil_op(info->db.front.stencilFailOp) << 25 |
982 translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 |
983 translate_stencil_op(info->db.front.stencilPassOp) << 19 |
984 1 << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -0600985 translate_compare_func(info->db.back.stencilCompareOp) << 12 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700986 translate_stencil_op(info->db.back.stencilFailOp) << 9 |
987 translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 |
988 translate_stencil_op(info->db.back.stencilPassOp) << 3;
989 }
990
991 pipeline->stencilTestEnable = info->db.stencilTestEnable;
992
993 /*
994 * From the Sandy Bridge PRM, volume 2 part 1, page 360:
995 *
996 * "Enabling the Depth Test function without defining a Depth Buffer is
997 * UNDEFINED."
998 *
999 * From the Sandy Bridge PRM, volume 2 part 1, page 375:
1000 *
1001 * "A Depth Buffer must be defined before enabling writes to it, or
1002 * operation is UNDEFINED."
1003 *
1004 * TODO We do not check these yet.
1005 */
1006 if (info->db.depthTestEnable) {
1007 pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
Tony Barbour8205d902015-04-16 15:59:00 -06001008 translate_compare_func(info->db.depthCompareOp) << 27;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001009 } else {
1010 pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27;
1011 }
1012
1013 if (info->db.depthWriteEnable)
1014 pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
1015}
1016
Tony Barbourfa6cac72015-01-16 14:27:35 -07001017static void pipeline_build_msaa(struct intel_pipeline *pipeline,
1018 const struct intel_pipeline_create_info *info)
1019{
1020 uint32_t cmd, cmd_len;
1021 uint32_t *dw;
1022
1023 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1024
Tony Barboure094edf2015-06-26 10:18:34 -06001025 pipeline->sample_count = (info->ms.rasterSamples <= 1) ? 1 : info->ms.rasterSamples;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001026
1027 /* 3DSTATE_SAMPLE_MASK */
1028 cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
1029 cmd_len = 2;
1030
Chia-I Wu8ada4242015-03-02 11:19:33 -07001031 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001032 dw[0] = cmd | (cmd_len - 2);
1033 dw[1] = info->ms.sampleMask & ((1 << pipeline->sample_count) - 1);
1034 pipeline->cmd_sample_mask = dw[1];
1035}
1036
1037static void pipeline_build_cb(struct intel_pipeline *pipeline,
1038 const struct intel_pipeline_create_info *info)
1039{
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001040 uint32_t i;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001041
1042 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1043 STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2);
1044 assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS);
1045
1046 uint32_t *dw = pipeline->cmd_cb;
1047
1048 for (i = 0; i < info->cb.attachmentCount; i++) {
Tony Barboure307f582015-07-10 15:29:03 -06001049 const VkPipelineColorBlendAttachmentState *att = &info->cb.pAttachments[i];
Tony Barbourfa6cac72015-01-16 14:27:35 -07001050 uint32_t dw0, dw1;
1051
1052
1053 dw0 = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001054 dw1 = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1055 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1056 GEN6_RT_DW1_POST_BLEND_CLAMP;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001057
1058 if (att->blendEnable) {
1059 dw0 = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -06001060 translate_blend_func(att->blendOpAlpha) << 26 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001061 translate_blend(att->srcBlendAlpha) << 20 |
1062 translate_blend(att->destBlendAlpha) << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -06001063 translate_blend_func(att->blendOpColor) << 11 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001064 translate_blend(att->srcBlendColor) << 5 |
1065 translate_blend(att->destBlendColor);
1066
Tony Barbour8205d902015-04-16 15:59:00 -06001067 if (att->blendOpAlpha != att->blendOpColor ||
Tony Barbourfa6cac72015-01-16 14:27:35 -07001068 att->srcBlendAlpha != att->srcBlendColor ||
1069 att->destBlendAlpha != att->destBlendColor)
1070 dw0 |= 1 << 30;
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -07001071
1072 pipeline->dual_source_blend_enable = icd_pipeline_cb_att_needs_dual_source_blending(att);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001073 }
1074
Courtney Goeltzenleuchter72af13a2015-06-26 17:45:23 -06001075 if (info->cb.logicOpEnable && info->cb.logicOp != VK_LOGIC_OP_COPY) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001076 int logicop;
1077
1078 switch (info->cb.logicOp) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001079 case VK_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
1080 case VK_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
1081 case VK_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
1082 case VK_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
1083 case VK_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
1084 case VK_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
1085 case VK_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
1086 case VK_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
1087 case VK_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
1088 case VK_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
1089 case VK_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
1090 case VK_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
1091 case VK_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
1092 case VK_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
1093 case VK_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001094 default:
1095 assert(!"unknown logic op");
1096 logicop = GEN6_LOGICOP_CLEAR;
1097 break;
1098 }
1099
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001100 dw1 |= GEN6_RT_DW1_LOGICOP_ENABLE |
1101 logicop << GEN6_RT_DW1_LOGICOP_FUNC__SHIFT;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001102 }
1103
1104 if (!(att->channelWriteMask & 0x1))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001105 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_R;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001106 if (!(att->channelWriteMask & 0x2))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001107 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_G;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001108 if (!(att->channelWriteMask & 0x4))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001109 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_B;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001110 if (!(att->channelWriteMask & 0x8))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001111 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001112
1113 dw[2 * i] = dw0;
1114 dw[2 * i + 1] = dw1;
1115 }
1116
1117 for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++)
1118 {
1119 dw[2 * i] = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001120 dw[2 * i + 1] = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1121 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1122 GEN6_RT_DW1_POST_BLEND_CLAMP |
1123 GEN6_RT_DW1_WRITE_DISABLE_R |
1124 GEN6_RT_DW1_WRITE_DISABLE_G |
1125 GEN6_RT_DW1_WRITE_DISABLE_B |
1126 GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001127 }
1128
1129}
1130
1131
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001132static VkResult pipeline_build_all(struct intel_pipeline *pipeline,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001133 const struct intel_pipeline_create_info *info)
Chia-I Wu3efef432014-08-28 15:00:16 +08001134{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001135 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001136
Chia-I Wu98824592014-09-02 09:42:46 +08001137 ret = pipeline_build_shaders(pipeline, info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001138 if (ret != VK_SUCCESS)
Chia-I Wu98824592014-09-02 09:42:46 +08001139 return ret;
1140
Chia-I Wu1d125092014-10-08 08:49:38 +08001141 if (info->vi.bindingCount > ARRAY_SIZE(pipeline->vb) ||
1142 info->vi.attributeCount > ARRAY_SIZE(pipeline->vb))
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001143 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu1d125092014-10-08 08:49:38 +08001144
1145 pipeline->vb_count = info->vi.bindingCount;
1146 memcpy(pipeline->vb, info->vi.pVertexBindingDescriptions,
1147 sizeof(pipeline->vb[0]) * pipeline->vb_count);
1148
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001149 pipeline_build_vertex_elements(pipeline, info);
Chia-I Wu86a5e0c2015-03-24 11:01:50 +08001150 pipeline_build_fragment_SBE(pipeline, info);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001151 pipeline_build_msaa(pipeline, info);
Chia-I Wu5bdb0962015-01-24 12:49:28 +08001152 pipeline_build_depth_stencil(pipeline, info);
Chia-I Wu4d9ad912014-08-29 14:20:36 +08001153
Chia-I Wu509b3f22014-09-02 10:24:05 +08001154 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001155 pipeline_build_urb_alloc_gen7(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001156 pipeline_build_gs(pipeline, info);
1157 pipeline_build_hs(pipeline, info);
1158 pipeline_build_te(pipeline, info);
1159 pipeline_build_ds(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001160
1161 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1162 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL |
1163 INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE |
1164 INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL |
1165 INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001166 } else {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001167 pipeline_build_urb_alloc_gen6(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001168
1169 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1170 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001171 }
1172
Chia-I Wube0a3d92014-09-02 13:20:59 +08001173 ret = pipeline_build_ia(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001174
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001175 if (ret == VK_SUCCESS)
Chia-I Wu6abcb0e2015-03-24 14:38:14 +08001176 ret = pipeline_build_rs_state(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001177
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001178 if (ret == VK_SUCCESS) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001179 pipeline_build_cb(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001180 pipeline->cb_state = info->cb;
1181 pipeline->tess_state = info->tess;
Chia-I Wu3efef432014-08-28 15:00:16 +08001182 }
1183
1184 return ret;
1185}
1186
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001187static VkResult pipeline_create_info_init(struct intel_pipeline_create_info *info,
1188 const VkGraphicsPipelineCreateInfo *vkinfo)
Chia-I Wu3efef432014-08-28 15:00:16 +08001189{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001190 memset(info, 0, sizeof(*info));
Chia-I Wu3efef432014-08-28 15:00:16 +08001191
Tony Barbourfa6cac72015-01-16 14:27:35 -07001192 /*
1193 * Do we need to set safe defaults in case the app doesn't provide all of
1194 * the necessary create infos?
1195 */
Tony Barboure094edf2015-06-26 10:18:34 -06001196 info->ms.rasterSamples = 1;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001197 info->ms.sampleMask = 1;
1198
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001199 memcpy(&info->graphics, vkinfo, sizeof (info->graphics));
Chia-I Wu3efef432014-08-28 15:00:16 +08001200
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001201 void *dst;
1202 for (uint32_t i = 0; i < vkinfo->stageCount; i++) {
1203 const VkPipelineShaderStageCreateInfo *thisStage = &vkinfo->pStages[i];
1204 switch (thisStage->stage) {
1205 case VK_SHADER_STAGE_VERTEX:
1206 dst = &info->vs;
1207 break;
1208 case VK_SHADER_STAGE_TESS_CONTROL:
1209 dst = &info->tcs;
1210 break;
1211 case VK_SHADER_STAGE_TESS_EVALUATION:
1212 dst = &info->tes;
1213 break;
1214 case VK_SHADER_STAGE_GEOMETRY:
1215 dst = &info->gs;
1216 break;
1217 case VK_SHADER_STAGE_FRAGMENT:
1218 dst = &info->fs;
1219 break;
1220 case VK_SHADER_STAGE_COMPUTE:
1221 dst = &info->compute;
1222 break;
1223 default:
1224 return VK_ERROR_BAD_PIPELINE_DATA;
1225 break;
Chia-I Wu3efef432014-08-28 15:00:16 +08001226 }
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001227 memcpy(dst, thisStage, sizeof(VkPipelineShaderStageCreateInfo));
1228 }
Chia-I Wu3efef432014-08-28 15:00:16 +08001229
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001230 if (vkinfo->pVertexInputState != NULL) {
1231 memcpy(&info->vi, vkinfo->pVertexInputState, sizeof (info->vi));
1232 }
Tony Barboure307f582015-07-10 15:29:03 -06001233 if (vkinfo->pInputAssemblyState != NULL) {
1234 memcpy(&info->ia, vkinfo->pInputAssemblyState, sizeof (info->ia));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001235 }
Tony Barboure307f582015-07-10 15:29:03 -06001236 if (vkinfo->pDepthStencilState != NULL) {
1237 memcpy(&info->db, vkinfo->pDepthStencilState, sizeof (info->db));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001238 }
Tony Barboure307f582015-07-10 15:29:03 -06001239 if (vkinfo->pColorBlendState != NULL) {
1240 memcpy(&info->cb, vkinfo->pColorBlendState, sizeof (info->cb));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001241 }
Tony Barboure307f582015-07-10 15:29:03 -06001242 if (vkinfo->pRasterState != NULL) {
1243 memcpy(&info->rs, vkinfo->pRasterState, sizeof (info->rs));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001244 }
Tony Barboure307f582015-07-10 15:29:03 -06001245 if (vkinfo->pTessellationState != NULL) {
1246 memcpy(&info->tess, vkinfo->pTessellationState, sizeof (info->tess));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001247 }
Tony Barboure307f582015-07-10 15:29:03 -06001248 if (vkinfo->pMultisampleState != NULL) {
1249 memcpy(&info->ms, vkinfo->pMultisampleState, sizeof (info->ms));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001250 }
Tony Barboure307f582015-07-10 15:29:03 -06001251 if (vkinfo->pViewportState != NULL) {
1252 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001253 }
Tony Barboure307f582015-07-10 15:29:03 -06001254 if (vkinfo->pViewportState != NULL) {
1255 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Chia-I Wu3efef432014-08-28 15:00:16 +08001256 }
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001257
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001258 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001259}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001260
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001261static VkResult graphics_pipeline_create(struct intel_dev *dev,
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001262 const VkGraphicsPipelineCreateInfo *info_,
1263 struct intel_pipeline **pipeline_ret)
Chia-I Wu3efef432014-08-28 15:00:16 +08001264{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001265 struct intel_pipeline_create_info info;
Chia-I Wu3efef432014-08-28 15:00:16 +08001266 struct intel_pipeline *pipeline;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001267 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001268
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001269 ret = pipeline_create_info_init(&info, info_);
1270
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001271 if (ret != VK_SUCCESS)
Chia-I Wu3efef432014-08-28 15:00:16 +08001272 return ret;
1273
Chia-I Wu545c2e12015-02-22 13:19:54 +08001274 pipeline = (struct intel_pipeline *) intel_base_create(&dev->base.handle,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001275 sizeof (*pipeline), dev->base.dbg,
1276 VK_OBJECT_TYPE_PIPELINE, info_, 0);
Chia-I Wu3efef432014-08-28 15:00:16 +08001277 if (!pipeline)
Tony Barbour8205d902015-04-16 15:59:00 -06001278 return VK_ERROR_OUT_OF_HOST_MEMORY;
Chia-I Wu3efef432014-08-28 15:00:16 +08001279
1280 pipeline->dev = dev;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001281 pipeline->pipeline_layout = intel_pipeline_layout(info.graphics.layout);
Chia-I Wudf601c42015-04-17 01:58:07 +08001282
Chia-I Wu3efef432014-08-28 15:00:16 +08001283 pipeline->obj.destroy = pipeline_destroy;
Chia-I Wu3efef432014-08-28 15:00:16 +08001284
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001285 ret = pipeline_build_all(pipeline, &info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001286 if (ret == VK_SUCCESS)
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001287 ret = pipeline_validate(pipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001288 if (ret != VK_SUCCESS) {
Chia-I Wu3efef432014-08-28 15:00:16 +08001289 pipeline_destroy(&pipeline->obj);
1290 return ret;
1291 }
1292
Tony Barbour2094dc72015-07-09 15:26:32 -06001293 VkMemoryAllocInfo mem_reqs;
1294 mem_reqs.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
1295 mem_reqs.allocationSize = pipeline->scratch_size;
1296 mem_reqs.pNext = NULL;
1297 mem_reqs.memoryTypeIndex = 0;
1298 intel_mem_alloc(dev, &mem_reqs, &pipeline->obj.mem);
1299
Chia-I Wu3efef432014-08-28 15:00:16 +08001300 *pipeline_ret = pipeline;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001301 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001302}
1303
Jon Ashburn0d60d272015-07-09 15:02:25 -06001304ICD_EXPORT VkResult VKAPI vkCreatePipelineCache(
1305 VkDevice device,
1306 const VkPipelineCacheCreateInfo* pCreateInfo,
1307 VkPipelineCache* pPipelineCache)
Chia-I Wu3efef432014-08-28 15:00:16 +08001308{
Chia-I Wu3efef432014-08-28 15:00:16 +08001309
Jon Ashburn0d60d272015-07-09 15:02:25 -06001310 // non-dispatchable objects only need to be 64 bits currently
1311 *((uint64_t *)pPipelineCache) = 1;
1312 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001313}
1314
Jon Ashburn0d60d272015-07-09 15:02:25 -06001315VkResult VKAPI vkDestroyPipelineCache(
1316 VkDevice device,
1317 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001318{
Jon Ashburn0d60d272015-07-09 15:02:25 -06001319 return VK_SUCCESS;
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001320}
1321
Jon Ashburn0d60d272015-07-09 15:02:25 -06001322ICD_EXPORT size_t VKAPI vkGetPipelineCacheSize(
1323 VkDevice device,
1324 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001325{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001326 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001327}
1328
Jon Ashburn0d60d272015-07-09 15:02:25 -06001329ICD_EXPORT VkResult VKAPI vkGetPipelineCacheData(
1330 VkDevice device,
1331 VkPipelineCache pipelineCache,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001332 void* pData)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001333{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001334 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001335}
1336
Jon Ashburn0d60d272015-07-09 15:02:25 -06001337ICD_EXPORT VkResult VKAPI vkMergePipelineCaches(
1338 VkDevice device,
1339 VkPipelineCache destCache,
1340 uint32_t srcCacheCount,
1341 const VkPipelineCache* pSrcCaches)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001342{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001343 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001344}
1345
Jon Ashburn0d60d272015-07-09 15:02:25 -06001346ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipelines(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001347 VkDevice device,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001348 VkPipelineCache pipelineCache,
1349 uint32_t count,
1350 const VkGraphicsPipelineCreateInfo* pCreateInfos,
1351 VkPipeline* pPipelines)
1352{
1353 struct intel_dev *dev = intel_dev(device);
1354 uint32_t i;
1355 VkResult res;
1356 bool one_succeeded = false;
1357
1358 for (i = 0; i < count; i++) {
1359 res = graphics_pipeline_create(dev, &(pCreateInfos[i]),
1360 (struct intel_pipeline **) &(pPipelines[i]));
1361 //return NULL handle for unsuccessful creates
1362 if (res != VK_SUCCESS)
Tony Barbourde4124d2015-07-03 10:33:54 -06001363 pPipelines[i].handle = 0;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001364 else
1365 one_succeeded = true;
1366 }
1367 //return VK_SUCCESS if any of count creates succeeded
1368 if (one_succeeded)
1369 return VK_SUCCESS;
1370 else
1371 return res;
1372}
1373
1374ICD_EXPORT VkResult VKAPI vkCreateComputePipelines(
1375 VkDevice device,
1376 VkPipelineCache pipelineCache,
1377 uint32_t count,
1378 const VkComputePipelineCreateInfo* pCreateInfos,
1379 VkPipeline* pPipelines)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001380{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001381 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001382}
Tony Barbourde4124d2015-07-03 10:33:54 -06001383
1384ICD_EXPORT VkResult VKAPI vkDestroyPipeline(
1385 VkDevice device,
1386 VkPipeline pipeline)
1387
1388 {
1389 struct intel_obj *obj = intel_obj(pipeline.handle);
1390
Tony Barbour2094dc72015-07-09 15:26:32 -06001391 intel_mem_free(obj->mem);
Tony Barbourde4124d2015-07-03 10:33:54 -06001392 obj->destroy(obj);
1393 return VK_SUCCESS;
1394 }