Blender V4.5
device/optix/compat.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 NVIDIA Corporation
2 * SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: Apache-2.0 */
5
6#pragma once
7
8#define __KERNEL_GPU__
9#define __KERNEL_CUDA__ /* OptiX kernels are implicitly CUDA kernels too */
10#define __KERNEL_OPTIX__
11#define CCL_NAMESPACE_BEGIN
12#define CCL_NAMESPACE_END
13
14#ifndef ATTR_FALLTHROUGH
15# define ATTR_FALLTHROUGH
16#endif
17
18/* Manual definitions so we can compile without CUDA toolkit. */
19
20#ifdef __CUDACC_RTC__
21typedef unsigned int uint32_t;
22typedef unsigned long long uint64_t;
23#else
24# include <stdint.h>
25#endif
26
27#ifdef CYCLES_CUBIN_CC
28# define FLT_MIN 1.175494350822287507969e-38f
29# define FLT_MAX 340282346638528859811704183484516925440.0f
30# define FLT_EPSILON 1.192092896e-07F
31#endif
32
33#define ccl_device \
34 static __device__ \
35 __forceinline__ // Function calls are bad for OptiX performance, so inline everything
36#define ccl_device_extern extern "C" __device__
37#define ccl_device_inline ccl_device
38#define ccl_device_forceinline ccl_device
39#define ccl_device_inline_method __device__ __forceinline__
40#define ccl_device_template_spec template<> __device__ __forceinline__
41#define ccl_device_noinline static __device__ __noinline__
42#define ccl_device_noinline_cpu ccl_device
43#define ccl_global
44#define ccl_inline_constant static __constant__
45#define ccl_device_constant __constant__ __device__
46#define ccl_static_constexpr static constexpr
47#define ccl_constant const
48#define ccl_gpu_shared __shared__
49#define ccl_private
50#define ccl_ray_data ccl_private
51#define ccl_may_alias
52#define ccl_restrict __restrict__
53#define ccl_align(n) __align__(n)
54
55/* Zero initialize structs to help the compiler figure out scoping */
56#define ccl_optional_struct_init = {}
57
58/* No assert supported for CUDA */
59
60#define kernel_assert(cond)
61
62/* GPU texture objects */
63
64typedef unsigned long long CUtexObject;
67
68template<typename T>
70 const float x,
71 const float y)
72{
73 return tex2D<T>(texobj, x, y);
74}
75
76template<typename T>
78 const float x,
79 const float y,
80 const float z)
81{
82 return tex3D<T>(texobj, x, y, z);
83}
84
85/* Half */
86
87typedef unsigned short half;
88
90{
91 half val;
92 asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(val) : "f"(f));
93 return val;
94}
95
97{
98 float val;
99 asm("{ cvt.f32.f16 %0, %1;}\n" : "=f"(val) : "h"(h));
100 return val;
101}
102
103/* Types */
104
105#include "util/half.h"
106#include "util/types.h"
107
108#define OPTIX_DONT_INCLUDE_CUDA
109#include <optix.h>
unsigned long long int uint64_t
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
Definition half.h:41
#define ccl_device_forceinline
CUtexObject ccl_gpu_tex_object_3D
unsigned long long CUtexObject
CUtexObject ccl_gpu_tex_object_2D
#define __float2half(x)
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
ccl_device_forceinline float __half2float(const half h)
#define T