blob: 11ea82e8efd248c7bd787b2dd4a8dd5bbafc0c2c [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;
Courtney Goeltzenleuchter99349ec2015-07-12 15:35:40 -0600307 pipeline->disable_vs_cache = false;
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;
Courtney Goeltzenleuchtera7281c22015-07-12 15:42:02 -0600353 pipeline->primitive_restart_index = 0;
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;
Cody Northropf5bd2252015-08-17 11:10:49 -0600369 pipeline->depthBiasEnable = rs_state->depthBiasEnable;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700370
Tony Barbourfa6cac72015-01-16 14:27:35 -0700371 switch (rs_state->fillMode) {
Tony Barbour8205d902015-04-16 15:59:00 -0600372 case VK_FILL_MODE_POINTS:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700373 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_POINT |
374 GEN7_SF_DW1_BACKFACE_POINT;
375 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600376 case VK_FILL_MODE_WIREFRAME:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700377 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_WIREFRAME |
378 GEN7_SF_DW1_BACKFACE_WIREFRAME;
379 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600380 case VK_FILL_MODE_SOLID:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700381 default:
382 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTFACE_SOLID |
383 GEN7_SF_DW1_BACKFACE_SOLID;
384 break;
385 }
386
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600387 ccw = (rs_state->frontFace == VK_FRONT_FACE_CCW);
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800388 /* flip the winding order */
Chia-I Wu6abcb0e2015-03-24 14:38:14 +0800389
390 if (ccw) {
Tony Barbourfa6cac72015-01-16 14:27:35 -0700391 pipeline->cmd_sf_fill |= GEN7_SF_DW1_FRONTWINDING_CCW;
392 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_FRONTWINDING_CCW;
393 }
394
395 switch (rs_state->cullMode) {
Tony Barbour8205d902015-04-16 15:59:00 -0600396 case VK_CULL_MODE_NONE:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700397 default:
398 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_NONE;
399 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_NONE;
400 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600401 case VK_CULL_MODE_FRONT:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700402 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_FRONT;
403 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_FRONT;
404 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600405 case VK_CULL_MODE_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700406 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BACK;
407 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BACK;
408 break;
Tony Barbour8205d902015-04-16 15:59:00 -0600409 case VK_CULL_MODE_FRONT_AND_BACK:
Tony Barbourfa6cac72015-01-16 14:27:35 -0700410 pipeline->cmd_sf_cull |= GEN7_SF_DW2_CULLMODE_BOTH;
411 pipeline->cmd_clip_cull |= GEN7_CLIP_DW1_CULLMODE_BOTH;
412 break;
413 }
414
415 /* only GEN7+ needs cull mode in 3DSTATE_CLIP */
416 if (intel_gpu_gen(pipeline->dev->gpu) == INTEL_GEN(6))
417 pipeline->cmd_clip_cull = 0;
418
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600419 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600420}
421
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600422static void pipeline_destroy(struct intel_obj *obj)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600423{
424 struct intel_pipeline *pipeline = intel_pipeline_from_obj(obj);
425
Chia-I Wu3f239832014-12-11 22:57:18 +0800426 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800427 intel_pipeline_shader_cleanup(&pipeline->vs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800428 }
429
430 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800431 intel_pipeline_shader_cleanup(&pipeline->tcs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800432 }
433
434 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800435 intel_pipeline_shader_cleanup(&pipeline->tes, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800436 }
437
438 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800439 intel_pipeline_shader_cleanup(&pipeline->gs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800440 }
441
442 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800443 intel_pipeline_shader_cleanup(&pipeline->fs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800444 }
445
446 if (pipeline->active_shaders & SHADER_COMPUTE_FLAG) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800447 intel_pipeline_shader_cleanup(&pipeline->cs, pipeline->dev->gpu);
Chia-I Wu3f239832014-12-11 22:57:18 +0800448 }
Chia-I Wued833872014-08-23 17:00:35 +0800449
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600450 intel_base_destroy(&pipeline->obj.base);
451}
452
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600453static VkResult pipeline_validate(struct intel_pipeline *pipeline)
Chia-I Wu3efef432014-08-28 15:00:16 +0800454{
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600455 /*
456 * Validate required elements
457 */
458 if (!(pipeline->active_shaders & SHADER_VERTEX_FLAG)) {
459 // TODO: Log debug message: Vertex Shader required.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600460 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600461 }
462
463 /*
464 * Tessalation control and evaluation have to both have a shader defined or
465 * neither should have a shader defined.
466 */
467 if (((pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) == 0) !=
468 ((pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) == 0) ) {
469 // TODO: Log debug message: Both Tess control and Tess eval are required to use tessalation
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600470 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600471 }
472
473 if ((pipeline->active_shaders & SHADER_COMPUTE_FLAG) &&
474 (pipeline->active_shaders & (SHADER_VERTEX_FLAG | SHADER_TESS_CONTROL_FLAG |
475 SHADER_TESS_EVAL_FLAG | SHADER_GEOMETRY_FLAG |
476 SHADER_FRAGMENT_FLAG))) {
477 // TODO: Log debug message: Can only specify compute shader when doing compute
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600478 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600479 }
480
481 /*
Tony Barbour8205d902015-04-16 15:59:00 -0600482 * VK_PRIMITIVE_TOPOLOGY_PATCH primitive topology is only valid for tessellation pipelines.
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600483 * Mismatching primitive topology and tessellation fails graphics pipeline creation.
484 */
485 if (pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG) &&
Tony Barbour8205d902015-04-16 15:59:00 -0600486 (pipeline->topology != VK_PRIMITIVE_TOPOLOGY_PATCH)) {
Tobin Ehlis43c973b2015-06-22 11:31:09 -0600487 // TODO: Log debug message: Invalid topology used with tessellation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600488 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600489 }
490
Tony Barbour8205d902015-04-16 15:59:00 -0600491 if ((pipeline->topology == VK_PRIMITIVE_TOPOLOGY_PATCH) &&
Tobin Ehlis43c973b2015-06-22 11:31:09 -0600492 (~pipeline->active_shaders & (SHADER_TESS_CONTROL_FLAG | SHADER_TESS_EVAL_FLAG))) {
493 // TODO: Log debug message: Cannot use TOPOLOGY_PATCH on non-tessellation shader.
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600494 return VK_ERROR_BAD_PIPELINE_DATA;
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600495 }
496
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600497 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +0800498}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600499
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800500static void pipeline_build_urb_alloc_gen6(struct intel_pipeline *pipeline,
501 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800502{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800503 const struct intel_gpu *gpu = pipeline->dev->gpu;
504 const int urb_size = ((gpu->gt == 2) ? 64 : 32) * 1024;
Chia-I Wua4d1b392014-10-10 13:57:29 +0800505 const struct intel_pipeline_shader *vs = &pipeline->vs;
506 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800507 int vs_entry_size, gs_entry_size;
508 int vs_size, gs_size;
509
Chia-I Wu509b3f22014-09-02 10:24:05 +0800510 INTEL_GPU_ASSERT(gpu, 6, 6);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800511
512 vs_entry_size = ((vs->in_count >= vs->out_count) ?
513 vs->in_count : vs->out_count);
514 gs_entry_size = (gs) ? gs->out_count : 0;
515
516 /* in bytes */
517 vs_entry_size *= sizeof(float) * 4;
518 gs_entry_size *= sizeof(float) * 4;
519
Chia-I Wua4d1b392014-10-10 13:57:29 +0800520 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800521 vs_size = urb_size / 2;
522 gs_size = vs_size;
523 } else {
524 vs_size = urb_size;
525 gs_size = 0;
526 }
527
528 /* 3DSTATE_URB */
529 {
530 const uint8_t cmd_len = 3;
531 const uint32_t dw0 = GEN6_RENDER_CMD(3D, 3DSTATE_URB) |
532 (cmd_len - 2);
533 int vs_alloc_size, gs_alloc_size;
534 int vs_entry_count, gs_entry_count;
535 uint32_t *dw;
536
537 /* in 1024-bit rows */
538 vs_alloc_size = (vs_entry_size + 128 - 1) / 128;
539 gs_alloc_size = (gs_entry_size + 128 - 1) / 128;
540
541 /* valid range is [1, 5] */
542 if (!vs_alloc_size)
543 vs_alloc_size = 1;
544 if (!gs_alloc_size)
545 gs_alloc_size = 1;
546 assert(vs_alloc_size <= 5 && gs_alloc_size <= 5);
547
548 /* valid range is [24, 256], multiples of 4 */
549 vs_entry_count = (vs_size / 128 / vs_alloc_size) & ~3;
550 if (vs_entry_count > 256)
551 vs_entry_count = 256;
552 assert(vs_entry_count >= 24);
553
554 /* valid range is [0, 256], multiples of 4 */
555 gs_entry_count = (gs_size / 128 / gs_alloc_size) & ~3;
556 if (gs_entry_count > 256)
557 gs_entry_count = 256;
558
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600559 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800560
561 dw[0] = dw0;
562 dw[1] = (vs_alloc_size - 1) << GEN6_URB_DW1_VS_ENTRY_SIZE__SHIFT |
563 vs_entry_count << GEN6_URB_DW1_VS_ENTRY_COUNT__SHIFT;
564 dw[2] = gs_entry_count << GEN6_URB_DW2_GS_ENTRY_COUNT__SHIFT |
565 (gs_alloc_size - 1) << GEN6_URB_DW2_GS_ENTRY_SIZE__SHIFT;
566 }
567}
568
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800569static void pipeline_build_urb_alloc_gen7(struct intel_pipeline *pipeline,
570 const struct intel_pipeline_create_info *info)
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800571{
Chia-I Wu509b3f22014-09-02 10:24:05 +0800572 const struct intel_gpu *gpu = pipeline->dev->gpu;
573 const int urb_size = ((gpu->gt == 3) ? 512 :
574 (gpu->gt == 2) ? 256 : 128) * 1024;
Cody Northrop306ec352014-10-06 15:11:45 -0600575 const struct intel_pipeline_shader *vs = &pipeline->vs;
576 const struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800577 /* some space is reserved for PCBs */
Chia-I Wu509b3f22014-09-02 10:24:05 +0800578 int urb_offset = ((gpu->gt == 3) ? 32 : 16) * 1024;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800579 int vs_entry_size, gs_entry_size;
580 int vs_size, gs_size;
581
Chia-I Wu509b3f22014-09-02 10:24:05 +0800582 INTEL_GPU_ASSERT(gpu, 7, 7.5);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800583
584 vs_entry_size = ((vs->in_count >= vs->out_count) ?
585 vs->in_count : vs->out_count);
586 gs_entry_size = (gs) ? gs->out_count : 0;
587
588 /* in bytes */
589 vs_entry_size *= sizeof(float) * 4;
590 gs_entry_size *= sizeof(float) * 4;
591
Chia-I Wua4d1b392014-10-10 13:57:29 +0800592 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800593 vs_size = (urb_size - urb_offset) / 2;
594 gs_size = vs_size;
595 } else {
596 vs_size = urb_size - urb_offset;
597 gs_size = 0;
598 }
599
600 /* 3DSTATE_URB_* */
601 {
602 const uint8_t cmd_len = 2;
603 int vs_alloc_size, gs_alloc_size;
604 int vs_entry_count, gs_entry_count;
605 uint32_t *dw;
606
607 /* in 512-bit rows */
608 vs_alloc_size = (vs_entry_size + 64 - 1) / 64;
609 gs_alloc_size = (gs_entry_size + 64 - 1) / 64;
610
611 if (!vs_alloc_size)
612 vs_alloc_size = 1;
613 if (!gs_alloc_size)
614 gs_alloc_size = 1;
615
616 /* avoid performance decrease due to banking */
617 if (vs_alloc_size == 5)
618 vs_alloc_size = 6;
619
620 /* in multiples of 8 */
621 vs_entry_count = (vs_size / 64 / vs_alloc_size) & ~7;
622 assert(vs_entry_count >= 32);
623
624 gs_entry_count = (gs_size / 64 / gs_alloc_size) & ~7;
625
Chia-I Wu509b3f22014-09-02 10:24:05 +0800626 if (intel_gpu_gen(gpu) >= INTEL_GEN(7.5)) {
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800627 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800628 (gpu->gt >= 2) ? 1664 : 640;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800629 const int max_gs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800630 (gpu->gt >= 2) ? 640 : 256;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800631 if (vs_entry_count >= max_vs_entry_count)
632 vs_entry_count = max_vs_entry_count;
633 if (gs_entry_count >= max_gs_entry_count)
634 gs_entry_count = max_gs_entry_count;
635 } else {
636 const int max_vs_entry_count =
Chia-I Wu509b3f22014-09-02 10:24:05 +0800637 (gpu->gt == 2) ? 704 : 512;
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) ? 320 : 192;
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 }
645
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600646 dw = pipeline_cmd_ptr(pipeline, cmd_len*4);
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800647 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_VS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700648 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
649 (vs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800650 vs_entry_count;
651
652 dw += 2;
653 if (gs_size)
654 urb_offset += vs_size;
655 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_GS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700656 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT |
657 (gs_alloc_size - 1) << GEN7_URB_DW1_ENTRY_SIZE__SHIFT |
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800658 gs_entry_count;
659
660 dw += 2;
661 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_HS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700662 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800663
664 dw += 2;
665 dw[0] = GEN7_RENDER_CMD(3D, 3DSTATE_URB_DS) | (cmd_len - 2);
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700666 dw[1] = (urb_offset / 8192) << GEN7_URB_DW1_OFFSET__SHIFT;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800667 }
668}
669
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800670static void pipeline_build_vertex_elements(struct intel_pipeline *pipeline,
671 const struct intel_pipeline_create_info *info)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800672{
Cody Northrop306ec352014-10-06 15:11:45 -0600673 const struct intel_pipeline_shader *vs = &pipeline->vs;
Chia-I Wu1d125092014-10-08 08:49:38 +0800674 uint8_t cmd_len;
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800675 uint32_t *dw;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600676 uint32_t i, j;
677 uint32_t attr_count;
678 uint32_t attrs_processed;
Chia-I Wu1d125092014-10-08 08:49:38 +0800679 int comps[4];
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800680
Chia-I Wu509b3f22014-09-02 10:24:05 +0800681 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800682
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600683 attr_count = u_popcountll(vs->inputs_read);
684 cmd_len = 1 + 2 * attr_count;
Chia-I Wu1d125092014-10-08 08:49:38 +0800685 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID))
686 cmd_len += 2;
687
688 if (cmd_len == 1)
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800689 return;
690
691 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Chia-I Wu1d125092014-10-08 08:49:38 +0800692
693 dw[0] = GEN6_RENDER_CMD(3D, 3DSTATE_VERTEX_ELEMENTS) |
694 (cmd_len - 2);
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800695 dw++;
696
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800697 /* VERTEX_ELEMENT_STATE */
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600698 for (i = 0, attrs_processed = 0; attrs_processed < attr_count; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600699 VkVertexInputAttributeDescription *attr = NULL;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600700
701 /*
702 * The compiler will pack the shader references and then
703 * indicate which locations are used via the bitmask in
704 * vs->inputs_read.
705 */
706 if (!(vs->inputs_read & (1L << i))) {
GregF2dc40212014-10-31 17:31:47 -0600707 continue;
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600708 }
709
710 /*
711 * For each bit set in the vs->inputs_read we'll need
712 * to find the corresponding attribute record and then
713 * set up the next HW vertex element based on that attribute.
714 */
715 for (j = 0; j < info->vi.attributeCount; j++) {
716 if (info->vi.pVertexAttributeDescriptions[j].location == i) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600717 attr = (VkVertexInputAttributeDescription *) &info->vi.pVertexAttributeDescriptions[j];
Courtney Goeltzenleuchterf5cdad02015-03-31 16:36:30 -0600718 attrs_processed++;
719 break;
720 }
721 }
722 assert(attr != NULL);
723
Chia-I Wu1d125092014-10-08 08:49:38 +0800724 const int format =
725 intel_format_translate_color(pipeline->dev->gpu, attr->format);
726
727 comps[0] = GEN6_VFCOMP_STORE_0;
728 comps[1] = GEN6_VFCOMP_STORE_0;
729 comps[2] = GEN6_VFCOMP_STORE_0;
730 comps[3] = icd_format_is_int(attr->format) ?
731 GEN6_VFCOMP_STORE_1_INT : GEN6_VFCOMP_STORE_1_FP;
732
733 switch (icd_format_get_channel_count(attr->format)) {
734 case 4: comps[3] = GEN6_VFCOMP_STORE_SRC; /* fall through */
735 case 3: comps[2] = GEN6_VFCOMP_STORE_SRC; /* fall through */
736 case 2: comps[1] = GEN6_VFCOMP_STORE_SRC; /* fall through */
737 case 1: comps[0] = GEN6_VFCOMP_STORE_SRC; break;
738 default:
739 break;
740 }
741
742 assert(attr->offsetInBytes <= 2047);
743
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700744 dw[0] = attr->binding << GEN6_VE_DW0_VB_INDEX__SHIFT |
745 GEN6_VE_DW0_VALID |
746 format << GEN6_VE_DW0_FORMAT__SHIFT |
Chia-I Wu1d125092014-10-08 08:49:38 +0800747 attr->offsetInBytes;
748
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700749 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
750 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
751 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
752 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
Chia-I Wu1d125092014-10-08 08:49:38 +0800753
754 dw += 2;
755 }
GregF932fcf52014-10-29 17:02:11 -0600756
757 if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) {
758 comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ?
759 GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0;
760 comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ?
761 GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE;
762 comps[2] = GEN6_VFCOMP_NOSTORE;
763 comps[3] = GEN6_VFCOMP_NOSTORE;
764
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700765 dw[0] = GEN6_VE_DW0_VALID;
766 dw[1] = comps[0] << GEN6_VE_DW1_COMP0__SHIFT |
767 comps[1] << GEN6_VE_DW1_COMP1__SHIFT |
768 comps[2] << GEN6_VE_DW1_COMP2__SHIFT |
769 comps[3] << GEN6_VE_DW1_COMP3__SHIFT;
GregF932fcf52014-10-29 17:02:11 -0600770
771 dw += 2;
772 }
Chia-I Wu4d9ad912014-08-29 14:20:36 +0800773}
774
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800775static void pipeline_build_fragment_SBE(struct intel_pipeline *pipeline,
776 const struct intel_pipeline_create_info *info)
GregF8cd81832014-11-18 18:01:01 -0700777{
778 const struct intel_pipeline_shader *fs = &pipeline->fs;
GregF8cd81832014-11-18 18:01:01 -0700779 uint8_t cmd_len;
780 uint32_t *body;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600781 uint32_t attr_skip, attr_count;
782 uint32_t vue_offset, vue_len;
783 uint32_t i;
GregF8cd81832014-11-18 18:01:01 -0700784
Cody Northrop293d4502015-05-05 09:38:03 -0600785 // If GS is active, use its outputs
786 const struct intel_pipeline_shader *src =
787 (pipeline->active_shaders & SHADER_GEOMETRY_FLAG)
788 ? &pipeline->gs
789 : &pipeline->vs;
790
GregF8cd81832014-11-18 18:01:01 -0700791 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
792
793 cmd_len = 14;
794
Chia-I Wuf85def42015-01-29 00:34:24 +0800795 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7))
796 body = pipeline_cmd_ptr(pipeline, cmd_len);
797 else
798 body = pipeline->cmd_3dstate_sbe;
GregF8cd81832014-11-18 18:01:01 -0700799
Cody Northrop293d4502015-05-05 09:38:03 -0600800 assert(!fs->reads_user_clip || src->enable_user_clip);
801 attr_skip = src->outputs_offset;
802 if (src->enable_user_clip != fs->reads_user_clip) {
GregF8cd81832014-11-18 18:01:01 -0700803 attr_skip += 2;
804 }
Cody Northrop293d4502015-05-05 09:38:03 -0600805 assert(src->out_count >= attr_skip);
806 attr_count = src->out_count - attr_skip;
GregF8cd81832014-11-18 18:01:01 -0700807
808 // LUNARG TODO: We currently are only handling 16 attrs;
809 // ultimately, we need to handle 32
810 assert(fs->in_count <= 16);
811 assert(attr_count <= 16);
812
813 vue_offset = attr_skip / 2;
814 vue_len = (attr_count + 1) / 2;
815 if (!vue_len)
816 vue_len = 1;
817
818 body[0] = GEN7_RENDER_CMD(3D, 3DSTATE_SBE) |
819 (cmd_len - 2);
820
821 // LUNARG TODO: If the attrs needed by the FS are exactly
822 // what is written by the VS, we don't need to enable
823 // swizzling, improving performance. Even if we swizzle,
824 // we can improve performance by reducing vue_len to
825 // just include the values needed by the FS:
826 // vue_len = ceiling((max_vs_out + 1)/2)
827
828 body[1] = GEN7_SBE_DW1_ATTR_SWIZZLE_ENABLE |
829 fs->in_count << GEN7_SBE_DW1_ATTR_COUNT__SHIFT |
830 vue_len << GEN7_SBE_DW1_URB_READ_LEN__SHIFT |
831 vue_offset << GEN7_SBE_DW1_URB_READ_OFFSET__SHIFT;
832
Courtney Goeltzenleuchter9c057f52015-07-12 14:53:14 -0600833 /* Vulkan default is point origin upper left */
834 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_UPPERLEFT;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800835
Cody Northrop293d4502015-05-05 09:38:03 -0600836 uint16_t src_slot[fs->in_count];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600837 int32_t fs_in = 0;
Cody Northrop293d4502015-05-05 09:38:03 -0600838 int32_t src_out = - (vue_offset * 2 - src->outputs_offset);
GregF8cd81832014-11-18 18:01:01 -0700839 for (i=0; i < 64; i++) {
Cody Northrop293d4502015-05-05 09:38:03 -0600840 bool srcWrites = src->outputs_written & (1L << i);
841 bool fsReads = fs->inputs_read & (1L << i);
Cody Northropd75c13e2015-01-02 14:07:20 -0700842
843 if (fsReads) {
Cody Northrop293d4502015-05-05 09:38:03 -0600844 assert(src_out >= 0);
GregF8cd81832014-11-18 18:01:01 -0700845 assert(fs_in < fs->in_count);
Cody Northrop293d4502015-05-05 09:38:03 -0600846 src_slot[fs_in] = src_out;
Cody Northropd75c13e2015-01-02 14:07:20 -0700847
Cody Northrop293d4502015-05-05 09:38:03 -0600848 if (!srcWrites) {
Cody Northropd75c13e2015-01-02 14:07:20 -0700849 // If the vertex shader did not write this input, we cannot
850 // program the SBE to read it. Our choices are to allow it to
851 // read junk from a GRF, or get zero. We're choosing zero.
852 if (i >= fs->generic_input_start) {
Cody Northrop293d4502015-05-05 09:38:03 -0600853 src_slot[fs_in] = GEN8_SBE_SWIZ_CONST_0000 |
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700854 GEN8_SBE_SWIZ_OVERRIDE_X |
855 GEN8_SBE_SWIZ_OVERRIDE_Y |
856 GEN8_SBE_SWIZ_OVERRIDE_Z |
857 GEN8_SBE_SWIZ_OVERRIDE_W;
Cody Northropd75c13e2015-01-02 14:07:20 -0700858 }
859 }
860
GregF8cd81832014-11-18 18:01:01 -0700861 fs_in += 1;
862 }
Cody Northrop293d4502015-05-05 09:38:03 -0600863 if (srcWrites) {
864 src_out += 1;
GregF8cd81832014-11-18 18:01:01 -0700865 }
866 }
867
868 for (i = 0; i < 8; i++) {
869 uint16_t hi, lo;
870
871 /* no attr swizzles */
872 if (i * 2 + 1 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600873 lo = src_slot[i * 2];
874 hi = src_slot[i * 2 + 1];
GregF8cd81832014-11-18 18:01:01 -0700875 } else if (i * 2 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600876 lo = src_slot[i * 2];
GregF8cd81832014-11-18 18:01:01 -0700877 hi = 0;
878 } else {
879 hi = 0;
880 lo = 0;
881 }
882
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700883 body[2 + i] = hi << GEN8_SBE_SWIZ_HIGH__SHIFT | lo;
GregF8cd81832014-11-18 18:01:01 -0700884 }
885
Tony Barbour8205d902015-04-16 15:59:00 -0600886 if (info->ia.topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
Chia-I Wu7f390562015-03-25 08:47:18 +0800887 body[10] = fs->point_sprite_enables;
888 else
889 body[10] = 0;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800890
GregF8cd81832014-11-18 18:01:01 -0700891 body[11] = 0; /* constant interpolation enables */
892 body[12] = 0; /* WrapShortest enables */
893 body[13] = 0;
894}
895
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800896static void pipeline_build_gs(struct intel_pipeline *pipeline,
897 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600898{
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600899 // gen7_emit_3DSTATE_GS done by cmd_pipeline
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600900}
901
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800902static void pipeline_build_hs(struct intel_pipeline *pipeline,
903 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600904{
905 const uint8_t cmd_len = 7;
906 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2);
907 uint32_t *dw;
908
Chia-I Wu509b3f22014-09-02 10:24:05 +0800909 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600910
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800911 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600912 dw[0] = dw0;
913 dw[1] = 0;
914 dw[2] = 0;
915 dw[3] = 0;
916 dw[4] = 0;
917 dw[5] = 0;
918 dw[6] = 0;
919}
920
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800921static void pipeline_build_te(struct intel_pipeline *pipeline,
922 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600923{
924 const uint8_t cmd_len = 4;
925 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2);
926 uint32_t *dw;
927
Chia-I Wu509b3f22014-09-02 10:24:05 +0800928 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600929
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800930 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600931 dw[0] = dw0;
932 dw[1] = 0;
933 dw[2] = 0;
934 dw[3] = 0;
935}
936
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800937static void pipeline_build_ds(struct intel_pipeline *pipeline,
938 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600939{
940 const uint8_t cmd_len = 6;
941 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2);
942 uint32_t *dw;
943
Chia-I Wu509b3f22014-09-02 10:24:05 +0800944 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600945
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800946 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600947 dw[0] = dw0;
948 dw[1] = 0;
949 dw[2] = 0;
950 dw[3] = 0;
951 dw[4] = 0;
952 dw[5] = 0;
953}
954
Tony Barbourfa6cac72015-01-16 14:27:35 -0700955static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline,
956 const struct intel_pipeline_create_info *info)
957{
958 pipeline->cmd_depth_stencil = 0;
959
960 if (info->db.stencilTestEnable) {
961 pipeline->cmd_depth_stencil = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -0600962 translate_compare_func(info->db.front.stencilCompareOp) << 28 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700963 translate_stencil_op(info->db.front.stencilFailOp) << 25 |
964 translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 |
965 translate_stencil_op(info->db.front.stencilPassOp) << 19 |
966 1 << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -0600967 translate_compare_func(info->db.back.stencilCompareOp) << 12 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700968 translate_stencil_op(info->db.back.stencilFailOp) << 9 |
969 translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 |
970 translate_stencil_op(info->db.back.stencilPassOp) << 3;
971 }
972
973 pipeline->stencilTestEnable = info->db.stencilTestEnable;
974
975 /*
976 * From the Sandy Bridge PRM, volume 2 part 1, page 360:
977 *
978 * "Enabling the Depth Test function without defining a Depth Buffer is
979 * UNDEFINED."
980 *
981 * From the Sandy Bridge PRM, volume 2 part 1, page 375:
982 *
983 * "A Depth Buffer must be defined before enabling writes to it, or
984 * operation is UNDEFINED."
985 *
986 * TODO We do not check these yet.
987 */
988 if (info->db.depthTestEnable) {
989 pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
Tony Barbour8205d902015-04-16 15:59:00 -0600990 translate_compare_func(info->db.depthCompareOp) << 27;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700991 } else {
992 pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27;
993 }
994
995 if (info->db.depthWriteEnable)
996 pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
997}
998
Tony Barbourfa6cac72015-01-16 14:27:35 -0700999static void pipeline_build_msaa(struct intel_pipeline *pipeline,
1000 const struct intel_pipeline_create_info *info)
1001{
1002 uint32_t cmd, cmd_len;
1003 uint32_t *dw;
1004
1005 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1006
Tony Barboure094edf2015-06-26 10:18:34 -06001007 pipeline->sample_count = (info->ms.rasterSamples <= 1) ? 1 : info->ms.rasterSamples;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001008
1009 /* 3DSTATE_SAMPLE_MASK */
1010 cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
1011 cmd_len = 2;
1012
Chia-I Wu8ada4242015-03-02 11:19:33 -07001013 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001014 dw[0] = cmd | (cmd_len - 2);
Cody Northrope9825b72015-08-04 14:34:54 -06001015 if (info->ms.pSampleMask) {
1016 /* "Bit B of mask word M corresponds to sample 32*M + B."
1017 * "The array is sized to a length of ceil(rasterSamples / 32) words."
1018 * "If pSampleMask is NULL, it is treated as if the mask has all bits enabled,"
1019 * "i.e. no coverage is removed from primitives."
1020 */
1021 assert(pipeline->sample_count / 32 == 0);
1022 dw[1] = *info->ms.pSampleMask & ((1 << pipeline->sample_count) - 1);
1023 } else {
1024 dw[1] = (1 << pipeline->sample_count) - 1;
1025 }
1026
Tony Barbourfa6cac72015-01-16 14:27:35 -07001027 pipeline->cmd_sample_mask = dw[1];
1028}
1029
1030static void pipeline_build_cb(struct intel_pipeline *pipeline,
1031 const struct intel_pipeline_create_info *info)
1032{
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001033 uint32_t i;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001034
1035 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1036 STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2);
1037 assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS);
1038
1039 uint32_t *dw = pipeline->cmd_cb;
1040
1041 for (i = 0; i < info->cb.attachmentCount; i++) {
Tony Barboure307f582015-07-10 15:29:03 -06001042 const VkPipelineColorBlendAttachmentState *att = &info->cb.pAttachments[i];
Tony Barbourfa6cac72015-01-16 14:27:35 -07001043 uint32_t dw0, dw1;
1044
1045
1046 dw0 = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001047 dw1 = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1048 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1049 GEN6_RT_DW1_POST_BLEND_CLAMP;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001050
1051 if (att->blendEnable) {
1052 dw0 = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -06001053 translate_blend_func(att->blendOpAlpha) << 26 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001054 translate_blend(att->srcBlendAlpha) << 20 |
1055 translate_blend(att->destBlendAlpha) << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -06001056 translate_blend_func(att->blendOpColor) << 11 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001057 translate_blend(att->srcBlendColor) << 5 |
1058 translate_blend(att->destBlendColor);
1059
Tony Barbour8205d902015-04-16 15:59:00 -06001060 if (att->blendOpAlpha != att->blendOpColor ||
Tony Barbourfa6cac72015-01-16 14:27:35 -07001061 att->srcBlendAlpha != att->srcBlendColor ||
1062 att->destBlendAlpha != att->destBlendColor)
1063 dw0 |= 1 << 30;
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -07001064
1065 pipeline->dual_source_blend_enable = icd_pipeline_cb_att_needs_dual_source_blending(att);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001066 }
1067
Courtney Goeltzenleuchter72af13a2015-06-26 17:45:23 -06001068 if (info->cb.logicOpEnable && info->cb.logicOp != VK_LOGIC_OP_COPY) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001069 int logicop;
1070
1071 switch (info->cb.logicOp) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001072 case VK_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
1073 case VK_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
1074 case VK_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
1075 case VK_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
1076 case VK_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
1077 case VK_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
1078 case VK_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
1079 case VK_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
1080 case VK_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
1081 case VK_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
1082 case VK_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
1083 case VK_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
1084 case VK_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
1085 case VK_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
1086 case VK_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001087 default:
1088 assert(!"unknown logic op");
1089 logicop = GEN6_LOGICOP_CLEAR;
1090 break;
1091 }
1092
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001093 dw1 |= GEN6_RT_DW1_LOGICOP_ENABLE |
1094 logicop << GEN6_RT_DW1_LOGICOP_FUNC__SHIFT;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001095 }
1096
1097 if (!(att->channelWriteMask & 0x1))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001098 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_R;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001099 if (!(att->channelWriteMask & 0x2))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001100 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_G;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001101 if (!(att->channelWriteMask & 0x4))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001102 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_B;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001103 if (!(att->channelWriteMask & 0x8))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001104 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001105
1106 dw[2 * i] = dw0;
1107 dw[2 * i + 1] = dw1;
1108 }
1109
1110 for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++)
1111 {
1112 dw[2 * i] = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001113 dw[2 * i + 1] = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1114 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1115 GEN6_RT_DW1_POST_BLEND_CLAMP |
1116 GEN6_RT_DW1_WRITE_DISABLE_R |
1117 GEN6_RT_DW1_WRITE_DISABLE_G |
1118 GEN6_RT_DW1_WRITE_DISABLE_B |
1119 GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001120 }
1121
1122}
1123
1124
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001125static VkResult pipeline_build_all(struct intel_pipeline *pipeline,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001126 const struct intel_pipeline_create_info *info)
Chia-I Wu3efef432014-08-28 15:00:16 +08001127{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001128 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001129
Chia-I Wu98824592014-09-02 09:42:46 +08001130 ret = pipeline_build_shaders(pipeline, info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001131 if (ret != VK_SUCCESS)
Chia-I Wu98824592014-09-02 09:42:46 +08001132 return ret;
1133
Chia-I Wu1d125092014-10-08 08:49:38 +08001134 if (info->vi.bindingCount > ARRAY_SIZE(pipeline->vb) ||
1135 info->vi.attributeCount > ARRAY_SIZE(pipeline->vb))
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001136 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu1d125092014-10-08 08:49:38 +08001137
1138 pipeline->vb_count = info->vi.bindingCount;
1139 memcpy(pipeline->vb, info->vi.pVertexBindingDescriptions,
1140 sizeof(pipeline->vb[0]) * pipeline->vb_count);
1141
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001142 pipeline_build_vertex_elements(pipeline, info);
Chia-I Wu86a5e0c2015-03-24 11:01:50 +08001143 pipeline_build_fragment_SBE(pipeline, info);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001144 pipeline_build_msaa(pipeline, info);
Chia-I Wu5bdb0962015-01-24 12:49:28 +08001145 pipeline_build_depth_stencil(pipeline, info);
Chia-I Wu4d9ad912014-08-29 14:20:36 +08001146
Chia-I Wu509b3f22014-09-02 10:24:05 +08001147 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001148 pipeline_build_urb_alloc_gen7(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001149 pipeline_build_gs(pipeline, info);
1150 pipeline_build_hs(pipeline, info);
1151 pipeline_build_te(pipeline, info);
1152 pipeline_build_ds(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001153
1154 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1155 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL |
1156 INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE |
1157 INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL |
1158 INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001159 } else {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001160 pipeline_build_urb_alloc_gen6(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001161
1162 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1163 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001164 }
1165
Chia-I Wube0a3d92014-09-02 13:20:59 +08001166 ret = pipeline_build_ia(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001167
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001168 if (ret == VK_SUCCESS)
Chia-I Wu6abcb0e2015-03-24 14:38:14 +08001169 ret = pipeline_build_rs_state(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001170
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001171 if (ret == VK_SUCCESS) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001172 pipeline_build_cb(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001173 pipeline->cb_state = info->cb;
1174 pipeline->tess_state = info->tess;
Chia-I Wu3efef432014-08-28 15:00:16 +08001175 }
1176
1177 return ret;
1178}
1179
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001180static VkResult pipeline_create_info_init(struct intel_pipeline_create_info *info,
1181 const VkGraphicsPipelineCreateInfo *vkinfo)
Chia-I Wu3efef432014-08-28 15:00:16 +08001182{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001183 memset(info, 0, sizeof(*info));
Chia-I Wu3efef432014-08-28 15:00:16 +08001184
Tony Barbourfa6cac72015-01-16 14:27:35 -07001185 /*
1186 * Do we need to set safe defaults in case the app doesn't provide all of
1187 * the necessary create infos?
1188 */
Tony Barboure094edf2015-06-26 10:18:34 -06001189 info->ms.rasterSamples = 1;
Cody Northrope9825b72015-08-04 14:34:54 -06001190 info->ms.pSampleMask = NULL;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001191
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001192 memcpy(&info->graphics, vkinfo, sizeof (info->graphics));
Chia-I Wu3efef432014-08-28 15:00:16 +08001193
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001194 void *dst;
1195 for (uint32_t i = 0; i < vkinfo->stageCount; i++) {
1196 const VkPipelineShaderStageCreateInfo *thisStage = &vkinfo->pStages[i];
1197 switch (thisStage->stage) {
1198 case VK_SHADER_STAGE_VERTEX:
1199 dst = &info->vs;
1200 break;
1201 case VK_SHADER_STAGE_TESS_CONTROL:
1202 dst = &info->tcs;
1203 break;
1204 case VK_SHADER_STAGE_TESS_EVALUATION:
1205 dst = &info->tes;
1206 break;
1207 case VK_SHADER_STAGE_GEOMETRY:
1208 dst = &info->gs;
1209 break;
1210 case VK_SHADER_STAGE_FRAGMENT:
1211 dst = &info->fs;
1212 break;
1213 case VK_SHADER_STAGE_COMPUTE:
1214 dst = &info->compute;
1215 break;
1216 default:
1217 return VK_ERROR_BAD_PIPELINE_DATA;
1218 break;
Chia-I Wu3efef432014-08-28 15:00:16 +08001219 }
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001220 memcpy(dst, thisStage, sizeof(VkPipelineShaderStageCreateInfo));
1221 }
Chia-I Wu3efef432014-08-28 15:00:16 +08001222
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001223 if (vkinfo->pVertexInputState != NULL) {
1224 memcpy(&info->vi, vkinfo->pVertexInputState, sizeof (info->vi));
1225 }
Tony Barboure307f582015-07-10 15:29:03 -06001226 if (vkinfo->pInputAssemblyState != NULL) {
1227 memcpy(&info->ia, vkinfo->pInputAssemblyState, sizeof (info->ia));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001228 }
Tony Barboure307f582015-07-10 15:29:03 -06001229 if (vkinfo->pDepthStencilState != NULL) {
1230 memcpy(&info->db, vkinfo->pDepthStencilState, sizeof (info->db));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001231 }
Tony Barboure307f582015-07-10 15:29:03 -06001232 if (vkinfo->pColorBlendState != NULL) {
1233 memcpy(&info->cb, vkinfo->pColorBlendState, sizeof (info->cb));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001234 }
Tony Barboure307f582015-07-10 15:29:03 -06001235 if (vkinfo->pRasterState != NULL) {
1236 memcpy(&info->rs, vkinfo->pRasterState, sizeof (info->rs));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001237 }
Tony Barboure307f582015-07-10 15:29:03 -06001238 if (vkinfo->pTessellationState != NULL) {
1239 memcpy(&info->tess, vkinfo->pTessellationState, sizeof (info->tess));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001240 }
Tony Barboure307f582015-07-10 15:29:03 -06001241 if (vkinfo->pMultisampleState != NULL) {
1242 memcpy(&info->ms, vkinfo->pMultisampleState, sizeof (info->ms));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001243 }
Tony Barboure307f582015-07-10 15:29:03 -06001244 if (vkinfo->pViewportState != NULL) {
1245 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001246 }
Tony Barboure307f582015-07-10 15:29:03 -06001247 if (vkinfo->pViewportState != NULL) {
1248 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Chia-I Wu3efef432014-08-28 15:00:16 +08001249 }
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001250
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001251 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001252}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001253
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001254static VkResult graphics_pipeline_create(struct intel_dev *dev,
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001255 const VkGraphicsPipelineCreateInfo *info_,
1256 struct intel_pipeline **pipeline_ret)
Chia-I Wu3efef432014-08-28 15:00:16 +08001257{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001258 struct intel_pipeline_create_info info;
Chia-I Wu3efef432014-08-28 15:00:16 +08001259 struct intel_pipeline *pipeline;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001260 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001261
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001262 ret = pipeline_create_info_init(&info, info_);
1263
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001264 if (ret != VK_SUCCESS)
Chia-I Wu3efef432014-08-28 15:00:16 +08001265 return ret;
1266
Chia-I Wu545c2e12015-02-22 13:19:54 +08001267 pipeline = (struct intel_pipeline *) intel_base_create(&dev->base.handle,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001268 sizeof (*pipeline), dev->base.dbg,
1269 VK_OBJECT_TYPE_PIPELINE, info_, 0);
Chia-I Wu3efef432014-08-28 15:00:16 +08001270 if (!pipeline)
Tony Barbour8205d902015-04-16 15:59:00 -06001271 return VK_ERROR_OUT_OF_HOST_MEMORY;
Chia-I Wu3efef432014-08-28 15:00:16 +08001272
1273 pipeline->dev = dev;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001274 pipeline->pipeline_layout = intel_pipeline_layout(info.graphics.layout);
Chia-I Wudf601c42015-04-17 01:58:07 +08001275
Chia-I Wu3efef432014-08-28 15:00:16 +08001276 pipeline->obj.destroy = pipeline_destroy;
Chia-I Wu3efef432014-08-28 15:00:16 +08001277
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001278 ret = pipeline_build_all(pipeline, &info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001279 if (ret == VK_SUCCESS)
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001280 ret = pipeline_validate(pipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001281 if (ret != VK_SUCCESS) {
Chia-I Wu3efef432014-08-28 15:00:16 +08001282 pipeline_destroy(&pipeline->obj);
1283 return ret;
1284 }
1285
Tony Barbour2094dc72015-07-09 15:26:32 -06001286 VkMemoryAllocInfo mem_reqs;
1287 mem_reqs.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
1288 mem_reqs.allocationSize = pipeline->scratch_size;
1289 mem_reqs.pNext = NULL;
1290 mem_reqs.memoryTypeIndex = 0;
1291 intel_mem_alloc(dev, &mem_reqs, &pipeline->obj.mem);
1292
Chia-I Wu3efef432014-08-28 15:00:16 +08001293 *pipeline_ret = pipeline;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001294 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001295}
1296
Jon Ashburn0d60d272015-07-09 15:02:25 -06001297ICD_EXPORT VkResult VKAPI vkCreatePipelineCache(
1298 VkDevice device,
1299 const VkPipelineCacheCreateInfo* pCreateInfo,
1300 VkPipelineCache* pPipelineCache)
Chia-I Wu3efef432014-08-28 15:00:16 +08001301{
Chia-I Wu3efef432014-08-28 15:00:16 +08001302
Jon Ashburn0d60d272015-07-09 15:02:25 -06001303 // non-dispatchable objects only need to be 64 bits currently
1304 *((uint64_t *)pPipelineCache) = 1;
1305 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001306}
1307
Jon Ashburn0d60d272015-07-09 15:02:25 -06001308VkResult VKAPI vkDestroyPipelineCache(
1309 VkDevice device,
1310 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001311{
Jon Ashburn0d60d272015-07-09 15:02:25 -06001312 return VK_SUCCESS;
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001313}
1314
Jon Ashburn0d60d272015-07-09 15:02:25 -06001315ICD_EXPORT size_t VKAPI vkGetPipelineCacheSize(
1316 VkDevice device,
1317 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001318{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001319 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001320}
1321
Jon Ashburn0d60d272015-07-09 15:02:25 -06001322ICD_EXPORT VkResult VKAPI vkGetPipelineCacheData(
1323 VkDevice device,
1324 VkPipelineCache pipelineCache,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001325 void* pData)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001326{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001327 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001328}
1329
Jon Ashburn0d60d272015-07-09 15:02:25 -06001330ICD_EXPORT VkResult VKAPI vkMergePipelineCaches(
1331 VkDevice device,
1332 VkPipelineCache destCache,
1333 uint32_t srcCacheCount,
1334 const VkPipelineCache* pSrcCaches)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001335{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001336 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001337}
1338
Jon Ashburn0d60d272015-07-09 15:02:25 -06001339ICD_EXPORT VkResult VKAPI vkCreateGraphicsPipelines(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001340 VkDevice device,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001341 VkPipelineCache pipelineCache,
1342 uint32_t count,
1343 const VkGraphicsPipelineCreateInfo* pCreateInfos,
1344 VkPipeline* pPipelines)
1345{
1346 struct intel_dev *dev = intel_dev(device);
1347 uint32_t i;
Tony Barbour9687cb12015-07-14 13:34:05 -06001348 VkResult res = VK_SUCCESS;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001349 bool one_succeeded = false;
1350
1351 for (i = 0; i < count; i++) {
1352 res = graphics_pipeline_create(dev, &(pCreateInfos[i]),
1353 (struct intel_pipeline **) &(pPipelines[i]));
1354 //return NULL handle for unsuccessful creates
1355 if (res != VK_SUCCESS)
Tony Barbourde4124d2015-07-03 10:33:54 -06001356 pPipelines[i].handle = 0;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001357 else
1358 one_succeeded = true;
1359 }
1360 //return VK_SUCCESS if any of count creates succeeded
1361 if (one_succeeded)
1362 return VK_SUCCESS;
1363 else
1364 return res;
1365}
1366
1367ICD_EXPORT VkResult VKAPI vkCreateComputePipelines(
1368 VkDevice device,
1369 VkPipelineCache pipelineCache,
1370 uint32_t count,
1371 const VkComputePipelineCreateInfo* pCreateInfos,
1372 VkPipeline* pPipelines)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001373{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001374 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001375}
Tony Barbourde4124d2015-07-03 10:33:54 -06001376
1377ICD_EXPORT VkResult VKAPI vkDestroyPipeline(
1378 VkDevice device,
1379 VkPipeline pipeline)
1380
1381 {
1382 struct intel_obj *obj = intel_obj(pipeline.handle);
1383
Tony Barbour2094dc72015-07-09 15:26:32 -06001384 intel_mem_free(obj->mem);
Tony Barbourde4124d2015-07-03 10:33:54 -06001385 obj->destroy(obj);
1386 return VK_SUCCESS;
1387 }