Blender V5.0
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;
66
67template<typename T>
69 const float x,
70 const float y)
71{
72 return tex2D<T>(texobj, x, y);
73}
74
75/* Half */
76
77typedef unsigned short half;
78
80{
81 half val;
82 asm("{ cvt.rn.f16.f32 %0, %1;}\n" : "=h"(val) : "f"(f));
83 return val;
84}
85
87{
88 float val;
89 asm("{ cvt.f32.f16 %0, %1;}\n" : "=f"(val) : "h"(h));
90 return val;
91}
92
93/* Types */
94
95#include "util/half.h"
96#include "util/types.h"
97
98#define OPTIX_DONT_INCLUDE_CUDA
99#include <optix.h>
unsigned long long int uint64_t
Definition half.h:41
#define ccl_device_forceinline
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 float __half2float(const half h)
#define T