12 # include <optix_function_table_definition.h>
16 # include <cuda_runtime.h>
21 static bool readSourceFile(
string& str,
const string& filename)
24 std::ifstream file(filename.c_str());
28 stringstream source_buffer;
29 source_buffer << file.rdbuf();
30 str = source_buffer.str();
36 static string getPtxFilename(
string filename)
40 ptxFilename +=
"cuda_compile_ptx_1";
41 ptxFilename +=
"_generated_";
42 ptxFilename += filename;
43 ptxFilename +=
".ptx";
47 string getPtxStringFromFile(
string filename,
53 string* ptx =
new string();
54 string sourceFilePath = SLOptix::exePath +
56 getPtxFilename(filename);
59 if (!readSourceFile(*ptx, sourceFilePath))
61 string err =
"Couldn't open source file " + sourceFilePath;
63 throw std::runtime_error(err.c_str());
69 float4 make_float4(
const SLVec4f& f)
71 return {f.
x, f.
y, f.
z, f.
w};
74 float3 make_float3(
const SLVec3f& f)
76 return {f.
x, f.
y, f.
z};
void log(const char *tag, const char *format,...)
logs a formatted string platform independently