Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:03

0001 #pragma once
0002 /**
0003 SBT : OptiX 7 RG,MS,HG program data preparation
0004 =================================================
0005 
0006 Aim to minimize geometry specifics in here ...
0007 
0008 
0009 NOT:WITH_SOPTIX_ACCEL
0010     ana geometry only using GAS.h IAS.h struct
0011 
0012     * TODO: remove this old code branch, after performance check
0013 
0014 
0015 WITH_SOPTIX_ACCEL
0016     ana+tri geometry capability both using SOPTIX_Accel
0017     note the GPU side ana/tri branch in __closesthit__ch
0018     and supporting SBT entries
0019 
0020     **THIS IS NOW DEFAULT**
0021 
0022 
0023 
0024 **/
0025 
0026 #include <map>
0027 #include <string>
0028 #include <vector>
0029 #include <optix.h>
0030 #include "plog/Severity.h"
0031 
0032 #include "Binding.h"
0033 #include "sqat4.h"
0034 
0035 struct PIP ;
0036 struct CSGFoundry ;
0037 struct CSGPrim ;
0038 struct Properties ;
0039 struct SScene ;
0040 
0041 #define WITH_SOPTIX_ACCEL 1
0042 
0043 #ifdef WITH_SOPTIX_ACCEL
0044 struct SOPTIX_Accel ;
0045 struct SOPTIX_MeshGroup ;
0046 struct SCUDA_MeshGroup ;
0047 #else
0048 #include "GAS.h"
0049 #include "IAS.h"
0050 #endif
0051 
0052 
0053 struct SBT
0054 {
0055     static const plog::Severity LEVEL ;
0056 
0057     static bool ValidSpec(const char* spec);
0058     std::vector<unsigned>  solid_selection ;
0059     unsigned long long emm ;
0060     const PIP*      pip ;
0061     const Properties* properties ;
0062     Raygen*       raygen ;
0063     Miss*         miss ;
0064     HitGroup*     hitgroup ;
0065     HitGroup*     check ;
0066 
0067     const CSGFoundry*  foundry ;
0068     const SScene*      scene ;
0069 
0070     CUdeviceptr   d_raygen ;
0071     CUdeviceptr   d_miss ;
0072     CUdeviceptr   d_hitgroup ;
0073 
0074     std::vector<OptixInstance> instances ;
0075 
0076     OptixShaderBindingTable sbt = {};
0077 
0078 
0079 #ifdef WITH_SOPTIX_ACCEL
0080     std::map<unsigned, SOPTIX_Accel*> vgas ;
0081     std::map<unsigned, const SOPTIX_MeshGroup*> xgas ;
0082     typedef std::map<unsigned, SOPTIX_Accel*>::const_iterator IT ;
0083     std::vector<SOPTIX_Accel*> vias ;
0084 #else
0085     std::map<unsigned, GAS> vgas ;
0086     typedef std::map<unsigned, GAS>::const_iterator IT ;
0087     std::vector<IAS> vias ;
0088 #endif
0089 
0090     static std::string Desc();
0091     SBT(const PIP* pip_ );
0092     ~SBT();
0093 
0094 
0095     void init();
0096     void destroy();
0097 
0098     void createRaygen();
0099     void destroyRaygen();
0100     void updateRaygen();
0101 
0102     void createMiss();
0103     void destroyMiss();
0104     void updateMiss();
0105 
0106     void setFoundry(const CSGFoundry* foundry);
0107     void createGeom();
0108 
0109     void createGAS();
0110     void createGAS(unsigned gas_idx);                             // dep. WITH_SOPTIX_ACCEL : create GAS of single CSGSolid and adds to vgas map
0111     OptixTraversableHandle getGASHandle(unsigned gas_idx) const ; // dep. WITH_SOPTIX_ACCEL : gets handle from vgas map
0112 
0113     void createIAS();
0114     void createIAS(unsigned ias_idx);                             // dep. WITH_SOPTIX_ACCEL
0115     void collectInstances( const std::vector<qat4>& ias_inst ) ;
0116     NP* serializeInstances() const ;
0117     std::string descIAS(const std::vector<qat4>& inst ) const ;
0118     OptixTraversableHandle getIASHandle(unsigned ias_idx) const ; // dep. WITH_SOPTIX_ACCEL
0119     OptixTraversableHandle getTOPHandle() const ;
0120 
0121 
0122 
0123     int getOffset(unsigned shape_idx_ , unsigned layer_idx_ ) const ;
0124     int _getOffset(unsigned shape_idx_ , unsigned layer_idx_ ) const ;  // dep. WITH_SOPTIX_ACCEL : gas/bi/sbt loop with early exit
0125     unsigned getTotalRec() const ;                                      // dep. WITH_SOPTIX_ACCEL : gas/bi loop
0126     std::string descGAS() const ;                                       // dep. WITH_SOPTIX_ACCEL : gas/bi loop
0127     void createHitgroup();                                              // dep. WITH_SOPTIX_ACCEL : gas/bi/sbt loop
0128 
0129     static void UploadHitGroup(OptixShaderBindingTable& sbt, CUdeviceptr& d_hitgroup, HitGroup* hitgroup, size_t tot_rec );
0130 
0131     void destroyHitgroup();
0132     void checkHitgroup();
0133 
0134     void setPrimData( CustomPrim& cp, const CSGPrim* prim);
0135     void checkPrimData( CustomPrim& cp, const CSGPrim* prim);
0136     void dumpPrimData( const CustomPrim& cp ) const ;
0137 
0138 #ifdef WITH_SOPTIX_ACCEL
0139     void setMeshData( TriMesh& tm, const SCUDA_MeshGroup* cmg, int j, int boundary, unsigned globalPrimIdx );
0140 #endif
0141 
0142 };
0143