Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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   ShProgramNode::PaletteList::const_iterator palettes_begin() const { return m_node->palettes_begin(); }
00122   ShProgramNode::PaletteList::const_iterator palettes_end() const { return m_node->palettes_end(); }
00123 
00124   // Call operators for channels and streams.
00125   // Equivalent to operator<< invocations.
00126   // Note that the template functions are implemented in
00127   // ShChannelImpl.hpp
00128   template<typename T0>
00129   ShProgram operator()(const ShChannel<T0>& t0) const;
00130   ShProgram operator()(const ShStream& s0) const;
00131   template<typename T0, typename T1>
00132   ShProgram operator()(const ShChannel<T0>& t0,
00133                         const ShChannel<T1>& t1) const;
00134   ShProgram operator()(const ShStream& s0,
00135                         const ShStream& s1) const;
00136   template<typename T0, typename T1, typename T2>
00137   ShProgram operator()(const ShChannel<T0>& t0,
00138                         const ShChannel<T1>& t1,
00139                         const ShChannel<T2>& t2) const;
00140   ShProgram operator()(const ShStream& s0,
00141                         const ShStream& s1,
00142                         const ShStream& s2) const;
00143   template<typename T0, typename T1, typename T2, typename T3>
00144   ShProgram operator()(const ShChannel<T0>& t0,
00145                         const ShChannel<T1>& t1,
00146                         const ShChannel<T2>& t2,
00147                         const ShChannel<T3>& t3) const;
00148   ShProgram operator()(const ShStream& s0,
00149                         const ShStream& s1,
00150                         const ShStream& s2,
00151                         const ShStream& s3) const;
00152   template<typename T0, typename T1, typename T2, typename T3,
00153            typename T4>
00154   ShProgram operator()(const ShChannel<T0>& t0,
00155                         const ShChannel<T1>& t1,
00156                         const ShChannel<T2>& t2,
00157                         const ShChannel<T3>& t3,
00158                         const ShChannel<T4>& t4) const;
00159   ShProgram operator()(const ShStream& s0,
00160                         const ShStream& s1,
00161                         const ShStream& s2,
00162                         const ShStream& s3,
00163                         const ShStream& s4) const;
00164   
00165 private:
00166 
00167   ShProgramNodePtr m_node;
00168 };
00169 
00170 }
00171 
00172 #endif
00173 

Generated on Mon Jan 24 18:36:35 2005 for Sh by  doxygen 1.4.1