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 "util/mesa-sha1.h"
31 #include "util/os_time.h"
32 #include "common/gen_l3_config.h"
33 #include "anv_private.h"
34 #include "compiler/brw_nir.h"
36 #include "nir/nir_xfb_info.h"
37 #include "spirv/nir_spirv.h"
40 /* Needed for SWIZZLE macros */
41 #include "program/prog_instruction.h"
45 VkResult
anv_CreateShaderModule(
47 const VkShaderModuleCreateInfo
* pCreateInfo
,
48 const VkAllocationCallbacks
* pAllocator
,
49 VkShaderModule
* pShaderModule
)
51 ANV_FROM_HANDLE(anv_device
, device
, _device
);
52 struct anv_shader_module
*module
;
54 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
);
55 assert(pCreateInfo
->flags
== 0);
57 module
= vk_alloc2(&device
->alloc
, pAllocator
,
58 sizeof(*module
) + pCreateInfo
->codeSize
, 8,
59 VK_SYSTEM_ALLOCATION_SCOPE_OBJECT
);
61 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
63 module
->size
= pCreateInfo
->codeSize
;
64 memcpy(module
->data
, pCreateInfo
->pCode
, module
->size
);
66 _mesa_sha1_compute(module
->data
, module
->size
, module
->sha1
);
68 *pShaderModule
= anv_shader_module_to_handle(module
);
73 void anv_DestroyShaderModule(
75 VkShaderModule _module
,
76 const VkAllocationCallbacks
* pAllocator
)
78 ANV_FROM_HANDLE(anv_device
, device
, _device
);
79 ANV_FROM_HANDLE(anv_shader_module
, module
, _module
);
84 vk_free2(&device
->alloc
, pAllocator
, module
);
87 #define SPIR_V_MAGIC_NUMBER 0x07230203
89 static const uint64_t stage_to_debug
[] = {
90 [MESA_SHADER_VERTEX
] = DEBUG_VS
,
91 [MESA_SHADER_TESS_CTRL
] = DEBUG_TCS
,
92 [MESA_SHADER_TESS_EVAL
] = DEBUG_TES
,
93 [MESA_SHADER_GEOMETRY
] = DEBUG_GS
,
94 [MESA_SHADER_FRAGMENT
] = DEBUG_WM
,
95 [MESA_SHADER_COMPUTE
] = DEBUG_CS
,
98 struct anv_spirv_debug_data
{
99 struct anv_device
*device
;
100 const struct anv_shader_module
*module
;
103 static void anv_spirv_nir_debug(void *private_data
,
104 enum nir_spirv_debug_level level
,
108 struct anv_spirv_debug_data
*debug_data
= private_data
;
109 static const VkDebugReportFlagsEXT vk_flags
[] = {
110 [NIR_SPIRV_DEBUG_LEVEL_INFO
] = VK_DEBUG_REPORT_INFORMATION_BIT_EXT
,
111 [NIR_SPIRV_DEBUG_LEVEL_WARNING
] = VK_DEBUG_REPORT_WARNING_BIT_EXT
,
112 [NIR_SPIRV_DEBUG_LEVEL_ERROR
] = VK_DEBUG_REPORT_ERROR_BIT_EXT
,
116 snprintf(buffer
, sizeof(buffer
), "SPIR-V offset %lu: %s", (unsigned long) spirv_offset
, message
);
118 vk_debug_report(&debug_data
->device
->instance
->debug_report_callbacks
,
120 VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT
,
121 (uint64_t) (uintptr_t) debug_data
->module
,
122 0, 0, "anv", buffer
);
125 /* Eventually, this will become part of anv_CreateShader. Unfortunately,
126 * we can't do that yet because we don't have the ability to copy nir.
129 anv_shader_compile_to_nir(struct anv_device
*device
,
131 const struct anv_shader_module
*module
,
132 const char *entrypoint_name
,
133 gl_shader_stage stage
,
134 const VkSpecializationInfo
*spec_info
)
136 const struct anv_physical_device
*pdevice
=
137 &device
->instance
->physicalDevice
;
138 const struct brw_compiler
*compiler
= pdevice
->compiler
;
139 const nir_shader_compiler_options
*nir_options
=
140 compiler
->glsl_compiler_options
[stage
].NirOptions
;
142 uint32_t *spirv
= (uint32_t *) module
->data
;
143 assert(spirv
[0] == SPIR_V_MAGIC_NUMBER
);
144 assert(module
->size
% 4 == 0);
146 uint32_t num_spec_entries
= 0;
147 struct nir_spirv_specialization
*spec_entries
= NULL
;
148 if (spec_info
&& spec_info
->mapEntryCount
> 0) {
149 num_spec_entries
= spec_info
->mapEntryCount
;
150 spec_entries
= malloc(num_spec_entries
* sizeof(*spec_entries
));
151 for (uint32_t i
= 0; i
< num_spec_entries
; i
++) {
152 VkSpecializationMapEntry entry
= spec_info
->pMapEntries
[i
];
153 const void *data
= spec_info
->pData
+ entry
.offset
;
154 assert(data
+ entry
.size
<= spec_info
->pData
+ spec_info
->dataSize
);
156 spec_entries
[i
].id
= spec_info
->pMapEntries
[i
].constantID
;
157 if (spec_info
->dataSize
== 8)
158 spec_entries
[i
].data64
= *(const uint64_t *)data
;
160 spec_entries
[i
].data32
= *(const uint32_t *)data
;
164 struct anv_spirv_debug_data spirv_debug_data
= {
168 struct spirv_to_nir_options spirv_options
= {
169 .lower_workgroup_access_to_offsets
= true,
171 .demote_to_helper_invocation
= true,
172 .derivative_group
= true,
173 .descriptor_array_dynamic_indexing
= true,
174 .descriptor_array_non_uniform_indexing
= true,
175 .descriptor_indexing
= true,
176 .device_group
= true,
177 .draw_parameters
= true,
178 .float16
= pdevice
->info
.gen
>= 8,
179 .float64
= pdevice
->info
.gen
>= 8,
180 .fragment_shader_sample_interlock
= pdevice
->info
.gen
>= 9,
181 .fragment_shader_pixel_interlock
= pdevice
->info
.gen
>= 9,
182 .geometry_streams
= true,
183 .image_write_without_format
= true,
184 .int8
= pdevice
->info
.gen
>= 8,
185 .int16
= pdevice
->info
.gen
>= 8,
186 .int64
= pdevice
->info
.gen
>= 8,
187 .int64_atomics
= pdevice
->info
.gen
>= 9 && pdevice
->use_softpin
,
190 .physical_storage_buffer_address
= pdevice
->has_a64_buffer_access
,
191 .post_depth_coverage
= pdevice
->info
.gen
>= 9,
192 .runtime_descriptor_array
= true,
193 .shader_viewport_index_layer
= true,
194 .stencil_export
= pdevice
->info
.gen
>= 9,
195 .storage_8bit
= pdevice
->info
.gen
>= 8,
196 .storage_16bit
= pdevice
->info
.gen
>= 8,
197 .subgroup_arithmetic
= true,
198 .subgroup_basic
= true,
199 .subgroup_ballot
= true,
200 .subgroup_quad
= true,
201 .subgroup_shuffle
= true,
202 .subgroup_vote
= true,
203 .tessellation
= true,
204 .transform_feedback
= pdevice
->info
.gen
>= 8,
205 .variable_pointers
= true,
207 .ubo_addr_format
= nir_address_format_32bit_index_offset
,
209 anv_nir_ssbo_addr_format(pdevice
, device
->robust_buffer_access
),
210 .phys_ssbo_addr_format
= nir_address_format_64bit_global
,
211 .push_const_addr_format
= nir_address_format_logical
,
213 /* TODO: Consider changing this to an address format that has the NULL
214 * pointer equals to 0. That might be a better format to play nice
215 * with certain code / code generators.
217 .shared_addr_format
= nir_address_format_32bit_offset
,
219 .func
= anv_spirv_nir_debug
,
220 .private_data
= &spirv_debug_data
,
226 spirv_to_nir(spirv
, module
->size
/ 4,
227 spec_entries
, num_spec_entries
,
228 stage
, entrypoint_name
, &spirv_options
, nir_options
);
229 assert(nir
->info
.stage
== stage
);
230 nir_validate_shader(nir
, "after spirv_to_nir");
231 ralloc_steal(mem_ctx
, nir
);
235 if (unlikely(INTEL_DEBUG
& stage_to_debug
[stage
])) {
236 fprintf(stderr
, "NIR (from SPIR-V) for %s shader:\n",
237 gl_shader_stage_name(stage
));
238 nir_print_shader(nir
, stderr
);
241 /* We have to lower away local constant initializers right before we
242 * inline functions. That way they get properly initialized at the top
243 * of the function and not at the top of its caller.
245 NIR_PASS_V(nir
, nir_lower_constant_initializers
, nir_var_function_temp
);
246 NIR_PASS_V(nir
, nir_lower_returns
);
247 NIR_PASS_V(nir
, nir_inline_functions
);
248 NIR_PASS_V(nir
, nir_opt_deref
);
250 /* Pick off the single entrypoint that we want */
251 foreach_list_typed_safe(nir_function
, func
, node
, &nir
->functions
) {
252 if (!func
->is_entrypoint
)
253 exec_node_remove(&func
->node
);
255 assert(exec_list_length(&nir
->functions
) == 1);
257 /* Now that we've deleted all but the main function, we can go ahead and
258 * lower the rest of the constant initializers. We do this here so that
259 * nir_remove_dead_variables and split_per_member_structs below see the
260 * corresponding stores.
262 NIR_PASS_V(nir
, nir_lower_constant_initializers
, ~0);
264 /* Split member structs. We do this before lower_io_to_temporaries so that
265 * it doesn't lower system values to temporaries by accident.
267 NIR_PASS_V(nir
, nir_split_var_copies
);
268 NIR_PASS_V(nir
, nir_split_per_member_structs
);
270 NIR_PASS_V(nir
, nir_remove_dead_variables
,
271 nir_var_shader_in
| nir_var_shader_out
| nir_var_system_value
);
273 NIR_PASS_V(nir
, nir_propagate_invariant
);
274 NIR_PASS_V(nir
, nir_lower_io_to_temporaries
,
275 nir_shader_get_entrypoint(nir
), true, false);
277 NIR_PASS_V(nir
, nir_lower_frexp
);
279 /* Vulkan uses the separate-shader linking model */
280 nir
->info
.separate_shader
= true;
282 brw_preprocess_nir(compiler
, nir
, NULL
);
287 void anv_DestroyPipeline(
289 VkPipeline _pipeline
,
290 const VkAllocationCallbacks
* pAllocator
)
292 ANV_FROM_HANDLE(anv_device
, device
, _device
);
293 ANV_FROM_HANDLE(anv_pipeline
, pipeline
, _pipeline
);
298 anv_reloc_list_finish(&pipeline
->batch_relocs
,
299 pAllocator
? pAllocator
: &device
->alloc
);
300 if (pipeline
->blend_state
.map
)
301 anv_state_pool_free(&device
->dynamic_state_pool
, pipeline
->blend_state
);
303 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
304 if (pipeline
->shaders
[s
])
305 anv_shader_bin_unref(device
, pipeline
->shaders
[s
]);
308 vk_free2(&device
->alloc
, pAllocator
, pipeline
);
311 static const uint32_t vk_to_gen_primitive_type
[] = {
312 [VK_PRIMITIVE_TOPOLOGY_POINT_LIST
] = _3DPRIM_POINTLIST
,
313 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST
] = _3DPRIM_LINELIST
,
314 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
] = _3DPRIM_LINESTRIP
,
315 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
] = _3DPRIM_TRILIST
,
316 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
] = _3DPRIM_TRISTRIP
,
317 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
] = _3DPRIM_TRIFAN
,
318 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY
] = _3DPRIM_LINELIST_ADJ
,
319 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY
] = _3DPRIM_LINESTRIP_ADJ
,
320 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY
] = _3DPRIM_TRILIST_ADJ
,
321 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY
] = _3DPRIM_TRISTRIP_ADJ
,
325 populate_sampler_prog_key(const struct gen_device_info
*devinfo
,
326 struct brw_sampler_prog_key_data
*key
)
328 /* Almost all multisampled textures are compressed. The only time when we
329 * don't compress a multisampled texture is for 16x MSAA with a surface
330 * width greater than 8k which is a bit of an edge case. Since the sampler
331 * just ignores the MCS parameter to ld2ms when MCS is disabled, it's safe
332 * to tell the compiler to always assume compression.
334 key
->compressed_multisample_layout_mask
= ~0;
336 /* SkyLake added support for 16x MSAA. With this came a new message for
337 * reading from a 16x MSAA surface with compression. The new message was
338 * needed because now the MCS data is 64 bits instead of 32 or lower as is
339 * the case for 8x, 4x, and 2x. The key->msaa_16 bit-field controls which
340 * message we use. Fortunately, the 16x message works for 8x, 4x, and 2x
341 * so we can just use it unconditionally. This may not be quite as
342 * efficient but it saves us from recompiling.
344 if (devinfo
->gen
>= 9)
347 /* XXX: Handle texture swizzle on HSW- */
348 for (int i
= 0; i
< MAX_SAMPLERS
; i
++) {
349 /* Assume color sampler, no swizzling. (Works for BDW+) */
350 key
->swizzles
[i
] = SWIZZLE_XYZW
;
355 populate_base_prog_key(const struct gen_device_info
*devinfo
,
356 struct brw_base_prog_key
*key
)
358 populate_sampler_prog_key(devinfo
, &key
->tex
);
362 populate_vs_prog_key(const struct gen_device_info
*devinfo
,
363 struct brw_vs_prog_key
*key
)
365 memset(key
, 0, sizeof(*key
));
367 populate_base_prog_key(devinfo
, &key
->base
);
369 /* XXX: Handle vertex input work-arounds */
371 /* XXX: Handle sampler_prog_key */
375 populate_tcs_prog_key(const struct gen_device_info
*devinfo
,
376 unsigned input_vertices
,
377 struct brw_tcs_prog_key
*key
)
379 memset(key
, 0, sizeof(*key
));
381 populate_base_prog_key(devinfo
, &key
->base
);
383 key
->input_vertices
= input_vertices
;
387 populate_tes_prog_key(const struct gen_device_info
*devinfo
,
388 struct brw_tes_prog_key
*key
)
390 memset(key
, 0, sizeof(*key
));
392 populate_base_prog_key(devinfo
, &key
->base
);
396 populate_gs_prog_key(const struct gen_device_info
*devinfo
,
397 struct brw_gs_prog_key
*key
)
399 memset(key
, 0, sizeof(*key
));
401 populate_base_prog_key(devinfo
, &key
->base
);
405 populate_wm_prog_key(const struct gen_device_info
*devinfo
,
406 const struct anv_subpass
*subpass
,
407 const VkPipelineMultisampleStateCreateInfo
*ms_info
,
408 struct brw_wm_prog_key
*key
)
410 memset(key
, 0, sizeof(*key
));
412 populate_base_prog_key(devinfo
, &key
->base
);
414 /* We set this to 0 here and set to the actual value before we call
417 key
->input_slots_valid
= 0;
419 /* Vulkan doesn't specify a default */
420 key
->high_quality_derivatives
= false;
422 /* XXX Vulkan doesn't appear to specify */
423 key
->clamp_fragment_color
= false;
425 assert(subpass
->color_count
<= MAX_RTS
);
426 for (uint32_t i
= 0; i
< subpass
->color_count
; i
++) {
427 if (subpass
->color_attachments
[i
].attachment
!= VK_ATTACHMENT_UNUSED
)
428 key
->color_outputs_valid
|= (1 << i
);
431 key
->nr_color_regions
= util_bitcount(key
->color_outputs_valid
);
433 /* To reduce possible shader recompilations we would need to know if
434 * there is a SampleMask output variable to compute if we should emit
435 * code to workaround the issue that hardware disables alpha to coverage
436 * when there is SampleMask output.
438 key
->alpha_to_coverage
= ms_info
&& ms_info
->alphaToCoverageEnable
;
440 /* Vulkan doesn't support fixed-function alpha test */
441 key
->alpha_test_replicate_alpha
= false;
444 /* We should probably pull this out of the shader, but it's fairly
445 * harmless to compute it and then let dead-code take care of it.
447 if (ms_info
->rasterizationSamples
> 1) {
448 key
->persample_interp
= ms_info
->sampleShadingEnable
&&
449 (ms_info
->minSampleShading
* ms_info
->rasterizationSamples
) > 1;
450 key
->multisample_fbo
= true;
453 key
->frag_coord_adds_sample_pos
= key
->persample_interp
;
458 populate_cs_prog_key(const struct gen_device_info
*devinfo
,
459 struct brw_cs_prog_key
*key
)
461 memset(key
, 0, sizeof(*key
));
463 populate_base_prog_key(devinfo
, &key
->base
);
466 struct anv_pipeline_stage
{
467 gl_shader_stage stage
;
469 const struct anv_shader_module
*module
;
470 const char *entrypoint
;
471 const VkSpecializationInfo
*spec_info
;
473 unsigned char shader_sha1
[20];
475 union brw_any_prog_key key
;
478 gl_shader_stage stage
;
479 unsigned char sha1
[20];
484 struct anv_pipeline_binding surface_to_descriptor
[256];
485 struct anv_pipeline_binding sampler_to_descriptor
[256];
486 struct anv_pipeline_bind_map bind_map
;
488 union brw_any_prog_data prog_data
;
490 VkPipelineCreationFeedbackEXT feedback
;
494 anv_pipeline_hash_shader(const struct anv_shader_module
*module
,
495 const char *entrypoint
,
496 gl_shader_stage stage
,
497 const VkSpecializationInfo
*spec_info
,
498 unsigned char *sha1_out
)
500 struct mesa_sha1 ctx
;
501 _mesa_sha1_init(&ctx
);
503 _mesa_sha1_update(&ctx
, module
->sha1
, sizeof(module
->sha1
));
504 _mesa_sha1_update(&ctx
, entrypoint
, strlen(entrypoint
));
505 _mesa_sha1_update(&ctx
, &stage
, sizeof(stage
));
507 _mesa_sha1_update(&ctx
, spec_info
->pMapEntries
,
508 spec_info
->mapEntryCount
*
509 sizeof(*spec_info
->pMapEntries
));
510 _mesa_sha1_update(&ctx
, spec_info
->pData
,
511 spec_info
->dataSize
);
514 _mesa_sha1_final(&ctx
, sha1_out
);
518 anv_pipeline_hash_graphics(struct anv_pipeline
*pipeline
,
519 struct anv_pipeline_layout
*layout
,
520 struct anv_pipeline_stage
*stages
,
521 unsigned char *sha1_out
)
523 struct mesa_sha1 ctx
;
524 _mesa_sha1_init(&ctx
);
526 _mesa_sha1_update(&ctx
, &pipeline
->subpass
->view_mask
,
527 sizeof(pipeline
->subpass
->view_mask
));
530 _mesa_sha1_update(&ctx
, layout
->sha1
, sizeof(layout
->sha1
));
532 const bool rba
= pipeline
->device
->robust_buffer_access
;
533 _mesa_sha1_update(&ctx
, &rba
, sizeof(rba
));
535 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
536 if (stages
[s
].entrypoint
) {
537 _mesa_sha1_update(&ctx
, stages
[s
].shader_sha1
,
538 sizeof(stages
[s
].shader_sha1
));
539 _mesa_sha1_update(&ctx
, &stages
[s
].key
, brw_prog_key_size(s
));
543 _mesa_sha1_final(&ctx
, sha1_out
);
547 anv_pipeline_hash_compute(struct anv_pipeline
*pipeline
,
548 struct anv_pipeline_layout
*layout
,
549 struct anv_pipeline_stage
*stage
,
550 unsigned char *sha1_out
)
552 struct mesa_sha1 ctx
;
553 _mesa_sha1_init(&ctx
);
556 _mesa_sha1_update(&ctx
, layout
->sha1
, sizeof(layout
->sha1
));
558 const bool rba
= pipeline
->device
->robust_buffer_access
;
559 _mesa_sha1_update(&ctx
, &rba
, sizeof(rba
));
561 _mesa_sha1_update(&ctx
, stage
->shader_sha1
,
562 sizeof(stage
->shader_sha1
));
563 _mesa_sha1_update(&ctx
, &stage
->key
.cs
, sizeof(stage
->key
.cs
));
565 _mesa_sha1_final(&ctx
, sha1_out
);
569 anv_pipeline_stage_get_nir(struct anv_pipeline
*pipeline
,
570 struct anv_pipeline_cache
*cache
,
572 struct anv_pipeline_stage
*stage
)
574 const struct brw_compiler
*compiler
=
575 pipeline
->device
->instance
->physicalDevice
.compiler
;
576 const nir_shader_compiler_options
*nir_options
=
577 compiler
->glsl_compiler_options
[stage
->stage
].NirOptions
;
580 nir
= anv_device_search_for_nir(pipeline
->device
, cache
,
585 assert(nir
->info
.stage
== stage
->stage
);
589 nir
= anv_shader_compile_to_nir(pipeline
->device
,
596 anv_device_upload_nir(pipeline
->device
, cache
, nir
, stage
->shader_sha1
);
604 anv_pipeline_lower_nir(struct anv_pipeline
*pipeline
,
606 struct anv_pipeline_stage
*stage
,
607 struct anv_pipeline_layout
*layout
)
609 const struct anv_physical_device
*pdevice
=
610 &pipeline
->device
->instance
->physicalDevice
;
611 const struct brw_compiler
*compiler
= pdevice
->compiler
;
613 struct brw_stage_prog_data
*prog_data
= &stage
->prog_data
.base
;
614 nir_shader
*nir
= stage
->nir
;
616 if (nir
->info
.stage
== MESA_SHADER_FRAGMENT
) {
617 NIR_PASS_V(nir
, nir_lower_wpos_center
, pipeline
->sample_shading_enable
);
618 NIR_PASS_V(nir
, nir_lower_input_attachments
, false);
621 NIR_PASS_V(nir
, anv_nir_lower_ycbcr_textures
, layout
);
623 NIR_PASS_V(nir
, anv_nir_lower_push_constants
);
625 if (nir
->info
.stage
!= MESA_SHADER_COMPUTE
)
626 NIR_PASS_V(nir
, anv_nir_lower_multiview
, pipeline
->subpass
->view_mask
);
628 if (nir
->info
.stage
== MESA_SHADER_COMPUTE
)
629 prog_data
->total_shared
= nir
->num_shared
;
631 nir_shader_gather_info(nir
, nir_shader_get_entrypoint(nir
));
633 if (nir
->num_uniforms
> 0) {
634 assert(prog_data
->nr_params
== 0);
636 /* If the shader uses any push constants at all, we'll just give
637 * them the maximum possible number
639 assert(nir
->num_uniforms
<= MAX_PUSH_CONSTANTS_SIZE
);
640 nir
->num_uniforms
= MAX_PUSH_CONSTANTS_SIZE
;
641 prog_data
->nr_params
+= MAX_PUSH_CONSTANTS_SIZE
/ sizeof(float);
642 prog_data
->param
= ralloc_array(mem_ctx
, uint32_t, prog_data
->nr_params
);
644 /* We now set the param values to be offsets into a
645 * anv_push_constant_data structure. Since the compiler doesn't
646 * actually dereference any of the gl_constant_value pointers in the
647 * params array, it doesn't really matter what we put here.
649 struct anv_push_constants
*null_data
= NULL
;
650 /* Fill out the push constants section of the param array */
651 for (unsigned i
= 0; i
< MAX_PUSH_CONSTANTS_SIZE
/ sizeof(float); i
++) {
652 prog_data
->param
[i
] = ANV_PARAM_PUSH(
653 (uintptr_t)&null_data
->client_data
[i
* sizeof(float)]);
657 if (nir
->info
.num_ssbos
> 0 || nir
->info
.num_images
> 0)
658 pipeline
->needs_data_cache
= true;
660 NIR_PASS_V(nir
, brw_nir_lower_image_load_store
, compiler
->devinfo
);
662 NIR_PASS_V(nir
, nir_lower_explicit_io
, nir_var_mem_global
,
663 nir_address_format_64bit_global
);
665 /* Apply the actual pipeline layout to UBOs, SSBOs, and textures */
667 anv_nir_apply_pipeline_layout(pdevice
,
668 pipeline
->device
->robust_buffer_access
,
669 layout
, nir
, prog_data
,
672 NIR_PASS_V(nir
, nir_lower_explicit_io
, nir_var_mem_ubo
,
673 nir_address_format_32bit_index_offset
);
674 NIR_PASS_V(nir
, nir_lower_explicit_io
, nir_var_mem_ssbo
,
675 anv_nir_ssbo_addr_format(pdevice
,
676 pipeline
->device
->robust_buffer_access
));
678 NIR_PASS_V(nir
, nir_opt_constant_folding
);
680 /* We don't support non-uniform UBOs and non-uniform SSBO access is
681 * handled naturally by falling back to A64 messages.
683 NIR_PASS_V(nir
, nir_lower_non_uniform_access
,
684 nir_lower_non_uniform_texture_access
|
685 nir_lower_non_uniform_image_access
);
688 if (nir
->info
.stage
!= MESA_SHADER_COMPUTE
)
689 brw_nir_analyze_ubo_ranges(compiler
, nir
, NULL
, prog_data
->ubo_ranges
);
691 assert(nir
->num_uniforms
== prog_data
->nr_params
* 4);
697 anv_pipeline_link_vs(const struct brw_compiler
*compiler
,
698 struct anv_pipeline_stage
*vs_stage
,
699 struct anv_pipeline_stage
*next_stage
)
702 brw_nir_link_shaders(compiler
, vs_stage
->nir
, next_stage
->nir
);
705 static const unsigned *
706 anv_pipeline_compile_vs(const struct brw_compiler
*compiler
,
708 struct anv_device
*device
,
709 struct anv_pipeline_stage
*vs_stage
)
711 brw_compute_vue_map(compiler
->devinfo
,
712 &vs_stage
->prog_data
.vs
.base
.vue_map
,
713 vs_stage
->nir
->info
.outputs_written
,
714 vs_stage
->nir
->info
.separate_shader
);
716 return brw_compile_vs(compiler
, device
, mem_ctx
, &vs_stage
->key
.vs
,
717 &vs_stage
->prog_data
.vs
, vs_stage
->nir
, -1, NULL
);
721 merge_tess_info(struct shader_info
*tes_info
,
722 const struct shader_info
*tcs_info
)
724 /* The Vulkan 1.0.38 spec, section 21.1 Tessellator says:
726 * "PointMode. Controls generation of points rather than triangles
727 * or lines. This functionality defaults to disabled, and is
728 * enabled if either shader stage includes the execution mode.
730 * and about Triangles, Quads, IsoLines, VertexOrderCw, VertexOrderCcw,
731 * PointMode, SpacingEqual, SpacingFractionalEven, SpacingFractionalOdd,
732 * and OutputVertices, it says:
734 * "One mode must be set in at least one of the tessellation
737 * So, the fields can be set in either the TCS or TES, but they must
738 * agree if set in both. Our backend looks at TES, so bitwise-or in
739 * the values from the TCS.
741 assert(tcs_info
->tess
.tcs_vertices_out
== 0 ||
742 tes_info
->tess
.tcs_vertices_out
== 0 ||
743 tcs_info
->tess
.tcs_vertices_out
== tes_info
->tess
.tcs_vertices_out
);
744 tes_info
->tess
.tcs_vertices_out
|= tcs_info
->tess
.tcs_vertices_out
;
746 assert(tcs_info
->tess
.spacing
== TESS_SPACING_UNSPECIFIED
||
747 tes_info
->tess
.spacing
== TESS_SPACING_UNSPECIFIED
||
748 tcs_info
->tess
.spacing
== tes_info
->tess
.spacing
);
749 tes_info
->tess
.spacing
|= tcs_info
->tess
.spacing
;
751 assert(tcs_info
->tess
.primitive_mode
== 0 ||
752 tes_info
->tess
.primitive_mode
== 0 ||
753 tcs_info
->tess
.primitive_mode
== tes_info
->tess
.primitive_mode
);
754 tes_info
->tess
.primitive_mode
|= tcs_info
->tess
.primitive_mode
;
755 tes_info
->tess
.ccw
|= tcs_info
->tess
.ccw
;
756 tes_info
->tess
.point_mode
|= tcs_info
->tess
.point_mode
;
760 anv_pipeline_link_tcs(const struct brw_compiler
*compiler
,
761 struct anv_pipeline_stage
*tcs_stage
,
762 struct anv_pipeline_stage
*tes_stage
)
764 assert(tes_stage
&& tes_stage
->stage
== MESA_SHADER_TESS_EVAL
);
766 brw_nir_link_shaders(compiler
, tcs_stage
->nir
, tes_stage
->nir
);
768 nir_lower_patch_vertices(tes_stage
->nir
,
769 tcs_stage
->nir
->info
.tess
.tcs_vertices_out
,
772 /* Copy TCS info into the TES info */
773 merge_tess_info(&tes_stage
->nir
->info
, &tcs_stage
->nir
->info
);
775 /* Whacking the key after cache lookup is a bit sketchy, but all of
776 * this comes from the SPIR-V, which is part of the hash used for the
777 * pipeline cache. So it should be safe.
779 tcs_stage
->key
.tcs
.tes_primitive_mode
=
780 tes_stage
->nir
->info
.tess
.primitive_mode
;
781 tcs_stage
->key
.tcs
.quads_workaround
=
782 compiler
->devinfo
->gen
< 9 &&
783 tes_stage
->nir
->info
.tess
.primitive_mode
== 7 /* GL_QUADS */ &&
784 tes_stage
->nir
->info
.tess
.spacing
== TESS_SPACING_EQUAL
;
787 static const unsigned *
788 anv_pipeline_compile_tcs(const struct brw_compiler
*compiler
,
790 struct anv_device
*device
,
791 struct anv_pipeline_stage
*tcs_stage
,
792 struct anv_pipeline_stage
*prev_stage
)
794 tcs_stage
->key
.tcs
.outputs_written
=
795 tcs_stage
->nir
->info
.outputs_written
;
796 tcs_stage
->key
.tcs
.patch_outputs_written
=
797 tcs_stage
->nir
->info
.patch_outputs_written
;
799 return brw_compile_tcs(compiler
, device
, mem_ctx
, &tcs_stage
->key
.tcs
,
800 &tcs_stage
->prog_data
.tcs
, tcs_stage
->nir
,
805 anv_pipeline_link_tes(const struct brw_compiler
*compiler
,
806 struct anv_pipeline_stage
*tes_stage
,
807 struct anv_pipeline_stage
*next_stage
)
810 brw_nir_link_shaders(compiler
, tes_stage
->nir
, next_stage
->nir
);
813 static const unsigned *
814 anv_pipeline_compile_tes(const struct brw_compiler
*compiler
,
816 struct anv_device
*device
,
817 struct anv_pipeline_stage
*tes_stage
,
818 struct anv_pipeline_stage
*tcs_stage
)
820 tes_stage
->key
.tes
.inputs_read
=
821 tcs_stage
->nir
->info
.outputs_written
;
822 tes_stage
->key
.tes
.patch_inputs_read
=
823 tcs_stage
->nir
->info
.patch_outputs_written
;
825 return brw_compile_tes(compiler
, device
, mem_ctx
, &tes_stage
->key
.tes
,
826 &tcs_stage
->prog_data
.tcs
.base
.vue_map
,
827 &tes_stage
->prog_data
.tes
, tes_stage
->nir
,
832 anv_pipeline_link_gs(const struct brw_compiler
*compiler
,
833 struct anv_pipeline_stage
*gs_stage
,
834 struct anv_pipeline_stage
*next_stage
)
837 brw_nir_link_shaders(compiler
, gs_stage
->nir
, next_stage
->nir
);
840 static const unsigned *
841 anv_pipeline_compile_gs(const struct brw_compiler
*compiler
,
843 struct anv_device
*device
,
844 struct anv_pipeline_stage
*gs_stage
,
845 struct anv_pipeline_stage
*prev_stage
)
847 brw_compute_vue_map(compiler
->devinfo
,
848 &gs_stage
->prog_data
.gs
.base
.vue_map
,
849 gs_stage
->nir
->info
.outputs_written
,
850 gs_stage
->nir
->info
.separate_shader
);
852 return brw_compile_gs(compiler
, device
, mem_ctx
, &gs_stage
->key
.gs
,
853 &gs_stage
->prog_data
.gs
, gs_stage
->nir
,
858 anv_pipeline_link_fs(const struct brw_compiler
*compiler
,
859 struct anv_pipeline_stage
*stage
)
861 unsigned num_rts
= 0;
862 const int max_rt
= FRAG_RESULT_DATA7
- FRAG_RESULT_DATA0
+ 1;
863 struct anv_pipeline_binding rt_bindings
[max_rt
];
864 nir_function_impl
*impl
= nir_shader_get_entrypoint(stage
->nir
);
865 int rt_to_bindings
[max_rt
];
866 memset(rt_to_bindings
, -1, sizeof(rt_to_bindings
));
867 bool rt_used
[max_rt
];
868 memset(rt_used
, 0, sizeof(rt_used
));
870 /* Flag used render targets */
871 nir_foreach_variable_safe(var
, &stage
->nir
->outputs
) {
872 if (var
->data
.location
< FRAG_RESULT_DATA0
)
875 const unsigned rt
= var
->data
.location
- FRAG_RESULT_DATA0
;
880 const unsigned array_len
=
881 glsl_type_is_array(var
->type
) ? glsl_get_length(var
->type
) : 1;
882 assert(rt
+ array_len
<= max_rt
);
885 if (!(stage
->key
.wm
.color_outputs_valid
& BITFIELD_RANGE(rt
, array_len
))) {
886 /* If this is the RT at location 0 and we have alpha to coverage
887 * enabled we will have to create a null RT for it, so mark it as
890 if (rt
> 0 || !stage
->key
.wm
.alpha_to_coverage
)
894 for (unsigned i
= 0; i
< array_len
; i
++)
895 rt_used
[rt
+ i
] = true;
898 /* Set new, compacted, location */
899 for (unsigned i
= 0; i
< max_rt
; i
++) {
903 rt_to_bindings
[i
] = num_rts
;
905 if (stage
->key
.wm
.color_outputs_valid
& (1 << i
)) {
906 rt_bindings
[rt_to_bindings
[i
]] = (struct anv_pipeline_binding
) {
907 .set
= ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS
,
912 /* Setup a null render target */
913 rt_bindings
[rt_to_bindings
[i
]] = (struct anv_pipeline_binding
) {
914 .set
= ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS
,
923 bool deleted_output
= false;
924 nir_foreach_variable_safe(var
, &stage
->nir
->outputs
) {
925 if (var
->data
.location
< FRAG_RESULT_DATA0
)
928 const unsigned rt
= var
->data
.location
- FRAG_RESULT_DATA0
;
930 if (rt
>= MAX_RTS
|| !rt_used
[rt
]) {
931 /* Unused or out-of-bounds, throw it away, unless it is the first
932 * RT and we have alpha to coverage enabled.
934 deleted_output
= true;
935 var
->data
.mode
= nir_var_function_temp
;
936 exec_node_remove(&var
->node
);
937 exec_list_push_tail(&impl
->locals
, &var
->node
);
941 /* Give it the new location */
942 assert(rt_to_bindings
[rt
] != -1);
943 var
->data
.location
= rt_to_bindings
[rt
] + FRAG_RESULT_DATA0
;
947 nir_fixup_deref_modes(stage
->nir
);
950 /* If we have no render targets, we need a null render target */
951 rt_bindings
[0] = (struct anv_pipeline_binding
) {
952 .set
= ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS
,
959 /* Now that we've determined the actual number of render targets, adjust
960 * the key accordingly.
962 stage
->key
.wm
.nr_color_regions
= num_rts
;
963 stage
->key
.wm
.color_outputs_valid
= (1 << num_rts
) - 1;
965 assert(num_rts
<= max_rt
);
966 assert(stage
->bind_map
.surface_count
== 0);
967 typed_memcpy(stage
->bind_map
.surface_to_descriptor
,
968 rt_bindings
, num_rts
);
969 stage
->bind_map
.surface_count
+= num_rts
;
972 static const unsigned *
973 anv_pipeline_compile_fs(const struct brw_compiler
*compiler
,
975 struct anv_device
*device
,
976 struct anv_pipeline_stage
*fs_stage
,
977 struct anv_pipeline_stage
*prev_stage
)
979 /* TODO: we could set this to 0 based on the information in nir_shader, but
980 * we need this before we call spirv_to_nir.
983 fs_stage
->key
.wm
.input_slots_valid
=
984 prev_stage
->prog_data
.vue
.vue_map
.slots_valid
;
986 const unsigned *code
=
987 brw_compile_fs(compiler
, device
, mem_ctx
, &fs_stage
->key
.wm
,
988 &fs_stage
->prog_data
.wm
, fs_stage
->nir
,
989 NULL
, -1, -1, -1, true, false, NULL
, NULL
);
991 if (fs_stage
->key
.wm
.nr_color_regions
== 0 &&
992 !fs_stage
->prog_data
.wm
.has_side_effects
&&
993 !fs_stage
->prog_data
.wm
.uses_kill
&&
994 fs_stage
->prog_data
.wm
.computed_depth_mode
== BRW_PSCDEPTH_OFF
&&
995 !fs_stage
->prog_data
.wm
.computed_stencil
) {
996 /* This fragment shader has no outputs and no side effects. Go ahead
997 * and return the code pointer so we don't accidentally think the
998 * compile failed but zero out prog_data which will set program_size to
999 * zero and disable the stage.
1001 memset(&fs_stage
->prog_data
, 0, sizeof(fs_stage
->prog_data
));
1008 anv_pipeline_compile_graphics(struct anv_pipeline
*pipeline
,
1009 struct anv_pipeline_cache
*cache
,
1010 const VkGraphicsPipelineCreateInfo
*info
)
1012 VkPipelineCreationFeedbackEXT pipeline_feedback
= {
1013 .flags
= VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT
,
1015 int64_t pipeline_start
= os_time_get_nano();
1017 const struct brw_compiler
*compiler
=
1018 pipeline
->device
->instance
->physicalDevice
.compiler
;
1019 struct anv_pipeline_stage stages
[MESA_SHADER_STAGES
] = {};
1021 pipeline
->active_stages
= 0;
1024 for (uint32_t i
= 0; i
< info
->stageCount
; i
++) {
1025 const VkPipelineShaderStageCreateInfo
*sinfo
= &info
->pStages
[i
];
1026 gl_shader_stage stage
= vk_to_mesa_shader_stage(sinfo
->stage
);
1028 pipeline
->active_stages
|= sinfo
->stage
;
1030 int64_t stage_start
= os_time_get_nano();
1032 stages
[stage
].stage
= stage
;
1033 stages
[stage
].module
= anv_shader_module_from_handle(sinfo
->module
);
1034 stages
[stage
].entrypoint
= sinfo
->pName
;
1035 stages
[stage
].spec_info
= sinfo
->pSpecializationInfo
;
1036 anv_pipeline_hash_shader(stages
[stage
].module
,
1037 stages
[stage
].entrypoint
,
1039 stages
[stage
].spec_info
,
1040 stages
[stage
].shader_sha1
);
1042 const struct gen_device_info
*devinfo
= &pipeline
->device
->info
;
1044 case MESA_SHADER_VERTEX
:
1045 populate_vs_prog_key(devinfo
, &stages
[stage
].key
.vs
);
1047 case MESA_SHADER_TESS_CTRL
:
1048 populate_tcs_prog_key(devinfo
,
1049 info
->pTessellationState
->patchControlPoints
,
1050 &stages
[stage
].key
.tcs
);
1052 case MESA_SHADER_TESS_EVAL
:
1053 populate_tes_prog_key(devinfo
, &stages
[stage
].key
.tes
);
1055 case MESA_SHADER_GEOMETRY
:
1056 populate_gs_prog_key(devinfo
, &stages
[stage
].key
.gs
);
1058 case MESA_SHADER_FRAGMENT
:
1059 populate_wm_prog_key(devinfo
, pipeline
->subpass
,
1060 info
->pMultisampleState
,
1061 &stages
[stage
].key
.wm
);
1064 unreachable("Invalid graphics shader stage");
1067 stages
[stage
].feedback
.duration
+= os_time_get_nano() - stage_start
;
1068 stages
[stage
].feedback
.flags
|= VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT
;
1071 if (pipeline
->active_stages
& VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
)
1072 pipeline
->active_stages
|= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
;
1074 assert(pipeline
->active_stages
& VK_SHADER_STAGE_VERTEX_BIT
);
1076 ANV_FROM_HANDLE(anv_pipeline_layout
, layout
, info
->layout
);
1078 unsigned char sha1
[20];
1079 anv_pipeline_hash_graphics(pipeline
, layout
, stages
, sha1
);
1082 unsigned cache_hits
= 0;
1083 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
1084 if (!stages
[s
].entrypoint
)
1087 int64_t stage_start
= os_time_get_nano();
1089 stages
[s
].cache_key
.stage
= s
;
1090 memcpy(stages
[s
].cache_key
.sha1
, sha1
, sizeof(sha1
));
1093 struct anv_shader_bin
*bin
=
1094 anv_device_search_for_kernel(pipeline
->device
, cache
,
1095 &stages
[s
].cache_key
,
1096 sizeof(stages
[s
].cache_key
), &cache_hit
);
1099 pipeline
->shaders
[s
] = bin
;
1104 stages
[s
].feedback
.flags
|=
1105 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT
;
1107 stages
[s
].feedback
.duration
+= os_time_get_nano() - stage_start
;
1110 if (found
== __builtin_popcount(pipeline
->active_stages
)) {
1111 if (cache_hits
== found
) {
1112 pipeline_feedback
.flags
|=
1113 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT
;
1115 /* We found all our shaders in the cache. We're done. */
1117 } else if (found
> 0) {
1118 /* We found some but not all of our shaders. This shouldn't happen
1119 * most of the time but it can if we have a partially populated
1122 assert(found
< __builtin_popcount(pipeline
->active_stages
));
1124 vk_debug_report(&pipeline
->device
->instance
->debug_report_callbacks
,
1125 VK_DEBUG_REPORT_WARNING_BIT_EXT
|
1126 VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT
,
1127 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT
,
1128 (uint64_t)(uintptr_t)cache
,
1130 "Found a partial pipeline in the cache. This is "
1131 "most likely caused by an incomplete pipeline cache "
1132 "import or export");
1134 /* We're going to have to recompile anyway, so just throw away our
1135 * references to the shaders in the cache. We'll get them out of the
1136 * cache again as part of the compilation process.
1138 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
1139 stages
[s
].feedback
.flags
= 0;
1140 if (pipeline
->shaders
[s
]) {
1141 anv_shader_bin_unref(pipeline
->device
, pipeline
->shaders
[s
]);
1142 pipeline
->shaders
[s
] = NULL
;
1147 void *pipeline_ctx
= ralloc_context(NULL
);
1149 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
1150 if (!stages
[s
].entrypoint
)
1153 int64_t stage_start
= os_time_get_nano();
1155 assert(stages
[s
].stage
== s
);
1156 assert(pipeline
->shaders
[s
] == NULL
);
1158 stages
[s
].bind_map
= (struct anv_pipeline_bind_map
) {
1159 .surface_to_descriptor
= stages
[s
].surface_to_descriptor
,
1160 .sampler_to_descriptor
= stages
[s
].sampler_to_descriptor
1163 stages
[s
].nir
= anv_pipeline_stage_get_nir(pipeline
, cache
,
1166 if (stages
[s
].nir
== NULL
) {
1167 result
= vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1171 stages
[s
].feedback
.duration
+= os_time_get_nano() - stage_start
;
1174 /* Walk backwards to link */
1175 struct anv_pipeline_stage
*next_stage
= NULL
;
1176 for (int s
= MESA_SHADER_STAGES
- 1; s
>= 0; s
--) {
1177 if (!stages
[s
].entrypoint
)
1181 case MESA_SHADER_VERTEX
:
1182 anv_pipeline_link_vs(compiler
, &stages
[s
], next_stage
);
1184 case MESA_SHADER_TESS_CTRL
:
1185 anv_pipeline_link_tcs(compiler
, &stages
[s
], next_stage
);
1187 case MESA_SHADER_TESS_EVAL
:
1188 anv_pipeline_link_tes(compiler
, &stages
[s
], next_stage
);
1190 case MESA_SHADER_GEOMETRY
:
1191 anv_pipeline_link_gs(compiler
, &stages
[s
], next_stage
);
1193 case MESA_SHADER_FRAGMENT
:
1194 anv_pipeline_link_fs(compiler
, &stages
[s
]);
1197 unreachable("Invalid graphics shader stage");
1200 next_stage
= &stages
[s
];
1203 struct anv_pipeline_stage
*prev_stage
= NULL
;
1204 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
1205 if (!stages
[s
].entrypoint
)
1208 int64_t stage_start
= os_time_get_nano();
1210 void *stage_ctx
= ralloc_context(NULL
);
1212 nir_xfb_info
*xfb_info
= NULL
;
1213 if (s
== MESA_SHADER_VERTEX
||
1214 s
== MESA_SHADER_TESS_EVAL
||
1215 s
== MESA_SHADER_GEOMETRY
)
1216 xfb_info
= nir_gather_xfb_info(stages
[s
].nir
, stage_ctx
);
1218 anv_pipeline_lower_nir(pipeline
, stage_ctx
, &stages
[s
], layout
);
1220 const unsigned *code
;
1222 case MESA_SHADER_VERTEX
:
1223 code
= anv_pipeline_compile_vs(compiler
, stage_ctx
, pipeline
->device
,
1226 case MESA_SHADER_TESS_CTRL
:
1227 code
= anv_pipeline_compile_tcs(compiler
, stage_ctx
, pipeline
->device
,
1228 &stages
[s
], prev_stage
);
1230 case MESA_SHADER_TESS_EVAL
:
1231 code
= anv_pipeline_compile_tes(compiler
, stage_ctx
, pipeline
->device
,
1232 &stages
[s
], prev_stage
);
1234 case MESA_SHADER_GEOMETRY
:
1235 code
= anv_pipeline_compile_gs(compiler
, stage_ctx
, pipeline
->device
,
1236 &stages
[s
], prev_stage
);
1238 case MESA_SHADER_FRAGMENT
:
1239 code
= anv_pipeline_compile_fs(compiler
, stage_ctx
, pipeline
->device
,
1240 &stages
[s
], prev_stage
);
1243 unreachable("Invalid graphics shader stage");
1246 ralloc_free(stage_ctx
);
1247 result
= vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1251 struct anv_shader_bin
*bin
=
1252 anv_device_upload_kernel(pipeline
->device
, cache
,
1253 &stages
[s
].cache_key
,
1254 sizeof(stages
[s
].cache_key
),
1255 code
, stages
[s
].prog_data
.base
.program_size
,
1256 stages
[s
].nir
->constant_data
,
1257 stages
[s
].nir
->constant_data_size
,
1258 &stages
[s
].prog_data
.base
,
1259 brw_prog_data_size(s
),
1260 xfb_info
, &stages
[s
].bind_map
);
1262 ralloc_free(stage_ctx
);
1263 result
= vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1267 pipeline
->shaders
[s
] = bin
;
1268 ralloc_free(stage_ctx
);
1270 stages
[s
].feedback
.duration
+= os_time_get_nano() - stage_start
;
1272 prev_stage
= &stages
[s
];
1275 ralloc_free(pipeline_ctx
);
1279 if (pipeline
->shaders
[MESA_SHADER_FRAGMENT
] &&
1280 pipeline
->shaders
[MESA_SHADER_FRAGMENT
]->prog_data
->program_size
== 0) {
1281 /* This can happen if we decided to implicitly disable the fragment
1282 * shader. See anv_pipeline_compile_fs().
1284 anv_shader_bin_unref(pipeline
->device
,
1285 pipeline
->shaders
[MESA_SHADER_FRAGMENT
]);
1286 pipeline
->shaders
[MESA_SHADER_FRAGMENT
] = NULL
;
1287 pipeline
->active_stages
&= ~VK_SHADER_STAGE_FRAGMENT_BIT
;
1290 pipeline_feedback
.duration
= os_time_get_nano() - pipeline_start
;
1292 const VkPipelineCreationFeedbackCreateInfoEXT
*create_feedback
=
1293 vk_find_struct_const(info
->pNext
, PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT
);
1294 if (create_feedback
) {
1295 *create_feedback
->pPipelineCreationFeedback
= pipeline_feedback
;
1297 assert(info
->stageCount
== create_feedback
->pipelineStageCreationFeedbackCount
);
1298 for (uint32_t i
= 0; i
< info
->stageCount
; i
++) {
1299 gl_shader_stage s
= vk_to_mesa_shader_stage(info
->pStages
[i
].stage
);
1300 create_feedback
->pPipelineStageCreationFeedbacks
[i
] = stages
[s
].feedback
;
1307 ralloc_free(pipeline_ctx
);
1309 for (unsigned s
= 0; s
< MESA_SHADER_STAGES
; s
++) {
1310 if (pipeline
->shaders
[s
])
1311 anv_shader_bin_unref(pipeline
->device
, pipeline
->shaders
[s
]);
1318 anv_pipeline_compile_cs(struct anv_pipeline
*pipeline
,
1319 struct anv_pipeline_cache
*cache
,
1320 const VkComputePipelineCreateInfo
*info
,
1321 const struct anv_shader_module
*module
,
1322 const char *entrypoint
,
1323 const VkSpecializationInfo
*spec_info
)
1325 VkPipelineCreationFeedbackEXT pipeline_feedback
= {
1326 .flags
= VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT
,
1328 int64_t pipeline_start
= os_time_get_nano();
1330 const struct brw_compiler
*compiler
=
1331 pipeline
->device
->instance
->physicalDevice
.compiler
;
1333 struct anv_pipeline_stage stage
= {
1334 .stage
= MESA_SHADER_COMPUTE
,
1336 .entrypoint
= entrypoint
,
1337 .spec_info
= spec_info
,
1339 .stage
= MESA_SHADER_COMPUTE
,
1342 .flags
= VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT
,
1345 anv_pipeline_hash_shader(stage
.module
,
1347 MESA_SHADER_COMPUTE
,
1351 struct anv_shader_bin
*bin
= NULL
;
1353 populate_cs_prog_key(&pipeline
->device
->info
, &stage
.key
.cs
);
1355 ANV_FROM_HANDLE(anv_pipeline_layout
, layout
, info
->layout
);
1357 anv_pipeline_hash_compute(pipeline
, layout
, &stage
, stage
.cache_key
.sha1
);
1359 bin
= anv_device_search_for_kernel(pipeline
->device
, cache
, &stage
.cache_key
,
1360 sizeof(stage
.cache_key
), &cache_hit
);
1363 int64_t stage_start
= os_time_get_nano();
1365 stage
.bind_map
= (struct anv_pipeline_bind_map
) {
1366 .surface_to_descriptor
= stage
.surface_to_descriptor
,
1367 .sampler_to_descriptor
= stage
.sampler_to_descriptor
1370 /* Set up a binding for the gl_NumWorkGroups */
1371 stage
.bind_map
.surface_count
= 1;
1372 stage
.bind_map
.surface_to_descriptor
[0] = (struct anv_pipeline_binding
) {
1373 .set
= ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS
,
1376 void *mem_ctx
= ralloc_context(NULL
);
1378 stage
.nir
= anv_pipeline_stage_get_nir(pipeline
, cache
, mem_ctx
, &stage
);
1379 if (stage
.nir
== NULL
) {
1380 ralloc_free(mem_ctx
);
1381 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1384 anv_pipeline_lower_nir(pipeline
, mem_ctx
, &stage
, layout
);
1386 NIR_PASS_V(stage
.nir
, anv_nir_add_base_work_group_id
,
1387 &stage
.prog_data
.cs
);
1389 const unsigned *shader_code
=
1390 brw_compile_cs(compiler
, pipeline
->device
, mem_ctx
, &stage
.key
.cs
,
1391 &stage
.prog_data
.cs
, stage
.nir
, -1, NULL
);
1392 if (shader_code
== NULL
) {
1393 ralloc_free(mem_ctx
);
1394 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1397 const unsigned code_size
= stage
.prog_data
.base
.program_size
;
1398 bin
= anv_device_upload_kernel(pipeline
->device
, cache
,
1399 &stage
.cache_key
, sizeof(stage
.cache_key
),
1400 shader_code
, code_size
,
1401 stage
.nir
->constant_data
,
1402 stage
.nir
->constant_data_size
,
1403 &stage
.prog_data
.base
,
1404 sizeof(stage
.prog_data
.cs
),
1405 NULL
, &stage
.bind_map
);
1407 ralloc_free(mem_ctx
);
1408 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
1411 ralloc_free(mem_ctx
);
1413 stage
.feedback
.duration
= os_time_get_nano() - stage_start
;
1417 stage
.feedback
.flags
|=
1418 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT
;
1419 pipeline_feedback
.flags
|=
1420 VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT
;
1422 pipeline_feedback
.duration
= os_time_get_nano() - pipeline_start
;
1424 const VkPipelineCreationFeedbackCreateInfoEXT
*create_feedback
=
1425 vk_find_struct_const(info
->pNext
, PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT
);
1426 if (create_feedback
) {
1427 *create_feedback
->pPipelineCreationFeedback
= pipeline_feedback
;
1429 assert(create_feedback
->pipelineStageCreationFeedbackCount
== 1);
1430 create_feedback
->pPipelineStageCreationFeedbacks
[0] = stage
.feedback
;
1433 pipeline
->active_stages
= VK_SHADER_STAGE_COMPUTE_BIT
;
1434 pipeline
->shaders
[MESA_SHADER_COMPUTE
] = bin
;
1440 * Copy pipeline state not marked as dynamic.
1441 * Dynamic state is pipeline state which hasn't been provided at pipeline
1442 * creation time, but is dynamically provided afterwards using various
1443 * vkCmdSet* functions.
1445 * The set of state considered "non_dynamic" is determined by the pieces of
1446 * state that have their corresponding VkDynamicState enums omitted from
1447 * VkPipelineDynamicStateCreateInfo::pDynamicStates.
1449 * @param[out] pipeline Destination non_dynamic state.
1450 * @param[in] pCreateInfo Source of non_dynamic state to be copied.
1453 copy_non_dynamic_state(struct anv_pipeline
*pipeline
,
1454 const VkGraphicsPipelineCreateInfo
*pCreateInfo
)
1456 anv_cmd_dirty_mask_t states
= ANV_CMD_DIRTY_DYNAMIC_ALL
;
1457 struct anv_subpass
*subpass
= pipeline
->subpass
;
1459 pipeline
->dynamic_state
= default_dynamic_state
;
1461 if (pCreateInfo
->pDynamicState
) {
1462 /* Remove all of the states that are marked as dynamic */
1463 uint32_t count
= pCreateInfo
->pDynamicState
->dynamicStateCount
;
1464 for (uint32_t s
= 0; s
< count
; s
++)
1465 states
&= ~(1 << pCreateInfo
->pDynamicState
->pDynamicStates
[s
]);
1468 struct anv_dynamic_state
*dynamic
= &pipeline
->dynamic_state
;
1470 /* Section 9.2 of the Vulkan 1.0.15 spec says:
1472 * pViewportState is [...] NULL if the pipeline
1473 * has rasterization disabled.
1475 if (!pCreateInfo
->pRasterizationState
->rasterizerDiscardEnable
) {
1476 assert(pCreateInfo
->pViewportState
);
1478 dynamic
->viewport
.count
= pCreateInfo
->pViewportState
->viewportCount
;
1479 if (states
& (1 << VK_DYNAMIC_STATE_VIEWPORT
)) {
1480 typed_memcpy(dynamic
->viewport
.viewports
,
1481 pCreateInfo
->pViewportState
->pViewports
,
1482 pCreateInfo
->pViewportState
->viewportCount
);
1485 dynamic
->scissor
.count
= pCreateInfo
->pViewportState
->scissorCount
;
1486 if (states
& (1 << VK_DYNAMIC_STATE_SCISSOR
)) {
1487 typed_memcpy(dynamic
->scissor
.scissors
,
1488 pCreateInfo
->pViewportState
->pScissors
,
1489 pCreateInfo
->pViewportState
->scissorCount
);
1493 if (states
& (1 << VK_DYNAMIC_STATE_LINE_WIDTH
)) {
1494 assert(pCreateInfo
->pRasterizationState
);
1495 dynamic
->line_width
= pCreateInfo
->pRasterizationState
->lineWidth
;
1498 if (states
& (1 << VK_DYNAMIC_STATE_DEPTH_BIAS
)) {
1499 assert(pCreateInfo
->pRasterizationState
);
1500 dynamic
->depth_bias
.bias
=
1501 pCreateInfo
->pRasterizationState
->depthBiasConstantFactor
;
1502 dynamic
->depth_bias
.clamp
=
1503 pCreateInfo
->pRasterizationState
->depthBiasClamp
;
1504 dynamic
->depth_bias
.slope
=
1505 pCreateInfo
->pRasterizationState
->depthBiasSlopeFactor
;
1508 /* Section 9.2 of the Vulkan 1.0.15 spec says:
1510 * pColorBlendState is [...] NULL if the pipeline has rasterization
1511 * disabled or if the subpass of the render pass the pipeline is
1512 * created against does not use any color attachments.
1514 bool uses_color_att
= false;
1515 for (unsigned i
= 0; i
< subpass
->color_count
; ++i
) {
1516 if (subpass
->color_attachments
[i
].attachment
!= VK_ATTACHMENT_UNUSED
) {
1517 uses_color_att
= true;
1522 if (uses_color_att
&&
1523 !pCreateInfo
->pRasterizationState
->rasterizerDiscardEnable
) {
1524 assert(pCreateInfo
->pColorBlendState
);
1526 if (states
& (1 << VK_DYNAMIC_STATE_BLEND_CONSTANTS
))
1527 typed_memcpy(dynamic
->blend_constants
,
1528 pCreateInfo
->pColorBlendState
->blendConstants
, 4);
1531 /* If there is no depthstencil attachment, then don't read
1532 * pDepthStencilState. The Vulkan spec states that pDepthStencilState may
1533 * be NULL in this case. Even if pDepthStencilState is non-NULL, there is
1534 * no need to override the depthstencil defaults in
1535 * anv_pipeline::dynamic_state when there is no depthstencil attachment.
1537 * Section 9.2 of the Vulkan 1.0.15 spec says:
1539 * pDepthStencilState is [...] NULL if the pipeline has rasterization
1540 * disabled or if the subpass of the render pass the pipeline is created
1541 * against does not use a depth/stencil attachment.
1543 if (!pCreateInfo
->pRasterizationState
->rasterizerDiscardEnable
&&
1544 subpass
->depth_stencil_attachment
) {
1545 assert(pCreateInfo
->pDepthStencilState
);
1547 if (states
& (1 << VK_DYNAMIC_STATE_DEPTH_BOUNDS
)) {
1548 dynamic
->depth_bounds
.min
=
1549 pCreateInfo
->pDepthStencilState
->minDepthBounds
;
1550 dynamic
->depth_bounds
.max
=
1551 pCreateInfo
->pDepthStencilState
->maxDepthBounds
;
1554 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
)) {
1555 dynamic
->stencil_compare_mask
.front
=
1556 pCreateInfo
->pDepthStencilState
->front
.compareMask
;
1557 dynamic
->stencil_compare_mask
.back
=
1558 pCreateInfo
->pDepthStencilState
->back
.compareMask
;
1561 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
)) {
1562 dynamic
->stencil_write_mask
.front
=
1563 pCreateInfo
->pDepthStencilState
->front
.writeMask
;
1564 dynamic
->stencil_write_mask
.back
=
1565 pCreateInfo
->pDepthStencilState
->back
.writeMask
;
1568 if (states
& (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE
)) {
1569 dynamic
->stencil_reference
.front
=
1570 pCreateInfo
->pDepthStencilState
->front
.reference
;
1571 dynamic
->stencil_reference
.back
=
1572 pCreateInfo
->pDepthStencilState
->back
.reference
;
1576 pipeline
->dynamic_state_mask
= states
;
1580 anv_pipeline_validate_create_info(const VkGraphicsPipelineCreateInfo
*info
)
1583 struct anv_render_pass
*renderpass
= NULL
;
1584 struct anv_subpass
*subpass
= NULL
;
1586 /* Assert that all required members of VkGraphicsPipelineCreateInfo are
1587 * present. See the Vulkan 1.0.28 spec, Section 9.2 Graphics Pipelines.
1589 assert(info
->sType
== VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
);
1591 renderpass
= anv_render_pass_from_handle(info
->renderPass
);
1594 assert(info
->subpass
< renderpass
->subpass_count
);
1595 subpass
= &renderpass
->subpasses
[info
->subpass
];
1597 assert(info
->stageCount
>= 1);
1598 assert(info
->pVertexInputState
);
1599 assert(info
->pInputAssemblyState
);
1600 assert(info
->pRasterizationState
);
1601 if (!info
->pRasterizationState
->rasterizerDiscardEnable
) {
1602 assert(info
->pViewportState
);
1603 assert(info
->pMultisampleState
);
1605 if (subpass
&& subpass
->depth_stencil_attachment
)
1606 assert(info
->pDepthStencilState
);
1608 if (subpass
&& subpass
->color_count
> 0) {
1609 bool all_color_unused
= true;
1610 for (int i
= 0; i
< subpass
->color_count
; i
++) {
1611 if (subpass
->color_attachments
[i
].attachment
!= VK_ATTACHMENT_UNUSED
)
1612 all_color_unused
= false;
1614 /* pColorBlendState is ignored if the pipeline has rasterization
1615 * disabled or if the subpass of the render pass the pipeline is
1616 * created against does not use any color attachments.
1618 assert(info
->pColorBlendState
|| all_color_unused
);
1622 for (uint32_t i
= 0; i
< info
->stageCount
; ++i
) {
1623 switch (info
->pStages
[i
].stage
) {
1624 case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
:
1625 case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
:
1626 assert(info
->pTessellationState
);
1636 * Calculate the desired L3 partitioning based on the current state of the
1637 * pipeline. For now this simply returns the conservative defaults calculated
1638 * by get_default_l3_weights(), but we could probably do better by gathering
1639 * more statistics from the pipeline state (e.g. guess of expected URB usage
1640 * and bound surfaces), or by using feed-back from performance counters.
1643 anv_pipeline_setup_l3_config(struct anv_pipeline
*pipeline
, bool needs_slm
)
1645 const struct gen_device_info
*devinfo
= &pipeline
->device
->info
;
1647 const struct gen_l3_weights w
=
1648 gen_get_default_l3_weights(devinfo
, pipeline
->needs_data_cache
, needs_slm
);
1650 pipeline
->urb
.l3_config
= gen_get_l3_config(devinfo
, w
);
1651 pipeline
->urb
.total_size
=
1652 gen_get_l3_config_urb_size(devinfo
, pipeline
->urb
.l3_config
);
1656 anv_pipeline_init(struct anv_pipeline
*pipeline
,
1657 struct anv_device
*device
,
1658 struct anv_pipeline_cache
*cache
,
1659 const VkGraphicsPipelineCreateInfo
*pCreateInfo
,
1660 const VkAllocationCallbacks
*alloc
)
1664 anv_pipeline_validate_create_info(pCreateInfo
);
1667 alloc
= &device
->alloc
;
1669 pipeline
->device
= device
;
1671 ANV_FROM_HANDLE(anv_render_pass
, render_pass
, pCreateInfo
->renderPass
);
1672 assert(pCreateInfo
->subpass
< render_pass
->subpass_count
);
1673 pipeline
->subpass
= &render_pass
->subpasses
[pCreateInfo
->subpass
];
1675 result
= anv_reloc_list_init(&pipeline
->batch_relocs
, alloc
);
1676 if (result
!= VK_SUCCESS
)
1679 pipeline
->batch
.alloc
= alloc
;
1680 pipeline
->batch
.next
= pipeline
->batch
.start
= pipeline
->batch_data
;
1681 pipeline
->batch
.end
= pipeline
->batch
.start
+ sizeof(pipeline
->batch_data
);
1682 pipeline
->batch
.relocs
= &pipeline
->batch_relocs
;
1683 pipeline
->batch
.status
= VK_SUCCESS
;
1685 copy_non_dynamic_state(pipeline
, pCreateInfo
);
1686 pipeline
->depth_clamp_enable
= pCreateInfo
->pRasterizationState
&&
1687 pCreateInfo
->pRasterizationState
->depthClampEnable
;
1689 /* Previously we enabled depth clipping when !depthClampEnable.
1690 * DepthClipStateCreateInfo now makes depth clipping explicit so if the
1691 * clipping info is available, use its enable value to determine clipping,
1692 * otherwise fallback to the previous !depthClampEnable logic.
1694 const VkPipelineRasterizationDepthClipStateCreateInfoEXT
*clip_info
=
1695 vk_find_struct_const(pCreateInfo
->pRasterizationState
->pNext
,
1696 PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT
);
1697 pipeline
->depth_clip_enable
= clip_info
? clip_info
->depthClipEnable
: !pipeline
->depth_clamp_enable
;
1699 pipeline
->sample_shading_enable
= pCreateInfo
->pMultisampleState
&&
1700 pCreateInfo
->pMultisampleState
->sampleShadingEnable
;
1702 pipeline
->needs_data_cache
= false;
1704 /* When we free the pipeline, we detect stages based on the NULL status
1705 * of various prog_data pointers. Make them NULL by default.
1707 memset(pipeline
->shaders
, 0, sizeof(pipeline
->shaders
));
1709 result
= anv_pipeline_compile_graphics(pipeline
, cache
, pCreateInfo
);
1710 if (result
!= VK_SUCCESS
) {
1711 anv_reloc_list_finish(&pipeline
->batch_relocs
, alloc
);
1715 assert(pipeline
->shaders
[MESA_SHADER_VERTEX
]);
1717 anv_pipeline_setup_l3_config(pipeline
, false);
1719 const VkPipelineVertexInputStateCreateInfo
*vi_info
=
1720 pCreateInfo
->pVertexInputState
;
1722 const uint64_t inputs_read
= get_vs_prog_data(pipeline
)->inputs_read
;
1724 pipeline
->vb_used
= 0;
1725 for (uint32_t i
= 0; i
< vi_info
->vertexAttributeDescriptionCount
; i
++) {
1726 const VkVertexInputAttributeDescription
*desc
=
1727 &vi_info
->pVertexAttributeDescriptions
[i
];
1729 if (inputs_read
& (1ull << (VERT_ATTRIB_GENERIC0
+ desc
->location
)))
1730 pipeline
->vb_used
|= 1 << desc
->binding
;
1733 for (uint32_t i
= 0; i
< vi_info
->vertexBindingDescriptionCount
; i
++) {
1734 const VkVertexInputBindingDescription
*desc
=
1735 &vi_info
->pVertexBindingDescriptions
[i
];
1737 pipeline
->vb
[desc
->binding
].stride
= desc
->stride
;
1739 /* Step rate is programmed per vertex element (attribute), not
1740 * binding. Set up a map of which bindings step per instance, for
1741 * reference by vertex element setup. */
1742 switch (desc
->inputRate
) {
1744 case VK_VERTEX_INPUT_RATE_VERTEX
:
1745 pipeline
->vb
[desc
->binding
].instanced
= false;
1747 case VK_VERTEX_INPUT_RATE_INSTANCE
:
1748 pipeline
->vb
[desc
->binding
].instanced
= true;
1752 pipeline
->vb
[desc
->binding
].instance_divisor
= 1;
1755 const VkPipelineVertexInputDivisorStateCreateInfoEXT
*vi_div_state
=
1756 vk_find_struct_const(vi_info
->pNext
,
1757 PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT
);
1759 for (uint32_t i
= 0; i
< vi_div_state
->vertexBindingDivisorCount
; i
++) {
1760 const VkVertexInputBindingDivisorDescriptionEXT
*desc
=
1761 &vi_div_state
->pVertexBindingDivisors
[i
];
1763 pipeline
->vb
[desc
->binding
].instance_divisor
= desc
->divisor
;
1767 /* Our implementation of VK_KHR_multiview uses instancing to draw the
1768 * different views. If the client asks for instancing, we need to multiply
1769 * the instance divisor by the number of views ensure that we repeat the
1770 * client's per-instance data once for each view.
1772 if (pipeline
->subpass
->view_mask
) {
1773 const uint32_t view_count
= anv_subpass_view_count(pipeline
->subpass
);
1774 for (uint32_t vb
= 0; vb
< MAX_VBS
; vb
++) {
1775 if (pipeline
->vb
[vb
].instanced
)
1776 pipeline
->vb
[vb
].instance_divisor
*= view_count
;
1780 const VkPipelineInputAssemblyStateCreateInfo
*ia_info
=
1781 pCreateInfo
->pInputAssemblyState
;
1782 const VkPipelineTessellationStateCreateInfo
*tess_info
=
1783 pCreateInfo
->pTessellationState
;
1784 pipeline
->primitive_restart
= ia_info
->primitiveRestartEnable
;
1786 if (anv_pipeline_has_stage(pipeline
, MESA_SHADER_TESS_EVAL
))
1787 pipeline
->topology
= _3DPRIM_PATCHLIST(tess_info
->patchControlPoints
);
1789 pipeline
->topology
= vk_to_gen_primitive_type
[ia_info
->topology
];