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

ShProgramNode.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 SHPROGRAMNODE_HPP 00028 #define SHPROGRAMNODE_HPP 00029 00030 #include <list> 00031 #include <map> 00032 #include <utility> 00033 #include <string> 00034 #include "ShDllExport.hpp" 00035 #include "ShRefCount.hpp" 00036 #include "ShTokenizer.hpp" 00037 #include "ShVariableNode.hpp" 00038 #include "ShCtrlGraph.hpp" 00039 #include "ShTextureNode.hpp" 00040 #include "ShChannelNode.hpp" 00041 #include "ShMeta.hpp" 00042 00043 namespace SH { 00044 00045 class ShBackendCode; 00046 class ShBackend; 00047 00050 class 00051 SH_DLLEXPORT ShProgramNode : public virtual ShRefCountable, public virtual ShMeta { 00052 public: 00053 ShProgramNode(const std::string& target); 00054 00055 ~ShProgramNode(); 00056 00062 void compile(const ShPointer<ShBackend>& backend); 00063 00066 void compile(const std::string& target, const ShPointer<ShBackend>& backend); 00067 00069 std::string describe_interface() const; 00070 00074 ShPointer<ShBackendCode> code(); 00075 00079 ShPointer<ShBackendCode> code(const ShPointer<ShBackend>& backend); 00080 00082 ShPointer<ShBackendCode> code(const std::string& target, const ShPointer<ShBackend>& backend); 00083 00085 void updateUniform(const ShVariableNodePtr& uniform); 00086 00089 ShTokenizer tokenizer; 00090 00094 ShPointer<ShCtrlGraph> ctrlGraph; 00095 00098 void collectVariables(); 00099 00100 typedef std::list<ShVariableNodePtr> VarList; 00101 typedef std::list<ShTextureNodePtr> TexList; 00102 typedef std::list<ShChannelNodePtr> ChannelList; 00103 00104 VarList::const_iterator inputs_begin() const; 00105 VarList::const_iterator inputs_end() const; 00106 VarList::const_iterator outputs_begin() const; 00107 VarList::const_iterator outputs_end() const; 00108 VarList::const_iterator temps_begin() const; 00109 VarList::const_iterator temps_end() const; 00110 VarList::const_iterator constants_begin() const; 00111 VarList::const_iterator constants_end() const; 00112 VarList::const_iterator uniforms_begin() const; 00113 VarList::const_iterator uniforms_end() const; 00114 00115 TexList::const_iterator textures_begin() const; 00116 TexList::const_iterator textures_end() const; 00117 00118 ChannelList::const_iterator channels_begin() const; 00119 ChannelList::const_iterator channels_end() const; 00120 00121 00122 VarList inputs; 00123 VarList outputs; 00124 VarList temps; 00125 VarList constants; 00126 VarList uniforms; 00127 TexList textures; 00128 ChannelList channels; 00129 00131 std::string target() const { return m_target; } 00132 00134 std::string& target() { return m_target; } 00135 00137 ShPointer<ShProgramNode> clone() const; 00138 00140 static std::ostream& print(std::ostream& out, const VarList& list); 00141 00143 bool finished() const; 00144 00146 void finish(); 00147 00151 void assign(const ShVariableNodePtr& var) const; 00152 00153 private: 00154 00155 std::string m_target; 00156 00157 void collectNodeVars(const ShPointer<ShCtrlGraphNode>& node); 00158 void collectVar(const ShVariableNodePtr& node); 00159 00160 typedef std::map< std::pair< std::string, ShPointer<ShBackend> >, 00161 ShPointer<ShBackendCode> > CodeMap; 00162 CodeMap m_code; 00163 00164 bool m_finished; 00165 00166 00167 mutable ShVariableNodePtr m_assigned_var; 00168 }; 00169 00170 typedef ShPointer<ShProgramNode> ShProgramNodePtr; 00171 typedef ShPointer<const ShProgramNode> ShProgramNodeCPtr; 00172 00173 } 00174 00175 #endif 00176

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