radv: fix a little memleak when we keep shader info

Submitted by Samuel Pitoiset on July 23, 2018, 11:50 a.m.

Details

Message ID 20180723115034.31587-1-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv: fix a little memleak when we keep shader info" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset July 23, 2018, 11:50 a.m.
When we keep shader info for eg. RADV_TRACE_FILE, we don't
free the NIR when creating the pipelines. Though, we have to
free it when destroying the shader module.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_shader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index aac5b8a21a..ef7c41af9e 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -599,8 +599,8 @@  shader_variant_create(struct radv_device *device,
 	if (device->keep_shader_info) {
 		variant->disasm_string = binary.disasm_string;
 		variant->llvm_ir_string = binary.llvm_ir_string;
+		variant->nir = *shaders;
 		if (!gs_copy_shader && !module->nir) {
-			variant->nir = *shaders;
 			variant->spirv = (uint32_t *)module->data;
 			variant->spirv_size = module->size;
 		}

Comments

On Mon, Jul 23, 2018 at 1:50 PM, Samuel Pitoiset
<samuel.pitoiset@gmail.com> wrote:
> When we keep shader info for eg. RADV_TRACE_FILE, we don't
> free the NIR when creating the pipelines. Though, we have to
> free it when destroying the shader module.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
> ---
>  src/amd/vulkan/radv_shader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
> index aac5b8a21a..ef7c41af9e 100644
> --- a/src/amd/vulkan/radv_shader.c
> +++ b/src/amd/vulkan/radv_shader.c
> @@ -599,8 +599,8 @@ shader_variant_create(struct radv_device *device,
>         if (device->keep_shader_info) {
>                 variant->disasm_string = binary.disasm_string;
>                 variant->llvm_ir_string = binary.llvm_ir_string;
> +               variant->nir = *shaders;

How does this work with merged shaders?

>                 if (!gs_copy_shader && !module->nir) {
> -                       variant->nir = *shaders;
>                         variant->spirv = (uint32_t *)module->data;
>                         variant->spirv_size = module->size;
>                 }
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
On 07/23/2018 04:02 PM, Bas Nieuwenhuizen wrote:
> On Mon, Jul 23, 2018 at 1:50 PM, Samuel Pitoiset
> <samuel.pitoiset@gmail.com> wrote:
>> When we keep shader info for eg. RADV_TRACE_FILE, we don't
>> free the NIR when creating the pipelines. Though, we have to
>> free it when destroying the shader module.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
>> ---
>>   src/amd/vulkan/radv_shader.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
>> index aac5b8a21a..ef7c41af9e 100644
>> --- a/src/amd/vulkan/radv_shader.c
>> +++ b/src/amd/vulkan/radv_shader.c
>> @@ -599,8 +599,8 @@ shader_variant_create(struct radv_device *device,
>>          if (device->keep_shader_info) {
>>                  variant->disasm_string = binary.disasm_string;
>>                  variant->llvm_ir_string = binary.llvm_ir_string;
>> +               variant->nir = *shaders;
> 
> How does this work with merged shaders?

You are right. I figured this on friday but I totally forgot during the 
weekend. :)

This still leaks memory for merged shaders.

> 
>>                  if (!gs_copy_shader && !module->nir) {
>> -                       variant->nir = *shaders;
>>                          variant->spirv = (uint32_t *)module->data;
>>                          variant->spirv_size = module->size;
>>                  }
>> --
>> 2.18.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev