triro 1.3.0
A Python Ray-Mesh Intersector in OptiX
Loading...
Searching...
No Matches
optix8.h
Go to the documentation of this file.
1// ======================================================================== //
2// Copyright 2018-2019 Ingo Wald //
3// //
4// Licensed under the Apache License, Version 2.0 (the "License"); //
5// you may not use this file except in compliance with the License. //
6// You may obtain a copy of the License at //
7// //
8// http://www.apache.org/licenses/LICENSE-2.0 //
9// //
10// Unless required by applicable law or agreed to in writing, software //
11// distributed under the License is distributed on an "AS IS" BASIS, //
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
13// See the License for the specific language governing permissions and //
14// limitations under the License. //
15// ======================================================================== //
16
17#pragma once
18
19// optix 8
20#include <cuda_runtime.h>
21#include <optix.h>
22#include <optix_stubs.h>
23#include <sstream>
24#include <stdexcept>
25
26#define CUDA_CHECK(call) \
27 { \
28 cudaError_t rc = cuda##call; \
29 if (rc != cudaSuccess) { \
30 std::stringstream txt; \
31 cudaError_t err = rc; /*cudaGetLastError();*/ \
32 txt << "CUDA Error " << cudaGetErrorName(err) << " (" \
33 << cudaGetErrorString(err) << ")"; \
34 throw std::runtime_error(txt.str()); \
35 } \
36 }
37
38#define CUDA_CHECK_NOEXCEPT(call) \
39 { cuda##call; }
40
41#define OPTIX_CHECK(call) \
42 { \
43 OptixResult res = call; \
44 if (res != OPTIX_SUCCESS) { \
45 fprintf(stderr, "Optix call (%s) failed with code %d (line %d)\n", \
46 #call, res, __LINE__); \
47 exit(2); \
48 } \
49 }
50
51#define CUDA_SYNC_CHECK() \
52 { \
53 cudaDeviceSynchronize(); \
54 cudaError_t error = cudaGetLastError(); \
55 if (error != cudaSuccess) { \
56 fprintf(stderr, "error (%s: line %d): %s\n", __FILE__, __LINE__, \
57 cudaGetErrorString(error)); \
58 exit(2); \
59 } \
60 }