lavapipe: always clone shader nir for shader states
these become owned and freed by llvmpipe, so ensure that freeing them there won't cause crashes cc: mesa-stable Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15281>
This commit is contained in:

committed by
Marge Bot

parent
2170c3ac63
commit
2f9976debc
@@ -64,6 +64,9 @@ VKAPI_ATTR void VKAPI_CALL lvp_DestroyPipeline(
|
||||
if (pipeline->shader_cso[PIPE_SHADER_COMPUTE])
|
||||
device->queue.ctx->delete_compute_state(device->queue.ctx, pipeline->shader_cso[PIPE_SHADER_COMPUTE]);
|
||||
|
||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++)
|
||||
ralloc_free(pipeline->pipeline_nir[i]);
|
||||
|
||||
ralloc_free(pipeline->mem_ctx);
|
||||
vk_object_base_finish(&pipeline->base);
|
||||
vk_free2(&device->vk.alloc, pAllocator, pipeline);
|
||||
@@ -765,7 +768,7 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
|
||||
static void fill_shader_prog(struct pipe_shader_state *state, gl_shader_stage stage, struct lvp_pipeline *pipeline)
|
||||
{
|
||||
state->type = PIPE_SHADER_IR_NIR;
|
||||
state->ir.nir = pipeline->pipeline_nir[stage];
|
||||
state->ir.nir = nir_shader_clone(NULL, pipeline->pipeline_nir[stage]);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -837,7 +840,7 @@ lvp_pipeline_compile(struct lvp_pipeline *pipeline,
|
||||
device->physical_device->pscreen->finalize_nir(device->physical_device->pscreen, pipeline->pipeline_nir[stage]);
|
||||
if (stage == MESA_SHADER_COMPUTE) {
|
||||
struct pipe_compute_state shstate = {0};
|
||||
shstate.prog = (void *)pipeline->pipeline_nir[MESA_SHADER_COMPUTE];
|
||||
shstate.prog = (void *)nir_shader_clone(NULL, pipeline->pipeline_nir[MESA_SHADER_COMPUTE]);
|
||||
shstate.ir_type = PIPE_SHADER_IR_NIR;
|
||||
shstate.req_local_mem = pipeline->pipeline_nir[MESA_SHADER_COMPUTE]->info.shared_size;
|
||||
pipeline->shader_cso[PIPE_SHADER_COMPUTE] = device->queue.ctx->create_compute_state(device->queue.ctx, &shstate);
|
||||
@@ -1023,7 +1026,7 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
|
||||
pipeline->pipeline_nir[MESA_SHADER_FRAGMENT] = b.shader;
|
||||
struct pipe_shader_state shstate = {0};
|
||||
shstate.type = PIPE_SHADER_IR_NIR;
|
||||
shstate.ir.nir = pipeline->pipeline_nir[MESA_SHADER_FRAGMENT];
|
||||
shstate.ir.nir = nir_shader_clone(NULL, pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]);
|
||||
pipeline->shader_cso[PIPE_SHADER_FRAGMENT] = device->queue.ctx->create_fs_state(device->queue.ctx, &shstate);
|
||||
}
|
||||
return VK_SUCCESS;
|
||||
|
Reference in New Issue
Block a user