blob: 4bda1a8bbe73380c423c3465ddd7b9a7fff85985 [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
Courtney Goeltzenleuchter9c057f52015-07-12 14:53:14 -0600842 /* Vulkan default is point origin upper left */
843 body[1] |= GEN7_SBE_DW1_POINT_SPRITE_TEXCOORD_UPPERLEFT;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800844
Cody Northrop293d4502015-05-05 09:38:03 -0600845 uint16_t src_slot[fs->in_count];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600846 int32_t fs_in = 0;
Cody Northrop293d4502015-05-05 09:38:03 -0600847 int32_t src_out = - (vue_offset * 2 - src->outputs_offset);
GregF8cd81832014-11-18 18:01:01 -0700848 for (i=0; i < 64; i++) {
Cody Northrop293d4502015-05-05 09:38:03 -0600849 bool srcWrites = src->outputs_written & (1L << i);
850 bool fsReads = fs->inputs_read & (1L << i);
Cody Northropd75c13e2015-01-02 14:07:20 -0700851
852 if (fsReads) {
Cody Northrop293d4502015-05-05 09:38:03 -0600853 assert(src_out >= 0);
GregF8cd81832014-11-18 18:01:01 -0700854 assert(fs_in < fs->in_count);
Cody Northrop293d4502015-05-05 09:38:03 -0600855 src_slot[fs_in] = src_out;
Cody Northropd75c13e2015-01-02 14:07:20 -0700856
Cody Northrop293d4502015-05-05 09:38:03 -0600857 if (!srcWrites) {
Cody Northropd75c13e2015-01-02 14:07:20 -0700858 // If the vertex shader did not write this input, we cannot
859 // program the SBE to read it. Our choices are to allow it to
860 // read junk from a GRF, or get zero. We're choosing zero.
861 if (i >= fs->generic_input_start) {
Cody Northrop293d4502015-05-05 09:38:03 -0600862 src_slot[fs_in] = GEN8_SBE_SWIZ_CONST_0000 |
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700863 GEN8_SBE_SWIZ_OVERRIDE_X |
864 GEN8_SBE_SWIZ_OVERRIDE_Y |
865 GEN8_SBE_SWIZ_OVERRIDE_Z |
866 GEN8_SBE_SWIZ_OVERRIDE_W;
Cody Northropd75c13e2015-01-02 14:07:20 -0700867 }
868 }
869
GregF8cd81832014-11-18 18:01:01 -0700870 fs_in += 1;
871 }
Cody Northrop293d4502015-05-05 09:38:03 -0600872 if (srcWrites) {
873 src_out += 1;
GregF8cd81832014-11-18 18:01:01 -0700874 }
875 }
876
877 for (i = 0; i < 8; i++) {
878 uint16_t hi, lo;
879
880 /* no attr swizzles */
881 if (i * 2 + 1 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600882 lo = src_slot[i * 2];
883 hi = src_slot[i * 2 + 1];
GregF8cd81832014-11-18 18:01:01 -0700884 } else if (i * 2 < fs->in_count) {
Cody Northrop293d4502015-05-05 09:38:03 -0600885 lo = src_slot[i * 2];
GregF8cd81832014-11-18 18:01:01 -0700886 hi = 0;
887 } else {
888 hi = 0;
889 lo = 0;
890 }
891
Chia-I Wu97aa4de2015-03-05 15:43:16 -0700892 body[2 + i] = hi << GEN8_SBE_SWIZ_HIGH__SHIFT | lo;
GregF8cd81832014-11-18 18:01:01 -0700893 }
894
Tony Barbour8205d902015-04-16 15:59:00 -0600895 if (info->ia.topology == VK_PRIMITIVE_TOPOLOGY_POINT_LIST)
Chia-I Wu7f390562015-03-25 08:47:18 +0800896 body[10] = fs->point_sprite_enables;
897 else
898 body[10] = 0;
Chia-I Wu86a5e0c2015-03-24 11:01:50 +0800899
GregF8cd81832014-11-18 18:01:01 -0700900 body[11] = 0; /* constant interpolation enables */
901 body[12] = 0; /* WrapShortest enables */
902 body[13] = 0;
903}
904
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800905static void pipeline_build_gs(struct intel_pipeline *pipeline,
906 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600907{
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600908 // gen7_emit_3DSTATE_GS done by cmd_pipeline
Courtney Goeltzenleuchterb2867702014-08-28 17:44:05 -0600909}
910
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800911static void pipeline_build_hs(struct intel_pipeline *pipeline,
912 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600913{
914 const uint8_t cmd_len = 7;
915 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_HS) | (cmd_len - 2);
916 uint32_t *dw;
917
Chia-I Wu509b3f22014-09-02 10:24:05 +0800918 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600919
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800920 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600921 dw[0] = dw0;
922 dw[1] = 0;
923 dw[2] = 0;
924 dw[3] = 0;
925 dw[4] = 0;
926 dw[5] = 0;
927 dw[6] = 0;
928}
929
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800930static void pipeline_build_te(struct intel_pipeline *pipeline,
931 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600932{
933 const uint8_t cmd_len = 4;
934 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_TE) | (cmd_len - 2);
935 uint32_t *dw;
936
Chia-I Wu509b3f22014-09-02 10:24:05 +0800937 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600938
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800939 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600940 dw[0] = dw0;
941 dw[1] = 0;
942 dw[2] = 0;
943 dw[3] = 0;
944}
945
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800946static void pipeline_build_ds(struct intel_pipeline *pipeline,
947 const struct intel_pipeline_create_info *info)
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600948{
949 const uint8_t cmd_len = 6;
950 const uint32_t dw0 = GEN7_RENDER_CMD(3D, 3DSTATE_DS) | (cmd_len - 2);
951 uint32_t *dw;
952
Chia-I Wu509b3f22014-09-02 10:24:05 +0800953 INTEL_GPU_ASSERT(pipeline->dev->gpu, 7, 7.5);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600954
Chia-I Wuf90ff0c2014-09-02 09:32:46 +0800955 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600956 dw[0] = dw0;
957 dw[1] = 0;
958 dw[2] = 0;
959 dw[3] = 0;
960 dw[4] = 0;
961 dw[5] = 0;
962}
963
Tony Barbourfa6cac72015-01-16 14:27:35 -0700964static void pipeline_build_depth_stencil(struct intel_pipeline *pipeline,
965 const struct intel_pipeline_create_info *info)
966{
967 pipeline->cmd_depth_stencil = 0;
968
969 if (info->db.stencilTestEnable) {
970 pipeline->cmd_depth_stencil = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -0600971 translate_compare_func(info->db.front.stencilCompareOp) << 28 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700972 translate_stencil_op(info->db.front.stencilFailOp) << 25 |
973 translate_stencil_op(info->db.front.stencilDepthFailOp) << 22 |
974 translate_stencil_op(info->db.front.stencilPassOp) << 19 |
975 1 << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -0600976 translate_compare_func(info->db.back.stencilCompareOp) << 12 |
Tony Barbourfa6cac72015-01-16 14:27:35 -0700977 translate_stencil_op(info->db.back.stencilFailOp) << 9 |
978 translate_stencil_op(info->db.back.stencilDepthFailOp) << 6 |
979 translate_stencil_op(info->db.back.stencilPassOp) << 3;
980 }
981
982 pipeline->stencilTestEnable = info->db.stencilTestEnable;
983
984 /*
985 * From the Sandy Bridge PRM, volume 2 part 1, page 360:
986 *
987 * "Enabling the Depth Test function without defining a Depth Buffer is
988 * UNDEFINED."
989 *
990 * From the Sandy Bridge PRM, volume 2 part 1, page 375:
991 *
992 * "A Depth Buffer must be defined before enabling writes to it, or
993 * operation is UNDEFINED."
994 *
995 * TODO We do not check these yet.
996 */
997 if (info->db.depthTestEnable) {
998 pipeline->cmd_depth_test = GEN6_ZS_DW2_DEPTH_TEST_ENABLE |
Tony Barbour8205d902015-04-16 15:59:00 -0600999 translate_compare_func(info->db.depthCompareOp) << 27;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001000 } else {
1001 pipeline->cmd_depth_test = GEN6_COMPAREFUNCTION_ALWAYS << 27;
1002 }
1003
1004 if (info->db.depthWriteEnable)
1005 pipeline->cmd_depth_test |= GEN6_ZS_DW2_DEPTH_WRITE_ENABLE;
1006}
1007
Tony Barbourfa6cac72015-01-16 14:27:35 -07001008static void pipeline_build_msaa(struct intel_pipeline *pipeline,
1009 const struct intel_pipeline_create_info *info)
1010{
1011 uint32_t cmd, cmd_len;
1012 uint32_t *dw;
1013
1014 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1015
Tony Barboure094edf2015-06-26 10:18:34 -06001016 pipeline->sample_count = (info->ms.rasterSamples <= 1) ? 1 : info->ms.rasterSamples;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001017
1018 /* 3DSTATE_SAMPLE_MASK */
1019 cmd = GEN6_RENDER_CMD(3D, 3DSTATE_SAMPLE_MASK);
1020 cmd_len = 2;
1021
Chia-I Wu8ada4242015-03-02 11:19:33 -07001022 dw = pipeline_cmd_ptr(pipeline, cmd_len);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001023 dw[0] = cmd | (cmd_len - 2);
1024 dw[1] = info->ms.sampleMask & ((1 << pipeline->sample_count) - 1);
1025 pipeline->cmd_sample_mask = dw[1];
1026}
1027
1028static void pipeline_build_cb(struct intel_pipeline *pipeline,
1029 const struct intel_pipeline_create_info *info)
1030{
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001031 uint32_t i;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001032
1033 INTEL_GPU_ASSERT(pipeline->dev->gpu, 6, 7.5);
1034 STATIC_ASSERT(ARRAY_SIZE(pipeline->cmd_cb) >= INTEL_MAX_RENDER_TARGETS*2);
1035 assert(info->cb.attachmentCount <= INTEL_MAX_RENDER_TARGETS);
1036
1037 uint32_t *dw = pipeline->cmd_cb;
1038
1039 for (i = 0; i < info->cb.attachmentCount; i++) {
Tony Barboure307f582015-07-10 15:29:03 -06001040 const VkPipelineColorBlendAttachmentState *att = &info->cb.pAttachments[i];
Tony Barbourfa6cac72015-01-16 14:27:35 -07001041 uint32_t dw0, dw1;
1042
1043
1044 dw0 = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001045 dw1 = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1046 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1047 GEN6_RT_DW1_POST_BLEND_CLAMP;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001048
1049 if (att->blendEnable) {
1050 dw0 = 1 << 31 |
Tony Barbour8205d902015-04-16 15:59:00 -06001051 translate_blend_func(att->blendOpAlpha) << 26 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001052 translate_blend(att->srcBlendAlpha) << 20 |
1053 translate_blend(att->destBlendAlpha) << 15 |
Tony Barbour8205d902015-04-16 15:59:00 -06001054 translate_blend_func(att->blendOpColor) << 11 |
Tony Barbourfa6cac72015-01-16 14:27:35 -07001055 translate_blend(att->srcBlendColor) << 5 |
1056 translate_blend(att->destBlendColor);
1057
Tony Barbour8205d902015-04-16 15:59:00 -06001058 if (att->blendOpAlpha != att->blendOpColor ||
Tony Barbourfa6cac72015-01-16 14:27:35 -07001059 att->srcBlendAlpha != att->srcBlendColor ||
1060 att->destBlendAlpha != att->destBlendColor)
1061 dw0 |= 1 << 30;
Courtney Goeltzenleuchterdf13a4d2015-02-11 14:14:45 -07001062
1063 pipeline->dual_source_blend_enable = icd_pipeline_cb_att_needs_dual_source_blending(att);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001064 }
1065
Courtney Goeltzenleuchter72af13a2015-06-26 17:45:23 -06001066 if (info->cb.logicOpEnable && info->cb.logicOp != VK_LOGIC_OP_COPY) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001067 int logicop;
1068
1069 switch (info->cb.logicOp) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001070 case VK_LOGIC_OP_CLEAR: logicop = GEN6_LOGICOP_CLEAR; break;
1071 case VK_LOGIC_OP_AND: logicop = GEN6_LOGICOP_AND; break;
1072 case VK_LOGIC_OP_AND_REVERSE: logicop = GEN6_LOGICOP_AND_REVERSE; break;
1073 case VK_LOGIC_OP_AND_INVERTED: logicop = GEN6_LOGICOP_AND_INVERTED; break;
1074 case VK_LOGIC_OP_NOOP: logicop = GEN6_LOGICOP_NOOP; break;
1075 case VK_LOGIC_OP_XOR: logicop = GEN6_LOGICOP_XOR; break;
1076 case VK_LOGIC_OP_OR: logicop = GEN6_LOGICOP_OR; break;
1077 case VK_LOGIC_OP_NOR: logicop = GEN6_LOGICOP_NOR; break;
1078 case VK_LOGIC_OP_EQUIV: logicop = GEN6_LOGICOP_EQUIV; break;
1079 case VK_LOGIC_OP_INVERT: logicop = GEN6_LOGICOP_INVERT; break;
1080 case VK_LOGIC_OP_OR_REVERSE: logicop = GEN6_LOGICOP_OR_REVERSE; break;
1081 case VK_LOGIC_OP_COPY_INVERTED: logicop = GEN6_LOGICOP_COPY_INVERTED; break;
1082 case VK_LOGIC_OP_OR_INVERTED: logicop = GEN6_LOGICOP_OR_INVERTED; break;
1083 case VK_LOGIC_OP_NAND: logicop = GEN6_LOGICOP_NAND; break;
1084 case VK_LOGIC_OP_SET: logicop = GEN6_LOGICOP_SET; break;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001085 default:
1086 assert(!"unknown logic op");
1087 logicop = GEN6_LOGICOP_CLEAR;
1088 break;
1089 }
1090
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001091 dw1 |= GEN6_RT_DW1_LOGICOP_ENABLE |
1092 logicop << GEN6_RT_DW1_LOGICOP_FUNC__SHIFT;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001093 }
1094
1095 if (!(att->channelWriteMask & 0x1))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001096 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_R;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001097 if (!(att->channelWriteMask & 0x2))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001098 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_G;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001099 if (!(att->channelWriteMask & 0x4))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001100 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_B;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001101 if (!(att->channelWriteMask & 0x8))
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001102 dw1 |= GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001103
1104 dw[2 * i] = dw0;
1105 dw[2 * i + 1] = dw1;
1106 }
1107
1108 for (i=info->cb.attachmentCount; i < INTEL_MAX_RENDER_TARGETS; i++)
1109 {
1110 dw[2 * i] = 0;
Chia-I Wu97aa4de2015-03-05 15:43:16 -07001111 dw[2 * i + 1] = GEN6_RT_DW1_COLORCLAMP_RTFORMAT |
1112 GEN6_RT_DW1_PRE_BLEND_CLAMP |
1113 GEN6_RT_DW1_POST_BLEND_CLAMP |
1114 GEN6_RT_DW1_WRITE_DISABLE_R |
1115 GEN6_RT_DW1_WRITE_DISABLE_G |
1116 GEN6_RT_DW1_WRITE_DISABLE_B |
1117 GEN6_RT_DW1_WRITE_DISABLE_A;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001118 }
1119
1120}
1121
1122
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001123static VkResult pipeline_build_all(struct intel_pipeline *pipeline,
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001124 const struct intel_pipeline_create_info *info)
Chia-I Wu3efef432014-08-28 15:00:16 +08001125{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001126 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001127
Chia-I Wu98824592014-09-02 09:42:46 +08001128 ret = pipeline_build_shaders(pipeline, info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001129 if (ret != VK_SUCCESS)
Chia-I Wu98824592014-09-02 09:42:46 +08001130 return ret;
1131
Chia-I Wu1d125092014-10-08 08:49:38 +08001132 if (info->vi.bindingCount > ARRAY_SIZE(pipeline->vb) ||
1133 info->vi.attributeCount > ARRAY_SIZE(pipeline->vb))
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001134 return VK_ERROR_BAD_PIPELINE_DATA;
Chia-I Wu1d125092014-10-08 08:49:38 +08001135
1136 pipeline->vb_count = info->vi.bindingCount;
1137 memcpy(pipeline->vb, info->vi.pVertexBindingDescriptions,
1138 sizeof(pipeline->vb[0]) * pipeline->vb_count);
1139
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001140 pipeline_build_vertex_elements(pipeline, info);
Chia-I Wu86a5e0c2015-03-24 11:01:50 +08001141 pipeline_build_fragment_SBE(pipeline, info);
Tony Barbourfa6cac72015-01-16 14:27:35 -07001142 pipeline_build_msaa(pipeline, info);
Chia-I Wu5bdb0962015-01-24 12:49:28 +08001143 pipeline_build_depth_stencil(pipeline, info);
Chia-I Wu4d9ad912014-08-29 14:20:36 +08001144
Chia-I Wu509b3f22014-09-02 10:24:05 +08001145 if (intel_gpu_gen(pipeline->dev->gpu) >= INTEL_GEN(7)) {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001146 pipeline_build_urb_alloc_gen7(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001147 pipeline_build_gs(pipeline, info);
1148 pipeline_build_hs(pipeline, info);
1149 pipeline_build_te(pipeline, info);
1150 pipeline_build_ds(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001151
1152 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1153 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL |
1154 INTEL_CMD_WA_GEN7_PRE_VS_DEPTH_STALL_WRITE |
1155 INTEL_CMD_WA_GEN7_POST_COMMAND_CS_STALL |
1156 INTEL_CMD_WA_GEN7_POST_COMMAND_DEPTH_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001157 } else {
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001158 pipeline_build_urb_alloc_gen6(pipeline, info);
Chia-I Wu8370b402014-08-29 12:28:37 +08001159
1160 pipeline->wa_flags = INTEL_CMD_WA_GEN6_PRE_DEPTH_STALL_WRITE |
1161 INTEL_CMD_WA_GEN6_PRE_COMMAND_SCOREBOARD_STALL;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +08001162 }
1163
Chia-I Wube0a3d92014-09-02 13:20:59 +08001164 ret = pipeline_build_ia(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001165
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001166 if (ret == VK_SUCCESS)
Chia-I Wu6abcb0e2015-03-24 14:38:14 +08001167 ret = pipeline_build_rs_state(pipeline, info);
Chia-I Wu3efef432014-08-28 15:00:16 +08001168
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001169 if (ret == VK_SUCCESS) {
Tony Barbourfa6cac72015-01-16 14:27:35 -07001170 pipeline_build_cb(pipeline, info);
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001171 pipeline->cb_state = info->cb;
1172 pipeline->tess_state = info->tess;
Chia-I Wu3efef432014-08-28 15:00:16 +08001173 }
1174
1175 return ret;
1176}
1177
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001178static VkResult pipeline_create_info_init(struct intel_pipeline_create_info *info,
1179 const VkGraphicsPipelineCreateInfo *vkinfo)
Chia-I Wu3efef432014-08-28 15:00:16 +08001180{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001181 memset(info, 0, sizeof(*info));
Chia-I Wu3efef432014-08-28 15:00:16 +08001182
Tony Barbourfa6cac72015-01-16 14:27:35 -07001183 /*
1184 * Do we need to set safe defaults in case the app doesn't provide all of
1185 * the necessary create infos?
1186 */
Tony Barboure094edf2015-06-26 10:18:34 -06001187 info->ms.rasterSamples = 1;
Tony Barbourfa6cac72015-01-16 14:27:35 -07001188 info->ms.sampleMask = 1;
1189
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001190 memcpy(&info->graphics, vkinfo, sizeof (info->graphics));
Chia-I Wu3efef432014-08-28 15:00:16 +08001191
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001192 void *dst;
1193 for (uint32_t i = 0; i < vkinfo->stageCount; i++) {
1194 const VkPipelineShaderStageCreateInfo *thisStage = &vkinfo->pStages[i];
1195 switch (thisStage->stage) {
1196 case VK_SHADER_STAGE_VERTEX:
1197 dst = &info->vs;
1198 break;
1199 case VK_SHADER_STAGE_TESS_CONTROL:
1200 dst = &info->tcs;
1201 break;
1202 case VK_SHADER_STAGE_TESS_EVALUATION:
1203 dst = &info->tes;
1204 break;
1205 case VK_SHADER_STAGE_GEOMETRY:
1206 dst = &info->gs;
1207 break;
1208 case VK_SHADER_STAGE_FRAGMENT:
1209 dst = &info->fs;
1210 break;
1211 case VK_SHADER_STAGE_COMPUTE:
1212 dst = &info->compute;
1213 break;
1214 default:
1215 return VK_ERROR_BAD_PIPELINE_DATA;
1216 break;
Chia-I Wu3efef432014-08-28 15:00:16 +08001217 }
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001218 memcpy(dst, thisStage, sizeof(VkPipelineShaderStageCreateInfo));
1219 }
Chia-I Wu3efef432014-08-28 15:00:16 +08001220
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001221 if (vkinfo->pVertexInputState != NULL) {
1222 memcpy(&info->vi, vkinfo->pVertexInputState, sizeof (info->vi));
1223 }
Tony Barboure307f582015-07-10 15:29:03 -06001224 if (vkinfo->pInputAssemblyState != NULL) {
1225 memcpy(&info->ia, vkinfo->pInputAssemblyState, sizeof (info->ia));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001226 }
Tony Barboure307f582015-07-10 15:29:03 -06001227 if (vkinfo->pDepthStencilState != NULL) {
1228 memcpy(&info->db, vkinfo->pDepthStencilState, sizeof (info->db));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001229 }
Tony Barboure307f582015-07-10 15:29:03 -06001230 if (vkinfo->pColorBlendState != NULL) {
1231 memcpy(&info->cb, vkinfo->pColorBlendState, sizeof (info->cb));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001232 }
Tony Barboure307f582015-07-10 15:29:03 -06001233 if (vkinfo->pRasterState != NULL) {
1234 memcpy(&info->rs, vkinfo->pRasterState, sizeof (info->rs));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001235 }
Tony Barboure307f582015-07-10 15:29:03 -06001236 if (vkinfo->pTessellationState != NULL) {
1237 memcpy(&info->tess, vkinfo->pTessellationState, sizeof (info->tess));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001238 }
Tony Barboure307f582015-07-10 15:29:03 -06001239 if (vkinfo->pMultisampleState != NULL) {
1240 memcpy(&info->ms, vkinfo->pMultisampleState, sizeof (info->ms));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001241 }
Tony Barboure307f582015-07-10 15:29:03 -06001242 if (vkinfo->pViewportState != NULL) {
1243 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001244 }
Tony Barboure307f582015-07-10 15:29:03 -06001245 if (vkinfo->pViewportState != NULL) {
1246 memcpy(&info->vp, vkinfo->pViewportState, sizeof (info->vp));
Chia-I Wu3efef432014-08-28 15:00:16 +08001247 }
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001248
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001249 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001250}
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001251
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001252static VkResult graphics_pipeline_create(struct intel_dev *dev,
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001253 const VkGraphicsPipelineCreateInfo *info_,
1254 struct intel_pipeline **pipeline_ret)
Chia-I Wu3efef432014-08-28 15:00:16 +08001255{
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001256 struct intel_pipeline_create_info info;
Chia-I Wu3efef432014-08-28 15:00:16 +08001257 struct intel_pipeline *pipeline;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001258 VkResult ret;
Chia-I Wu3efef432014-08-28 15:00:16 +08001259
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -06001260 ret = pipeline_create_info_init(&info, info_);
1261
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001262 if (ret != VK_SUCCESS)
Chia-I Wu3efef432014-08-28 15:00:16 +08001263 return ret;
1264
Chia-I Wu545c2e12015-02-22 13:19:54 +08001265 pipeline = (struct intel_pipeline *) intel_base_create(&dev->base.handle,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001266 sizeof (*pipeline), dev->base.dbg,
1267 VK_OBJECT_TYPE_PIPELINE, info_, 0);
Chia-I Wu3efef432014-08-28 15:00:16 +08001268 if (!pipeline)
Tony Barbour8205d902015-04-16 15:59:00 -06001269 return VK_ERROR_OUT_OF_HOST_MEMORY;
Chia-I Wu3efef432014-08-28 15:00:16 +08001270
1271 pipeline->dev = dev;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001272 pipeline->pipeline_layout = intel_pipeline_layout(info.graphics.layout);
Chia-I Wudf601c42015-04-17 01:58:07 +08001273
Chia-I Wu3efef432014-08-28 15:00:16 +08001274 pipeline->obj.destroy = pipeline_destroy;
Chia-I Wu3efef432014-08-28 15:00:16 +08001275
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001276 ret = pipeline_build_all(pipeline, &info);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001277 if (ret == VK_SUCCESS)
Chia-I Wuf90ff0c2014-09-02 09:32:46 +08001278 ret = pipeline_validate(pipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001279 if (ret != VK_SUCCESS) {
Chia-I Wu3efef432014-08-28 15:00:16 +08001280 pipeline_destroy(&pipeline->obj);
1281 return ret;
1282 }
1283
Tony Barbour2094dc72015-07-09 15:26:32 -06001284 VkMemoryAllocInfo mem_reqs;
1285 mem_reqs.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO;
1286 mem_reqs.allocationSize = pipeline->scratch_size;
1287 mem_reqs.pNext = NULL;
1288 mem_reqs.memoryTypeIndex = 0;
1289 intel_mem_alloc(dev, &mem_reqs, &pipeline->obj.mem);
1290
Chia-I Wu3efef432014-08-28 15:00:16 +08001291 *pipeline_ret = pipeline;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001292 return VK_SUCCESS;
Chia-I Wu3efef432014-08-28 15:00:16 +08001293}
1294
Jon Ashburn0d60d272015-07-09 15:02:25 -06001295ICD_EXPORT VkResult VKAPI vkCreatePipelineCache(
1296 VkDevice device,
1297 const VkPipelineCacheCreateInfo* pCreateInfo,
1298 VkPipelineCache* pPipelineCache)
Chia-I Wu3efef432014-08-28 15:00:16 +08001299{
Chia-I Wu3efef432014-08-28 15:00:16 +08001300
Jon Ashburn0d60d272015-07-09 15:02:25 -06001301 // non-dispatchable objects only need to be 64 bits currently
1302 *((uint64_t *)pPipelineCache) = 1;
1303 return VK_SUCCESS;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001304}
1305
Jon Ashburn0d60d272015-07-09 15:02:25 -06001306VkResult VKAPI vkDestroyPipelineCache(
1307 VkDevice device,
1308 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001309{
Jon Ashburn0d60d272015-07-09 15:02:25 -06001310 return VK_SUCCESS;
Courtney Goeltzenleuchter32876a12015-03-25 15:37:49 -06001311}
1312
Jon Ashburn0d60d272015-07-09 15:02:25 -06001313ICD_EXPORT size_t VKAPI vkGetPipelineCacheSize(
1314 VkDevice device,
1315 VkPipelineCache pipelineCache)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001316{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001317 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001318}
1319
Jon Ashburn0d60d272015-07-09 15:02:25 -06001320ICD_EXPORT VkResult VKAPI vkGetPipelineCacheData(
1321 VkDevice device,
1322 VkPipelineCache pipelineCache,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001323 void* pData)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001324{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001325 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001326}
1327
Jon Ashburn0d60d272015-07-09 15:02:25 -06001328ICD_EXPORT VkResult VKAPI vkMergePipelineCaches(
1329 VkDevice device,
1330 VkPipelineCache destCache,
1331 uint32_t srcCacheCount,
1332 const VkPipelineCache* pSrcCaches)
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 vkCreateGraphicsPipelines(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001338 VkDevice device,
Jon Ashburn0d60d272015-07-09 15:02:25 -06001339 VkPipelineCache pipelineCache,
1340 uint32_t count,
1341 const VkGraphicsPipelineCreateInfo* pCreateInfos,
1342 VkPipeline* pPipelines)
1343{
1344 struct intel_dev *dev = intel_dev(device);
1345 uint32_t i;
1346 VkResult res;
1347 bool one_succeeded = false;
1348
1349 for (i = 0; i < count; i++) {
1350 res = graphics_pipeline_create(dev, &(pCreateInfos[i]),
1351 (struct intel_pipeline **) &(pPipelines[i]));
1352 //return NULL handle for unsuccessful creates
1353 if (res != VK_SUCCESS)
Tony Barbourde4124d2015-07-03 10:33:54 -06001354 pPipelines[i].handle = 0;
Jon Ashburn0d60d272015-07-09 15:02:25 -06001355 else
1356 one_succeeded = true;
1357 }
1358 //return VK_SUCCESS if any of count creates succeeded
1359 if (one_succeeded)
1360 return VK_SUCCESS;
1361 else
1362 return res;
1363}
1364
1365ICD_EXPORT VkResult VKAPI vkCreateComputePipelines(
1366 VkDevice device,
1367 VkPipelineCache pipelineCache,
1368 uint32_t count,
1369 const VkComputePipelineCreateInfo* pCreateInfos,
1370 VkPipeline* pPipelines)
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001371{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001372 return VK_ERROR_UNAVAILABLE;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001373}
Tony Barbourde4124d2015-07-03 10:33:54 -06001374
1375ICD_EXPORT VkResult VKAPI vkDestroyPipeline(
1376 VkDevice device,
1377 VkPipeline pipeline)
1378
1379 {
1380 struct intel_obj *obj = intel_obj(pipeline.handle);
1381
Tony Barbour2094dc72015-07-09 15:26:32 -06001382 intel_mem_free(obj->mem);
Tony Barbourde4124d2015-07-03 10:33:54 -06001383 obj->destroy(obj);
1384 return VK_SUCCESS;
1385 }