nvk: Pull the NIR options from NAK

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:53:19 -06:00 committed by Marge Bot
parent 0e4480d8b3
commit 05ba3f8144
3 changed files with 16 additions and 5 deletions

View file

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

View file

@ -17,6 +17,7 @@
#include <sys/types.h>
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];

View file

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