Fix T103258: Deleting a shader with OptiX OSL results in an illegal address error

Materials without connections to the output node would crash with OSL
in OptiX, since the Cycles `OSLCompiler` generates an empty shader
group reference for them, which resulted in the OptiX device
implementation setting an empty SBT entry for the corresponding direct
callables, which then crashed when calling those direct callables was
attempted in `osl_eval_nodes`. This fixes that by setting the SBT entries
for empty shader groups to a dummy direct callable that does nothing.
This commit is contained in:
Patrick Mours 2022-12-16 15:41:21 +01:00 committed by Hans Goudey
parent cfb77c54b0
commit 6bd6d7aec7
1 changed files with 5 additions and 0 deletions

View File

@ -866,6 +866,11 @@ bool OptiXDevice::load_osl_kernels()
optix_assert(optixSbtRecordPackHeader(osl_groups[i], &sbt_data[NUM_PROGRAM_GROUPS + i]));
optix_assert(optixProgramGroupGetStackSize(osl_groups[i], &osl_stack_size[i]));
}
else {
/* Default to "__direct_callable__dummy_services", so that OSL evaluation for empty
* materials has direct callables to call and does not crash. */
optix_assert(optixSbtRecordPackHeader(osl_groups.back(), &sbt_data[NUM_PROGRAM_GROUPS + i]));
}
}
sbt_data.copy_to_device(); /* Upload updated SBT to device. */