mesa/src/amd/vulkan/radv_pipeline_cache.h
Natalie Vock a03e9287c3 radv/rt: Compile ahit/isec shaders to asm
We can express any-hit/intersection shaders as functions, too.
Any-hit/Intersection shaders need the usual parameters like launch
IDs/descriptor data/ray properties, origin, direction/etc., but also
some special parameters related to traversal state. Any-hit/intersection
shaders need to return whether the hit was accepted and/or traversal
should be terminated, as well as the intersection T value (for
intersection shaders). Both any-hit and intersection shaders also need
to be passed hit attributes via parameters. Closest-Hit shaders need
those too, but we pass them out-of-band via LDS. LDS is used for the
traversal stack when any-hit/intersection shaders, so we need to pass
them via parameters.

Hit attributes are similar to ray payloads in the sense that they're
dynamically sized depending on how much space the application uses.
However, unlike ray payloads, hit attribute sizes have a strict upper
bound of 8 dwords. To make managing parameters easier, we put all hit
attributes in a single vector parameter with 0-8 components. This
prevents having a function with two sets of arbitrary numbers of
parameters.

This commit sets up ahit/isec function signatures and implements
lowering for ahit/isec-specific intrinsics in the context of these
functions. Subsequent commits will merely have to call into these
functions to execute a separate-compiled any-hit/intersection shader.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39314>
2026-01-20 21:49:55 +00:00

83 lines
4 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_stage;
struct radv_spirv_to_nir_options;
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);
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(struct radv_device *device, struct vk_pipeline_cache *cache,
mesa_shader_stage stage, const blake3_hash key);
void radv_pipeline_cache_insert_nir(struct radv_device *device, struct vk_pipeline_cache *cache, const blake3_hash key,
const nir_shader *nir);
struct vk_pipeline_cache_object *radv_pipeline_cache_lookup_nir_handle(struct radv_device *device,
struct vk_pipeline_cache *cache,
const unsigned char *sha1);
struct nir_shader *radv_pipeline_cache_handle_to_nir(struct radv_device *device,
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 *sha1,
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 *sha1, struct util_dynarray *pipeline_binaries,
uint32_t *num_binaries, bool *found_in_internal_cache);
#endif /* RADV_PIPELINE_CACHE_H */