From 05ba3f814496cf83934a6dc5d9f82a264481dcd7 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:53:19 -0600 Subject: [PATCH] nvk: Pull the NIR options from NAK Part-of: --- src/nouveau/vulkan/nvk_physical_device.c | 10 ++++++++++ src/nouveau/vulkan/nvk_physical_device.h | 2 ++ src/nouveau/vulkan/nvk_shader.c | 9 ++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index 257d3b9021f..a01f68ec420 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -4,6 +4,7 @@ */ #include "nvk_physical_device.h" +#include "nak.h" #include "nvk_buffer.h" #include "nvk_entrypoints.h" #include "nvk_format.h" @@ -833,6 +834,12 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, pdev->render_dev = render_dev; pdev->info = info; + pdev->nak = nak_compiler_create(&pdev->info); + if (pdev->nak == NULL) { + result = vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY); + goto fail_init; + } + nvk_physical_device_init_pipeline_cache(pdev); pdev->mem_heaps[0].flags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT; @@ -882,6 +889,8 @@ nvk_create_drm_physical_device(struct vk_instance *_instance, fail_disk_cache: nvk_physical_device_free_disk_cache(pdev); + nak_compiler_destroy(pdev->nak); +fail_init: vk_physical_device_finish(&pdev->vk); fail_alloc: vk_free(&instance->vk.alloc, pdev); @@ -896,6 +905,7 @@ nvk_physical_device_destroy(struct vk_physical_device *vk_pdev) nvk_finish_wsi(pdev); nvk_physical_device_free_disk_cache(pdev); + nak_compiler_destroy(pdev->nak); vk_physical_device_finish(&pdev->vk); vk_free(&pdev->vk.instance->alloc, pdev); } diff --git a/src/nouveau/vulkan/nvk_physical_device.h b/src/nouveau/vulkan/nvk_physical_device.h index 738ffcfbe08..6722cd94c51 100644 --- a/src/nouveau/vulkan/nvk_physical_device.h +++ b/src/nouveau/vulkan/nvk_physical_device.h @@ -17,6 +17,7 @@ #include +struct nak_compiler; struct nvk_instance; struct nvk_physical_device { @@ -24,6 +25,7 @@ struct nvk_physical_device { struct nv_device_info info; dev_t render_dev; dev_t primary_dev; + struct nak_compiler *nak; struct wsi_device wsi_device; uint8_t device_uuid[VK_UUID_SIZE]; diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c index bb6ab54fca6..70383fcfb2c 100644 --- a/src/nouveau/vulkan/nvk_shader.c +++ b/src/nouveau/vulkan/nvk_shader.c @@ -120,6 +120,9 @@ const nir_shader_compiler_options * nvk_physical_device_nir_options(const struct nvk_physical_device *pdev, gl_shader_stage stage) { + if (use_nak(stage)) + return nak_nir_options(pdev->nak); + enum pipe_shader_type p_stage = pipe_shader_type_from_mesa(stage); return nv50_ir_nir_shader_compiler_options(pdev->info.chipset, p_stage); } @@ -1210,9 +1213,7 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev, const struct nvk_fs_key *fs_key, struct nvk_shader *shader) { - struct nak_compiler *nak = nak_compiler_create(&pdev->info); - - struct nak_shader_bin *bin = nak_compile_shader(nir, nak); + struct nak_shader_bin *bin = nak_compile_shader(nir, pdev->nak); shader->stage = nir->info.stage; @@ -1239,8 +1240,6 @@ nvk_compile_nir_with_nak(struct nvk_physical_device *pdev, nvk_shader_dump(shader); #endif - nak_compiler_destroy(nak); - return VK_SUCCESS; }