File indexing completed on 2026-04-09 07:49:02
0001 #include "SRG.h"
0002 #include "Params.h"
0003
0004 #ifndef __CUDACC__
0005
0006 #include <iostream>
0007 #include <iomanip>
0008 #include "CUDA_CHECK.h"
0009 #include <glm/glm.hpp>
0010 #include <cuda_runtime.h>
0011 #include <iostream>
0012
0013
0014 void Params::setCenterExtent(float x, float y, float z, float w)
0015 {
0016 center_extent.x = x ;
0017 center_extent.y = y ;
0018 center_extent.z = z ;
0019 center_extent.w = w ;
0020 }
0021
0022 void Params::setPIDXYZ(unsigned x, unsigned y, unsigned z)
0023 {
0024 pidxyz.x = x ;
0025 pidxyz.y = y ;
0026 pidxyz.z = z ;
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 void Params::setView(const glm::vec3& eye_, const glm::vec3& U_, const glm::vec3& V_, const glm::vec3& W_, const glm::vec3& WNORM_ )
0039 {
0040 eye.x = eye_.x ;
0041 eye.y = eye_.y ;
0042 eye.z = eye_.z ;
0043
0044 U.x = U_.x ;
0045 U.y = U_.y ;
0046 U.z = U_.z ;
0047
0048 V.x = V_.x ;
0049 V.y = V_.y ;
0050 V.z = V_.z ;
0051
0052 W.x = W_.x ;
0053 W.y = W_.y ;
0054 W.z = W_.z ;
0055
0056 WNORM.x = WNORM_.x ;
0057 WNORM.y = WNORM_.y ;
0058 WNORM.z = WNORM_.z ;
0059
0060 }
0061
0062
0063 void Params::setCamera(
0064 float tmin_,
0065 float tmax_,
0066 unsigned cameratype_,
0067 int traceyflip_,
0068 int rendertype_,
0069 const glm::vec4& ZPROJ_ )
0070 {
0071 tmin = tmin_ ;
0072 tmax = tmax_ ;
0073 cameratype = cameratype_ ;
0074 traceyflip = traceyflip_ ;
0075 rendertype = rendertype_ ;
0076
0077 ZPROJ.x = ZPROJ_.x ;
0078 ZPROJ.y = ZPROJ_.y ;
0079 ZPROJ.z = ZPROJ_.z ;
0080 ZPROJ.w = ZPROJ_.w ;
0081 }
0082
0083 std::string Params::desc() const
0084 {
0085 std::stringstream ss ;
0086 ss << "Params::desc"
0087 << std::endl
0088 << std::setw(20) << " raygenmode " << std::setw(10) << raygenmode << std::endl
0089 << std::setw(20) << " handle " << std::setw(10) << handle << std::endl
0090 << std::setw(20) << " width " << std::setw(10) << width << std::endl
0091 << std::setw(20) << " height " << std::setw(10) << height << std::endl
0092 << std::setw(20) << " depth " << std::setw(10) << depth << std::endl
0093 << std::setw(20) << " cameratype " << std::setw(10) << cameratype << std::endl
0094 << std::setw(20) << " traceyflip " << std::setw(10) << traceyflip << std::endl
0095 << std::setw(20) << " rendertype " << std::setw(10) << rendertype << std::endl
0096 << std::setw(20) << " origin_x " << std::setw(10) << origin_x << std::endl
0097 << std::setw(20) << " origin_y " << std::setw(10) << origin_y << std::endl
0098 << std::setw(20) << " tmin " << std::setw(10) << tmin << std::endl
0099 << std::setw(20) << " tmax " << std::setw(10) << tmax << std::endl
0100 ;
0101
0102 std::string s = ss.str();
0103 return s ;
0104 }
0105
0106 std::string Params::detail() const
0107 {
0108 std::stringstream ss ;
0109 ss
0110 << "Params::detail"
0111 << std::endl
0112 << "(values)" << std::endl
0113 << desc()
0114 << std::endl
0115 << "(device pointers)" << std::endl
0116 << std::setw(20) << " node " << std::setw(10) << node << std::endl
0117 << std::setw(20) << " plan " << std::setw(10) << plan << std::endl
0118 << std::setw(20) << " tran " << std::setw(10) << tran << std::endl
0119 << std::setw(20) << " itra " << std::setw(10) << itra << std::endl
0120 << std::setw(20) << " pixels " << std::setw(10) << pixels << std::endl
0121 << std::setw(20) << " isect " << std::setw(10) << isect << std::endl
0122 << std::setw(20) << " sim " << std::setw(10) << sim << std::endl
0123 << std::setw(20) << " evt " << std::setw(10) << evt << std::endl
0124 ;
0125 std::string s = ss.str();
0126 return s ;
0127 }
0128
0129
0130 Params::Params(int raygenmode_, unsigned width, unsigned height, unsigned depth)
0131 :
0132 raygenmode(SRG_RENDER),
0133 node(nullptr),
0134 plan(nullptr),
0135 tran(nullptr),
0136 itra(nullptr),
0137 #if OPTIX_VERSION < 70000
0138 handle(nullptr),
0139 #else
0140 handle(0),
0141 #endif
0142 pixels(nullptr),
0143 isect(nullptr),
0144 fphoton(nullptr),
0145 width(0),
0146 height(0),
0147 depth(0),
0148 cameratype(0),
0149 traceyflip(0),
0150 origin_x(0),
0151 origin_y(0),
0152 tmin(0.f),
0153 tmin0(0.f),
0154 PropagateEpsilon0Mask(0u),
0155 tmax(0.f),
0156 vizmask(0xff),
0157 sim(nullptr),
0158 evt(nullptr),
0159 event_index(0),
0160 photon_slot_offset(0ull),
0161 max_time(1.e27f)
0162 {
0163 setRaygenMode(raygenmode_);
0164 setSize(width, height, depth);
0165 setPIDXYZ(-1,-1,-1);
0166 }
0167
0168 void Params::setRaygenMode(int raygenmode_)
0169 {
0170 raygenmode = raygenmode_ ;
0171 }
0172
0173 void Params::setSize(unsigned width_, unsigned height_, unsigned depth_ )
0174 {
0175 width = width_ ;
0176 height = height_ ;
0177 depth = depth_ ;
0178
0179 origin_x = width_ / 2;
0180 origin_y = height_ / 2;
0181 }
0182
0183 void Params::setVizmask(unsigned vizmask_)
0184 {
0185 vizmask = vizmask_ ;
0186 }
0187
0188 void Params::set_photon_slot_offset(unsigned long long photon_slot_offset_)
0189 {
0190 photon_slot_offset = photon_slot_offset_ ;
0191 }
0192
0193
0194 Params* Params::d_param = nullptr ;
0195
0196 void Params::device_alloc()
0197 {
0198 CUDA_CHECK( cudaMalloc( reinterpret_cast<void**>( &d_param ), sizeof( Params ) ) );
0199 assert( d_param );
0200 }
0201 void Params::upload()
0202 {
0203 assert( d_param );
0204 CUDA_CHECK( cudaMemcpy( reinterpret_cast<void*>( d_param ), this, sizeof( Params ), cudaMemcpyHostToDevice) );
0205 }
0206
0207 #endif
0208