Blender  V2.93
util_types.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 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 __UTIL_TYPES_H__
18 #define __UTIL_TYPES_H__
19 
20 #ifndef __KERNEL_OPENCL__
21 # include <stdlib.h>
22 #endif
23 
24 /* Standard Integer Types */
25 
26 #if !defined(__KERNEL_GPU__)
27 # include <stdint.h>
28 #endif
29 
30 #include "util/util_defines.h"
31 
32 #ifndef __KERNEL_GPU__
33 # include "util/util_optimization.h"
34 # include "util/util_simd.h"
35 #endif
36 
38 
39 /* Types
40  *
41  * Define simpler unsigned type names, and integer with defined number of bits.
42  * Also vector types, named to be compatible with OpenCL builtin types, while
43  * working for CUDA and C++ too. */
44 
45 /* Shorter Unsigned Names */
46 
47 #ifndef __KERNEL_OPENCL__
48 typedef unsigned char uchar;
49 typedef unsigned int uint;
50 typedef unsigned short ushort;
51 #endif
52 
53 /* Fixed Bits Types */
54 
55 #ifdef __KERNEL_OPENCL__
56 typedef unsigned long uint64_t;
57 #endif
58 
59 #ifndef __KERNEL_GPU__
60 /* Generic Memory Pointer */
61 
63 #endif /* __KERNEL_GPU__ */
64 
65 ccl_device_inline size_t align_up(size_t offset, size_t alignment)
66 {
67  return (offset + alignment - 1) & ~(alignment - 1);
68 }
69 
70 ccl_device_inline size_t divide_up(size_t x, size_t y)
71 {
72  return (x + y - 1) / y;
73 }
74 
75 ccl_device_inline size_t round_up(size_t x, size_t multiple)
76 {
77  return ((x + multiple - 1) / multiple) * multiple;
78 }
79 
80 ccl_device_inline size_t round_down(size_t x, size_t multiple)
81 {
82  return (x / multiple) * multiple;
83 }
84 
86 {
87  return (x & (x - 1)) == 0;
88 }
89 
91 
92 /* Vectorized types declaration. */
93 #include "util/util_types_uchar2.h"
94 #include "util/util_types_uchar3.h"
95 #include "util/util_types_uchar4.h"
96 
97 #include "util/util_types_int2.h"
98 #include "util/util_types_int3.h"
99 #include "util/util_types_int4.h"
100 
101 #include "util/util_types_uint2.h"
102 #include "util/util_types_uint3.h"
103 #include "util/util_types_uint4.h"
104 
105 #include "util/util_types_ushort4.h"
106 
107 #include "util/util_types_float2.h"
108 #include "util/util_types_float3.h"
109 #include "util/util_types_float4.h"
110 #include "util/util_types_float8.h"
111 
112 #include "util/util_types_vector3.h"
113 
114 /* Vectorized types implementation. */
118 
122 
126 
131 
133 
134 /* SSE types. */
135 #ifndef __KERNEL_GPU__
136 # include "util/util_sseb.h"
137 # include "util/util_ssef.h"
138 # include "util/util_ssei.h"
139 # if defined(__KERNEL_AVX__) || defined(__KERNEL_AVX2__)
140 # include "util/util_avxb.h"
141 # include "util/util_avxf.h"
142 # include "util/util_avxi.h"
143 # endif
144 #endif
145 
146 #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
#define CCL_NAMESPACE_END
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
ccl_device_inline size_t round_down(size_t x, size_t multiple)
Definition: util_types.h:80
ccl_device_inline size_t round_up(size_t x, size_t multiple)
Definition: util_types.h:75
unsigned int uint
Definition: util_types.h:49
CCL_NAMESPACE_BEGIN typedef unsigned char uchar
Definition: util_types.h:48
ccl_device_inline bool is_power_of_two(size_t x)
Definition: util_types.h:85
ccl_device_inline size_t divide_up(size_t x, size_t y)
Definition: util_types.h:70
unsigned short ushort
Definition: util_types.h:50
uint64_t device_ptr
Definition: util_types.h:62