asahi: Deserialize libagx when opening device

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498>
This commit is contained in:
Alyssa Rosenzweig 2023-09-28 12:45:27 -04:00 committed by Marge Bot
parent 75fe90dab0
commit 0be124b77e
3 changed files with 20 additions and 2 deletions

View file

@ -7,15 +7,21 @@
#include "agx_device.h"
#include <inttypes.h>
#include "agx_bo.h"
#include "agx_compile.h"
#include "decode.h"
#include "glsl_types.h"
#include "libagx_shaders.h"
#include <fcntl.h>
#include <xf86drm.h>
#include "drm-uapi/dma-buf.h"
#include "util/blob.h"
#include "util/log.h"
#include "util/os_file.h"
#include "util/os_mman.h"
#include "util/simple_mtx.h"
#include "git_sha1.h"
#include "nir_serialize.h"
/* TODO: Linux UAPI. Dummy defines to get some things to compile. */
#define ASAHI_BIND_READ 0
@ -334,6 +340,12 @@ agx_open_device(void *memctx, struct agx_device *dev)
dev->queue_id = agx_create_command_queue(dev, 0 /* TODO: CAPS */);
agx_get_global_ids(dev);
glsl_type_singleton_init_or_ref();
struct blob_reader blob;
blob_reader_init(&blob, (void *)libagx_shaders_nir,
sizeof(libagx_shaders_nir));
dev->libagx = nir_deserialize(memctx, &agx_nir_options, &blob);
return true;
}

View file

@ -61,9 +61,15 @@ struct drm_asahi_params_global {
/* Fencepost problem, hence the off-by-one */
#define NR_BO_CACHE_BUCKETS (MAX_BO_CACHE_BUCKET - MIN_BO_CACHE_BUCKET + 1)
/* Forward decl only, do not pull in all of NIR */
struct nir_shader;
struct agx_device {
uint32_t debug;
/* NIR library of AGX helpers/shaders. Immutable once created. */
const struct nir_shader *libagx;
char name[64];
struct drm_asahi_params_global params;
uint64_t next_global_id, last_global_id;

View file

@ -18,11 +18,11 @@ files_asahi = files(
libasahi = static_library(
'asahi',
files_asahi,
[files_asahi],
include_directories : [inc_gallium_aux, inc_gallium, inc_include, inc_src],
c_args : [c_msvc_compat_args],
gnu_symbol_visibility : 'hidden',
dependencies : [idep_nir, idep_mesautil, idep_agx_pack, dep_libdrm],
dependencies : [idep_nir, idep_mesautil, idep_agx_pack, dep_libdrm, idep_mesaclc],
)
driver_asahi = declare_dependency(