nvk: Implement VK_KHR_zero_initialize_workgroup_memory

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9609
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27130>
This commit is contained in:
Faith Ekstrand
2023-12-05 22:34:37 -06:00
committed by Marge Bot
parent 6e214f2157
commit 184bcfdc1c
2 changed files with 11 additions and 0 deletions

View File

@@ -146,6 +146,7 @@ nvk_get_device_extensions(const struct nvk_instance *instance,
.KHR_variable_pointers = true,
.KHR_vulkan_memory_model = nvk_use_nak(info),
.KHR_workgroup_memory_explicit_layout = true,
.KHR_zero_initialize_workgroup_memory = true,
.EXT_4444_formats = true,
.EXT_attachment_feedback_loop_layout = true,
.EXT_border_color_swizzle = true,
@@ -334,6 +335,7 @@ nvk_get_device_features(const struct nv_device_info *info,
.subgroupSizeControl = true,
.computeFullSubgroups = true,
.synchronization2 = true,
.shaderZeroInitializeWorkgroupMemory = true,
.dynamicRendering = true,
.shaderIntegerDotProduct = true,
.maintenance4 = true,

View File

@@ -389,6 +389,15 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
}
NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_shared,
nir_address_format_32bit_offset);
if (nir->info.zero_initialize_shared_memory && nir->info.shared_size > 0) {
/* QMD::SHARED_MEMORY_SIZE requires an alignment of 256B so it's safe to
* align everything up to 16B so we can write whole vec4s.
*/
nir->info.shared_size = align(nir->info.shared_size, 16);
NIR_PASS(_, nir, nir_zero_initialize_shared_memory,
nir->info.shared_size, 16);
}
}
#ifndef NDEBUG