| … | … | @@ -1324,12 +1324,17 @@ void SceneShaderRaytracing::_finalize_pipeline_build(PipelineBuildTask *p_task) |
| 1324 | 1324 | } |
| 1325 | 1325 | RD::get_singleton()->hit_sbt_range_update(new_sbt, sbt_range, 0, indices); |
| 1326 | 1326 | |
| 1327 | | if (bundle.pipeline.is_valid()) { |
| 1328 | | RD::get_singleton()->free_rid(bundle.pipeline); |
| 1329 | | } |
| 1327 | // SBT before pipeline, never the other way round: hit_sbt_create registers the |
| 1328 | // SBT as a dependency of its pipeline (rendering_device.cpp:768), so freeing the |
| 1329 | // pipeline first frees the SBT with it and the next free is a double free. |
| 1330 | // Freeing the SBT first unregisters it from the pipeline's dependency set, which |
| 1331 | // is what invalidate_pipeline_bundles() already does. |
| 1330 | 1332 | if (bundle.hit_sbt.is_valid()) { |
| 1331 | 1333 | RD::get_singleton()->free_rid(bundle.hit_sbt); |
| 1332 | 1334 | } |
| 1335 | if (bundle.pipeline.is_valid()) { |
| 1336 | RD::get_singleton()->free_rid(bundle.pipeline); |
| 1337 | } |
| 1333 | 1338 | RD::get_singleton()->set_resource_name(p_task->new_pipeline, String("RT Pipeline [flags=") + itos(p_task->rt_flags) + "]"); |
| 1334 | 1339 | bundle.pipeline = p_task->new_pipeline; |
| 1335 | 1340 | bundle.hit_sbt = new_sbt; |