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

ShSyntax.hpp

Go to the documentation of this file.
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 SHSYNTAX_HPP 00028 #define SHSYNTAX_HPP 00029 00030 #include "ShDllExport.hpp" 00031 #include "ShProgram.hpp" 00032 #include "ShUtility.hpp" 00033 00038 00039 00040 #define SH_PUSH_ARG_QUEUE ::SH::ShContext::current()->parsing()->tokenizer.pushArgQueue() 00041 #define SH_PUSH_ARG ::SH::ShContext::current()->parsing()->tokenizer.pushArg() 00042 #define SH_PROCESS_ARG(arg) ::SH::ShContext::current()->parsing()->tokenizer.processArg(arg) 00043 00044 00046 00047 00053 #define SH_BEGIN_PROGRAM(target) ::SH::shBeginShader(target); 00054 00062 #define SH_END_PROGRAM ::SH::shEndShader(); 00063 00064 00065 #define SH_END SH_END_PROGRAM 00066 00067 #define SH_BEGIN_VERTEX_PROGRAM ::SH::shBeginShader("gpu:vertex"); 00068 #define SH_BEGIN_FRAGMENT_PROGRAM ::SH::shBeginShader("gpu:fragment"); 00069 00071 00072 00077 #define SH_IF(cond) ::SH::shIf(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond)); {{ 00078 00083 #define SH_ELSE }} ::SH::shElse(); {{ 00084 00089 #define SH_ENDIF ::SH::shEndIf();}} 00090 00091 00093 00094 00098 #define SH_WHILE(cond) ::SH::shWhile(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond)); {{{ 00099 00103 #define SH_ENDWHILE ::SH::shEndWhile();}}} 00104 00105 00107 00108 00112 #define SH_DO ::SH::shDo(); {{{{ 00113 00117 #define SH_UNTIL(cond) ::SH::shUntil(SH_PUSH_ARG_QUEUE && SH_PUSH_ARG && SH_PROCESS_ARG(cond));}}}} 00118 00119 00121 00122 00128 // TODO: It is possible to make declaring variables in init work. do so. 00129 #define SH_FOR(init,cond,update) ::SH::shFor(SH_PUSH_ARG_QUEUE \ 00130 && SH_PUSH_ARG && SH_PROCESS_ARG(init) \ 00131 && SH_PUSH_ARG && SH_PROCESS_ARG(cond) \ 00132 && SH_PUSH_ARG && SH_PROCESS_ARG(update)); {{{{{ 00133 00137 #define SH_ENDFOR ::SH::shEndFor();}}}}} 00138 00139 00141 00142 00149 #define SH_BREAK ::SH::shBreak(); 00150 00157 #define SH_CONTINUE ::SH::shBreak(); 00158 00159 00161 00162 00168 #define SH_NAME(var) do { var.name( # var); } while (0) 00169 00179 #define SH_DECL(var) var; var.name( # var ); ::SH::ShIgnore() & var 00180 00189 #define SH_NAMEDECL(var, varName) var; var.name( varName ); ::SH::ShIgnore() & var 00190 00191 00192 namespace SH { 00193 00195 SH_DLLEXPORT 00196 ShProgram shBeginShader(const std::string& kind = ""); 00198 SH_DLLEXPORT 00199 void shEndShader(); 00200 00202 SH_DLLEXPORT 00203 void shCompile(ShProgram& prg); 00205 SH_DLLEXPORT 00206 void shCompile(ShProgram& prg, const std::string& target); 00207 00209 SH_DLLEXPORT 00210 void shCompileShader(ShProgram& prg); 00212 SH_DLLEXPORT 00213 void shCompileShader(ShProgram& prg, const std::string& target); 00214 00216 SH_DLLEXPORT 00217 void shBind(ShProgram& prg); 00219 SH_DLLEXPORT 00220 void shBind(const std::string& target, ShProgram& shader); 00221 00223 SH_DLLEXPORT 00224 void shBindShader(ShProgram& shader); 00226 SH_DLLEXPORT 00227 void shBindShader(const std::string& target, ShProgram& shader); 00228 00230 SH_DLLEXPORT 00231 bool shSetBackend(const std::string& name); 00232 00233 00239 SH_DLLEXPORT 00240 void shInit(); 00241 00243 SH_DLLEXPORT 00244 void shIf(bool); 00246 SH_DLLEXPORT 00247 void shElse(); 00249 SH_DLLEXPORT 00250 void shEndIf(); 00251 00253 SH_DLLEXPORT 00254 void shWhile(bool); 00256 SH_DLLEXPORT 00257 void shEndWhile(); 00258 00260 SH_DLLEXPORT 00261 void shDo(); 00263 SH_DLLEXPORT 00264 void shUntil(bool); 00265 00267 SH_DLLEXPORT 00268 void shFor(bool); 00270 SH_DLLEXPORT 00271 void shEndFor(); 00272 00274 SH_DLLEXPORT 00275 void shBreak(); 00277 SH_DLLEXPORT 00278 void shContinue(); 00279 00280 } 00281 00282 #endif

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