radv: upload shader binaries after they are all compiled

Instead of mixing compilation and upload. This will allow us to
upload all shader binaries contiguously in memory and also for future
pipeline libraries work.

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/13690>
This commit is contained in:
Samuel Pitoiset
2021-11-05 13:30:28 +01:00
committed by Marge Bot
parent ff61b36ba2
commit 13143b3c11
4 changed files with 26 additions and 4 deletions

View File

@@ -3691,6 +3691,21 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_pipeline_layout
}
}
/* Upload shader binaries. */
for (int i = 0; i < MESA_VULKAN_SHADER_STAGES; ++i) {
struct radv_shader *shader = pipeline->shaders[i];
if (!shader)
continue;
if (!radv_shader_binary_upload(device, binaries[i], shader))
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
if (i == MESA_SHADER_GEOMETRY && pipeline->gs_copy_shader) {
if (!radv_shader_binary_upload(device, gs_copy_binary, pipeline->gs_copy_shader))
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
}
if (!keep_executable_info) {
if (pipeline->gs_copy_shader) {
assert(!binaries[MESA_SHADER_COMPUTE] && !pipeline->shaders[MESA_SHADER_COMPUTE]);

View File

@@ -355,6 +355,13 @@ radv_create_shaders_from_pipeline_cache(
p += entry->binary_sizes[i];
entry->shaders[i] = radv_shader_create(device, binary, false, true, NULL);
if (!radv_shader_binary_upload(device, binary, entry->shaders[i])) {
free(binary);
radv_pipeline_cache_unlock(cache);
return false;
}
free(binary);
} else if (entry->binary_sizes[i]) {
p += entry->binary_sizes[i];

View File

@@ -1606,7 +1606,7 @@ radv_open_rtld_binary(struct radv_device *device, const struct radv_shader *shad
return ac_rtld_open(rtld_binary, open_info);
}
static bool
bool
radv_shader_binary_upload(struct radv_device *device, const struct radv_shader_binary *binary,
struct radv_shader *shader)
{
@@ -1710,9 +1710,6 @@ radv_shader_create(struct radv_device *device, const struct radv_shader_binary *
radv_postprocess_config(device, &config, &binary->info, binary->stage, args, &shader->config);
}
if (!radv_shader_binary_upload(device, binary, shader))
return NULL;
if (binary->type == RADV_BINARY_TYPE_RTLD) {
struct radv_shader_binary_rtld *bin = (struct radv_shader_binary_rtld *)binary;
struct ac_rtld_binary rtld_binary = {0};

View File

@@ -514,6 +514,9 @@ struct radv_shader *radv_shader_compile(
struct radv_shader_info *info, bool keep_shader_info, bool keep_statistic_info,
struct radv_shader_binary **binary_out);
bool radv_shader_binary_upload(struct radv_device *device, const struct radv_shader_binary *binary,
struct radv_shader *shader);
struct radv_shader *
radv_create_gs_copy_shader(struct radv_device *device, struct nir_shader *nir,
struct radv_shader_info *info, struct radv_shader_binary **binary_out,