SCM Repository
Annotation of /branches/pure-cfg/src/include/Diderot/shadow-types.h
Parent Directory
|
Revision Log
Revision 1355 - (view) (download) (as text)
1 : | jhr | 1354 | /*! \file shadow-types.h |
2 : | * | ||
3 : | * \author John Reppy | ||
4 : | * | ||
5 : | * Type definitions for the shadow globals. | ||
6 : | */ | ||
7 : | |||
8 : | /* | ||
9 : | * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu) | ||
10 : | * All rights reserved. | ||
11 : | */ | ||
12 : | |||
13 : | #ifndef _SHADOW_TYPES_H_ | ||
14 : | #define _SHADOW_TYPES_H_ | ||
15 : | |||
16 : | #if defined(CL_VERSION_1_1) | ||
17 : | # define HAS_VEC3_TYPE | ||
18 : | #endif | ||
19 : | |||
20 : | #if defined(DIDEROT_SINGLE_PRECISION) | ||
21 : | typedef cl_float Shadow_real_t; | ||
22 : | typedef cl_float2 Shadow_vec2_t; | ||
23 : | #ifdef HAS_VEC3_TYPE | ||
24 : | typedef cl_float3 Shadow_vec3_t; | ||
25 : | #else | ||
26 : | typedef cl_float4 Shadow_vec3_t; | ||
27 : | #endif | ||
28 : | typedef cl_float4 Shadow_vec4_t; | ||
29 : | #else | ||
30 : | typedef cl_double Shadow_real_t; | ||
31 : | typedef cl_double2 Shadow_vec2_t; | ||
32 : | #ifdef HAS_VEC3_TYPE | ||
33 : | typedef cl_double3 Shadow_vec3_t; | ||
34 : | #else | ||
35 : | typedef cl_double4 Shadow_vec3_t; | ||
36 : | #endif | ||
37 : | typedef cl_double4 Shadow_vec4_t; | ||
38 : | #endif | ||
39 : | typedef Shadow_vec2_t Shadow_Mat2x2_t[2]; | ||
40 : | typedef Shadow_vec3_t Shadow_Mat3x3_t[3]; | ||
41 : | typedef Shadow_vec4_t Shadow_Mat4x4_t[4]; | ||
42 : | |||
43 : | //! shadow wrapper for 1D image data | ||
44 : | typedef struct { | ||
45 : | cl_mem data; //!< GPU-side memory object for data. | ||
46 : | cl_int size[1]; | ||
47 : | Shadow_real_t s; //!< scaling from world-space to image-space | ||
48 : | Shadow_real_t t; //!< translation from world-space to image-space | ||
49 : | } Shadow_image1D_t; | ||
50 : | |||
51 : | //! shadow wrapper for 2D image data | ||
52 : | typedef struct { | ||
53 : | cl_mem data; //!< GPU-side memory object for data. | ||
54 : | cl_int size[2]; //!< sizes (fast to slow) | ||
55 : | Shadow_Mat2x2_t w2i; //!< affine tranform from world space to index space. This is the | ||
56 : | //! inverse of the index to world-space transform that is loaded from | ||
57 : | //! the Nrrd file. | ||
58 : | Shadow_vec2_t tVec; //!< translation part of world to index transform | ||
59 : | Shadow_Mat2x2_t w2iT; //!< transpose w3i | ||
60 : | } Shadow_image2D_t; | ||
61 : | |||
62 : | //! shadow wrapper for 3D image data | ||
63 : | typedef struct { | ||
64 : | cl_mem data; //!< GPU-side memory object for data. | ||
65 : | cl_int size[3]; //!< sizes (fast to slow) | ||
66 : | Shadow_Mat3x3_t w2i; //!< affine tranform from world space to index space. This is the | ||
67 : | //! inverse of the index to world-space transform that is loaded from | ||
68 : | //! the Nrrd file. | ||
69 : | Shadow_vec3_t tVec; //!< translation part of world to index transform | ||
70 : | Shadow_Mat3x3_t w2iT; //!< transpose w3i | ||
71 : | } Shadow_image3D_t; | ||
72 : | |||
73 : | jhr | 1355 | /*! \brief initialize a shadow 2D vector from a host vector. |
74 : | * \param dst the shadow value to initialize (an array) | ||
75 : | * \param src the host vector to shadow. | ||
76 : | * | ||
77 : | * Note that the correctness of this function depends on the fact that | ||
78 : | * the Shadow_vec2_t type is an array. | ||
79 : | */ | ||
80 : | STATIC_INLINE void ShadowVec2 (Shadow_vec2_t dst, Diderot_vec2_t src) | ||
81 : | { | ||
82 : | dst[0] = ((Diderot_union2_t)(src)).r[0]; | ||
83 : | dst[1] = ((Diderot_union2_t)(src)).r[1]; | ||
84 : | } | ||
85 : | |||
86 : | /*! \brief initialize a shadow 3D vector from a host vector. | ||
87 : | * \param dst the shadow value to initialize (an array) | ||
88 : | * \param src the host vector to shadow. | ||
89 : | * | ||
90 : | * Note that the correctness of this function depends on the fact that | ||
91 : | * the Shadow_vec3_t type is an array. | ||
92 : | */ | ||
93 : | STATIC_INLINE void ShadowVec3 (Shadow_vec3_t dst, Diderot_vec3_t src) | ||
94 : | { | ||
95 : | dst[0] = ((Diderot_union3_t)(src)).r[0]; | ||
96 : | dst[1] = ((Diderot_union3_t)(src)).r[1]; | ||
97 : | dst[2] = ((Diderot_union3_t)(src)).r[2]; | ||
98 : | } | ||
99 : | |||
100 : | /*! \brief initialize a shadow 4D vector from a host vector. | ||
101 : | * \param dst the shadow value to initialize (an array) | ||
102 : | * \param src the host vector to shadow. | ||
103 : | * | ||
104 : | * Note that the correctness of this function depends on the fact that | ||
105 : | * the Shadow_vec4_t type is an array. | ||
106 : | */ | ||
107 : | STATIC_INLINE void ShadowVec4 (Shadow_vec4_t dst, Diderot_vec4_t src) | ||
108 : | { | ||
109 : | dst[0] = ((Diderot_union4_t)(src)).r[0]; | ||
110 : | dst[1] = ((Diderot_union4_t)(src)).r[1]; | ||
111 : | dst[2] = ((Diderot_union4_t)(src)).r[2]; | ||
112 : | dst[3] = ((Diderot_union4_t)(src)).r[3]; | ||
113 : | } | ||
114 : | |||
115 : | /*! \brief initialize a shadow 2x2 matrix from a host matrix. | ||
116 : | * \param dst the shadow value to initialize (an array of arrays) | ||
117 : | * \param src the host matrix to shadow. | ||
118 : | */ | ||
119 : | STATIC_INLINE void ShadowMat2x2 (Shadow_Mat2x2_t dst, Diderot_Mat2x2_t src) | ||
120 : | { | ||
121 : | ShadowVec2 (dst[0], src[0].v); | ||
122 : | ShadowVec2 (dst[1], src[1].v); | ||
123 : | } | ||
124 : | |||
125 : | /*! \brief initialize a shadow 3x3 matrix from a host matrix. | ||
126 : | * \param dst the shadow value to initialize (an array of arrays) | ||
127 : | * \param src the host matrix to shadow. | ||
128 : | */ | ||
129 : | STATIC_INLINE void ShadowMat3x3 (Shadow_Mat3x3_t dst, Diderot_Mat3x3_t src) | ||
130 : | { | ||
131 : | ShadowVec3 (dst[0], src[0].v); | ||
132 : | ShadowVec3 (dst[1], src[1].v); | ||
133 : | ShadowVec3 (dst[2], src[2].v); | ||
134 : | } | ||
135 : | |||
136 : | /*! \brief initialize a shadow 4x4 matrix from a host matrix. | ||
137 : | * \param dst the shadow value to initialize (an array of arrays) | ||
138 : | * \param src the host matrix to shadow. | ||
139 : | */ | ||
140 : | STATIC_INLINE void ShadowMat4x4 (Shadow_Mat4x4_t dst, Diderot_Mat4x4_t src) | ||
141 : | { | ||
142 : | ShadowVec4 (dst[0], src[0].v); | ||
143 : | ShadowVec4 (dst[1], src[1].v); | ||
144 : | ShadowVec4 (dst[2], src[2].v); | ||
145 : | ShadowVec4 (dst[3], src[3].v); | ||
146 : | } | ||
147 : | |||
148 : | jhr | 1354 | /*! \brief initialize a shadow for a 1D image |
149 : | * \param cxt the OpenCL context used to allocate the shadow buffer | ||
150 : | * \param dst the pointer to the shadow image | ||
151 : | * \param src the source image to shadow | ||
152 : | */ | ||
153 : | void ShadowImage1D (cl_context cxt, Shadow_image1D_t *dst, Diderot_image1D_t *img); | ||
154 : | |||
155 : | /*! \brief initialize a shadow for a 2D image | ||
156 : | * \param cxt the OpenCL context used to allocate the shadow buffer | ||
157 : | * \param dst the pointer to the shadow image | ||
158 : | * \param src the source image to shadow | ||
159 : | */ | ||
160 : | void ShadowImage2D (cl_context cxt, Shadow_image2D_t *dst, Diderot_image2D_t *img); | ||
161 : | |||
162 : | /*! \brief initialize a shadow for a 3D image | ||
163 : | * \param cxt the OpenCL context used to allocate the shadow buffer | ||
164 : | * \param dst the pointer to the shadow image | ||
165 : | * \param src the source image to shadow | ||
166 : | */ | ||
167 : | void ShadowImage3D (cl_context cxt, Shadow_image3D_t *dst, Diderot_image3D_t *img); | ||
168 : | |||
169 : | #endif /* !_SHADOW_TYPES_H_ */ |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |