00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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},
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},
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},
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 }