Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShGenericImpl.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHGENERICIMPL_HPP 00028 #define SHGENERICIMPL_HPP 00029 00030 #include "ShGeneric.hpp" 00031 #include "ShAttrib.hpp" 00032 #include "ShLib.hpp" 00033 #include "ShInstructions.hpp" 00034 #include "ShProgram.hpp" 00035 00036 namespace SH { 00037 00038 template<int N, typename T> 00039 inline 00040 ShGeneric<N, T>::ShGeneric(const ShVariableNodePtr& node) 00041 : ShVariable(node) 00042 { 00043 } 00044 00045 template<int N, typename T> 00046 inline 00047 ShGeneric<N, T>::ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg) 00048 : ShVariable(node) 00049 { 00050 m_swizzle = swizzle; 00051 m_neg = neg; 00052 } 00053 00054 template<int N, typename T> 00055 inline 00056 ShGeneric<N, T>::~ShGeneric() 00057 { 00058 } 00059 00060 template<int N, typename T> 00061 inline 00062 ShGeneric<N, T>& ShGeneric<N, T>::operator=(const ShProgram& prg) 00063 { 00064 this->ShVariable::operator=(prg); 00065 return *this; 00066 } 00067 00068 template<int N, typename T> 00069 inline 00070 ShGeneric<N, T>& ShGeneric<N, T>::operator=(const ShGeneric<N, T>& other) 00071 { 00072 shASN(*this, other); 00073 return *this; 00074 } 00075 00076 template<int N, typename T> 00077 inline 00078 ShGeneric<N, T>& ShGeneric<N, T>::operator+=(const ShGeneric<N, T>& right) 00079 { 00080 *this = *this + right; 00081 return *this; 00082 } 00083 00084 template<int N, typename T> 00085 inline 00086 ShGeneric<N, T>& ShGeneric<N, T>::operator-=(const ShGeneric<N, T>& right) 00087 { 00088 *this = *this - right; 00089 return *this; 00090 } 00091 00092 template<int N, typename T> 00093 inline 00094 ShGeneric<N, T>& ShGeneric<N, T>::operator*=(const ShGeneric<N, T>& right) 00095 { 00096 *this = *this * right; 00097 return *this; 00098 } 00099 00100 template<int N, typename T> 00101 inline 00102 ShGeneric<N, T>& ShGeneric<N, T>::operator/=(const ShGeneric<N, T>& right) 00103 { 00104 *this = *this / right; 00105 return *this; 00106 } 00107 00108 template<int N, typename T> 00109 inline 00110 ShGeneric<N, T>& ShGeneric<N, T>::operator%=(const ShGeneric<N, T>& right) 00111 { 00112 *this = *this % right; 00113 return *this; 00114 } 00115 00116 template<int N, typename T> 00117 inline 00118 ShGeneric<N, T>& ShGeneric<N, T>::operator+=(const ShGeneric<1, T>& right) 00119 { 00120 *this = *this + right; 00121 return *this; 00122 } 00123 00124 template<int N, typename T> 00125 inline 00126 ShGeneric<N, T>& ShGeneric<N, T>::operator-=(const ShGeneric<1, T>& right) 00127 { 00128 *this = *this - right; 00129 return *this; 00130 } 00131 00132 template<int N, typename T> 00133 inline 00134 ShGeneric<N, T>& ShGeneric<N, T>::operator*=(const ShGeneric<1, T>& right) 00135 { 00136 *this = *this * right; 00137 return *this; 00138 } 00139 00140 template<int N, typename T> 00141 inline 00142 ShGeneric<N, T>& ShGeneric<N, T>::operator/=(const ShGeneric<1, T>& right) 00143 { 00144 *this = *this / right; 00145 return *this; 00146 } 00147 00148 template<int N, typename T> 00149 inline 00150 ShGeneric<N, T>& ShGeneric<N, T>::operator%=(const ShGeneric<1, T>& right) 00151 { 00152 *this = *this % right; 00153 return *this; 00154 } 00155 00156 template<int N, typename T> 00157 inline 00158 ShGeneric<N, T>& ShGeneric<N, T>::operator+=(T right) 00159 { 00160 *this = *this + right; 00161 return *this; 00162 } 00163 00164 template<int N, typename T> 00165 inline 00166 ShGeneric<N, T>& ShGeneric<N, T>::operator-=(T right) 00167 { 00168 *this = *this - right; 00169 return *this; 00170 } 00171 00172 template<int N, typename T> 00173 inline 00174 ShGeneric<N, T>& ShGeneric<N, T>::operator*=(T right) 00175 { 00176 *this = *this * right; 00177 return *this; 00178 } 00179 00180 template<int N, typename T> 00181 inline 00182 ShGeneric<N, T>& ShGeneric<N, T>::operator/=(T right) 00183 { 00184 *this = *this / right; 00185 return *this; 00186 } 00187 00188 template<int N, typename T> 00189 inline 00190 ShGeneric<N, T>& ShGeneric<N, T>::operator%=(T right) 00191 { 00192 *this = *this % right; 00193 return *this; 00194 } 00195 00196 template<int N, typename T> 00197 inline 00198 ShGeneric<N, T> ShGeneric<N, T>::operator-() const 00199 { 00200 return ShGeneric<N, T>(m_node, m_swizzle, !m_neg); 00201 } 00202 00203 00204 template<int N, typename T> 00205 inline 00206 ShGeneric<N, T> ShGeneric<N, T>::operator()() const 00207 { 00208 return ShGeneric<N, T>(m_node, m_swizzle, m_neg); 00209 } 00210 00211 template<int N, typename T> 00212 inline 00213 ShGeneric<1, T> ShGeneric<N, T>::operator()(int i1) const 00214 { 00215 return ShGeneric<1, T>(m_node, m_swizzle * ShSwizzle(size(), i1), m_neg); 00216 } 00217 00218 template<int N, typename T> 00219 inline 00220 ShGeneric<1, T> ShGeneric<N, T>::operator[](int i1) const 00221 { 00222 return ShGeneric<1, T>(m_node, m_swizzle * ShSwizzle(size(), i1), m_neg); 00223 } 00224 00225 template<int N, typename T> 00226 inline 00227 ShGeneric<2, T> ShGeneric<N, T>::operator()(int i1, int i2) const 00228 { 00229 return ShGeneric<2, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2), m_neg); 00230 } 00231 00232 template<int N, typename T> 00233 inline 00234 ShGeneric<3, T> ShGeneric<N, T>::operator()(int i1, int i2, int i3) const 00235 { 00236 return ShGeneric<3, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2, i3), m_neg); 00237 } 00238 00239 template<int N, typename T> 00240 inline 00241 ShGeneric<4, T> ShGeneric<N, T>::operator()(int i1, int i2, int i3, int i4) const 00242 { 00243 return ShGeneric<4, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2, i3, i4), m_neg); 00244 } 00245 00246 template<int N, typename T> 00247 template<int N2> 00248 ShGeneric<N2, T> ShGeneric<N, T>::swiz(int indices[]) const 00249 { 00250 return ShGeneric<N2, T>(m_node, m_swizzle * ShSwizzle(N, N2, indices), m_neg); 00251 } 00252 00253 template<typename T> 00254 inline 00255 ShGeneric<1, T>::ShGeneric(const ShVariableNodePtr& node) 00256 : ShVariable(node) 00257 { 00258 } 00259 00260 template<typename T> 00261 inline 00262 ShGeneric<1, T>::ShGeneric(const ShVariableNodePtr& node, ShSwizzle swizzle, bool neg) 00263 : ShVariable(node) 00264 { 00265 m_swizzle = swizzle; 00266 m_neg = neg; 00267 } 00268 00269 template<typename T> 00270 inline 00271 ShGeneric<1, T>::~ShGeneric() 00272 { 00273 } 00274 00275 template<typename T> 00276 inline 00277 ShGeneric<1, T>& ShGeneric<1, T>::operator=(const ShProgram& prg) 00278 { 00279 this->ShVariable::operator=(prg); 00280 return *this; 00281 } 00282 00283 template<typename T> 00284 inline 00285 ShGeneric<1, T>& ShGeneric<1, T>::operator=(const ShGeneric<1, T>& other) 00286 { 00287 shASN(*this, other); 00288 return *this; 00289 } 00290 00291 template<typename T> 00292 inline 00293 ShGeneric<1, T>& ShGeneric<1, T>::operator=(T other) 00294 { 00295 shASN(*this, ShAttrib<1, SH_CONST, T>(other)); 00296 return *this; 00297 } 00298 00299 template<typename T> 00300 inline 00301 ShGeneric<1, T>& ShGeneric<1, T>::operator+=(const ShGeneric<1, T>& right) 00302 { 00303 *this = *this + right; 00304 return *this; 00305 } 00306 00307 template<typename T> 00308 inline 00309 ShGeneric<1, T>& ShGeneric<1, T>::operator-=(const ShGeneric<1, T>& right) 00310 { 00311 *this = *this - right; 00312 return *this; 00313 } 00314 00315 template<typename T> 00316 inline 00317 ShGeneric<1, T>& ShGeneric<1, T>::operator*=(const ShGeneric<1, T>& right) 00318 { 00319 *this = *this * right; 00320 return *this; 00321 } 00322 00323 template<typename T> 00324 inline 00325 ShGeneric<1, T>& ShGeneric<1, T>::operator/=(const ShGeneric<1, T>& right) 00326 { 00327 *this = *this / right; 00328 return *this; 00329 } 00330 00331 template<typename T> 00332 inline 00333 ShGeneric<1, T>& ShGeneric<1, T>::operator%=(const ShGeneric<1, T>& right) 00334 { 00335 *this = *this % right; 00336 return *this; 00337 } 00338 00339 template<typename T> 00340 inline 00341 ShGeneric<1, T>& ShGeneric<1, T>::operator*=(T right) 00342 { 00343 *this = *this * right; 00344 return *this; 00345 } 00346 00347 template<typename T> 00348 inline 00349 ShGeneric<1, T>& ShGeneric<1, T>::operator/=(T right) 00350 { 00351 *this = *this / right; 00352 return *this; 00353 } 00354 00355 template<typename T> 00356 inline 00357 ShGeneric<1, T>& ShGeneric<1, T>::operator%=(T right) 00358 { 00359 *this = *this % right; 00360 return *this; 00361 } 00362 00363 template<typename T> 00364 inline 00365 ShGeneric<1, T>& ShGeneric<1, T>::operator+=(T right) 00366 { 00367 *this = *this + right; 00368 return *this; 00369 } 00370 00371 template<typename T> 00372 inline 00373 ShGeneric<1, T>& ShGeneric<1, T>::operator-=(T right) 00374 { 00375 *this = *this - right; 00376 return *this; 00377 } 00378 00379 template<typename T> 00380 inline 00381 ShGeneric<1, T> ShGeneric<1, T>::operator-() const 00382 { 00383 return ShGeneric<1, T>(m_node, m_swizzle, !m_neg); 00384 } 00385 00386 00387 template<typename T> 00388 inline 00389 ShGeneric<1, T> ShGeneric<1, T>::operator()() const 00390 { 00391 return ShGeneric<1, T>(m_node, m_swizzle, m_neg); 00392 } 00393 00394 template<typename T> 00395 inline 00396 ShGeneric<1, T> ShGeneric<1, T>::operator()(int i1) const 00397 { 00398 return ShGeneric<1, T>(m_node, m_swizzle * ShSwizzle(size(), i1), m_neg); 00399 } 00400 00401 template<typename T> 00402 inline 00403 ShGeneric<1, T> ShGeneric<1, T>::operator[](int i1) const 00404 { 00405 return ShGeneric<1, T>(m_node, m_swizzle * ShSwizzle(size(), i1), m_neg); 00406 } 00407 00408 template<typename T> 00409 inline 00410 ShGeneric<2, T> ShGeneric<1, T>::operator()(int i1, int i2) const 00411 { 00412 return ShGeneric<2, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2), m_neg); 00413 } 00414 00415 template<typename T> 00416 inline 00417 ShGeneric<3, T> ShGeneric<1, T>::operator()(int i1, int i2, int i3) const 00418 { 00419 return ShGeneric<3, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2, i3), m_neg); 00420 } 00421 00422 template<typename T> 00423 inline 00424 ShGeneric<4, T> ShGeneric<1, T>::operator()(int i1, int i2, int i3, int i4) const 00425 { 00426 return ShGeneric<4, T>(m_node, m_swizzle * ShSwizzle(size(), i1, i2, i3, i4), m_neg); 00427 } 00428 00429 template<typename T> 00430 template<int N2> 00431 ShGeneric<N2, T> ShGeneric<1, T>::swiz(int indices[]) const 00432 { 00433 return ShGeneric<N2, T>(m_node, m_swizzle * ShSwizzle(1, N2, indices), m_neg); 00434 } 00435 00436 } 00437 00438 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7