Blender  V2.93
kernel_split_data.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __KERNEL_SPLIT_DATA_H__
18 #define __KERNEL_SPLIT_DATA_H__
19 
21 
22 #include "kernel/kernel_globals.h"
23 
25 
26 ccl_device_inline uint64_t split_data_buffer_size(KernelGlobals *kg, size_t num_elements)
27 {
28  (void)kg; /* Unused on CPU. */
29 
30  uint64_t size = 0;
31 #define SPLIT_DATA_ENTRY(type, name, num) +align_up(num_elements *num * sizeof(type), 16)
33 #undef SPLIT_DATA_ENTRY
34 
35  uint64_t closure_size = sizeof(ShaderClosure) * (kernel_data.integrator.max_closures - 1);
36 
37 #ifdef __BRANCHED_PATH__
38  size += align_up(num_elements * (sizeof(ShaderData) + closure_size), 16);
39 #endif
40 
41  size += align_up(num_elements * (sizeof(ShaderData) + closure_size), 16);
42 
43  return size;
44 }
45 
46 ccl_device_inline void split_data_init(KernelGlobals *kg,
47  ccl_global SplitData *split_data,
48  size_t num_elements,
49  ccl_global void *data,
50  ccl_global char *ray_state)
51 {
52  (void)kg; /* Unused on CPU. */
53 
54  ccl_global char *p = (ccl_global char *)data;
55 
56 #define SPLIT_DATA_ENTRY(type, name, num) \
57  split_data->name = (type *)p; \
58  p += align_up(num_elements * num * sizeof(type), 16);
60 #undef SPLIT_DATA_ENTRY
61 
62  uint64_t closure_size = sizeof(ShaderClosure) * (kernel_data.integrator.max_closures - 1);
63 
64 #ifdef __BRANCHED_PATH__
65  split_data->_branched_state_sd = (ShaderData *)p;
66  p += align_up(num_elements * (sizeof(ShaderData) + closure_size), 16);
67 #endif
68 
69  split_data->_sd = (ShaderData *)p;
70  p += align_up(num_elements * (sizeof(ShaderData) + closure_size), 16);
71 
72  split_data->ray_state = ray_state;
73 }
74 
76 
77 #endif /* __KERNEL_SPLIT_DATA_H__ */
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
#define kernel_data
#define ccl_device_inline
#define ccl_global
#define CCL_NAMESPACE_END
ccl_device_inline void split_data_init(KernelGlobals *kg, ccl_global SplitData *split_data, size_t num_elements, ccl_global void *data, ccl_global char *ray_state)
CCL_NAMESPACE_BEGIN ccl_device_inline uint64_t split_data_buffer_size(KernelGlobals *kg, size_t num_elements)
#define SPLIT_DATA_ENTRIES
__kernel void ccl_constant KernelData ccl_global void ccl_global char * ray_state
ShaderData
ShaderClosure
Definition: kernel_types.h:831
unsigned __int64 uint64_t
Definition: stdint.h:93
ccl_device_inline size_t align_up(size_t offset, size_t alignment)
Definition: util_types.h:65