hk: mutex shader compiles when debugging

make the prints readable.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31532>
This commit is contained in:
Alyssa Rosenzweig 2024-09-19 18:00:01 -04:00 committed by Marge Bot
parent d0a3856771
commit 3d1d1baa07
3 changed files with 16 additions and 0 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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;