Skip to content

Commit 71276ab

Browse files
authored
Fix zeroing of OptiX structs (#1565)
1 parent 2cabc5f commit 71276ab

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/render/scene_optix.inl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ size_t init_optix_config(uint32_t optix_config_shapes) {
236236
// program groups will have a closest hit program.
237237

238238
OptixProgramGroupOptions program_group_options = {};
239-
OptixProgramGroupDesc pgd[MAX_PROGRAM_GROUP_COUNT] {};
239+
OptixProgramGroupDesc pgd[MAX_PROGRAM_GROUP_COUNT];
240+
memset(pgd, 0, sizeof(pgd)); // Use memset due to union member.
240241

241242
size_t pg_count = 0;
242243
for (size_t i = 0; i < MI_OPTIX_SHAPE_TYPE_COUNT; i++) {
@@ -282,13 +283,10 @@ size_t init_optix_config(uint32_t optix_config_shapes) {
282283
config.program_index_mapping[i] = pg_count - 1;
283284

284285
pgd[pg_count - 1].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
285-
pgd[pg_count - 1].hitgroup.moduleCH = nullptr;
286-
pgd[pg_count - 1].hitgroup.entryFunctionNameCH = nullptr;
287286
pgd[pg_count - 1].hitgroup.entryFunctionNameIS = config.intersection_pg_name[i];
288287

289288
switch(shape_type) {
290289
case MiOptixShapeType::Mesh:
291-
pgd[pg_count - 1].hitgroup.moduleIS = nullptr;
292290
break;
293291
case MiOptixShapeType::BSplineCurve:
294292
pgd[pg_count - 1].hitgroup.moduleIS = config.bspline_curve_module;
@@ -305,10 +303,6 @@ size_t init_optix_config(uint32_t optix_config_shapes) {
305303
// Create a dummy program so that we can still build a valid pipeline
306304
pg_count = 1;
307305
pgd[0].kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
308-
pgd[0].hitgroup.moduleCH = nullptr;
309-
pgd[0].hitgroup.entryFunctionNameCH = nullptr;
310-
pgd[0].hitgroup.entryFunctionNameIS = nullptr;
311-
pgd[0].hitgroup.moduleIS = nullptr;
312306
}
313307

314308
optix_log_size = sizeof(optix_log);
@@ -530,7 +524,8 @@ MI_VARIANT void Scene<Float, Spectrum>::accel_parameters_changed_gpu() {
530524
s.ias_data = {};
531525
s.ias_data.inputs = jit_malloc_migrate(d_ias, AllocType::Device, 1);
532526

533-
OptixBuildInput build_input{};
527+
OptixBuildInput build_input;
528+
memset(&build_input, 0, sizeof(OptixBuildInput)); // Use memset due to union member.
534529
build_input.type = OPTIX_BUILD_INPUT_TYPE_INSTANCES;
535530
build_input.instanceArray.instances = (CUdeviceptr) s.ias_data.inputs;
536531
build_input.instanceArray.numInstances = (unsigned int) ias.size();

0 commit comments

Comments
 (0)