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