Blender  V3.3
util/types.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __UTIL_TYPES_H__
5 #define __UTIL_TYPES_H__
6 
7 #if !defined(__KERNEL_METAL__)
8 # include <stdlib.h>
9 #endif
10 
11 /* Standard Integer Types */
12 
13 #if !defined(__KERNEL_GPU__)
14 # include <stdint.h>
15 #endif
16 
17 #include "util/defines.h"
18 
19 #ifndef __KERNEL_GPU__
20 # include "util/optimization.h"
21 # include "util/simd.h"
22 #endif
23 
25 
26 /* Types
27  *
28  * Define simpler unsigned type names, and integer with defined number of bits.
29  * Also vector types, named to be compatible with OpenCL builtin types, while
30  * working for CUDA and C++ too. */
31 
32 /* Shorter Unsigned Names */
33 
34 typedef unsigned char uchar;
35 typedef unsigned int uint;
36 typedef unsigned short ushort;
37 
38 /* Fixed Bits Types */
39 
40 #ifndef __KERNEL_GPU__
41 /* Generic Memory Pointer */
42 
44 #endif /* __KERNEL_GPU__ */
45 
46 ccl_device_inline size_t align_up(size_t offset, size_t alignment)
47 {
48  return (offset + alignment - 1) & ~(alignment - 1);
49 }
50 
51 ccl_device_inline size_t divide_up(size_t x, size_t y)
52 {
53  return (x + y - 1) / y;
54 }
55 
56 ccl_device_inline size_t round_up(size_t x, size_t multiple)
57 {
58  return ((x + multiple - 1) / multiple) * multiple;
59 }
60 
61 ccl_device_inline size_t round_down(size_t x, size_t multiple)
62 {
63  return (x / multiple) * multiple;
64 }
65 
67 {
68  return (x & (x - 1)) == 0;
69 }
70 
72 
73 /* Vectorized types declaration. */
74 #include "util/types_uchar2.h"
75 #include "util/types_uchar3.h"
76 #include "util/types_uchar4.h"
77 
78 #include "util/types_int2.h"
79 #include "util/types_int3.h"
80 #include "util/types_int4.h"
81 
82 #include "util/types_uint2.h"
83 #include "util/types_uint3.h"
84 #include "util/types_uint4.h"
85 
86 #include "util/types_ushort4.h"
87 
88 #include "util/types_float2.h"
89 #include "util/types_float3.h"
90 #include "util/types_float4.h"
91 #include "util/types_float8.h"
92 
93 #include "util/types_vector3.h"
94 
95 /* Vectorized types implementation. */
96 #include "util/types_uchar2_impl.h"
97 #include "util/types_uchar3_impl.h"
98 #include "util/types_uchar4_impl.h"
99 
100 #include "util/types_int2_impl.h"
101 #include "util/types_int3_impl.h"
102 #include "util/types_int4_impl.h"
103 
104 #include "util/types_uint2_impl.h"
105 #include "util/types_uint3_impl.h"
106 #include "util/types_uint4_impl.h"
107 
108 #include "util/types_float2_impl.h"
109 #include "util/types_float3_impl.h"
110 #include "util/types_float4_impl.h"
111 #include "util/types_float8_impl.h"
112 
113 #include "util/types_vector3_impl.h"
114 
115 /* SSE types. */
116 #ifndef __KERNEL_GPU__
117 # include "util/sseb.h"
118 # include "util/ssef.h"
119 # include "util/ssei.h"
120 # if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__)
121 # include "util/avxb.h"
122 # include "util/avxf.h"
123 # include "util/avxi.h"
124 # endif
125 #endif
126 
127 #endif /* __UTIL_TYPES_H__ */
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
#define ccl_device_inline
Definition: cuda/compat.h:34
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
unsigned __int64 uint64_t
Definition: stdint.h:90
ccl_device_inline size_t align_up(size_t offset, size_t alignment)
Definition: util/types.h:46
ccl_device_inline size_t round_down(size_t x, size_t multiple)
Definition: util/types.h:61
ccl_device_inline size_t round_up(size_t x, size_t multiple)
Definition: util/types.h:56
unsigned int uint
Definition: util/types.h:35
CCL_NAMESPACE_BEGIN typedef unsigned char uchar
Definition: util/types.h:34
ccl_device_inline bool is_power_of_two(size_t x)
Definition: util/types.h:66
ccl_device_inline size_t divide_up(size_t x, size_t y)
Definition: util/types.h:51
unsigned short ushort
Definition: util/types.h:36
uint64_t device_ptr
Definition: util/types.h:43