File indexing completed on 2026-04-09 07:49:03
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
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);
0111 OptixTraversableHandle getGASHandle(unsigned gas_idx) const ;
0112
0113 void createIAS();
0114 void createIAS(unsigned ias_idx);
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 ;
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 ;
0125 unsigned getTotalRec() const ;
0126 std::string descGAS() const ;
0127 void createHitgroup();
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