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

ArbReg.cpp

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 #include "ArbReg.hpp" 00028 #include <iostream> 00029 #include <string> 00030 #include "Arb.hpp" 00031 00032 namespace shgl { 00033 00036 struct { 00037 char* name; 00038 char* estName; 00039 } arbRegTypeInfo[] = { 00040 {"ATTRIB", "i"}, 00041 {"PARAM", "u"}, 00042 {"TEMP", "t"}, 00043 {"ADDRESS", "a"}, 00044 {"OUTPUT", "o"}, 00045 {"PARAM", "c"}, 00046 {"<texture>", "<texture>"} 00047 }; 00048 00051 struct { 00052 ArbRegType type; 00053 char* name; 00054 bool indexed; 00055 } arbRegBindingInfo[] = { 00056 {SH_ARB_REG_PARAM, "program.local", true}, 00057 {SH_ARB_REG_PARAM, "program.env", true}, 00058 {SH_ARB_REG_OUTPUT, "result.color", false}, // TODO: Special case? 00059 00060 {SH_ARB_REG_ATTRIB, "vertex.position", false}, 00061 {SH_ARB_REG_ATTRIB, "vertex.weight", true}, 00062 {SH_ARB_REG_ATTRIB, "vertex.normal", false}, 00063 {SH_ARB_REG_ATTRIB, "vertex.color", false}, // TODO: Special case? 00064 {SH_ARB_REG_ATTRIB, "vertex.fogcoord", false}, 00065 {SH_ARB_REG_ATTRIB, "vertex.texcoord", true}, 00066 {SH_ARB_REG_ATTRIB, "vertex.matrixindex", true}, 00067 {SH_ARB_REG_ATTRIB, "vertex.attrib", true}, 00068 {SH_ARB_REG_OUTPUT, "result.position", false}, 00069 {SH_ARB_REG_OUTPUT, "result.fogcoord", false}, 00070 {SH_ARB_REG_OUTPUT, "result.pointsize", false}, 00071 {SH_ARB_REG_OUTPUT, "result.texcoord", true}, 00072 00073 {SH_ARB_REG_ATTRIB, "fragment.color", false}, // TODO: Special case? 00074 {SH_ARB_REG_ATTRIB, "fragment.texcoord", true}, 00075 {SH_ARB_REG_ATTRIB, "fragment.fogcoord", false}, 00076 {SH_ARB_REG_ATTRIB, "fragment.position", false}, 00077 {SH_ARB_REG_OUTPUT, "result.depth", false}, 00078 00079 {SH_ARB_REG_ATTRIB, "<nil>", false}, 00080 }; 00081 00082 ArbReg::ArbReg() 00083 : type(SH_ARB_REG_TEMP), index(-1), name(""), binding(SH_ARB_REG_NONE), bindingIndex(-1) 00084 { 00085 } 00086 00087 ArbReg::ArbReg(ArbRegType type, int index, std::string name) 00088 : type(type), index(index), name(name), binding(SH_ARB_REG_NONE), bindingIndex(-1) 00089 { 00090 } 00091 00092 00093 std::ostream& ArbReg::printDecl(std::ostream& out) const 00094 { 00095 out << arbRegTypeInfo[type].name << " " << *this; 00096 if (type == SH_ARB_REG_CONST) { 00097 out << " = " << "{"; 00098 for (int i = 0; i < 4; i++) { 00099 if (i) out << ", "; 00100 out << values[i]; 00101 } 00102 out << "}"; 00103 } else if (binding != SH_ARB_REG_NONE) { 00104 out << " = " << arbRegBindingInfo[binding].name; 00105 if (arbRegBindingInfo[binding].indexed) { 00106 out << "[" << bindingIndex << "]"; 00107 } 00108 } 00109 out << ";"; 00110 if(!name.empty() && type != SH_ARB_REG_CONST) out << " # " << name; 00111 return out; 00112 } 00113 00116 std::ostream& operator<<(std::ostream& out, const ArbReg& reg) 00117 { 00118 out << arbRegTypeInfo[reg.type].estName << reg.index; 00119 return out; 00120 } 00121 00122 }

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