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 SH_PALETTE = 7 00050 }; 00051 00054 enum ShSemanticType { 00055 SH_ATTRIB, 00056 SH_POINT, 00057 SH_VECTOR, 00058 SH_NORMAL, 00059 SH_COLOR, 00060 SH_TEXCOORD, 00061 SH_POSITION 00062 }; 00063 00064 // ensure these match the BindingType and SemanticType enums 00065 SH_DLLEXPORT extern const char* ShBindingTypeName[]; 00066 SH_DLLEXPORT extern const char* ShSemanticTypeName[]; 00067 00068 class ShProgramNode; 00069 00070 // Used to hide our use of ShProgramNodePtr, since MSVC7 doesn't allow it. 00071 struct ShVariableNodeEval; 00072 00075 class 00076 SH_DLLEXPORT ShVariableNode : public virtual ShRefCountable, 00077 public virtual ShMeta { 00078 public: 00079 ShVariableNode(ShBindingType kind, int size, ShSemanticType type = SH_ATTRIB); 00080 virtual ~ShVariableNode(); 00081 00082 bool uniform() const; 00083 bool hasValues() const; 00084 00085 int size() const; 00086 00087 // Don't call this on uniforms! 00088 void size(int size); 00089 00090 void lock(); 00091 void unlock(); 00092 00093 00094 typedef float ValueType; 00095 00096 // Metadata 00097 std::string name() const; 00098 void name(const std::string& n); 00099 00101 void range(ShVariableNode::ValueType low, ShVariableNode::ValueType high); 00102 ShVariableNode::ValueType lowBound() const; 00103 ShVariableNode::ValueType highBound() const; 00104 00105 ShBindingType kind() const; 00106 ShSemanticType specialType() const; 00107 void specialType(ShSemanticType); 00108 00109 std::string nameOfType() const; 00110 00115 void setValue(int i, ValueType value); 00116 00118 ValueType getValue(int i) const; 00119 00124 void addValues(); 00125 00131 00132 00133 void attach(const ShPointer<ShProgramNode>& evaluator); 00134 00136 void update(); 00137 00139 const ShPointer<ShProgramNode>& evaluator() const; 00140 00143 #ifdef SH_USE_MEMORY_POOL 00144 // Memory pool stuff. 00145 void* operator new(std::size_t size); 00146 void operator delete(void* d); 00147 #endif 00148 00149 protected: 00150 00151 void add_dependent(ShVariableNode* dep); 00152 void remove_dependent(ShVariableNode* dep); 00153 00154 void update_dependents(); 00155 void detach_dependencies(); 00156 00157 bool m_uniform; 00158 00159 ShBindingType m_kind; 00160 ShSemanticType m_specialType; 00161 int m_size; 00162 int m_id; 00163 int m_locked; 00164 00165 ValueType* m_values; 00166 00167 // Metadata (range) 00168 ValueType m_lowBound, m_highBound; 00169 00170 // Dependent uniform evaluation 00171 mutable ShVariableNodeEval* m_eval; 00172 std::list<ShVariableNode*> m_dependents; 00173 00174 static int m_maxID; 00175 00176 #ifdef SH_USE_MEMORY_POOL 00177 static ShPool* m_pool; 00178 #endif 00179 }; 00180 00181 typedef ShPointer<ShVariableNode> ShVariableNodePtr; 00182 typedef ShPointer<const ShVariableNode> ShVariableNodeCPtr; 00183 00184 } 00185 00186 #endif

Generated on Fri Nov 5 16:51:21 2004 for Sh by doxygen 1.3.7