radv/rt: unify radv_ray_tracing_lib_pipeline and radv_ray_tracing_pipeline
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22503>
This commit is contained in:

committed by
Marge Bot

parent
97721f32ca
commit
1100f7dcd5
@@ -98,9 +98,6 @@ radv_pipeline_destroy(struct radv_device *device, struct radv_pipeline *pipeline
|
|||||||
case RADV_PIPELINE_COMPUTE:
|
case RADV_PIPELINE_COMPUTE:
|
||||||
radv_destroy_compute_pipeline(device, radv_pipeline_to_compute(pipeline));
|
radv_destroy_compute_pipeline(device, radv_pipeline_to_compute(pipeline));
|
||||||
break;
|
break;
|
||||||
case RADV_PIPELINE_RAY_TRACING_LIB:
|
|
||||||
radv_destroy_ray_tracing_lib_pipeline(device, radv_pipeline_to_ray_tracing_lib(pipeline));
|
|
||||||
break;
|
|
||||||
case RADV_PIPELINE_RAY_TRACING:
|
case RADV_PIPELINE_RAY_TRACING:
|
||||||
radv_destroy_ray_tracing_pipeline(device, radv_pipeline_to_ray_tracing(pipeline));
|
radv_destroy_ray_tracing_pipeline(device, radv_pipeline_to_ray_tracing(pipeline));
|
||||||
break;
|
break;
|
||||||
|
@@ -111,7 +111,7 @@ radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKH
|
|||||||
if (pCreateInfo->pLibraryInfo) {
|
if (pCreateInfo->pLibraryInfo) {
|
||||||
for (uint32_t i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
for (uint32_t i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||||
RADV_FROM_HANDLE(radv_pipeline, lib_pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
RADV_FROM_HANDLE(radv_pipeline, lib_pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||||
struct radv_ray_tracing_lib_pipeline *lib = radv_pipeline_to_ray_tracing_lib(lib_pipeline);
|
struct radv_ray_tracing_pipeline *lib = radv_pipeline_to_ray_tracing(lib_pipeline);
|
||||||
_mesa_sha1_update(&ctx, lib->sha1, SHA1_DIGEST_LENGTH);
|
_mesa_sha1_update(&ctx, lib->sha1, SHA1_DIGEST_LENGTH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,8 @@ radv_hash_rt_shaders(unsigned char *hash, const VkRayTracingPipelineCreateInfoKH
|
|||||||
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR |
|
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR |
|
||||||
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR |
|
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR |
|
||||||
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR |
|
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR |
|
||||||
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR);
|
VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR |
|
||||||
|
VK_PIPELINE_CREATE_LIBRARY_BIT_KHR);
|
||||||
_mesa_sha1_update(&ctx, &pipeline_flags, 4);
|
_mesa_sha1_update(&ctx, &pipeline_flags, 4);
|
||||||
|
|
||||||
_mesa_sha1_update(&ctx, &flags, 4);
|
_mesa_sha1_update(&ctx, &flags, 4);
|
||||||
|
@@ -155,8 +155,8 @@ radv_rt_fill_group_info(struct radv_device *device,
|
|||||||
unsigned stage_count = pCreateInfo->stageCount;
|
unsigned stage_count = pCreateInfo->stageCount;
|
||||||
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||||
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||||
struct radv_ray_tracing_lib_pipeline *library_pipeline =
|
struct radv_ray_tracing_pipeline *library_pipeline =
|
||||||
radv_pipeline_to_ray_tracing_lib(pipeline);
|
radv_pipeline_to_ray_tracing(pipeline);
|
||||||
|
|
||||||
for (unsigned j = 0; j < library_pipeline->group_count; ++j) {
|
for (unsigned j = 0; j < library_pipeline->group_count; ++j) {
|
||||||
struct radv_ray_tracing_group *dst = &groups[idx + j];
|
struct radv_ray_tracing_group *dst = &groups[idx + j];
|
||||||
@@ -187,8 +187,8 @@ radv_rt_fill_stage_info(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo,
|
|||||||
if (pCreateInfo->pLibraryInfo) {
|
if (pCreateInfo->pLibraryInfo) {
|
||||||
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||||
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||||
struct radv_ray_tracing_lib_pipeline *library_pipeline =
|
struct radv_ray_tracing_pipeline *library_pipeline =
|
||||||
radv_pipeline_to_ray_tracing_lib(pipeline);
|
radv_pipeline_to_ray_tracing(pipeline);
|
||||||
for (unsigned j = 0; j < library_pipeline->stage_count; ++j)
|
for (unsigned j = 0; j < library_pipeline->stage_count; ++j)
|
||||||
stages[idx++].stage = library_pipeline->stages[j].stage;
|
stages[idx++].stage = library_pipeline->stages[j].stage;
|
||||||
}
|
}
|
||||||
@@ -205,8 +205,8 @@ radv_create_merged_rt_create_info(const VkRayTracingPipelineCreateInfoKHR *pCrea
|
|||||||
if (pCreateInfo->pLibraryInfo) {
|
if (pCreateInfo->pLibraryInfo) {
|
||||||
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||||
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||||
struct radv_ray_tracing_lib_pipeline *library_pipeline =
|
struct radv_ray_tracing_pipeline *library_pipeline =
|
||||||
radv_pipeline_to_ray_tracing_lib(pipeline);
|
radv_pipeline_to_ray_tracing(pipeline);
|
||||||
|
|
||||||
total_stages += library_pipeline->stage_count;
|
total_stages += library_pipeline->stage_count;
|
||||||
total_groups += library_pipeline->group_count;
|
total_groups += library_pipeline->group_count;
|
||||||
@@ -271,7 +271,7 @@ radv_rt_precompile_shaders(struct radv_device *device, struct vk_pipeline_cache
|
|||||||
if (pCreateInfo->pLibraryInfo) {
|
if (pCreateInfo->pLibraryInfo) {
|
||||||
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
for (unsigned i = 0; i < pCreateInfo->pLibraryInfo->libraryCount; ++i) {
|
||||||
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
RADV_FROM_HANDLE(radv_pipeline, pipeline, pCreateInfo->pLibraryInfo->pLibraries[i]);
|
||||||
struct radv_ray_tracing_lib_pipeline *library = radv_pipeline_to_ray_tracing_lib(pipeline);
|
struct radv_ray_tracing_pipeline *library = radv_pipeline_to_ray_tracing(pipeline);
|
||||||
|
|
||||||
for (unsigned j = 0; j < library->stage_count; ++j)
|
for (unsigned j = 0; j < library->stage_count; ++j)
|
||||||
stages[idx++].shader = vk_pipeline_cache_object_ref(library->stages[j].shader);
|
stages[idx++].shader = vk_pipeline_cache_object_ref(library->stages[j].shader);
|
||||||
@@ -404,7 +404,7 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache,
|
|||||||
{
|
{
|
||||||
RADV_FROM_HANDLE(radv_device, device, _device);
|
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||||
VK_FROM_HANDLE(vk_pipeline_cache, cache, _cache);
|
VK_FROM_HANDLE(vk_pipeline_cache, cache, _cache);
|
||||||
struct radv_ray_tracing_lib_pipeline *pipeline;
|
struct radv_ray_tracing_pipeline *pipeline;
|
||||||
VkResult result = VK_SUCCESS;
|
VkResult result = VK_SUCCESS;
|
||||||
bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pCreateInfo->flags);
|
bool keep_statistic_info = radv_pipeline_capture_shader_stats(device, pCreateInfo->flags);
|
||||||
const VkPipelineCreationFeedbackCreateInfo *creation_feedback =
|
const VkPipelineCreationFeedbackCreateInfo *creation_feedback =
|
||||||
@@ -424,7 +424,7 @@ radv_rt_pipeline_library_create(VkDevice _device, VkPipelineCache _cache,
|
|||||||
if (!pipeline)
|
if (!pipeline)
|
||||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||||
|
|
||||||
radv_pipeline_init(device, &pipeline->base.base, RADV_PIPELINE_RAY_TRACING_LIB);
|
radv_pipeline_init(device, &pipeline->base.base, RADV_PIPELINE_RAY_TRACING);
|
||||||
|
|
||||||
struct radv_pipeline_key key =
|
struct radv_pipeline_key key =
|
||||||
radv_generate_pipeline_key(device, &pipeline->base.base, pCreateInfo->flags);
|
radv_generate_pipeline_key(device, &pipeline->base.base, pCreateInfo->flags);
|
||||||
@@ -467,20 +467,6 @@ pipeline_fail:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
radv_destroy_ray_tracing_lib_pipeline(struct radv_device *device,
|
|
||||||
struct radv_ray_tracing_lib_pipeline *pipeline)
|
|
||||||
{
|
|
||||||
if (pipeline->stages) {
|
|
||||||
for (unsigned i = 0; i < pipeline->stage_count; i++) {
|
|
||||||
if (pipeline->stages[i].shader)
|
|
||||||
vk_pipeline_cache_object_unref(&device->vk, pipeline->stages[i].shader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ralloc_free(pipeline->ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
radv_rt_pipeline_has_dynamic_stack_size(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo)
|
radv_rt_pipeline_has_dynamic_stack_size(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo)
|
||||||
{
|
{
|
||||||
@@ -707,10 +693,19 @@ void
|
|||||||
radv_destroy_ray_tracing_pipeline(struct radv_device *device,
|
radv_destroy_ray_tracing_pipeline(struct radv_device *device,
|
||||||
struct radv_ray_tracing_pipeline *pipeline)
|
struct radv_ray_tracing_pipeline *pipeline)
|
||||||
{
|
{
|
||||||
|
if (pipeline->stages) {
|
||||||
|
for (unsigned i = 0; i < pipeline->stage_count; i++) {
|
||||||
|
if (pipeline->stages[i].shader)
|
||||||
|
vk_pipeline_cache_object_unref(&device->vk, pipeline->stages[i].shader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pipeline->base.base.shaders[MESA_SHADER_COMPUTE])
|
if (pipeline->base.base.shaders[MESA_SHADER_COMPUTE])
|
||||||
radv_shader_unref(device, pipeline->base.base.shaders[MESA_SHADER_COMPUTE]);
|
radv_shader_unref(device, pipeline->base.base.shaders[MESA_SHADER_COMPUTE]);
|
||||||
if (pipeline->base.base.shaders[MESA_SHADER_RAYGEN])
|
if (pipeline->base.base.shaders[MESA_SHADER_RAYGEN])
|
||||||
radv_shader_unref(device, pipeline->base.base.shaders[MESA_SHADER_RAYGEN]);
|
radv_shader_unref(device, pipeline->base.base.shaders[MESA_SHADER_RAYGEN]);
|
||||||
|
|
||||||
|
ralloc_free(pipeline->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
VKAPI_ATTR VkResult VKAPI_CALL
|
VKAPI_ATTR VkResult VKAPI_CALL
|
||||||
@@ -753,12 +748,7 @@ radv_GetRayTracingShaderGroupHandlesKHR(VkDevice device, VkPipeline _pipeline, u
|
|||||||
uint32_t groupCount, size_t dataSize, void *pData)
|
uint32_t groupCount, size_t dataSize, void *pData)
|
||||||
{
|
{
|
||||||
RADV_FROM_HANDLE(radv_pipeline, pipeline, _pipeline);
|
RADV_FROM_HANDLE(radv_pipeline, pipeline, _pipeline);
|
||||||
struct radv_ray_tracing_group *groups;
|
struct radv_ray_tracing_group *groups = radv_pipeline_to_ray_tracing(pipeline)->groups;
|
||||||
if (pipeline->type == RADV_PIPELINE_RAY_TRACING_LIB) {
|
|
||||||
groups = radv_pipeline_to_ray_tracing_lib(pipeline)->groups;
|
|
||||||
} else {
|
|
||||||
groups = radv_pipeline_to_ray_tracing(pipeline)->groups;
|
|
||||||
}
|
|
||||||
char *data = pData;
|
char *data = pData;
|
||||||
|
|
||||||
STATIC_ASSERT(sizeof(struct radv_pipeline_group_handle) <= RADV_RT_HANDLE_SIZE);
|
STATIC_ASSERT(sizeof(struct radv_pipeline_group_handle) <= RADV_RT_HANDLE_SIZE);
|
||||||
|
@@ -2175,7 +2175,6 @@ enum radv_pipeline_type {
|
|||||||
RADV_PIPELINE_GRAPHICS_LIB,
|
RADV_PIPELINE_GRAPHICS_LIB,
|
||||||
/* Compute pipeline */
|
/* Compute pipeline */
|
||||||
RADV_PIPELINE_COMPUTE,
|
RADV_PIPELINE_COMPUTE,
|
||||||
RADV_PIPELINE_RAY_TRACING_LIB,
|
|
||||||
/* Raytracing pipeline */
|
/* Raytracing pipeline */
|
||||||
RADV_PIPELINE_RAY_TRACING,
|
RADV_PIPELINE_RAY_TRACING,
|
||||||
};
|
};
|
||||||
@@ -2324,7 +2323,7 @@ struct radv_ray_tracing_stage {
|
|||||||
gl_shader_stage stage;
|
gl_shader_stage stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct radv_ray_tracing_lib_pipeline {
|
struct radv_ray_tracing_pipeline {
|
||||||
struct radv_compute_pipeline base;
|
struct radv_compute_pipeline base;
|
||||||
|
|
||||||
/* ralloc context used for allocating pipeline library resources. */
|
/* ralloc context used for allocating pipeline library resources. */
|
||||||
@@ -2334,6 +2333,7 @@ struct radv_ray_tracing_lib_pipeline {
|
|||||||
unsigned group_count;
|
unsigned group_count;
|
||||||
struct radv_ray_tracing_stage *stages;
|
struct radv_ray_tracing_stage *stages;
|
||||||
uint8_t sha1[SHA1_DIGEST_LENGTH];
|
uint8_t sha1[SHA1_DIGEST_LENGTH];
|
||||||
|
uint32_t stack_size;
|
||||||
struct radv_ray_tracing_group groups[];
|
struct radv_ray_tracing_group groups[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2358,14 +2358,6 @@ struct radv_graphics_lib_pipeline {
|
|||||||
VkPipelineShaderStageCreateInfo *stages;
|
VkPipelineShaderStageCreateInfo *stages;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct radv_ray_tracing_pipeline {
|
|
||||||
struct radv_compute_pipeline base;
|
|
||||||
|
|
||||||
uint32_t group_count;
|
|
||||||
uint32_t stack_size;
|
|
||||||
struct radv_ray_tracing_group groups[];
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RADV_DECL_PIPELINE_DOWNCAST(pipe_type, pipe_enum) \
|
#define RADV_DECL_PIPELINE_DOWNCAST(pipe_type, pipe_enum) \
|
||||||
static inline struct radv_##pipe_type##_pipeline * \
|
static inline struct radv_##pipe_type##_pipeline * \
|
||||||
radv_pipeline_to_##pipe_type(struct radv_pipeline *pipeline) \
|
radv_pipeline_to_##pipe_type(struct radv_pipeline *pipeline) \
|
||||||
@@ -2377,7 +2369,6 @@ struct radv_ray_tracing_pipeline {
|
|||||||
RADV_DECL_PIPELINE_DOWNCAST(graphics, RADV_PIPELINE_GRAPHICS)
|
RADV_DECL_PIPELINE_DOWNCAST(graphics, RADV_PIPELINE_GRAPHICS)
|
||||||
RADV_DECL_PIPELINE_DOWNCAST(graphics_lib, RADV_PIPELINE_GRAPHICS_LIB)
|
RADV_DECL_PIPELINE_DOWNCAST(graphics_lib, RADV_PIPELINE_GRAPHICS_LIB)
|
||||||
RADV_DECL_PIPELINE_DOWNCAST(compute, RADV_PIPELINE_COMPUTE)
|
RADV_DECL_PIPELINE_DOWNCAST(compute, RADV_PIPELINE_COMPUTE)
|
||||||
RADV_DECL_PIPELINE_DOWNCAST(ray_tracing_lib, RADV_PIPELINE_RAY_TRACING_LIB)
|
|
||||||
RADV_DECL_PIPELINE_DOWNCAST(ray_tracing, RADV_PIPELINE_RAY_TRACING)
|
RADV_DECL_PIPELINE_DOWNCAST(ray_tracing, RADV_PIPELINE_RAY_TRACING)
|
||||||
|
|
||||||
struct radv_pipeline_stage {
|
struct radv_pipeline_stage {
|
||||||
@@ -3683,8 +3674,6 @@ void radv_destroy_graphics_lib_pipeline(struct radv_device *device,
|
|||||||
struct radv_graphics_lib_pipeline *pipeline);
|
struct radv_graphics_lib_pipeline *pipeline);
|
||||||
void radv_destroy_compute_pipeline(struct radv_device *device,
|
void radv_destroy_compute_pipeline(struct radv_device *device,
|
||||||
struct radv_compute_pipeline *pipeline);
|
struct radv_compute_pipeline *pipeline);
|
||||||
void radv_destroy_ray_tracing_lib_pipeline(struct radv_device *device,
|
|
||||||
struct radv_ray_tracing_lib_pipeline *pipeline);
|
|
||||||
void radv_destroy_ray_tracing_pipeline(struct radv_device *device,
|
void radv_destroy_ray_tracing_pipeline(struct radv_device *device,
|
||||||
struct radv_ray_tracing_pipeline *pipeline);
|
struct radv_ray_tracing_pipeline *pipeline);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user