Blender  V2.93
kernel_compat_optix.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019, NVIDIA Corporation.
3  * Copyright 2019, Blender Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __KERNEL_COMPAT_OPTIX_H__
19 #define __KERNEL_COMPAT_OPTIX_H__
20 
21 #define OPTIX_DONT_INCLUDE_CUDA
22 #include <optix.h>
23 
24 #define __KERNEL_GPU__
25 #define __KERNEL_CUDA__ // OptiX kernels are implicitly CUDA kernels too
26 #define __KERNEL_OPTIX__
27 #define CCL_NAMESPACE_BEGIN
28 #define CCL_NAMESPACE_END
29 
30 #ifndef ATTR_FALLTHROUGH
31 # define ATTR_FALLTHROUGH
32 #endif
33 
34 #ifdef __CUDACC_RTC__
35 typedef unsigned int uint32_t;
36 typedef unsigned long long uint64_t;
37 #else
38 # include <stdint.h>
39 #endif
40 typedef unsigned short half;
41 typedef unsigned long long CUtexObject;
42 
43 #ifdef CYCLES_CUBIN_CC
44 # define FLT_MIN 1.175494350822287507969e-38f
45 # define FLT_MAX 340282346638528859811704183484516925440.0f
46 # define FLT_EPSILON 1.192092896e-07F
47 #endif
48 
49 __device__ half __float2half(const float f)
50 {
51  half val;
52  asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(val) : "f"(f));
53  return val;
54 }
55 
56 /* Selective nodes compilation. */
57 #ifndef __NODES_MAX_GROUP__
58 # define __NODES_MAX_GROUP__ NODE_GROUP_LEVEL_MAX
59 #endif
60 #ifndef __NODES_FEATURES__
61 # define __NODES_FEATURES__ NODE_FEATURE_ALL
62 #endif
63 
64 #define ccl_device \
65  __device__ __forceinline__ // Function calls are bad for OptiX performance, so inline everything
66 #define ccl_device_inline ccl_device
67 #define ccl_device_forceinline ccl_device
68 #define ccl_device_noinline __device__ __noinline__
69 #define ccl_device_noinline_cpu ccl_device
70 #define ccl_global
71 #define ccl_static_constant __constant__
72 #define ccl_constant const
73 #define ccl_local
74 #define ccl_local_param
75 #define ccl_private
76 #define ccl_may_alias
77 #define ccl_addr_space
78 #define ccl_loop_no_unroll
79 #define ccl_restrict __restrict__
80 #define ccl_ref
81 #define ccl_align(n) __align__(n)
82 
83 // Zero initialize structs to help the compiler figure out scoping
84 #define ccl_optional_struct_init = {}
85 
86 #define kernel_data __params.data // See kernel_globals.h
87 #define kernel_tex_array(t) __params.t
88 #define kernel_tex_fetch(t, index) __params.t[(index)]
89 
90 #define kernel_assert(cond)
91 
92 /* Types */
93 
94 #include "util/util_half.h"
95 #include "util/util_types.h"
96 
97 #endif /* __KERNEL_COMPAT_OPTIX_H__ */
Definition: util_half.h:41
__device__ half __float2half(const float f)
unsigned short half
unsigned long long CUtexObject
unsigned int uint32_t
Definition: stdint.h:83
unsigned __int64 uint64_t
Definition: stdint.h:93