diff --git a/src/asahi/vulkan/hk_physical_device.c b/src/asahi/vulkan/hk_physical_device.c index 0af91587837..59f6227c27c 100644 --- a/src/asahi/vulkan/hk_physical_device.c +++ b/src/asahi/vulkan/hk_physical_device.c @@ -20,6 +20,7 @@ #include "hk_shader.h" #include "hk_wsi.h" +#include "util/simple_mtx.h" #include "util/u_debug.h" #include "vulkan/vulkan_core.h" #include "vulkan/wsi/wsi_common.h" @@ -1218,6 +1219,7 @@ hk_create_drm_physical_device(struct vk_instance *_instance, if (result != VK_SUCCESS) goto fail_disk_cache; + simple_mtx_init(&pdev->debug_compile_lock, mtx_plain); *pdev_out = &pdev->vk; return VK_SUCCESS; @@ -1248,6 +1250,7 @@ hk_physical_device_destroy(struct vk_physical_device *vk_pdev) if (pdev->master_fd >= 0) close(pdev->master_fd); + simple_mtx_destroy(&pdev->debug_compile_lock); hk_physical_device_free_disk_cache(pdev); agx_close_device(&pdev->dev); vk_physical_device_finish(&pdev->vk); diff --git a/src/asahi/vulkan/hk_physical_device.h b/src/asahi/vulkan/hk_physical_device.h index 8b8b318d8be..0acdbe4316b 100644 --- a/src/asahi/vulkan/hk_physical_device.h +++ b/src/asahi/vulkan/hk_physical_device.h @@ -52,6 +52,8 @@ struct hk_physical_device { struct vk_sync_type syncobj_sync_type; const struct vk_sync_type *sync_types[2]; + + simple_mtx_t debug_compile_lock; }; VK_DEFINE_HANDLE_CASTS(hk_physical_device, vk.base, VkPhysicalDevice, diff --git a/src/asahi/vulkan/hk_shader.c b/src/asahi/vulkan/hk_shader.c index c0cf36419d1..29bc0370e49 100644 --- a/src/asahi/vulkan/hk_shader.c +++ b/src/asahi/vulkan/hk_shader.c @@ -6,6 +6,7 @@ */ #include "hk_shader.h" +#include "agx_debug.h" #include "agx_device.h" #include "agx_helpers.h" #include "agx_nir_lower_gs.h" @@ -817,8 +818,18 @@ hk_compile_nir(struct hk_device *dev, const VkAllocationCallbacks *pAllocator, nir->info.fs.uses_sample_shading) backend_key.fs.inside_sample_loop = true; + simple_mtx_t *lock = NULL; + if (agx_get_compiler_debug()) + lock = &hk_device_physical(dev)->debug_compile_lock; + + if (lock) + simple_mtx_lock(lock); + agx_compile_shader_nir(nir, &backend_key, NULL, &shader->b); + if (lock) + simple_mtx_unlock(lock); + shader->code_ptr = shader->b.binary; shader->code_size = shader->b.binary_size;