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

ShVariableNode.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 SHVARIABLENODE_HPP 00028 #define SHVARIABLENODE_HPP 00029 00030 #include <string> 00031 #include <list> 00032 #include "ShDllExport.hpp" 00033 #include "ShRefCount.hpp" 00034 #include "ShMeta.hpp" 00035 #include "ShPool.hpp" 00036 00037 namespace SH { 00038 00041 enum ShBindingType { 00042 SH_INPUT = 0, 00043 SH_OUTPUT = 1, 00044 SH_INOUT = 2, 00045 SH_TEMP = 3, 00046 SH_CONST = 4, 00047 SH_TEXTURE = 5, 00048 SH_STREAM = 6 00049 }; 00050 00053 enum ShSemanticType { 00054 SH_ATTRIB, 00055 SH_POINT, 00056 SH_VECTOR, 00057 SH_NORMAL, 00058 SH_COLOR, 00059 SH_TEXCOORD, 00060 SH_POSITION 00061 }; 00062 00063 // ensure these match the BindingType and SemanticType enums 00064 SH_DLLEXPORT extern const char* ShBindingTypeName[]; 00065 SH_DLLEXPORT extern const char* ShSemanticTypeName[]; 00066 00067 class ShProgramNode; 00068 00069 // Used to hide our use of ShProgramNodePtr, since MSVC7 doesn't allow it. 00070 struct ShVariableNodeEval; 00071 00074 class 00075 SH_DLLEXPORT ShVariableNode : public virtual ShRefCountable, 00076 public virtual ShMeta { 00077 public: 00078 ShVariableNode(ShBindingType kind, int size, ShSemanticType type = SH_ATTRIB); 00079 virtual ~ShVariableNode(); 00080 00081 bool uniform() const; 00082 bool hasValues() const; 00083 00084 int size() const; 00085 00086 // Don't call this on uniforms! 00087 void size(int size); 00088 00089 void lock(); 00090 void unlock(); 00091 00092 00093 typedef float ValueType; 00094 00095 // Metadata 00096 std::string name() const; 00097 void name(const std::string& n); 00098 00100 void range(ShVariableNode::ValueType low, ShVariableNode::ValueType high); 00101 ShVariableNode::ValueType lowBound() const; 00102 ShVariableNode::ValueType highBound() const; 00103 00104 ShBindingType kind() const; 00105 ShSemanticType specialType() const; 00106 void specialType(ShSemanticType); 00107 00108 std::string nameOfType() const; 00109 00114 void setValue(int i, ValueType value); 00115 00117 ValueType getValue(int i) const; 00118 00123 void addValues(); 00124 00130 00131 00132 void attach(const ShPointer<ShProgramNode>& evaluator); 00133 00135 void update(); 00136 00138 const ShPointer<ShProgramNode>& evaluator() const; 00139 00142 #ifdef SH_USE_MEMORY_POOL 00143 // Memory pool stuff. 00144 void* operator new(std::size_t size); 00145 void operator delete(void* d); 00146 #endif 00147 00148 protected: 00149 00150 void add_dependent(ShVariableNode* dep); 00151 void remove_dependent(ShVariableNode* dep); 00152 00153 void update_dependents(); 00154 void detach_dependencies(); 00155 00156 bool m_uniform; 00157 00158 ShBindingType m_kind; 00159 ShSemanticType m_specialType; 00160 int m_size; 00161 int m_id; 00162 int m_locked; 00163 00164 ValueType* m_values; 00165 00166 // Metadata (range) 00167 ValueType m_lowBound, m_highBound; 00168 00169 // Dependent uniform evaluation 00170 mutable ShVariableNodeEval* m_eval; 00171 std::list<ShVariableNode*> m_dependents; 00172 00173 static int m_maxID; 00174 00175 #ifdef SH_USE_MEMORY_POOL 00176 static ShPool* m_pool; 00177 #endif 00178 }; 00179 00180 typedef ShPointer<ShVariableNode> ShVariableNodePtr; 00181 typedef ShPointer<const ShVariableNode> ShVariableNodeCPtr; 00182 00183 } 00184 00185 #endif

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