blob: 2ccecce11dfcabf712169d2ae3efb47a2751ba6d [file] [log] [blame]
Chia-I Wu1f7540b2014-08-22 13:56:18 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu1f7540b2014-08-22 13:56:18 +080026 */
27
Chia-I Wu98824592014-09-02 09:42:46 +080028#include "shader.h"
Chia-I Wu1f7540b2014-08-22 13:56:18 +080029#include "pipeline_priv.h"
Cody Northropbc851432014-09-23 10:06:32 -060030#include "compiler/pipeline/pipeline_compiler_interface.h"
Chia-I Wu1f7540b2014-08-22 13:56:18 +080031
Chia-I Wu20983762014-09-02 12:07:28 +080032static struct intel_pipeline_rmap_slot *rmap_get_slot(struct intel_pipeline_rmap *rmap,
33 XGL_DESCRIPTOR_SET_SLOT_TYPE type,
34 XGL_UINT index)
Chia-I Wu1f7540b2014-08-22 13:56:18 +080035{
36 const XGL_UINT resource_offset = rmap->rt_count;
37 const XGL_UINT uav_offset = resource_offset + rmap->resource_count;
38 const XGL_UINT sampler_offset = uav_offset + rmap->uav_count;
Chia-I Wu1d125092014-10-08 08:49:38 +080039 const XGL_UINT ve_offset = sampler_offset + rmap->sampler_count;
Chia-I Wu20983762014-09-02 12:07:28 +080040 struct intel_pipeline_rmap_slot *slot;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080041
42 switch (type) {
43 case XGL_SLOT_UNUSED:
44 slot = NULL;
45 break;
46 case XGL_SLOT_SHADER_RESOURCE:
47 slot = &rmap->slots[resource_offset + index];
48 break;
49 case XGL_SLOT_SHADER_UAV:
50 slot = &rmap->slots[uav_offset + index];
51 break;
52 case XGL_SLOT_SHADER_SAMPLER:
53 slot = &rmap->slots[sampler_offset + index];
54 break;
Chia-I Wu1d125092014-10-08 08:49:38 +080055 case XGL_SLOT_VERTEX_INPUT:
56 slot = &rmap->slots[ve_offset + index];
57 break;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080058 default:
59 assert(!"unknown rmap slot type");
60 slot = NULL;
61 break;
62 }
63
64 return slot;
65}
66
Chia-I Wu20983762014-09-02 12:07:28 +080067static bool rmap_init_slots_with_path(struct intel_pipeline_rmap *rmap,
Chia-I Wu1f7540b2014-08-22 13:56:18 +080068 const XGL_DESCRIPTOR_SET_MAPPING *mapping,
69 XGL_UINT *nest_path,
70 XGL_UINT nest_level)
71{
72 XGL_UINT i;
73
74 for (i = 0; i < mapping->descriptorCount; i++) {
75 const XGL_DESCRIPTOR_SLOT_INFO *info = &mapping->pDescriptorInfo[i];
Chia-I Wu20983762014-09-02 12:07:28 +080076 struct intel_pipeline_rmap_slot *slot;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080077
78 if (info->slotObjectType == XGL_SLOT_NEXT_DESCRIPTOR_SET) {
79 nest_path[nest_level] = i;
80 if (!rmap_init_slots_with_path(rmap, info->pNextLevelSet,
81 nest_path, nest_level + 1))
82 return false;
83
84 continue;
85 }
86
87 slot = rmap_get_slot(rmap, info->slotObjectType,
88 info->shaderEntityIndex);
89 if (!slot)
90 continue;
91
92 assert(!slot->path_len);
93 slot->path_len = nest_level + 1;
94
95 if (nest_level) {
96 slot->u.path = icd_alloc(sizeof(slot->u.path[0]) *
97 slot->path_len, 0, XGL_SYSTEM_ALLOC_INTERNAL);
98 if (!slot->u.path) {
99 slot->path_len = 0;
100 return false;
101 }
102
103 memcpy(slot->u.path, nest_path,
104 sizeof(slot->u.path[0]) * nest_level);
105 slot->u.path[nest_level] = i;
106 } else {
107 slot->u.index = i;
108 }
109 }
110
111 return true;
112}
113
Chia-I Wu20983762014-09-02 12:07:28 +0800114static bool rmap_init_slots(struct intel_pipeline_rmap *rmap,
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800115 const XGL_DESCRIPTOR_SET_MAPPING *mapping,
116 XGL_UINT depth)
117{
118 XGL_UINT *nest_path;
119 bool ok;
120
121 if (depth) {
122 nest_path = icd_alloc(sizeof(nest_path[0]) * depth,
123 0, XGL_SYSTEM_ALLOC_INTERNAL_TEMP);
124 if (!nest_path)
125 return false;
126 } else {
127 nest_path = NULL;
128 }
129
130 ok = rmap_init_slots_with_path(rmap, mapping, nest_path, 0);
131
132 if (nest_path)
133 icd_free(nest_path);
134
135 return ok;
136}
137
Chia-I Wu20983762014-09-02 12:07:28 +0800138static void rmap_update_count(struct intel_pipeline_rmap *rmap,
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800139 XGL_DESCRIPTOR_SET_SLOT_TYPE type,
140 XGL_UINT index)
141{
142 switch (type) {
143 case XGL_SLOT_UNUSED:
144 break;
145 case XGL_SLOT_SHADER_RESOURCE:
146 if (rmap->resource_count < index + 1)
147 rmap->resource_count = index + 1;
148 break;
149 case XGL_SLOT_SHADER_UAV:
150 if (rmap->uav_count < index + 1)
151 rmap->uav_count = index + 1;
152 break;
153 case XGL_SLOT_SHADER_SAMPLER:
154 if (rmap->sampler_count < index + 1)
155 rmap->sampler_count = index + 1;
156 break;
Chia-I Wu1d125092014-10-08 08:49:38 +0800157 case XGL_SLOT_VERTEX_INPUT:
158 if (rmap->vb_count < index + 1)
159 rmap->vb_count = index + 1;
160 break;
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800161 default:
162 assert(!"unknown rmap slot type");
163 break;
164 }
165}
166
Chia-I Wu20983762014-09-02 12:07:28 +0800167static XGL_UINT rmap_init_counts(struct intel_pipeline_rmap *rmap,
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800168 const XGL_DESCRIPTOR_SET_MAPPING *mapping)
169{
170 XGL_UINT depth = 0;
171 XGL_UINT i;
172
173 for (i = 0; i < mapping->descriptorCount; i++) {
174 const XGL_DESCRIPTOR_SLOT_INFO *info = &mapping->pDescriptorInfo[i];
175
176 if (info->slotObjectType == XGL_SLOT_NEXT_DESCRIPTOR_SET) {
177 const XGL_UINT d = rmap_init_counts(rmap,
178 info->pNextLevelSet);
179 if (depth < d + 1)
180 depth = d + 1;
181
182 continue;
183 }
184
185 rmap_update_count(rmap, info->slotObjectType,
186 info->shaderEntityIndex);
187 }
188
189 return depth;
190}
191
Chia-I Wu20983762014-09-02 12:07:28 +0800192static void rmap_destroy(struct intel_pipeline_rmap *rmap)
Chia-I Wua6d50aa2014-09-02 10:21:34 +0800193{
194 XGL_UINT i;
195
196 for (i = 0; i < rmap->slot_count; i++) {
Chia-I Wu20983762014-09-02 12:07:28 +0800197 struct intel_pipeline_rmap_slot *slot = &rmap->slots[i];
Chia-I Wua6d50aa2014-09-02 10:21:34 +0800198
199 switch (slot->path_len) {
200 case 0:
201 case 1:
Chia-I Wu20983762014-09-02 12:07:28 +0800202 case INTEL_PIPELINE_RMAP_SLOT_RT:
203 case INTEL_PIPELINE_RMAP_SLOT_DYN:
Chia-I Wua6d50aa2014-09-02 10:21:34 +0800204 break;
205 default:
206 icd_free(slot->u.path);
207 break;
208 }
209 }
210
211 icd_free(rmap->slots);
212 icd_free(rmap);
213}
214
Chia-I Wu20983762014-09-02 12:07:28 +0800215static struct intel_pipeline_rmap *rmap_create(struct intel_dev *dev,
216 const XGL_DESCRIPTOR_SET_MAPPING *mapping,
217 const XGL_DYNAMIC_MEMORY_VIEW_SLOT_INFO *dyn,
218 XGL_UINT rt_count)
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800219{
Chia-I Wu20983762014-09-02 12:07:28 +0800220 struct intel_pipeline_rmap *rmap;
221 struct intel_pipeline_rmap_slot *slot;
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800222 XGL_UINT depth, rt;
223
224 rmap = icd_alloc(sizeof(*rmap), 0, XGL_SYSTEM_ALLOC_INTERNAL);
225 if (!rmap)
226 return NULL;
227
228 memset(rmap, 0, sizeof(*rmap));
229
230 depth = rmap_init_counts(rmap, mapping);
231
232 /* add RTs and the dynamic memory view */
233 rmap_update_count(rmap, dyn->slotObjectType, dyn->shaderEntityIndex);
234 rmap->rt_count = rt_count;
235
236 rmap->slot_count = rmap->rt_count + rmap->resource_count +
Chia-I Wu1d125092014-10-08 08:49:38 +0800237 rmap->uav_count + rmap->sampler_count + rmap->vb_count;
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800238
239 rmap->slots = icd_alloc(sizeof(rmap->slots[0]) * rmap->slot_count,
240 0, XGL_SYSTEM_ALLOC_INTERNAL);
241 if (!rmap->slots) {
242 icd_free(rmap);
243 return NULL;
244 }
245
246 memset(rmap->slots, 0, sizeof(rmap->slots[0]) * rmap->slot_count);
247
248 if (!rmap_init_slots(rmap, mapping, depth)) {
Chia-I Wua6d50aa2014-09-02 10:21:34 +0800249 rmap_destroy(rmap);
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800250 return NULL;
251 }
252
253 /* add RTs and the dynamic memory view */
254 slot = rmap_get_slot(rmap, dyn->slotObjectType, dyn->shaderEntityIndex);
255 if (slot) {
Chia-I Wu20983762014-09-02 12:07:28 +0800256 slot->path_len = INTEL_PIPELINE_RMAP_SLOT_DYN;
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800257 slot->u.index = 0;
258 }
259 for (rt = 0; rt < rmap->rt_count; rt++) {
260 slot = &rmap->slots[rt];
Chia-I Wu20983762014-09-02 12:07:28 +0800261 slot->path_len = INTEL_PIPELINE_RMAP_SLOT_RT;
Chia-I Wu1f7540b2014-08-22 13:56:18 +0800262 slot->u.index = rt;
263 }
264
265 return rmap;
266}
267
Chia-I Wu39026c92014-09-02 10:03:19 +0800268static XGL_RESULT pipeline_build_vs(struct intel_pipeline *pipeline,
269 const struct intel_pipeline_create_info *info)
270{
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800271 struct intel_pipeline_shader *vs = &pipeline->vs;
Chia-I Wu39026c92014-09-02 10:03:19 +0800272 XGL_RESULT ret;
273
Chia-I Wu46809782014-10-07 15:40:38 +0800274 assert(!info->vs.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800275
Cody Northrop83e2b032014-09-25 17:00:31 -0600276 // Right here, lower the IR to ISA using NOS
277 // This must be after assignment of pipeline constant buffer
Chia-I Wu714f0a32014-10-11 14:08:15 +0800278 ret = intel_pipeline_shader_compile(vs, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800279 intel_shader(info->vs.shader)->ir);
Cody Northrop83e2b032014-09-25 17:00:31 -0600280 if (ret != XGL_SUCCESS)
281 return ret;
282
Chia-I Wu39026c92014-09-02 10:03:19 +0800283 vs->rmap = rmap_create(pipeline->dev,
284 &info->vs.descriptorSetMapping[0],
285 &info->vs.dynamicMemoryViewMapping, 0);
286 if (!vs->rmap) {
287 icd_free(vs->pCode);
288 return XGL_ERROR_OUT_OF_MEMORY;
Chia-I Wu98824592014-09-02 09:42:46 +0800289 }
290
Chia-I Wu39026c92014-09-02 10:03:19 +0800291 pipeline->active_shaders |= SHADER_VERTEX_FLAG;
292
293 return XGL_SUCCESS;
294}
295
296static XGL_RESULT pipeline_build_tcs(struct intel_pipeline *pipeline,
297 const struct intel_pipeline_create_info *info)
298{
Chia-I Wu95959fb2014-09-02 11:01:03 +0800299 struct intel_pipeline_shader *tcs = &pipeline->tcs;
Chia-I Wu39026c92014-09-02 10:03:19 +0800300 XGL_RESULT ret;
301
Chia-I Wu714f0a32014-10-11 14:08:15 +0800302 ret = intel_pipeline_shader_compile(tcs, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800303 intel_shader(info->tcs.shader)->ir);
Chia-I Wu39026c92014-09-02 10:03:19 +0800304 if (ret != XGL_SUCCESS)
305 return ret;
306
Chia-I Wu46809782014-10-07 15:40:38 +0800307 assert(!info->tcs.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800308
Chia-I Wu39026c92014-09-02 10:03:19 +0800309 pipeline->active_shaders |= SHADER_TESS_CONTROL_FLAG;
310
311 return XGL_SUCCESS;
312}
313
314static XGL_RESULT pipeline_build_tes(struct intel_pipeline *pipeline,
315 const struct intel_pipeline_create_info *info)
316{
Chia-I Wu95959fb2014-09-02 11:01:03 +0800317 struct intel_pipeline_shader *tes = &pipeline->tes;
Chia-I Wu39026c92014-09-02 10:03:19 +0800318 XGL_RESULT ret;
319
Chia-I Wu714f0a32014-10-11 14:08:15 +0800320 ret = intel_pipeline_shader_compile(tes, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800321 intel_shader(info->tes.shader)->ir);
Chia-I Wu39026c92014-09-02 10:03:19 +0800322 if (ret != XGL_SUCCESS)
323 return ret;
324
Chia-I Wu46809782014-10-07 15:40:38 +0800325 assert(!info->tes.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800326
Chia-I Wu39026c92014-09-02 10:03:19 +0800327 pipeline->active_shaders |= SHADER_TESS_EVAL_FLAG;
328
329 return XGL_SUCCESS;
330}
331
332static XGL_RESULT pipeline_build_gs(struct intel_pipeline *pipeline,
333 const struct intel_pipeline_create_info *info)
334{
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800335 struct intel_pipeline_shader *gs = &pipeline->gs;
Chia-I Wu39026c92014-09-02 10:03:19 +0800336 XGL_RESULT ret;
337
Chia-I Wu714f0a32014-10-11 14:08:15 +0800338 ret = intel_pipeline_shader_compile(gs, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800339 intel_shader(info->gs.shader)->ir);
Chia-I Wu39026c92014-09-02 10:03:19 +0800340 if (ret != XGL_SUCCESS)
341 return ret;
342
Chia-I Wu46809782014-10-07 15:40:38 +0800343 assert(!info->tes.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800344
Chia-I Wu39026c92014-09-02 10:03:19 +0800345 pipeline->active_shaders |= SHADER_GEOMETRY_FLAG;
346
347 return XGL_SUCCESS;
348}
349
350static XGL_RESULT pipeline_build_fs(struct intel_pipeline *pipeline,
351 const struct intel_pipeline_create_info *info)
352{
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800353 struct intel_pipeline_shader *fs = &pipeline->fs;
Chia-I Wu39026c92014-09-02 10:03:19 +0800354 XGL_RESULT ret;
355
Chia-I Wu46809782014-10-07 15:40:38 +0800356 assert(!info->fs.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800357
Cody Northropbc851432014-09-23 10:06:32 -0600358 // Right here, lower the IR to ISA using NOS
Cody Northrop83e2b032014-09-25 17:00:31 -0600359 // This must be after assignment of pipeline constant buffer
Chia-I Wu714f0a32014-10-11 14:08:15 +0800360 ret = intel_pipeline_shader_compile(fs, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800361 intel_shader(info->fs.shader)->ir);
Cody Northropbc851432014-09-23 10:06:32 -0600362 if (ret != XGL_SUCCESS)
363 return ret;
364
Chia-I Wu39026c92014-09-02 10:03:19 +0800365 /* assuming one RT; need to parse the shader */
366 fs->rmap = rmap_create(pipeline->dev,
367 &info->fs.descriptorSetMapping[0],
368 &info->fs.dynamicMemoryViewMapping, 1);
369 if (!fs->rmap) {
370 icd_free(fs->pCode);
371 return XGL_ERROR_OUT_OF_MEMORY;
372 }
373
Chia-I Wu39026c92014-09-02 10:03:19 +0800374 pipeline->active_shaders |= SHADER_FRAGMENT_FLAG;
375
376 return XGL_SUCCESS;
377}
378
379static XGL_RESULT pipeline_build_cs(struct intel_pipeline *pipeline,
380 const struct intel_pipeline_create_info *info)
381{
Chia-I Wu95959fb2014-09-02 11:01:03 +0800382 struct intel_pipeline_shader *cs = &pipeline->cs;
Chia-I Wu39026c92014-09-02 10:03:19 +0800383 XGL_RESULT ret;
384
Chia-I Wu714f0a32014-10-11 14:08:15 +0800385 ret = intel_pipeline_shader_compile(cs, pipeline->dev->gpu,
Chia-I Wua4d1b392014-10-10 13:57:29 +0800386 intel_shader(info->compute.cs.shader)->ir);
Chia-I Wu39026c92014-09-02 10:03:19 +0800387 if (ret != XGL_SUCCESS)
388 return ret;
389
Chia-I Wu46809782014-10-07 15:40:38 +0800390 assert(!info->compute.cs.linkConstBufferCount);
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800391
Chia-I Wu39026c92014-09-02 10:03:19 +0800392 pipeline->active_shaders |= SHADER_COMPUTE_FLAG;
393
Chia-I Wu98824592014-09-02 09:42:46 +0800394 return XGL_SUCCESS;
395}
396
397XGL_RESULT pipeline_build_shaders(struct intel_pipeline *pipeline,
398 const struct intel_pipeline_create_info *info)
399{
400 XGL_RESULT ret = XGL_SUCCESS;
401
402 if (ret == XGL_SUCCESS && info->vs.shader)
Chia-I Wu39026c92014-09-02 10:03:19 +0800403 ret = pipeline_build_vs(pipeline, info);
Chia-I Wu98824592014-09-02 09:42:46 +0800404 if (ret == XGL_SUCCESS && info->tcs.shader)
Chia-I Wu39026c92014-09-02 10:03:19 +0800405 ret = pipeline_build_tcs(pipeline, info);
Chia-I Wu98824592014-09-02 09:42:46 +0800406 if (ret == XGL_SUCCESS && info->tes.shader)
Chia-I Wu39026c92014-09-02 10:03:19 +0800407 ret = pipeline_build_tes(pipeline, info);
Chia-I Wu98824592014-09-02 09:42:46 +0800408 if (ret == XGL_SUCCESS && info->gs.shader)
Chia-I Wu39026c92014-09-02 10:03:19 +0800409 ret = pipeline_build_gs(pipeline, info);
Chia-I Wu98824592014-09-02 09:42:46 +0800410 if (ret == XGL_SUCCESS && info->fs.shader)
Chia-I Wu39026c92014-09-02 10:03:19 +0800411 ret = pipeline_build_fs(pipeline, info);
412
413 if (ret == XGL_SUCCESS && info->compute.cs.shader)
414 ret = pipeline_build_cs(pipeline, info);
Chia-I Wu98824592014-09-02 09:42:46 +0800415
416 return ret;
417}
418
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800419static void pipeline_tear_shader(struct intel_pipeline_shader *sh)
Chia-I Wu39026c92014-09-02 10:03:19 +0800420{
421 icd_free(sh->pCode);
422 if (sh->rmap)
423 rmap_destroy(sh->rmap);
424}
425
Chia-I Wu98824592014-09-02 09:42:46 +0800426void pipeline_tear_shaders(struct intel_pipeline *pipeline)
427{
428 if (pipeline->active_shaders & SHADER_VERTEX_FLAG) {
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800429 pipeline_tear_shader(&pipeline->vs);
Chia-I Wu98824592014-09-02 09:42:46 +0800430 }
431
Chia-I Wu39026c92014-09-02 10:03:19 +0800432 if (pipeline->active_shaders & SHADER_TESS_CONTROL_FLAG) {
Chia-I Wu95959fb2014-09-02 11:01:03 +0800433 pipeline_tear_shader(&pipeline->tcs);
Chia-I Wu39026c92014-09-02 10:03:19 +0800434 }
435
436 if (pipeline->active_shaders & SHADER_TESS_EVAL_FLAG) {
Chia-I Wu95959fb2014-09-02 11:01:03 +0800437 pipeline_tear_shader(&pipeline->tes);
Chia-I Wu39026c92014-09-02 10:03:19 +0800438 }
439
440 if (pipeline->active_shaders & SHADER_GEOMETRY_FLAG) {
441 pipeline_tear_shader(&pipeline->gs);
442 }
443
444 if (pipeline->active_shaders & SHADER_FRAGMENT_FLAG) {
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800445 pipeline_tear_shader(&pipeline->fs);
Chia-I Wu39026c92014-09-02 10:03:19 +0800446 }
447
448 if (pipeline->active_shaders & SHADER_COMPUTE_FLAG) {
Chia-I Wu95959fb2014-09-02 11:01:03 +0800449 pipeline_tear_shader(&pipeline->cs);
Chia-I Wu39026c92014-09-02 10:03:19 +0800450 }
Chia-I Wu98824592014-09-02 09:42:46 +0800451}
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800452
453struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
454 enum intel_dev_meta_shader id)
455{
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800456 struct intel_pipeline_shader *sh;
Chia-I Wu005c47c2014-10-22 13:49:13 +0800457 XGL_RESULT ret;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800458
459 sh = icd_alloc(sizeof(*sh), 0, XGL_SYSTEM_ALLOC_INTERNAL);
460 if (!sh)
461 return NULL;
462 memset(sh, 0, sizeof(*sh));
463
Chia-I Wu005c47c2014-10-22 13:49:13 +0800464 ret = intel_pipeline_shader_compile_meta(sh, dev->gpu, id);
465 if (ret != XGL_SUCCESS) {
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800466 icd_free(sh);
467 return NULL;
468 }
469
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800470 return sh;
471}
472
473void intel_pipeline_shader_destroy(struct intel_pipeline_shader *sh)
474{
475 if (sh->rmap)
476 rmap_destroy(sh->rmap);
477 if (sh->pCode)
478 icd_free(sh->pCode);
479 icd_free(sh);
480}