intel/blorp: Rework our usage of ralloc when compiling shaders
Previously, we were creating the shader with a NULL ralloc context and then trusting in blorp_compile_fs to clean it up. The only problem was that blorp_compile_fs didn't clean up its context properly so we were leaking. When I went to fix that, I realized that it couldn't because it has to return the shader binary which is allocated off of that context and used by the caller. The solution is to make blorp_compile_fs take a ralloc context, allocate the nir_shaders directly off that context, and clean it all up in whatever function creates the shader and calls blorp_compile_fs. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Cc: "12.0, 13.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
@@ -55,7 +55,7 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
|
||||
void *mem_ctx = ralloc_context(NULL);
|
||||
|
||||
nir_builder b;
|
||||
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
|
||||
nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL);
|
||||
b.shader->info->name = ralloc_strdup(b.shader, "BLORP-clear");
|
||||
|
||||
nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
|
||||
@@ -76,7 +76,7 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
|
||||
struct brw_blorp_prog_data prog_data;
|
||||
unsigned program_size;
|
||||
const unsigned *program =
|
||||
blorp_compile_fs(blorp, b.shader, &wm_key, use_replicated_data,
|
||||
blorp_compile_fs(blorp, mem_ctx, b.shader, &wm_key, use_replicated_data,
|
||||
&prog_data, &program_size);
|
||||
|
||||
blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key),
|
||||
|
Reference in New Issue
Block a user