radv: clean up pipeline-cache interface
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22030>
This commit is contained in:

committed by
Marge Bot

parent
c2b9279227
commit
dcfca69e67
@@ -3307,9 +3307,8 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool found_in_application_cache = true;
|
bool found_in_application_cache = true;
|
||||||
if (!skip_shaders_cache &&
|
if (!skip_shaders_cache && radv_pipeline_cache_search(device, cache, &pipeline->base, hash,
|
||||||
radv_create_shaders_from_pipeline_cache(device, cache, hash, &pipeline->base, NULL, 0,
|
&found_in_application_cache)) {
|
||||||
&found_in_application_cache)) {
|
|
||||||
if (found_in_application_cache)
|
if (found_in_application_cache)
|
||||||
pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
pipeline_feedback.flags |= VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
||||||
|
|
||||||
@@ -3451,8 +3450,7 @@ radv_graphics_pipeline_compile(struct radv_graphics_pipeline *pipeline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!skip_shaders_cache) {
|
if (!skip_shaders_cache) {
|
||||||
radv_pipeline_cache_insert_shaders(device, cache, hash, &pipeline->base, binaries,
|
radv_pipeline_cache_insert(device, cache, &pipeline->base, ps_epilog_binary, hash);
|
||||||
ps_epilog_binary, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(gs_copy_binary);
|
free(gs_copy_binary);
|
||||||
@@ -5112,9 +5110,8 @@ radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline,
|
|||||||
pipeline->base.pipeline_hash = *(uint64_t *)hash;
|
pipeline->base.pipeline_hash = *(uint64_t *)hash;
|
||||||
|
|
||||||
bool found_in_application_cache = true;
|
bool found_in_application_cache = true;
|
||||||
if (!keep_executable_info &&
|
if (!keep_executable_info && radv_pipeline_cache_search(device, cache, &pipeline->base, hash,
|
||||||
radv_create_shaders_from_pipeline_cache(device, cache, hash, &pipeline->base, NULL, 0,
|
&found_in_application_cache)) {
|
||||||
&found_in_application_cache)) {
|
|
||||||
if (found_in_application_cache)
|
if (found_in_application_cache)
|
||||||
pipeline_feedback.flags |=
|
pipeline_feedback.flags |=
|
||||||
VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
||||||
@@ -5175,7 +5172,7 @@ radv_compute_pipeline_compile(struct radv_compute_pipeline *pipeline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!keep_executable_info) {
|
if (!keep_executable_info) {
|
||||||
radv_pipeline_cache_insert_shaders(device, cache, hash, &pipeline->base, binaries, NULL, NULL, 0);
|
radv_pipeline_cache_insert(device, cache, &pipeline->base, NULL, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(binaries[MESA_SHADER_COMPUTE]);
|
free(binaries[MESA_SHADER_COMPUTE]);
|
||||||
|
@@ -362,10 +362,9 @@ const struct vk_pipeline_cache_object_ops radv_pipeline_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
radv_create_shaders_from_pipeline_cache(struct radv_device *device, struct vk_pipeline_cache *cache,
|
radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
|
||||||
const unsigned char *sha1, struct radv_pipeline *pipeline,
|
struct radv_pipeline *pipeline, const unsigned char *sha1,
|
||||||
struct radv_ray_tracing_module *rt_groups,
|
bool *found_in_application_cache)
|
||||||
uint32_t num_rt_groups, bool *found_in_application_cache)
|
|
||||||
{
|
{
|
||||||
*found_in_application_cache = false;
|
*found_in_application_cache = false;
|
||||||
|
|
||||||
@@ -399,7 +398,6 @@ radv_create_shaders_from_pipeline_cache(struct radv_device *device, struct vk_pi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pipeline_obj->ps_epilog) {
|
if (pipeline_obj->ps_epilog) {
|
||||||
assert(num_rt_groups == 0);
|
|
||||||
struct radv_shader_part *ps_epilog = radv_shader_part_ref(pipeline_obj->ps_epilog);
|
struct radv_shader_part *ps_epilog = radv_shader_part_ref(pipeline_obj->ps_epilog);
|
||||||
|
|
||||||
if (pipeline->type == RADV_PIPELINE_GRAPHICS)
|
if (pipeline->type == RADV_PIPELINE_GRAPHICS)
|
||||||
@@ -408,10 +406,11 @@ radv_create_shaders_from_pipeline_cache(struct radv_device *device, struct vk_pi
|
|||||||
radv_pipeline_to_graphics_lib(pipeline)->base.ps_epilog = ps_epilog;
|
radv_pipeline_to_graphics_lib(pipeline)->base.ps_epilog = ps_epilog;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_rt_groups) {
|
if (pipeline->type == RADV_PIPELINE_RAY_TRACING) {
|
||||||
|
unsigned num_rt_groups = radv_pipeline_to_ray_tracing(pipeline)->group_count;
|
||||||
assert(num_rt_groups == pipeline_obj->num_stack_sizes);
|
assert(num_rt_groups == pipeline_obj->num_stack_sizes);
|
||||||
assert(pipeline_obj->ps_epilog == NULL);
|
|
||||||
struct radv_pipeline_shader_stack_size *stack_sizes = pipeline_obj->data;
|
struct radv_pipeline_shader_stack_size *stack_sizes = pipeline_obj->data;
|
||||||
|
struct radv_ray_tracing_module *rt_groups = radv_pipeline_to_ray_tracing(pipeline)->groups;
|
||||||
for (unsigned i = 0; i < num_rt_groups; i++)
|
for (unsigned i = 0; i < num_rt_groups; i++)
|
||||||
rt_groups[i].stack_size = stack_sizes[i];
|
rt_groups[i].stack_size = stack_sizes[i];
|
||||||
}
|
}
|
||||||
@@ -421,12 +420,10 @@ radv_create_shaders_from_pipeline_cache(struct radv_device *device, struct vk_pi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
radv_pipeline_cache_insert_shaders(struct radv_device *device, struct vk_pipeline_cache *cache,
|
radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
|
||||||
const unsigned char *sha1, struct radv_pipeline *pipeline,
|
struct radv_pipeline *pipeline,
|
||||||
struct radv_shader_binary *const *binaries,
|
struct radv_shader_part_binary *ps_epilog_binary,
|
||||||
struct radv_shader_part_binary *ps_epilog_binary,
|
const unsigned char *sha1)
|
||||||
const struct radv_ray_tracing_module *rt_groups,
|
|
||||||
uint32_t num_rt_groups)
|
|
||||||
{
|
{
|
||||||
if (radv_is_cache_disabled(device))
|
if (radv_is_cache_disabled(device))
|
||||||
return;
|
return;
|
||||||
@@ -441,6 +438,9 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct vk_pipelin
|
|||||||
num_shaders += pipeline->gs_copy_shader ? 1 : 0;
|
num_shaders += pipeline->gs_copy_shader ? 1 : 0;
|
||||||
|
|
||||||
unsigned ps_epilog_binary_size = ps_epilog_binary ? ps_epilog_binary->total_size : 0;
|
unsigned ps_epilog_binary_size = ps_epilog_binary ? ps_epilog_binary->total_size : 0;
|
||||||
|
unsigned num_rt_groups = 0;
|
||||||
|
if (pipeline->type == RADV_PIPELINE_RAY_TRACING)
|
||||||
|
num_rt_groups = radv_pipeline_to_ray_tracing(pipeline)->group_count;
|
||||||
|
|
||||||
struct radv_pipeline_cache_object *pipeline_obj;
|
struct radv_pipeline_cache_object *pipeline_obj;
|
||||||
pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, sha1, num_rt_groups,
|
pipeline_obj = radv_pipeline_cache_object_create(&device->vk, num_shaders, sha1, num_rt_groups,
|
||||||
@@ -471,9 +471,12 @@ radv_pipeline_cache_insert_shaders(struct radv_device *device, struct vk_pipelin
|
|||||||
pipeline_obj->ps_epilog = radv_shader_part_ref(ps_epilog);
|
pipeline_obj->ps_epilog = radv_shader_part_ref(ps_epilog);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct radv_pipeline_shader_stack_size *stack_sizes = pipeline_obj->data;
|
if (pipeline->type == RADV_PIPELINE_RAY_TRACING) {
|
||||||
for (unsigned i = 0; i < num_rt_groups; i++)
|
struct radv_pipeline_shader_stack_size *stack_sizes = pipeline_obj->data;
|
||||||
stack_sizes[i] = rt_groups[i].stack_size;
|
struct radv_ray_tracing_module *rt_groups = radv_pipeline_to_ray_tracing(pipeline)->groups;
|
||||||
|
for (unsigned i = 0; i < num_rt_groups; i++)
|
||||||
|
stack_sizes[i] = rt_groups[i].stack_size;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add the object to the cache */
|
/* Add the object to the cache */
|
||||||
struct vk_pipeline_cache_object *object =
|
struct vk_pipeline_cache_object *object =
|
||||||
|
@@ -235,9 +235,8 @@ radv_rt_pipeline_compile(struct radv_ray_tracing_pipeline *pipeline,
|
|||||||
pipeline->base.base.pipeline_hash = *(uint64_t *)hash;
|
pipeline->base.base.pipeline_hash = *(uint64_t *)hash;
|
||||||
|
|
||||||
bool found_in_application_cache = true;
|
bool found_in_application_cache = true;
|
||||||
if (!keep_executable_info &&
|
if (!keep_executable_info && radv_pipeline_cache_search(device, cache, &pipeline->base.base,
|
||||||
radv_create_shaders_from_pipeline_cache(device, cache, hash, &pipeline->base.base, rt_groups,
|
hash, &found_in_application_cache)) {
|
||||||
num_rt_groups, &found_in_application_cache)) {
|
|
||||||
if (found_in_application_cache)
|
if (found_in_application_cache)
|
||||||
pipeline_feedback.flags |=
|
pipeline_feedback.flags |=
|
||||||
VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT;
|
||||||
@@ -298,8 +297,7 @@ radv_rt_pipeline_compile(struct radv_ray_tracing_pipeline *pipeline,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!keep_executable_info) {
|
if (!keep_executable_info) {
|
||||||
radv_pipeline_cache_insert_shaders(device, cache, hash, &pipeline->base.base, binaries, NULL,
|
radv_pipeline_cache_insert(device, cache, &pipeline->base.base, NULL, hash);
|
||||||
rt_groups, num_rt_groups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(binaries[rt_stage.stage]);
|
free(binaries[rt_stage.stage]);
|
||||||
|
@@ -415,19 +415,16 @@ struct radv_instance {
|
|||||||
VkResult radv_init_wsi(struct radv_physical_device *physical_device);
|
VkResult radv_init_wsi(struct radv_physical_device *physical_device);
|
||||||
void radv_finish_wsi(struct radv_physical_device *physical_device);
|
void radv_finish_wsi(struct radv_physical_device *physical_device);
|
||||||
|
|
||||||
bool radv_create_shaders_from_pipeline_cache(
|
|
||||||
struct radv_device *device, struct vk_pipeline_cache *cache, const unsigned char *sha1,
|
|
||||||
struct radv_pipeline *pipeline, struct radv_ray_tracing_module *rt_groups,
|
|
||||||
uint32_t num_rt_groups, bool *found_in_application_cache);
|
|
||||||
|
|
||||||
struct radv_shader_binary_part;
|
struct radv_shader_binary_part;
|
||||||
|
|
||||||
void radv_pipeline_cache_insert_shaders(struct radv_device *device, struct vk_pipeline_cache *cache,
|
bool radv_pipeline_cache_search(struct radv_device *device, struct vk_pipeline_cache *cache,
|
||||||
const unsigned char *sha1, struct radv_pipeline *pipeline,
|
struct radv_pipeline *pipeline, const unsigned char *sha1,
|
||||||
struct radv_shader_binary *const *binaries,
|
bool *found_in_application_cache);
|
||||||
struct radv_shader_part_binary *ps_epilog_binary,
|
|
||||||
const struct radv_ray_tracing_module *rt_groups,
|
void radv_pipeline_cache_insert(struct radv_device *device, struct vk_pipeline_cache *cache,
|
||||||
uint32_t num_rt_groups);
|
struct radv_pipeline *pipeline,
|
||||||
|
struct radv_shader_part_binary *ps_epilog_binary,
|
||||||
|
const unsigned char *sha1);
|
||||||
|
|
||||||
enum radv_blit_ds_layout {
|
enum radv_blit_ds_layout {
|
||||||
RADV_BLIT_DS_LAYOUT_TILE_ENABLE,
|
RADV_BLIT_DS_LAYOUT_TILE_ENABLE,
|
||||||
|
Reference in New Issue
Block a user