2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include "anv_private.h"
33 #include "glsl/nir/spirv/nir_spirv.h"
35 /* Needed for SWIZZLE macros */
36 #include "program/prog_instruction.h"
40 VkResult
anv_CreateShaderModule(
42 const VkShaderModuleCreateInfo
* pCreateInfo
,
43 const VkAllocationCallbacks
* pAllocator
,
44 VkShaderModule
* pShaderModule
)
46 ANV_FROM_HANDLE(anv_device
, device
, _device
);
47 struct anv_shader_module
*module
;
49 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
);
50 assert(pCreateInfo
->flags
== 0);
52 module
= anv_alloc2(&device
->alloc
, pAllocator
,
53 sizeof(*module
) + pCreateInfo
->codeSize
, 8,
54 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
56 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
59 module
->size
= pCreateInfo
->codeSize
;
60 memcpy(module
->data
, pCreateInfo
->pCode
, module
->size
);
62 *pShaderModule
= anv_shader_module_to_handle(module
);
67 void anv_DestroyShaderModule(
69 VkShaderModule _module
,
70 const VkAllocationCallbacks
* pAllocator
)
72 ANV_FROM_HANDLE(anv_device
, device
, _device
);
73 ANV_FROM_HANDLE(anv_shader_module
, module
, _module
);
75 anv_free2(&device
->alloc
, pAllocator
, module
);
78 #define SPIR_V_MAGIC_NUMBER 0x07230203
80 /* Eventually, this will become part of anv_CreateShader. Unfortunately,
81 * we can't do that yet because we don't have the ability to copy nir.
84 anv_shader_compile_to_nir(struct anv_device
*device
,
85 struct anv_shader_module
*module
,
86 const char *entrypoint_name
,
87 gl_shader_stage stage
)
89 if (strcmp(entrypoint_name
, "main") != 0) {
90 anv_finishme("Multiple shaders per module not really supported");
93 const struct brw_compiler
*compiler
=
94 device
->instance
->physicalDevice
.compiler
;
95 const nir_shader_compiler_options
*nir_options
=
96 compiler
->glsl_compiler_options
[stage
].NirOptions
;
99 nir_function
*entry_point
;
101 /* Some things such as our meta clear/blit code will give us a NIR
102 * shader directly. In that case, we just ignore the SPIR-V entirely
103 * and just use the NIR shader */
105 nir
->options
= nir_options
;
106 nir_validate_shader(nir
);
108 assert(exec_list_length(&nir
->functions
) == 1);
109 struct exec_node
*node
= exec_list_get_head(&nir
->functions
);
110 entry_point
= exec_node_data(nir_function
, node
, node
);
112 uint32_t *spirv
= (uint32_t *) module
->data
;
113 assert(spirv
[0] == SPIR_V_MAGIC_NUMBER
);
114 assert(module
->size
% 4 == 0);
116 entry_point
= spirv_to_nir(spirv
, module
->size
/ 4, entrypoint_name
,
118 nir
= entry_point
->shader
;
119 assert(nir
->stage
== stage
);
120 nir_validate_shader(nir
);
122 nir_lower_returns(nir
);
123 nir_validate_shader(nir
);
125 nir_inline_functions(nir
);
126 nir_validate_shader(nir
);
128 nir_lower_system_values(nir
);
129 nir_validate_shader(nir
);
132 /* Vulkan uses the separate-shader linking model */
133 nir
->info
.separate_shader
= true;
135 /* Pick off the single entrypoint that we want */
136 foreach_list_typed_safe(nir_function
, func
, node
, &nir
->functions
) {
137 if (func
!= entry_point
)
138 exec_node_remove(&func
->node
);
140 assert(exec_list_length(&nir
->functions
) == 1);
142 nir
= brw_preprocess_nir(nir
, compiler
->scalar_stage
[stage
]);
144 nir_shader_gather_info(nir
, entry_point
->impl
);
150 anv_pipeline_cache_init(struct anv_pipeline_cache
*cache
,
151 struct anv_device
*device
)
153 cache
->device
= device
;
154 anv_state_stream_init(&cache
->program_stream
,
155 &device
->instruction_block_pool
);
156 pthread_mutex_init(&cache
->mutex
, NULL
);
160 anv_pipeline_cache_finish(struct anv_pipeline_cache
*cache
)
162 anv_state_stream_finish(&cache
->program_stream
);
163 pthread_mutex_destroy(&cache
->mutex
);
167 anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache
*cache
,
168 const void *data
, size_t size
)
170 pthread_mutex_lock(&cache
->mutex
);
172 struct anv_state state
=
173 anv_state_stream_alloc(&cache
->program_stream
, size
, 64);
175 pthread_mutex_unlock(&cache
->mutex
);
177 assert(size
< cache
->program_stream
.block_pool
->block_size
);
179 memcpy(state
.map
, data
, size
);
181 if (!cache
->device
->info
.has_llc
)
182 anv_state_clflush(state
);
187 VkResult
anv_CreatePipelineCache(
189 const VkPipelineCacheCreateInfo
* pCreateInfo
,
190 const VkAllocationCallbacks
* pAllocator
,
191 VkPipelineCache
* pPipelineCache
)
193 ANV_FROM_HANDLE(anv_device
, device
, _device
);
194 struct anv_pipeline_cache
*cache
;
196 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO
);
197 assert(pCreateInfo
->flags
== 0);
199 cache
= anv_alloc2(&device
->alloc
, pAllocator
,
201 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
203 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
205 anv_pipeline_cache_init(cache
, device
);
207 *pPipelineCache
= anv_pipeline_cache_to_handle(cache
);
212 void anv_DestroyPipelineCache(
214 VkPipelineCache _cache
,
215 const VkAllocationCallbacks
* pAllocator
)
217 ANV_FROM_HANDLE(anv_device
, device
, _device
);
218 ANV_FROM_HANDLE(anv_pipeline_cache
, cache
, _cache
);
220 anv_pipeline_cache_finish(cache
);
222 anv_free2(&device
->alloc
, pAllocator
, cache
);
225 VkResult
anv_GetPipelineCacheData(
227 VkPipelineCache pipelineCache
,
236 VkResult
anv_MergePipelineCaches(
238 VkPipelineCache destCache
,
239 uint32_t srcCacheCount
,
240 const VkPipelineCache
* pSrcCaches
)
242 stub_return(VK_SUCCESS
);
245 void anv_DestroyPipeline(
247 VkPipeline _pipeline
,
248 const VkAllocationCallbacks
* pAllocator
)
250 ANV_FROM_HANDLE(anv_device
, device
, _device
);
251 ANV_FROM_HANDLE(anv_pipeline
, pipeline
, _pipeline
);
253 anv_reloc_list_finish(&pipeline
->batch_relocs
,
254 pAllocator
? pAllocator
: &device
->alloc
);
255 if (pipeline
->blend_state
.map
)
256 anv_state_pool_free(&device
->dynamic_state_pool
, pipeline
->blend_state
);
257 anv_free2(&device
->alloc
, pAllocator
, pipeline
);
260 static const uint32_t vk_to_gen_primitive_type
[] = {
261 [VK_PRIMITIVE_TOPOLOGY_POINT_LIST
] = _3DPRIM_POINTLIST
,
262 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST
] = _3DPRIM_LINELIST
,
263 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
] = _3DPRIM_LINESTRIP
,
264 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
] = _3DPRIM_TRILIST
,
265 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
] = _3DPRIM_TRISTRIP
,
266 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
] = _3DPRIM_TRIFAN
,
267 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY
] = _3DPRIM_LINELIST_ADJ
,
268 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY
] = _3DPRIM_LINESTRIP_ADJ
,
269 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY
] = _3DPRIM_TRILIST_ADJ
,
270 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY
] = _3DPRIM_TRISTRIP_ADJ
,
271 /* [VK_PRIMITIVE_TOPOLOGY_PATCH_LIST] = _3DPRIM_PATCHLIST_1 */
275 populate_sampler_prog_key(const struct brw_device_info
*devinfo
,
276 struct brw_sampler_prog_key_data
*key
)
278 /* XXX: Handle texture swizzle on HSW- */
279 for (int i
= 0; i
< MAX_SAMPLERS
; i
++) {
280 /* Assume color sampler, no swizzling. (Works for BDW+) */
281 key
->swizzles
[i
] = SWIZZLE_XYZW
;
286 populate_vs_prog_key(const struct brw_device_info
*devinfo
,
287 struct brw_vs_prog_key
*key
)
289 memset(key
, 0, sizeof(*key
));
291 populate_sampler_prog_key(devinfo
, &key
->tex
);
293 /* XXX: Handle vertex input work-arounds */
295 /* XXX: Handle sampler_prog_key */
299 populate_gs_prog_key(const struct brw_device_info
*devinfo
,
300 struct brw_gs_prog_key
*key
)
302 memset(key
, 0, sizeof(*key
));
304 populate_sampler_prog_key(devinfo
, &key
->tex
);
308 populate_wm_prog_key(const struct brw_device_info
*devinfo
,
309 const VkGraphicsPipelineCreateInfo
*info
,
310 struct brw_wm_prog_key
*key
)
312 ANV_FROM_HANDLE(anv_render_pass
, render_pass
, info
->renderPass
);
314 memset(key
, 0, sizeof(*key
));
316 populate_sampler_prog_key(devinfo
, &key
->tex
);
318 /* TODO: Fill out key->input_slots_valid */
320 /* Vulkan doesn't specify a default */
321 key
->high_quality_derivatives
= false;
323 /* XXX Vulkan doesn't appear to specify */
324 key
->clamp_fragment_color
= false;
326 /* Vulkan always specifies upper-left coordinates */
327 key
->drawable_height
= 0;
328 key
->render_to_fbo
= false;
330 key
->nr_color_regions
= render_pass
->subpasses
[info
->subpass
].color_count
;
332 key
->replicate_alpha
= key
->nr_color_regions
> 1 &&
333 info
->pMultisampleState
&&
334 info
->pMultisampleState
->alphaToCoverageEnable
;
336 if (info
->pMultisampleState
&& info
->pMultisampleState
->rasterizationSamples
> 1) {
337 /* We should probably pull this out of the shader, but it's fairly
338 * harmless to compute it and then let dead-code take care of it.
340 key
->persample_shading
= info
->pMultisampleState
->sampleShadingEnable
;
341 if (key
->persample_shading
)
342 key
->persample_2x
= info
->pMultisampleState
->rasterizationSamples
== 2;
344 key
->compute_pos_offset
= info
->pMultisampleState
->sampleShadingEnable
;
345 key
->compute_sample_id
= info
->pMultisampleState
->sampleShadingEnable
;
350 populate_cs_prog_key(const struct brw_device_info
*devinfo
,
351 struct brw_cs_prog_key
*key
)
353 memset(key
, 0, sizeof(*key
));
355 populate_sampler_prog_key(devinfo
, &key
->tex
);
359 anv_pipeline_compile(struct anv_pipeline
*pipeline
,
360 struct anv_shader_module
*module
,
361 const char *entrypoint
,
362 gl_shader_stage stage
,
363 struct brw_stage_prog_data
*prog_data
)
365 const struct brw_compiler
*compiler
=
366 pipeline
->device
->instance
->physicalDevice
.compiler
;
368 nir_shader
*nir
= anv_shader_compile_to_nir(pipeline
->device
,
369 module
, entrypoint
, stage
);
373 anv_nir_lower_push_constants(nir
, compiler
->scalar_stage
[stage
]);
375 /* Figure out the number of parameters */
376 prog_data
->nr_params
= 0;
378 if (nir
->num_uniforms
> 0) {
379 /* If the shader uses any push constants at all, we'll just give
380 * them the maximum possible number
382 prog_data
->nr_params
+= MAX_PUSH_CONSTANTS_SIZE
/ sizeof(float);
385 if (pipeline
->layout
&& pipeline
->layout
->stage
[stage
].has_dynamic_offsets
)
386 prog_data
->nr_params
+= MAX_DYNAMIC_BUFFERS
* 2;
388 if (pipeline
->layout
&& pipeline
->layout
->stage
[stage
].image_count
> 0)
389 prog_data
->nr_params
+= pipeline
->layout
->stage
[stage
].image_count
*
390 BRW_IMAGE_PARAM_SIZE
;
392 if (prog_data
->nr_params
> 0) {
393 /* XXX: I think we're leaking this */
394 prog_data
->param
= (const union gl_constant_value
**)
395 malloc(prog_data
->nr_params
* sizeof(union gl_constant_value
*));
397 /* We now set the param values to be offsets into a
398 * anv_push_constant_data structure. Since the compiler doesn't
399 * actually dereference any of the gl_constant_value pointers in the
400 * params array, it doesn't really matter what we put here.
402 struct anv_push_constants
*null_data
= NULL
;
403 if (nir
->num_uniforms
> 0) {
404 /* Fill out the push constants section of the param array */
405 for (unsigned i
= 0; i
< MAX_PUSH_CONSTANTS_SIZE
/ sizeof(float); i
++)
406 prog_data
->param
[i
] = (const union gl_constant_value
*)
407 &null_data
->client_data
[i
* sizeof(float)];
411 /* Set up dynamic offsets */
412 anv_nir_apply_dynamic_offsets(pipeline
, nir
, prog_data
);
414 /* Apply the actual pipeline layout to UBOs, SSBOs, and textures */
415 if (pipeline
->layout
)
416 anv_nir_apply_pipeline_layout(nir
, prog_data
, pipeline
->layout
);
418 /* All binding table offsets provided by apply_pipeline_layout() are
419 * relative to the start of the bindint table (plus MAX_RTS for VS).
423 case MESA_SHADER_FRAGMENT
:
426 case MESA_SHADER_COMPUTE
:
433 prog_data
->binding_table
.size_bytes
= 0;
434 prog_data
->binding_table
.texture_start
= bias
;
435 prog_data
->binding_table
.ubo_start
= bias
;
436 prog_data
->binding_table
.ssbo_start
= bias
;
437 prog_data
->binding_table
.image_start
= bias
;
439 /* Finish the optimization and compilation process */
440 nir
= brw_nir_lower_io(nir
, &pipeline
->device
->info
,
441 compiler
->scalar_stage
[stage
]);
443 /* nir_lower_io will only handle the push constants; we need to set this
444 * to the full number of possible uniforms.
446 nir
->num_uniforms
= prog_data
->nr_params
* 4;
452 anv_pipeline_add_compiled_stage(struct anv_pipeline
*pipeline
,
453 gl_shader_stage stage
,
454 struct brw_stage_prog_data
*prog_data
)
456 struct brw_device_info
*devinfo
= &pipeline
->device
->info
;
457 uint32_t max_threads
[] = {
458 [MESA_SHADER_VERTEX
] = devinfo
->max_vs_threads
,
459 [MESA_SHADER_TESS_CTRL
] = 0,
460 [MESA_SHADER_TESS_EVAL
] = 0,
461 [MESA_SHADER_GEOMETRY
] = devinfo
->max_gs_threads
,
462 [MESA_SHADER_FRAGMENT
] = devinfo
->max_wm_threads
,
463 [MESA_SHADER_COMPUTE
] = devinfo
->max_cs_threads
,
466 pipeline
->prog_data
[stage
] = prog_data
;
467 pipeline
->active_stages
|= mesa_to_vk_shader_stage(stage
);
468 pipeline
->scratch_start
[stage
] = pipeline
->total_scratch
;
469 pipeline
->total_scratch
=
470 align_u32(pipeline
->total_scratch
, 1024) +
471 prog_data
->total_scratch
* max_threads
[stage
];
475 anv_pipeline_compile_vs(struct anv_pipeline
*pipeline
,
476 struct anv_pipeline_cache
*cache
,
477 const VkGraphicsPipelineCreateInfo
*info
,
478 struct anv_shader_module
*module
,
479 const char *entrypoint
)
481 const struct brw_compiler
*compiler
=
482 pipeline
->device
->instance
->physicalDevice
.compiler
;
483 struct brw_vs_prog_data
*prog_data
= &pipeline
->vs_prog_data
;
484 struct brw_vs_prog_key key
;
486 populate_vs_prog_key(&pipeline
->device
->info
, &key
);
488 /* TODO: Look up shader in cache */
490 memset(prog_data
, 0, sizeof(*prog_data
));
492 nir_shader
*nir
= anv_pipeline_compile(pipeline
, module
, entrypoint
,
494 &prog_data
->base
.base
);
496 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
498 void *mem_ctx
= ralloc_context(NULL
);
500 if (module
->nir
== NULL
)
501 ralloc_steal(mem_ctx
, nir
);
503 prog_data
->inputs_read
= nir
->info
.inputs_read
;
504 pipeline
->writes_point_size
= nir
->info
.outputs_written
& VARYING_SLOT_PSIZ
;
506 brw_compute_vue_map(&pipeline
->device
->info
,
507 &prog_data
->base
.vue_map
,
508 nir
->info
.outputs_written
,
509 nir
->info
.separate_shader
);
512 const unsigned *shader_code
=
513 brw_compile_vs(compiler
, NULL
, mem_ctx
, &key
, prog_data
, nir
,
514 NULL
, false, -1, &code_size
, NULL
);
515 if (shader_code
== NULL
) {
516 ralloc_free(mem_ctx
);
517 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
520 const uint32_t offset
=
521 anv_pipeline_cache_upload_kernel(cache
, shader_code
, code_size
);
522 if (prog_data
->base
.dispatch_mode
== DISPATCH_MODE_SIMD8
) {
523 pipeline
->vs_simd8
= offset
;
524 pipeline
->vs_vec4
= NO_KERNEL
;
526 pipeline
->vs_simd8
= NO_KERNEL
;
527 pipeline
->vs_vec4
= offset
;
530 ralloc_free(mem_ctx
);
532 anv_pipeline_add_compiled_stage(pipeline
, MESA_SHADER_VERTEX
,
533 &prog_data
->base
.base
);
539 anv_pipeline_compile_gs(struct anv_pipeline
*pipeline
,
540 struct anv_pipeline_cache
*cache
,
541 const VkGraphicsPipelineCreateInfo
*info
,
542 struct anv_shader_module
*module
,
543 const char *entrypoint
)
545 const struct brw_compiler
*compiler
=
546 pipeline
->device
->instance
->physicalDevice
.compiler
;
547 struct brw_gs_prog_data
*prog_data
= &pipeline
->gs_prog_data
;
548 struct brw_gs_prog_key key
;
550 populate_gs_prog_key(&pipeline
->device
->info
, &key
);
552 /* TODO: Look up shader in cache */
554 memset(prog_data
, 0, sizeof(*prog_data
));
556 nir_shader
*nir
= anv_pipeline_compile(pipeline
, module
, entrypoint
,
557 MESA_SHADER_GEOMETRY
,
558 &prog_data
->base
.base
);
560 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
562 void *mem_ctx
= ralloc_context(NULL
);
564 if (module
->nir
== NULL
)
565 ralloc_steal(mem_ctx
, nir
);
567 brw_compute_vue_map(&pipeline
->device
->info
,
568 &prog_data
->base
.vue_map
,
569 nir
->info
.outputs_written
,
570 nir
->info
.separate_shader
);
573 const unsigned *shader_code
=
574 brw_compile_gs(compiler
, NULL
, mem_ctx
, &key
, prog_data
, nir
,
575 NULL
, -1, &code_size
, NULL
);
576 if (shader_code
== NULL
) {
577 ralloc_free(mem_ctx
);
578 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
582 pipeline
->gs_kernel
=
583 anv_pipeline_cache_upload_kernel(cache
, shader_code
, code_size
);
584 pipeline
->gs_vertex_count
= nir
->info
.gs
.vertices_in
;
586 ralloc_free(mem_ctx
);
588 anv_pipeline_add_compiled_stage(pipeline
, MESA_SHADER_GEOMETRY
,
589 &prog_data
->base
.base
);
595 anv_pipeline_compile_fs(struct anv_pipeline
*pipeline
,
596 struct anv_pipeline_cache
*cache
,
597 const VkGraphicsPipelineCreateInfo
*info
,
598 struct anv_shader_module
*module
,
599 const char *entrypoint
)
601 const struct brw_compiler
*compiler
=
602 pipeline
->device
->instance
->physicalDevice
.compiler
;
603 struct brw_wm_prog_data
*prog_data
= &pipeline
->wm_prog_data
;
604 struct brw_wm_prog_key key
;
606 populate_wm_prog_key(&pipeline
->device
->info
, info
, &key
);
608 if (pipeline
->use_repclear
)
609 key
.nr_color_regions
= 1;
611 /* TODO: Look up shader in cache */
613 memset(prog_data
, 0, sizeof(*prog_data
));
615 prog_data
->binding_table
.render_target_start
= 0;
617 nir_shader
*nir
= anv_pipeline_compile(pipeline
, module
, entrypoint
,
618 MESA_SHADER_FRAGMENT
,
621 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
623 void *mem_ctx
= ralloc_context(NULL
);
625 if (module
->nir
== NULL
)
626 ralloc_steal(mem_ctx
, nir
);
629 const unsigned *shader_code
=
630 brw_compile_fs(compiler
, NULL
, mem_ctx
, &key
, prog_data
, nir
,
631 NULL
, -1, -1, pipeline
->use_repclear
, &code_size
, NULL
);
632 if (shader_code
== NULL
) {
633 ralloc_free(mem_ctx
);
634 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
638 anv_pipeline_cache_upload_kernel(cache
, shader_code
, code_size
);
640 pipeline
->ps_simd8
= NO_KERNEL
;
642 pipeline
->ps_simd8
= offset
;
644 if (prog_data
->no_8
|| prog_data
->prog_offset_16
) {
645 pipeline
->ps_simd16
= offset
+ prog_data
->prog_offset_16
;
647 pipeline
->ps_simd16
= NO_KERNEL
;
650 pipeline
->ps_ksp2
= 0;
651 pipeline
->ps_grf_start2
= 0;
652 if (pipeline
->ps_simd8
!= NO_KERNEL
) {
653 pipeline
->ps_ksp0
= pipeline
->ps_simd8
;
654 pipeline
->ps_grf_start0
= prog_data
->base
.dispatch_grf_start_reg
;
655 if (pipeline
->ps_simd16
!= NO_KERNEL
) {
656 pipeline
->ps_ksp2
= pipeline
->ps_simd16
;
657 pipeline
->ps_grf_start2
= prog_data
->dispatch_grf_start_reg_16
;
659 } else if (pipeline
->ps_simd16
!= NO_KERNEL
) {
660 pipeline
->ps_ksp0
= pipeline
->ps_simd16
;
661 pipeline
->ps_grf_start0
= prog_data
->dispatch_grf_start_reg_16
;
664 ralloc_free(mem_ctx
);
666 anv_pipeline_add_compiled_stage(pipeline
, MESA_SHADER_FRAGMENT
,
673 anv_pipeline_compile_cs(struct anv_pipeline
*pipeline
,
674 struct anv_pipeline_cache
*cache
,
675 const VkComputePipelineCreateInfo
*info
,
676 struct anv_shader_module
*module
,
677 const char *entrypoint
)
679 const struct brw_compiler
*compiler
=
680 pipeline
->device
->instance
->physicalDevice
.compiler
;
681 struct brw_cs_prog_data
*prog_data
= &pipeline
->cs_prog_data
;
682 struct brw_cs_prog_key key
;
684 populate_cs_prog_key(&pipeline
->device
->info
, &key
);
686 /* TODO: Look up shader in cache */
688 memset(prog_data
, 0, sizeof(*prog_data
));
690 prog_data
->binding_table
.work_groups_start
= 0;
692 nir_shader
*nir
= anv_pipeline_compile(pipeline
, module
, entrypoint
,
696 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
698 void *mem_ctx
= ralloc_context(NULL
);
700 if (module
->nir
== NULL
)
701 ralloc_steal(mem_ctx
, nir
);
704 const unsigned *shader_code
=
705 brw_compile_cs(compiler
, NULL
, mem_ctx
, &key
, prog_data
, nir
,
706 -1, &code_size
, NULL
);
707 if (shader_code
== NULL
) {
708 ralloc_free(mem_ctx
);
709 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
713 anv_pipeline_cache_upload_kernel(cache
, shader_code
, code_size
);
714 ralloc_free(mem_ctx
);
716 anv_pipeline_add_compiled_stage(pipeline
, MESA_SHADER_COMPUTE
,
722 static const int gen8_push_size
= 32 * 1024;
725 gen7_compute_urb_partition(struct anv_pipeline
*pipeline
)
727 const struct brw_device_info
*devinfo
= &pipeline
->device
->info
;
728 bool vs_present
= pipeline
->active_stages
& VK_SHADER_STAGE_VERTEX_BIT
;
729 unsigned vs_size
= vs_present
? pipeline
->vs_prog_data
.base
.urb_entry_size
: 1;
730 unsigned vs_entry_size_bytes
= vs_size
* 64;
731 bool gs_present
= pipeline
->active_stages
& VK_SHADER_STAGE_GEOMETRY_BIT
;
732 unsigned gs_size
= gs_present
? pipeline
->gs_prog_data
.base
.urb_entry_size
: 1;
733 unsigned gs_entry_size_bytes
= gs_size
* 64;
735 /* From p35 of the Ivy Bridge PRM (section 1.7.1: 3DSTATE_URB_GS):
737 * VS Number of URB Entries must be divisible by 8 if the VS URB Entry
738 * Allocation Size is less than 9 512-bit URB entries.
740 * Similar text exists for GS.
742 unsigned vs_granularity
= (vs_size
< 9) ? 8 : 1;
743 unsigned gs_granularity
= (gs_size
< 9) ? 8 : 1;
745 /* URB allocations must be done in 8k chunks. */
746 unsigned chunk_size_bytes
= 8192;
748 /* Determine the size of the URB in chunks. */
749 unsigned urb_chunks
= devinfo
->urb
.size
* 1024 / chunk_size_bytes
;
751 /* Reserve space for push constants */
752 unsigned push_constant_bytes
= gen8_push_size
;
753 unsigned push_constant_chunks
=
754 push_constant_bytes
/ chunk_size_bytes
;
756 /* Initially, assign each stage the minimum amount of URB space it needs,
757 * and make a note of how much additional space it "wants" (the amount of
758 * additional space it could actually make use of).
761 /* VS has a lower limit on the number of URB entries */
763 ALIGN(devinfo
->urb
.min_vs_entries
* vs_entry_size_bytes
,
764 chunk_size_bytes
) / chunk_size_bytes
;
766 ALIGN(devinfo
->urb
.max_vs_entries
* vs_entry_size_bytes
,
767 chunk_size_bytes
) / chunk_size_bytes
- vs_chunks
;
769 unsigned gs_chunks
= 0;
770 unsigned gs_wants
= 0;
772 /* There are two constraints on the minimum amount of URB space we can
775 * (1) We need room for at least 2 URB entries, since we always operate
776 * the GS in DUAL_OBJECT mode.
778 * (2) We can't allocate less than nr_gs_entries_granularity.
780 gs_chunks
= ALIGN(MAX2(gs_granularity
, 2) * gs_entry_size_bytes
,
781 chunk_size_bytes
) / chunk_size_bytes
;
783 ALIGN(devinfo
->urb
.max_gs_entries
* gs_entry_size_bytes
,
784 chunk_size_bytes
) / chunk_size_bytes
- gs_chunks
;
787 /* There should always be enough URB space to satisfy the minimum
788 * requirements of each stage.
790 unsigned total_needs
= push_constant_chunks
+ vs_chunks
+ gs_chunks
;
791 assert(total_needs
<= urb_chunks
);
793 /* Mete out remaining space (if any) in proportion to "wants". */
794 unsigned total_wants
= vs_wants
+ gs_wants
;
795 unsigned remaining_space
= urb_chunks
- total_needs
;
796 if (remaining_space
> total_wants
)
797 remaining_space
= total_wants
;
798 if (remaining_space
> 0) {
799 unsigned vs_additional
= (unsigned)
800 round(vs_wants
* (((double) remaining_space
) / total_wants
));
801 vs_chunks
+= vs_additional
;
802 remaining_space
-= vs_additional
;
803 gs_chunks
+= remaining_space
;
806 /* Sanity check that we haven't over-allocated. */
807 assert(push_constant_chunks
+ vs_chunks
+ gs_chunks
<= urb_chunks
);
809 /* Finally, compute the number of entries that can fit in the space
810 * allocated to each stage.
812 unsigned nr_vs_entries
= vs_chunks
* chunk_size_bytes
/ vs_entry_size_bytes
;
813 unsigned nr_gs_entries
= gs_chunks
* chunk_size_bytes
/ gs_entry_size_bytes
;
815 /* Since we rounded up when computing *_wants, this may be slightly more
816 * than the maximum allowed amount, so correct for that.
818 nr_vs_entries
= MIN2(nr_vs_entries
, devinfo
->urb
.max_vs_entries
);
819 nr_gs_entries
= MIN2(nr_gs_entries
, devinfo
->urb
.max_gs_entries
);
821 /* Ensure that we program a multiple of the granularity. */
822 nr_vs_entries
= ROUND_DOWN_TO(nr_vs_entries
, vs_granularity
);
823 nr_gs_entries
= ROUND_DOWN_TO(nr_gs_entries
, gs_granularity
);
825 /* Finally, sanity check to make sure we have at least the minimum number
826 * of entries needed for each stage.
828 assert(nr_vs_entries
>= devinfo
->urb
.min_vs_entries
);
830 assert(nr_gs_entries
>= 2);
832 /* Lay out the URB in the following order:
837 pipeline
->urb
.vs_start
= push_constant_chunks
;
838 pipeline
->urb
.vs_size
= vs_size
;
839 pipeline
->urb
.nr_vs_entries
= nr_vs_entries
;
841 pipeline
->urb
.gs_start
= push_constant_chunks
+ vs_chunks
;
842 pipeline
->urb
.gs_size
= gs_size
;
843 pipeline
->urb
.nr_gs_entries
= nr_gs_entries
;
847 anv_pipeline_init_dynamic_state(struct anv_pipeline
*pipeline
,
848 const VkGraphicsPipelineCreateInfo
*pCreateInfo
)
850 anv_cmd_dirty_mask_t states
= ANV_CMD_DIRTY_DYNAMIC_ALL
;
851 ANV_FROM_HANDLE(anv_render_pass
, pass
, pCreateInfo
->renderPass
);
852 struct anv_subpass
*subpass
= &pass
->subpasses
[pCreateInfo
->subpass
];
854 pipeline
->dynamic_state
= default_dynamic_state
;
856 if (pCreateInfo
->pDynamicState
) {
857 /* Remove all of the states that are marked as dynamic */
858 uint32_t count
= pCreateInfo
->pDynamicState
->dynamicStateCount
;
859 for (uint32_t s
= 0; s
< count
; s
++)
860 states
&= ~(1 << pCreateInfo
->pDynamicState
->pDynamicStates
[s
]);
863 struct anv_dynamic_state
*dynamic
= &pipeline
->dynamic_state
;
865 dynamic
->viewport
.count
= pCreateInfo
->pViewportState
->viewportCount
;
866 if (states
& (1 << VK_DYNAMIC_STATE_VIEWPORT
)) {
867 typed_memcpy(dynamic
->viewport
.viewports
,
868 pCreateInfo
->pViewportState
->pViewports
,
869 pCreateInfo
->pViewportState
->viewportCount
);
872 dynamic
->scissor
.count
= pCreateInfo
->pViewportState
->scissorCount
;
873 if (states
& (1 << VK_DYNAMIC_STATE_SCISSOR
)) {
874 typed_memcpy(dynamic
->scissor
.scissors
,
875 pCreateInfo
->pViewportState
->pScissors
,
876 pCreateInfo
->pViewportState
->scissorCount
);
879 if (states
& (1 << VK_DYNAMIC_STATE_LINE_WIDTH
)) {
880 assert(pCreateInfo
->pRasterizationState
);
881 dynamic
->line_width
= pCreateInfo
->pRasterizationState
->lineWidth
;
884 if (states
& (1 << VK_DYNAMIC_STATE_DEPTH_BIAS
)) {
885 assert(pCreateInfo
->pRasterizationState
);
886 dynamic
->depth_bias
.bias
=
887 pCreateInfo
->pRasterizationState
->depthBiasConstantFactor
;
888 dynamic
->depth_bias
.clamp
=
889 pCreateInfo
->pRasterizationState
->depthBiasClamp
;
890 dynamic
->depth_bias
.slope
=
891 pCreateInfo
->pRasterizationState
->depthBiasSlopeFactor
;
894 if (states
& (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS
)) {
895 assert(pCreateInfo
->pColorBlendState
);
896 typed_memcpy(dynamic
->blend_constants
,
897 pCreateInfo
->pColorBlendState
->blendConstants
, 4);
900 /* If there is no depthstencil attachment, then don't read
901 * pDepthStencilState. The Vulkan spec states that pDepthStencilState may
902 * be NULL in this case. Even if pDepthStencilState is non-NULL, there is
903 * no need to override the depthstencil defaults in
904 * anv_pipeline::dynamic_state when there is no depthstencil attachment.
906 * From the Vulkan spec (20 Oct 2015, git-aa308cb):
908 * pDepthStencilState [...] may only be NULL if renderPass and subpass
909 * specify a subpass that has no depth/stencil attachment.
911 if (subpass
->depth_stencil_attachment
!= VK_ATTACHMENT_UNUSED
) {
912 if (states
& (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS
)) {
913 assert(pCreateInfo
->pDepthStencilState
);
914 dynamic
->depth_bounds
.min
=
915 pCreateInfo
->pDepthStencilState
->minDepthBounds
;
916 dynamic
->depth_bounds
.max
=
917 pCreateInfo
->pDepthStencilState
->maxDepthBounds
;
920 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
)) {
921 assert(pCreateInfo
->pDepthStencilState
);
922 dynamic
->stencil_compare_mask
.front
=
923 pCreateInfo
->pDepthStencilState
->front
.compareMask
;
924 dynamic
->stencil_compare_mask
.back
=
925 pCreateInfo
->pDepthStencilState
->back
.compareMask
;
928 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
)) {
929 assert(pCreateInfo
->pDepthStencilState
);
930 dynamic
->stencil_write_mask
.front
=
931 pCreateInfo
->pDepthStencilState
->front
.writeMask
;
932 dynamic
->stencil_write_mask
.back
=
933 pCreateInfo
->pDepthStencilState
->back
.writeMask
;
936 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE
)) {
937 assert(pCreateInfo
->pDepthStencilState
);
938 dynamic
->stencil_reference
.front
=
939 pCreateInfo
->pDepthStencilState
->front
.reference
;
940 dynamic
->stencil_reference
.back
=
941 pCreateInfo
->pDepthStencilState
->back
.reference
;
945 pipeline
->dynamic_state_mask
= states
;
949 anv_pipeline_validate_create_info(const VkGraphicsPipelineCreateInfo
*info
)
951 struct anv_render_pass
*renderpass
= NULL
;
952 struct anv_subpass
*subpass
= NULL
;
954 /* Assert that all required members of VkGraphicsPipelineCreateInfo are
955 * present, as explained by the Vulkan (20 Oct 2015, git-aa308cb), Section
956 * 4.2 Graphics Pipeline.
958 assert(info
->sType
== VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
);
960 renderpass
= anv_render_pass_from_handle(info
->renderPass
);
963 if (renderpass
!= &anv_meta_dummy_renderpass
) {
964 assert(info
->subpass
< renderpass
->subpass_count
);
965 subpass
= &renderpass
->subpasses
[info
->subpass
];
968 assert(info
->stageCount
>= 1);
969 assert(info
->pVertexInputState
);
970 assert(info
->pInputAssemblyState
);
971 assert(info
->pViewportState
);
972 assert(info
->pRasterizationState
);
974 if (subpass
&& subpass
->depth_stencil_attachment
!= VK_ATTACHMENT_UNUSED
)
975 assert(info
->pDepthStencilState
);
977 if (subpass
&& subpass
->color_count
> 0)
978 assert(info
->pColorBlendState
);
980 for (uint32_t i
= 0; i
< info
->stageCount
; ++i
) {
981 switch (info
->pStages
[i
].stage
) {
982 case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
:
983 case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
:
984 assert(info
->pTessellationState
);
993 anv_pipeline_init(struct anv_pipeline
*pipeline
,
994 struct anv_device
*device
,
995 struct anv_pipeline_cache
*cache
,
996 const VkGraphicsPipelineCreateInfo
*pCreateInfo
,
997 const struct anv_graphics_pipeline_create_info
*extra
,
998 const VkAllocationCallbacks
*alloc
)
1003 anv_pipeline_validate_create_info(pCreateInfo
);
1007 alloc
= &device
->alloc
;
1009 pipeline
->device
= device
;
1010 pipeline
->layout
= anv_pipeline_layout_from_handle(pCreateInfo
->layout
);
1012 result
= anv_reloc_list_init(&pipeline
->batch_relocs
, alloc
);
1013 if (result
!= VK_SUCCESS
)
1016 pipeline
->batch
.alloc
= alloc
;
1017 pipeline
->batch
.next
= pipeline
->batch
.start
= pipeline
->batch_data
;
1018 pipeline
->batch
.end
= pipeline
->batch
.start
+ sizeof(pipeline
->batch_data
);
1019 pipeline
->batch
.relocs
= &pipeline
->batch_relocs
;
1021 anv_pipeline_init_dynamic_state(pipeline
, pCreateInfo
);
1023 if (pCreateInfo
->pTessellationState
)
1024 anv_finishme("VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO");
1025 if (pCreateInfo
->pMultisampleState
&&
1026 pCreateInfo
->pMultisampleState
->rasterizationSamples
> 1)
1027 anv_finishme("VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO");
1029 pipeline
->use_repclear
= extra
&& extra
->use_repclear
;
1030 pipeline
->writes_point_size
= false;
1032 /* When we free the pipeline, we detect stages based on the NULL status
1033 * of various prog_data pointers. Make them NULL by default.
1035 memset(pipeline
->prog_data
, 0, sizeof(pipeline
->prog_data
));
1036 memset(pipeline
->scratch_start
, 0, sizeof(pipeline
->scratch_start
));
1038 pipeline
->vs_simd8
= NO_KERNEL
;
1039 pipeline
->vs_vec4
= NO_KERNEL
;
1040 pipeline
->gs_kernel
= NO_KERNEL
;
1042 pipeline
->active_stages
= 0;
1043 pipeline
->total_scratch
= 0;
1045 for (uint32_t i
= 0; i
< pCreateInfo
->stageCount
; i
++) {
1046 ANV_FROM_HANDLE(anv_shader_module
, module
,
1047 pCreateInfo
->pStages
[i
].module
);
1048 const char *entrypoint
= pCreateInfo
->pStages
[i
].pName
;
1050 switch (pCreateInfo
->pStages
[i
].stage
) {
1051 case VK_SHADER_STAGE_VERTEX_BIT
:
1052 anv_pipeline_compile_vs(pipeline
, cache
, pCreateInfo
, module
, entrypoint
);
1054 case VK_SHADER_STAGE_GEOMETRY_BIT
:
1055 anv_pipeline_compile_gs(pipeline
, cache
, pCreateInfo
, module
, entrypoint
);
1057 case VK_SHADER_STAGE_FRAGMENT_BIT
:
1058 anv_pipeline_compile_fs(pipeline
, cache
, pCreateInfo
, module
, entrypoint
);
1061 anv_finishme("Unsupported shader stage");
1065 if (!(pipeline
->active_stages
& VK_SHADER_STAGE_VERTEX_BIT
)) {
1066 /* Vertex is only optional if disable_vs is set */
1067 assert(extra
->disable_vs
);
1068 memset(&pipeline
->vs_prog_data
, 0, sizeof(pipeline
->vs_prog_data
));
1071 gen7_compute_urb_partition(pipeline
);
1073 const VkPipelineVertexInputStateCreateInfo
*vi_info
=
1074 pCreateInfo
->pVertexInputState
;
1076 uint64_t inputs_read
;
1077 if (extra
&& extra
->disable_vs
) {
1078 /* If the VS is disabled, just assume the user knows what they're
1079 * doing and apply the layout blindly. This can only come from
1080 * meta, so this *should* be safe.
1082 inputs_read
= ~0ull;
1084 inputs_read
= pipeline
->vs_prog_data
.inputs_read
;
1087 pipeline
->vb_used
= 0;
1088 for (uint32_t i
= 0; i
< vi_info
->vertexAttributeDescriptionCount
; i
++) {
1089 const VkVertexInputAttributeDescription
*desc
=
1090 &vi_info
->pVertexAttributeDescriptions
[i
];
1092 if (inputs_read
& (1 << (VERT_ATTRIB_GENERIC0
+ desc
->location
)))
1093 pipeline
->vb_used
|= 1 << desc
->binding
;
1096 for (uint32_t i
= 0; i
< vi_info
->vertexBindingDescriptionCount
; i
++) {
1097 const VkVertexInputBindingDescription
*desc
=
1098 &vi_info
->pVertexBindingDescriptions
[i
];
1100 pipeline
->binding_stride
[desc
->binding
] = desc
->stride
;
1102 /* Step rate is programmed per vertex element (attribute), not
1103 * binding. Set up a map of which bindings step per instance, for
1104 * reference by vertex element setup. */
1105 switch (desc
->inputRate
) {
1107 case VK_VERTEX_INPUT_RATE_VERTEX
:
1108 pipeline
->instancing_enable
[desc
->binding
] = false;
1110 case VK_VERTEX_INPUT_RATE_INSTANCE
:
1111 pipeline
->instancing_enable
[desc
->binding
] = true;
1116 const VkPipelineInputAssemblyStateCreateInfo
*ia_info
=
1117 pCreateInfo
->pInputAssemblyState
;
1118 pipeline
->primitive_restart
= ia_info
->primitiveRestartEnable
;
1119 pipeline
->topology
= vk_to_gen_primitive_type
[ia_info
->topology
];
1121 if (extra
&& extra
->use_rectlist
)
1122 pipeline
->topology
= _3DPRIM_RECTLIST
;
1128 anv_graphics_pipeline_create(
1130 VkPipelineCache _cache
,
1131 const VkGraphicsPipelineCreateInfo
*pCreateInfo
,
1132 const struct anv_graphics_pipeline_create_info
*extra
,
1133 const VkAllocationCallbacks
*pAllocator
,
1134 VkPipeline
*pPipeline
)
1136 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1137 ANV_FROM_HANDLE(anv_pipeline_cache
, cache
, _cache
);
1140 cache
= &device
->default_pipeline_cache
;
1142 switch (device
->info
.gen
) {
1144 if (device
->info
.is_haswell
)
1145 return gen75_graphics_pipeline_create(_device
, cache
, pCreateInfo
, extra
, pAllocator
, pPipeline
);
1147 return gen7_graphics_pipeline_create(_device
, cache
, pCreateInfo
, extra
, pAllocator
, pPipeline
);
1149 return gen8_graphics_pipeline_create(_device
, cache
, pCreateInfo
, extra
, pAllocator
, pPipeline
);
1151 return gen9_graphics_pipeline_create(_device
, cache
, pCreateInfo
, extra
, pAllocator
, pPipeline
);
1153 unreachable("unsupported gen\n");
1157 VkResult
anv_CreateGraphicsPipelines(
1159 VkPipelineCache pipelineCache
,
1161 const VkGraphicsPipelineCreateInfo
* pCreateInfos
,
1162 const VkAllocationCallbacks
* pAllocator
,
1163 VkPipeline
* pPipelines
)
1165 VkResult result
= VK_SUCCESS
;
1168 for (; i
< count
; i
++) {
1169 result
= anv_graphics_pipeline_create(_device
,
1172 NULL
, pAllocator
, &pPipelines
[i
]);
1173 if (result
!= VK_SUCCESS
) {
1174 for (unsigned j
= 0; j
< i
; j
++) {
1175 anv_DestroyPipeline(_device
, pPipelines
[j
], pAllocator
);
1185 static VkResult
anv_compute_pipeline_create(
1187 VkPipelineCache _cache
,
1188 const VkComputePipelineCreateInfo
* pCreateInfo
,
1189 const VkAllocationCallbacks
* pAllocator
,
1190 VkPipeline
* pPipeline
)
1192 ANV_FROM_HANDLE(anv_device
, device
, _device
);
1193 ANV_FROM_HANDLE(anv_pipeline_cache
, cache
, _cache
);
1196 cache
= &device
->default_pipeline_cache
;
1198 switch (device
->info
.gen
) {
1200 if (device
->info
.is_haswell
)
1201 return gen75_compute_pipeline_create(_device
, cache
, pCreateInfo
, pAllocator
, pPipeline
);
1203 return gen7_compute_pipeline_create(_device
, cache
, pCreateInfo
, pAllocator
, pPipeline
);
1205 return gen8_compute_pipeline_create(_device
, cache
, pCreateInfo
, pAllocator
, pPipeline
);
1207 return gen9_compute_pipeline_create(_device
, cache
, pCreateInfo
, pAllocator
, pPipeline
);
1209 unreachable("unsupported gen\n");
1213 VkResult
anv_CreateComputePipelines(
1215 VkPipelineCache pipelineCache
,
1217 const VkComputePipelineCreateInfo
* pCreateInfos
,
1218 const VkAllocationCallbacks
* pAllocator
,
1219 VkPipeline
* pPipelines
)
1221 VkResult result
= VK_SUCCESS
;
1224 for (; i
< count
; i
++) {
1225 result
= anv_compute_pipeline_create(_device
, pipelineCache
,
1227 pAllocator
, &pPipelines
[i
]);
1228 if (result
!= VK_SUCCESS
) {
1229 for (unsigned j
= 0; j
< i
; j
++) {
1230 anv_DestroyPipeline(_device
, pPipelines
[j
], pAllocator
);