mesa/src/amd/vulkan/radv_pipeline_cache.h
Samuel Pitoiset 371316e989 radv: use radv_compiler_info everywhere during compilation
This prevents the compiler to access the logical/physical devices and
the instance during compilation.

The main goal is to make it more robust against cache related issues
when something isn't hashed correctly (this used to happen a lot in the
past). Also it would be much more robust for sharing binaries between
two GPUs in the same generation (eg. Vangogh/Rembrandt) because
everything needed for compilation is in radv_compiler_info. There is
still some work to do to achieve that but it's making good progress.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40992>
2026-04-23 07:56:48 +00:00

87 lines
4.3 KiB
C

/*
* Copyright © 2016 Red Hat.
* Copyright © 2016 Bas Nieuwenhuizen
*
* based in part on anv driver which is:
* Copyright © 2015 Intel Corporation
*
* SPDX-License-Identifier: MIT
*/
#ifndef RADV_PIPELINE_CACHE_H
#define RADV_PIPELINE_CACHE_H
#include "util/mesa-blake3.h"
#include "vk_pipeline_cache.h"
struct radv_device;
struct radv_graphics_state_key;
struct radv_pipeline;
struct radv_ray_tracing_group;
struct radv_ray_tracing_pipeline;
struct radv_graphics_pipeline;
struct radv_compute_pipeline;
struct radv_ray_tracing_stage;
struct radv_shader_binary;
struct radv_shader_debug_info;
struct radv_shader_stage;
struct radv_spirv_to_nir_options;
struct radv_compiler_info;
struct util_dynarray;
struct nir_shader;
typedef struct nir_shader nir_shader;
void radv_hash_graphics_spirv_to_nir(blake3_hash hash, const struct radv_shader_stage *stage,
const struct radv_spirv_to_nir_options *options);
struct radv_shader *radv_shader_create(struct radv_device *device, struct vk_pipeline_cache *cache,
const struct radv_shader_binary *binary, bool skip_cache,
struct radv_shader_debug_info *dbg);
bool radv_graphics_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_graphics_pipeline *pipeline, bool *found_in_application_cache);
bool radv_compute_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_compute_pipeline *pipeline, bool *found_in_application_cache);
void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_pipeline *pipeline);
bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_ray_tracing_pipeline *pipeline,
bool *found_in_application_cache);
void radv_ray_tracing_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
struct radv_ray_tracing_pipeline *pipeline, unsigned num_stages,
unsigned num_groups);
nir_shader *radv_pipeline_cache_lookup_nir(const struct radv_compiler_info *compiler_info,
struct vk_pipeline_cache *cache, mesa_shader_stage stage,
const blake3_hash key);
void radv_pipeline_cache_insert_nir(const struct radv_compiler_info *compiler_info, struct vk_pipeline_cache *cache,
const blake3_hash key, const nir_shader *nir);
struct vk_pipeline_cache_object *radv_pipeline_cache_lookup_nir_handle(const struct radv_compiler_info *compiler_info,
struct vk_pipeline_cache *cache,
const unsigned char *blake3);
struct nir_shader *radv_pipeline_cache_handle_to_nir(const struct radv_compiler_info *compiler_info,
struct vk_pipeline_cache_object *object);
struct vk_pipeline_cache_object *radv_pipeline_cache_nir_to_handle(struct radv_device *device,
struct vk_pipeline_cache *cache,
struct nir_shader *nir, const unsigned char *blake3,
bool cached);
void radv_shader_serialize(struct radv_shader *shader, struct blob *blob);
struct radv_shader *radv_shader_deserialize(struct radv_device *device, const void *key_data, size_t key_size,
struct blob_reader *blob);
VkResult radv_pipeline_cache_get_binaries(struct radv_device *device, const VkAllocationCallbacks *pAllocator,
const unsigned char *blake3, struct util_dynarray *pipeline_binaries,
uint32_t *num_binaries, bool *found_in_internal_cache);
#endif /* RADV_PIPELINE_CACHE_H */