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

ShProgram.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 SHPROGRAM_HPP 00028 #define SHPROGRAM_HPP 00029 00030 #include "ShDllExport.hpp" 00031 #include "ShProgramNode.hpp" 00032 #include "ShBackend.hpp" 00033 00034 namespace SH { 00035 00036 class ShStream; 00037 template<typename T> class ShChannel; 00038 00041 class 00042 SH_DLLEXPORT ShProgram : public ShMetaForwarder { 00043 public: 00044 ShProgram(); 00045 ShProgram(const ShProgram& other); 00046 ShProgram(const std::string& target); 00047 ShProgram(const ShProgramNodePtr& node); 00048 00049 ShProgram& operator=(const ShProgram& other); 00050 00052 ShProgramNodeCPtr node() const { return m_node; } 00053 00055 ShProgramNodePtr node() { return m_node; } 00056 00062 void compile(const ShPointer<ShBackend>& backend) { m_node->compile(backend); } 00063 00066 void compile(const std::string& target, const ShPointer<ShBackend>& backend) 00067 { 00068 m_node->compile(target, backend); 00069 } 00070 00073 std::string describe_interface() const 00074 { 00075 return m_node->describe_interface(); 00076 } 00077 00081 ShPointer<ShBackendCode> code() { return m_node->code(); } 00082 00086 ShPointer<ShBackendCode> code(const ShPointer<ShBackend>& backend) { 00087 return m_node->code(backend); 00088 } 00089 00091 ShPointer<ShBackendCode> code(const std::string& target, const ShPointer<ShBackend>& backend) 00092 { 00093 return m_node->code(target, backend); 00094 } 00095 00097 void updateUniform(const ShVariableNodePtr& uniform) 00098 { 00099 m_node->updateUniform(uniform); 00100 } 00101 00102 std::string target() const { return m_node->target(); } 00103 00105 std::string& target() { return m_node->target(); } 00106 00107 ShProgramNode::VarList::const_iterator inputs_begin() const { return m_node->inputs_begin(); } 00108 ShProgramNode::VarList::const_iterator inputs_end() const { return m_node->inputs_end(); } 00109 ShProgramNode::VarList::const_iterator outputs_begin() const { return m_node->outputs_begin(); } 00110 ShProgramNode::VarList::const_iterator outputs_end() const { return m_node->outputs_end(); } 00111 ShProgramNode::VarList::const_iterator temps_begin() const { return m_node->temps_begin(); } 00112 ShProgramNode::VarList::const_iterator temps_end() const { return m_node->temps_end(); } 00113 ShProgramNode::VarList::const_iterator constants_begin() const { return m_node->constants_begin(); } 00114 ShProgramNode::VarList::const_iterator constants_end() const { return m_node->constants_end(); } 00115 ShProgramNode::VarList::const_iterator uniforms_begin() const { return m_node->uniforms_begin(); } 00116 ShProgramNode::VarList::const_iterator uniforms_end() const { return m_node->uniforms_end(); } 00117 ShProgramNode::TexList::const_iterator textures_begin() const { return m_node->textures_begin(); } 00118 ShProgramNode::TexList::const_iterator textures_end() const { return m_node->textures_end(); } 00119 ShProgramNode::ChannelList::const_iterator channels_begin() const { return m_node->channels_begin(); } 00120 ShProgramNode::ChannelList::const_iterator channels_end() const { return m_node->channels_end(); } 00121 00122 // Call operators for channels and streams. 00123 // Equivalent to operator<< invocations. 00124 // Note that the template functions are implemented in 00125 // ShChannelImpl.hpp 00126 template<typename T0> 00127 ShProgram operator()(const ShChannel<T0>& t0) const; 00128 ShProgram operator()(const ShStream& s0) const; 00129 template<typename T0, typename T1> 00130 ShProgram operator()(const ShChannel<T0>& t0, 00131 const ShChannel<T1>& t1) const; 00132 ShProgram operator()(const ShStream& s0, 00133 const ShStream& s1) const; 00134 template<typename T0, typename T1, typename T2> 00135 ShProgram operator()(const ShChannel<T0>& t0, 00136 const ShChannel<T1>& t1, 00137 const ShChannel<T2>& t2) const; 00138 ShProgram operator()(const ShStream& s0, 00139 const ShStream& s1, 00140 const ShStream& s2) const; 00141 template<typename T0, typename T1, typename T2, typename T3> 00142 ShProgram operator()(const ShChannel<T0>& t0, 00143 const ShChannel<T1>& t1, 00144 const ShChannel<T2>& t2, 00145 const ShChannel<T3>& t3) const; 00146 ShProgram operator()(const ShStream& s0, 00147 const ShStream& s1, 00148 const ShStream& s2, 00149 const ShStream& s3) const; 00150 template<typename T0, typename T1, typename T2, typename T3, 00151 typename T4> 00152 ShProgram operator()(const ShChannel<T0>& t0, 00153 const ShChannel<T1>& t1, 00154 const ShChannel<T2>& t2, 00155 const ShChannel<T3>& t3, 00156 const ShChannel<T4>& t4) const; 00157 ShProgram operator()(const ShStream& s0, 00158 const ShStream& s1, 00159 const ShStream& s2, 00160 const ShStream& s3, 00161 const ShStream& s4) const; 00162 00163 private: 00164 00165 ShProgramNodePtr m_node; 00166 }; 00167 00168 } 00169 00170 #endif 00171

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