radv: store the post-processed shader binary config to the cache

This will allow us to reduce the size of radv_shader_info which is
stored in the cache entry.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12992>
This commit is contained in:
Samuel Pitoiset
2021-09-22 10:31:19 +02:00
committed by Marge Bot
parent 1585629db2
commit ced950e42f
3 changed files with 14 additions and 5 deletions

View File

@@ -353,7 +353,7 @@ radv_create_shader_variants_from_pipeline_cache(
memcpy(binary, p, entry->binary_sizes[i]);
p += entry->binary_sizes[i];
entry->variants[i] = radv_shader_variant_create(device, binary, false);
entry->variants[i] = radv_shader_variant_create(device, binary, false, true);
free(binary);
} else if (entry->binary_sizes[i]) {
p += entry->binary_sizes[i];

View File

@@ -1378,7 +1378,7 @@ radv_postprocess_config(const struct radv_device *device, const struct ac_shader
struct radv_shader_variant *
radv_shader_variant_create(struct radv_device *device, const struct radv_shader_binary *binary,
bool keep_shader_info)
bool keep_shader_info, bool from_cache)
{
struct ac_shader_config config = {0};
struct ac_rtld_binary rtld_binary = {0};
@@ -1452,7 +1452,13 @@ radv_shader_variant_create(struct radv_device *device, const struct radv_shader_
}
variant->info = binary->info;
if (from_cache) {
/* Copy the shader binary configuration from the cache. */
memcpy(&variant->config, &binary->config, sizeof(variant->config));
} else {
radv_postprocess_config(device, &config, &binary->info, binary->stage, &variant->config);
}
void *dest_ptr = radv_alloc_shader_memory(device, variant);
if (!dest_ptr) {
@@ -1617,7 +1623,7 @@ shader_variant_compile(struct radv_device *device, struct vk_shader_module *modu
binary->info = *info;
struct radv_shader_variant *variant =
radv_shader_variant_create(device, binary, keep_shader_info);
radv_shader_variant_create(device, binary, keep_shader_info, false);
if (!variant) {
free(binary);
return NULL;
@@ -1646,6 +1652,9 @@ shader_variant_compile(struct radv_device *device, struct vk_shader_module *modu
}
}
/* Copy the shader binary configuration to store it in the cache. */
memcpy(&binary->config, &variant->config, sizeof(binary->config));
if (binary_out)
*binary_out = binary;
else

View File

@@ -434,7 +434,7 @@ VkResult radv_create_shaders(struct radv_pipeline *pipeline,
struct radv_shader_variant *radv_shader_variant_create(struct radv_device *device,
const struct radv_shader_binary *binary,
bool keep_shader_info);
bool keep_shader_info, bool from_cache);
struct radv_shader_variant *radv_shader_variant_compile(
struct radv_device *device, struct vk_shader_module *module, struct nir_shader *const *shaders,
int shader_count, struct radv_pipeline_layout *layout, const struct radv_pipeline_key *key,