xref: /aosp_15_r20/external/mesa3d/src/amd/vulkan/radv_pipeline_cache.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2016 Red Hat.
3  * Copyright © 2016 Bas Nieuwenhuizen
4  *
5  * based in part on anv driver which is:
6  * Copyright © 2015 Intel Corporation
7  *
8  * SPDX-License-Identifier: MIT
9  */
10 
11 #ifndef RADV_PIPELINE_CACHE_H
12 #define RADV_PIPELINE_CACHE_H
13 
14 #include "util/mesa-blake3.h"
15 
16 #include "nir.h"
17 
18 #include "vk_pipeline_cache.h"
19 
20 struct radv_device;
21 struct radv_graphics_state_key;
22 struct radv_pipeline;
23 struct radv_pipeline_layout;
24 struct radv_ray_tracing_group;
25 struct radv_ray_tracing_pipeline;
26 struct radv_graphics_pipeline;
27 struct radv_compute_pipeline;
28 struct radv_ray_tracing_stage;
29 struct radv_shader_binary;
30 struct radv_shader_stage;
31 struct radv_spirv_to_nir_options;
32 struct util_dynarray;
33 
34 void radv_hash_graphics_spirv_to_nir(blake3_hash hash, const struct radv_shader_stage *stage,
35                                      const struct radv_spirv_to_nir_options *options);
36 
37 struct radv_shader *radv_shader_create(struct radv_device *device, struct vk_pipeline_cache *cache,
38                                        const struct radv_shader_binary *binary, bool skip_cache);
39 
40 bool radv_graphics_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
41                                          struct radv_graphics_pipeline *pipeline, bool *found_in_application_cache);
42 
43 bool radv_compute_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
44                                         struct radv_compute_pipeline *pipeline, bool *found_in_application_cache);
45 
46 void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
47                                 struct radv_pipeline *pipeline);
48 
49 bool radv_ray_tracing_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
50                                             struct radv_ray_tracing_pipeline *pipeline,
51                                             bool *found_in_application_cache);
52 
53 void radv_ray_tracing_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
54                                             struct radv_ray_tracing_pipeline *pipeline, unsigned num_stages);
55 
56 nir_shader *radv_pipeline_cache_lookup_nir(struct radv_device *device, struct vk_pipeline_cache *cache,
57                                            gl_shader_stage stage, const blake3_hash key);
58 
59 void radv_pipeline_cache_insert_nir(struct radv_device *device, struct vk_pipeline_cache *cache, const blake3_hash key,
60                                     const nir_shader *nir);
61 
62 struct vk_pipeline_cache_object *radv_pipeline_cache_lookup_nir_handle(struct radv_device *device,
63                                                                        struct vk_pipeline_cache *cache,
64                                                                        const unsigned char *sha1);
65 
66 struct nir_shader *radv_pipeline_cache_handle_to_nir(struct radv_device *device,
67                                                      struct vk_pipeline_cache_object *object);
68 
69 struct vk_pipeline_cache_object *radv_pipeline_cache_nir_to_handle(struct radv_device *device,
70                                                                    struct vk_pipeline_cache *cache,
71                                                                    struct nir_shader *nir, const unsigned char *sha1,
72                                                                    bool cached);
73 
74 void radv_shader_serialize(struct radv_shader *shader, struct blob *blob);
75 
76 struct radv_shader *radv_shader_deserialize(struct radv_device *device, const void *key_data, size_t key_size,
77                                             struct blob_reader *blob);
78 
79 VkResult radv_pipeline_cache_get_binaries(struct radv_device *device, const VkAllocationCallbacks *pAllocator,
80                                           const unsigned char *sha1, struct util_dynarray *pipeline_binaries,
81                                           uint32_t *num_binaries, bool *found_in_internal_cache);
82 
83 #endif /* RADV_PIPELINE_CACHE_H */
84