radv: store the binary to radv_shader_part
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 1 Sep 2022 10:14:11 +0000 (12:14 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 13 Sep 2022 07:03:14 +0000 (07:03 +0000)
This is currently always freed after the upload but this will allow
to upload the PS epilog later.

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/18363>

src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader.h

index 1b65b94..2098430 100644 (file)
@@ -2102,6 +2102,7 @@ radv_shader_part_create(struct radv_shader_part_binary *binary, unsigned wave_si
       return NULL;
 
    shader_part->ref_count = 1;
+   shader_part->binary = binary;
    shader_part->code_size = code_size;
    shader_part->rsrc1 = S_00B848_VGPRS((binary->num_vgprs - 1) / (wave_size == 32 ? 8 : 4)) |
                         S_00B228_SGPRS((binary->num_sgprs - 1) / 8);
@@ -2468,7 +2469,9 @@ radv_create_vs_prolog(struct radv_device *device, const struct radv_vs_prolog_ke
       fprintf(stderr, "\ndisasm:\n%s\n", prolog->disasm_string);
    }
 
-   free(binary);
+   free(prolog->binary);
+   prolog->binary = NULL;
+
    return prolog;
 
 fail_alloc:
@@ -2533,7 +2536,9 @@ radv_create_ps_epilog(struct radv_device *device, const struct radv_ps_epilog_ke
       fprintf(stderr, "\ndisasm:\n%s\n", epilog->disasm_string);
    }
 
-   free(binary);
+   free(epilog->binary);
+   epilog->binary = NULL;
+
    return epilog;
 
 fail_alloc:
@@ -2564,6 +2569,7 @@ radv_shader_part_destroy(struct radv_device *device, struct radv_shader_part *sh
 
    if (shader_part->alloc)
       radv_free_shader_memory(device, shader_part->alloc);
+   free(shader_part->binary);
    free(shader_part->disasm_string);
    free(shader_part);
 }
index 4ac1e07..a6c7839 100644 (file)
@@ -513,6 +513,8 @@ struct radv_shader_part {
    uint8_t num_preserved_sgprs;
    bool nontrivial_divisors;
 
+   struct radv_shader_part_binary *binary;
+
    /* debug only */
    char *disasm_string;
 };