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

ShTransformer.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 SHTRANSFORMER_HPP
00028 #define SHTRANSFORMER_HPP
00029 
00030 #include "ShDllExport.hpp"
00031 #include "ShBackend.hpp"
00032 #include "ShProgram.hpp"
00033 #include "ShCtrlGraph.hpp"
00034 #include "ShInternals.hpp"
00035 #include "ShVariableType.hpp"
00036 
00037 namespace SH {
00038 
00052 class 
00053 SH_DLLEXPORT ShTransformer {
00054 public:
00055   ShTransformer(const ShProgramNodePtr& program);
00056   ShTransformer::~ShTransformer();
00057   bool changed(); //< returns true iff one of the transformations changed the shader
00058 
00069   typedef std::vector<ShVariableNodePtr> VarNodeVec;
00070   typedef std::map<ShVariableNodePtr, VarNodeVec> VarSplitMap;
00071   friend struct VariableSplitter;
00072   friend struct StatementSplitter;
00073   void splitTuples(int maxTuple, VarSplitMap &splits);
00075   
00085   friend struct InputOutputConvertor;
00086   void convertInputOutput();
00088   
00094   void convertTextureLookups();
00096 
00097   
00107   void convertIntervalTypes(VarSplitMap &splits);
00108 
00109 
00110   typedef std::map<ShValueType, ShValueType> ValueTypeMap;  
00121   void convertToFloat(ValueTypeMap &typeMap);
00122 
00123   //@todo  use dependent uniforms in conversion and spliting functions
00124   //instead of separate VarSplitMaps and ShVarMaps
00125   
00126 private:
00128   ShTransformer(const ShTransformer& other);
00130   ShTransformer& operator=(const ShTransformer& other);
00131 
00132   ShProgramNodePtr m_program;
00133   bool m_changed;
00134 };
00135 
00136 }
00137 
00138 #endif

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