Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ jobs:
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_opticks.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_simg4ox.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPURaytrace.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_triangulated.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPUPhotonFileSource.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_GPUPhotonSource_8x8SiPM.sh
docker run --rm --gpus 'device=1' ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} tests/test_wavelength_shifting.sh
Expand Down
98 changes: 61 additions & 37 deletions CSGOptiX/PIP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ OptixPipelineCompileOptions PIP::CreatePipelineOptions(unsigned numPayloadValues
pipeline_compile_options.numAttributeValues = numAttributeValues ;
pipeline_compile_options.exceptionFlags = OPT::ExceptionFlags( CreatePipelineOptions_exceptionFlags ) ;
pipeline_compile_options.pipelineLaunchParamsVariableName = "params";
pipeline_compile_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM ;
pipeline_compile_options.usesPrimitiveTypeFlags = OPTIX_PRIMITIVE_TYPE_FLAGS_CUSTOM | OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE;

return pipeline_compile_options ;
}
Expand Down Expand Up @@ -410,40 +410,62 @@ PIP::createHitgroupPG

void PIP::createHitgroupPG()
{
OptixProgramGroupDesc desc = {};
desc.kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;

desc.hitgroup.moduleIS = module ;
desc.hitgroup.entryFunctionNameIS = IS ;

desc.hitgroup.moduleCH = module ;
desc.hitgroup.entryFunctionNameCH = CH ;

desc.hitgroup.moduleAH = nullptr ;
desc.hitgroup.entryFunctionNameAH = nullptr ;

size_t sizeof_log = 0 ;
char log[2048];
unsigned num_program_groups = 1 ;


OPTIX_CHECK_LOG( optixProgramGroupCreate(
Ctx::context,
&desc,
num_program_groups,
&program_group_options,
log,
&sizeof_log,
&hitgroup_pg
) );

if(sizeof_log > 0) std::cout << log << std::endl ;
assert( sizeof_log == 0);
size_t sizeof_log = 0;
char log[2048];
unsigned num_program_groups = 1;

// analytic (custom primitive) hitgroup: custom IS + CH
OptixProgramGroupDesc desc_ana = {};
desc_ana.kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
desc_ana.hitgroup.moduleIS = module;
desc_ana.hitgroup.entryFunctionNameIS = IS;
desc_ana.hitgroup.moduleCH = module;
desc_ana.hitgroup.entryFunctionNameCH = CH;
desc_ana.hitgroup.moduleAH = nullptr;
desc_ana.hitgroup.entryFunctionNameAH = nullptr;

OPTIX_CHECK_LOG(optixProgramGroupCreate(
Ctx::context,
&desc_ana,
num_program_groups,
&program_group_options,
log,
&sizeof_log,
&hitgroup_pg));

if (sizeof_log > 0)
std::cout << log << std::endl;
assert(sizeof_log == 0);

// triangle hitgroup: builtin IS (must be null) + CH
sizeof_log = 0;
OptixProgramGroupDesc desc_tri = {};
desc_tri.kind = OPTIX_PROGRAM_GROUP_KIND_HITGROUP;
desc_tri.hitgroup.moduleIS = nullptr;
desc_tri.hitgroup.entryFunctionNameIS = nullptr;
desc_tri.hitgroup.moduleCH = module;
desc_tri.hitgroup.entryFunctionNameCH = CH;
desc_tri.hitgroup.moduleAH = nullptr;
desc_tri.hitgroup.entryFunctionNameAH = nullptr;

OPTIX_CHECK_LOG(optixProgramGroupCreate(
Ctx::context,
&desc_tri,
num_program_groups,
&program_group_options,
log,
&sizeof_log,
&hitgroup_pg_tri));

if (sizeof_log > 0)
std::cout << log << std::endl;
assert(sizeof_log == 0);
}

void PIP::destroyHitgroupPG()
{
OPTIX_CHECK( optixProgramGroupDestroy( hitgroup_pg ) );
OPTIX_CHECK(optixProgramGroupDestroy(hitgroup_pg_tri));
}


Expand Down Expand Up @@ -482,7 +504,7 @@ std::string PIP::Desc_PipelineLinkOptions(const OptixPipelineLinkOptions& pipeli

void PIP::linkPipeline(unsigned max_trace_depth)
{
OptixProgramGroup program_groups[] = { raygen_pg, miss_pg, hitgroup_pg };
OptixProgramGroup program_groups[] = {raygen_pg, miss_pg, hitgroup_pg, hitgroup_pg_tri};

OptixPipelineLinkOptions pipeline_link_options = {};
pipeline_link_options.maxTraceDepth = max_trace_depth ;
Expand Down Expand Up @@ -550,13 +572,15 @@ void PIP::configureStack()
OptixStackSizes stackSizes = {};

#if OPTIX_VERSION <= 70600
OPTIX_CHECK( optixUtilAccumulateStackSizes( raygen_pg, &stackSizes ) );
OPTIX_CHECK( optixUtilAccumulateStackSizes( miss_pg, &stackSizes ) );
OPTIX_CHECK( optixUtilAccumulateStackSizes( hitgroup_pg, &stackSizes ) );
OPTIX_CHECK(optixUtilAccumulateStackSizes(raygen_pg, &stackSizes));
OPTIX_CHECK(optixUtilAccumulateStackSizes(miss_pg, &stackSizes));
OPTIX_CHECK(optixUtilAccumulateStackSizes(hitgroup_pg, &stackSizes));
OPTIX_CHECK(optixUtilAccumulateStackSizes(hitgroup_pg_tri, &stackSizes));
#else
OPTIX_CHECK( optixUtilAccumulateStackSizes( raygen_pg, &stackSizes, pipeline ) );
OPTIX_CHECK( optixUtilAccumulateStackSizes( miss_pg, &stackSizes, pipeline ) );
OPTIX_CHECK( optixUtilAccumulateStackSizes( hitgroup_pg, &stackSizes, pipeline ) );
OPTIX_CHECK(optixUtilAccumulateStackSizes(raygen_pg, &stackSizes, pipeline));
OPTIX_CHECK(optixUtilAccumulateStackSizes(miss_pg, &stackSizes, pipeline));
OPTIX_CHECK(optixUtilAccumulateStackSizes(hitgroup_pg, &stackSizes, pipeline));
OPTIX_CHECK(optixUtilAccumulateStackSizes(hitgroup_pg_tri, &stackSizes, pipeline));
#endif


Expand Down
7 changes: 4 additions & 3 deletions CSGOptiX/PIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ struct PIP

OptixModule module = nullptr;

OptixProgramGroup raygen_pg = nullptr;
OptixProgramGroup miss_pg = nullptr;
OptixProgramGroup hitgroup_pg = nullptr;
OptixProgramGroup raygen_pg = nullptr;
OptixProgramGroup miss_pg = nullptr;
OptixProgramGroup hitgroup_pg = nullptr; // analytic (custom primitive): IS + CH
OptixProgramGroup hitgroup_pg_tri = nullptr; // triangle: CH only (builtin IS)

OptixPipeline pipeline = nullptr;

Expand Down
6 changes: 3 additions & 3 deletions CSGOptiX/SBT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,6 @@ void SBT::createHitgroup()
hitgroup = new HitGroup[tot_rec] ;
HitGroup* hg = hitgroup ;

for(unsigned i=0 ; i < tot_rec ; i++) // pack headers CPU side
OPTIX_CHECK( optixSbtRecordPackHeader( pip->hitgroup_pg, hitgroup + i ) );

unsigned sbt_offset = 0 ;

for(IT it=vgas.begin() ; it !=vgas.end() ; it++)
Expand Down Expand Up @@ -974,6 +971,9 @@ void SBT::createHitgroup()
int boundary = foundry->getPrimBoundary_(prim);
assert( boundary > -1 );

OptixProgramGroup record_pg = trimesh ? pip->hitgroup_pg_tri : pip->hitgroup_pg;
OPTIX_CHECK(optixSbtRecordPackHeader(record_pg, hg));

if( trimesh == false ) // analytic
{
setPrimData( hg->data.prim, prim ); // copy numNode, nodeOffset from CSGPrim into hg->data
Expand Down
24 changes: 24 additions & 0 deletions tests/test_triangulated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Forcing triangulation of a box-shaped solid (here G4_WATER_solid in
# opticks_raindrop.gdml) must produce bit-identical GPU hit counts vs
# the analytic CSG path: a G4Box triangulates to 12 flat triangles that
# coincide with the analytic surface, so the only thing this test can
# detect breaking is the triangulated-GAS wiring (pipeline flags, second
# hitgroup PG, per-record SBT header packing).
set -e

GDML="$OPTICKS_HOME/tests/geom/opticks_raindrop.gdml"
MAC="$OPTICKS_HOME/tests/run.mac"
SEED=42

ANA=$(USER=ci GEOM=triraindrop_ana \
GPURaytrace -g "$GDML" -m "$MAC" -s "$SEED" 2>&1 \
| awk '/Opticks: NumHits:/ {print $NF}')

TRI=$(USER=ci GEOM=triraindrop_tri stree__force_triangulate_solid=G4_WATER_solid \
GPURaytrace -g "$GDML" -m "$MAC" -s "$SEED" 2>&1 \
| awk '/Opticks: NumHits:/ {print $NF}')

echo "analytic=$ANA triangulated=$TRI"
[ -n "$ANA" ] && [ "$ANA" = "$TRI" ] || { echo "FAILED: triangulated($TRI) != analytic($ANA)"; exit 1; }
echo "PASSED"
Loading