Blender V4.3
oneapi/context_begin.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2022 Intel Corporation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifdef WITH_NANOVDB
6/* Data type to replace `double` used in the NanoVDB headers. Cycles don't need doubles, and is
7 * safer and more portable to never use double datatype on GPU.
8 * Use a special structure, so that the following is true:
9 * - No unnoticed implicit cast or mathematical operations used on scalar 64bit type
10 * (which rules out trick like using `uint64_t` as a drop-in replacement for double).
11 * - Padding rules are matching exactly `double`
12 * (which rules out array of `uint8_t`). */
13typedef struct ccl_vdb_double_t {
14 union ccl_vdb_helper_t {
15 double d;
16 uint64_t i;
17 };
18
19 uint64_t i;
20 ccl_vdb_double_t(double value)
21 {
22 ccl_vdb_helper_t helper;
23 helper.d = value;
24 i = helper.i;
25 }
26 /* We intentionally allow conversion to float in order to workaround compilation errors
27 * for defined math functions that take doubles. */
28 operator float() const
29 {
30 ccl_vdb_helper_t helper;
31 helper.i = i;
32 return (float)helper.d;
33 }
34} ccl_vdb_double_t;
35
36# define double ccl_vdb_double_t
37# include "kernel/util/nanovdb.h"
38# undef double
39#endif
40
41/* clang-format off */
42struct ONEAPIKernelContext : public KernelGlobalsGPU {
43 public:
45 /* clang-format on */
draw_view in_light_buf[] float
unsigned __int64 uint64_t
Definition stdint.h:90