mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 07:20:10 +01:00
vulkan/runtime: add ray tracing pipeline support
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Ivan Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36757>
This commit is contained in:
parent
daac500e98
commit
69a04151db
3 changed files with 1143 additions and 0 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -121,6 +121,24 @@ vk_shader_cmp_graphics_stages(mesa_shader_stage a, mesa_shader_stage b)
|
|||
return stage_order[a] - stage_order[b];
|
||||
}
|
||||
|
||||
int
|
||||
vk_shader_cmp_rt_stages(mesa_shader_stage a, mesa_shader_stage b)
|
||||
{
|
||||
static const int stage_order[MESA_SHADER_CALLABLE + 1] = {
|
||||
[MESA_SHADER_RAYGEN] = 1,
|
||||
[MESA_SHADER_ANY_HIT] = 2,
|
||||
[MESA_SHADER_CLOSEST_HIT] = 3,
|
||||
[MESA_SHADER_MISS] = 4,
|
||||
[MESA_SHADER_INTERSECTION] = 5,
|
||||
[MESA_SHADER_CALLABLE] = 6,
|
||||
};
|
||||
|
||||
assert(a < ARRAY_SIZE(stage_order) && stage_order[a] > 0);
|
||||
assert(b < ARRAY_SIZE(stage_order) && stage_order[b] > 0);
|
||||
|
||||
return stage_order[a] - stage_order[b];
|
||||
}
|
||||
|
||||
struct stage_idx {
|
||||
mesa_shader_stage stage;
|
||||
uint32_t idx;
|
||||
|
|
|
|||
|
|
@ -47,13 +47,45 @@ struct vk_pipeline;
|
|||
struct vk_pipeline_robustness_state;
|
||||
|
||||
int vk_shader_cmp_graphics_stages(mesa_shader_stage a, mesa_shader_stage b);
|
||||
int vk_shader_cmp_rt_stages(mesa_shader_stage a, mesa_shader_stage b);
|
||||
|
||||
#define VK_SHADER_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_MESA 0x1000
|
||||
#define VK_SHADER_CREATE_UNALIGNED_DISPATCH_BIT_MESA 0x2000
|
||||
|
||||
#define MESA_VK_PIPELINE_RAY_TRACING_FLAGS ( \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_BUILT_IN_PRIMITIVES_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_SPHERES_AND_LINEAR_SWEPT_SPHERES_BIT_NV | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_AABBS_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_MOTION_BIT_NV | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT | \
|
||||
VK_PIPELINE_CREATE_2_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV | \
|
||||
VK_PIPELINE_CREATE_2_DISALLOW_OPACITY_MICROMAP_BIT_ARM)
|
||||
|
||||
struct vk_shader_compile_info {
|
||||
mesa_shader_stage stage;
|
||||
VkShaderCreateFlagsEXT flags;
|
||||
/* RT flags only includes :
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_BUILT_IN_PRIMITIVES_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_SPHERES_AND_LINEAR_SWEPT_SPHERES_BIT_NV
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_AABBS_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_MOTION_BIT_NV
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT
|
||||
* - VK_PIPELINE_CREATE_2_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV
|
||||
* - VK_PIPELINE_CREATE_2_DISALLOW_OPACITY_MICROMAP_BIT_ARM
|
||||
*/
|
||||
VkPipelineCreateFlags2KHR rt_flags;
|
||||
VkShaderStageFlags next_stage_mask;
|
||||
struct nir_shader *nir;
|
||||
|
||||
|
|
@ -219,6 +251,16 @@ struct vk_device_shader_ops {
|
|||
nir_shader *nir,
|
||||
const struct vk_pipeline_robustness_state *rs);
|
||||
|
||||
/** Return shader stages that should be linked together in a group
|
||||
*
|
||||
* The driver should return 0 if it does not require any linking, otherwise
|
||||
* it should return the stages that need to be linked together. The return
|
||||
* value should have more than one shader stage and be included in the
|
||||
* stages given as parameter.
|
||||
*/
|
||||
VkShaderStageFlags (*get_rt_group_linking)(struct vk_physical_device *device,
|
||||
VkShaderStageFlags stages);
|
||||
|
||||
/** Hash a vk_graphics_state object and a vk_features object.
|
||||
*
|
||||
* This callback hashes whatever bits of vk_graphics_pipeline_state might
|
||||
|
|
@ -261,6 +303,20 @@ struct vk_device_shader_ops {
|
|||
const VkAllocationCallbacks* pAllocator,
|
||||
struct vk_shader **shader_out);
|
||||
|
||||
|
||||
/** Writes a HW shader record from a shader group */
|
||||
void (*write_rt_shader_group)(struct vk_device *device,
|
||||
VkRayTracingShaderGroupTypeKHR type,
|
||||
const struct vk_shader **shaders,
|
||||
uint32_t shader_count,
|
||||
void *output);
|
||||
|
||||
/** Writes a group replay handle for a shader group */
|
||||
void (*write_rt_shader_group_replay_handle)(struct vk_device *device,
|
||||
const struct vk_shader **shaders,
|
||||
uint32_t shader_count,
|
||||
void *output);
|
||||
|
||||
/** Bind a set of shaders
|
||||
*
|
||||
* This is roughly equivalent to vkCmdBindShadersEXT()
|
||||
|
|
@ -273,6 +329,15 @@ struct vk_device_shader_ops {
|
|||
/** Sets dynamic state */
|
||||
void (*cmd_set_dynamic_graphics_state)(struct vk_command_buffer *cmd_buffer,
|
||||
const struct vk_dynamic_graphics_state *state);
|
||||
|
||||
/** Sets scratch size & ray query count for RT pipelines */
|
||||
void (*cmd_set_rt_state)(struct vk_command_buffer *cmd_buffer,
|
||||
VkDeviceSize scratch_size,
|
||||
uint32_t ray_queries);
|
||||
|
||||
/** Sets stack size for RT pipelines */
|
||||
void (*cmd_set_stack_size)(struct vk_command_buffer *cmd_buffer,
|
||||
VkDeviceSize stack_size);
|
||||
};
|
||||
|
||||
extern const struct vk_pipeline_robustness_state vk_robustness_disabled;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue