vertex_program_parse.cpp File Reference


Detailed Description

Id
vertex_program_parse.cpp,v 1.4 2003/03/31 10:31:16 vizerie Exp

Definition in file vertex_program_parse.cpp.

#include "std3d.h"
#include "vertex_program_parse.h"

Go to the source code of this file.

Functions

void dumpInstr (const CVPInstruction &instr, std::string &out)
void dumpOperand (const CVPOperand &op, bool destOperand, std::string &out)
void dumpSwizzle (const CVPSwizzle &swz, std::string &out)
void dumpWriteMask (uint mask, std::string &out)
std::string getStringUntilCR (const char *src)
bool letterToSwizzleComp (char letter, CVPSwizzle::EComp &comp)
const char * parseUInt (const char *src, uint &dest)

Variables

const char * instrToName []
const char * outputRegisterToName []


Function Documentation

void dumpInstr const CVPInstruction instr,
std::string &  out
[static]
 

Dump an instruction in a string

Definition at line 1091 of file vertex_program_parse.cpp.

References CVPInstruction::Dest, dumpOperand(), CVPInstruction::getNumUsedSrc(), CVPInstruction::getSrc(), instrToName, nlassert, CVPInstruction::Opcode, and uint.

Referenced by CVPParser::dump().

01092 {
01093         nlassert(instr.Opcode < CVPInstruction::OpcodeCount);
01094         out = instrToName[instr.Opcode];
01095         uint nbOp = instr.getNumUsedSrc();
01096         std::string destOperand;
01097         dumpOperand(instr.Dest, true, destOperand);
01098         out += destOperand;
01099         for(uint k = 0; k < nbOp; ++k)
01100         {
01101                 out += ", ";
01102                 std::string srcOperand;
01103                 dumpOperand(instr.getSrc(k), false, srcOperand);
01104                 out += srcOperand;
01105         }
01106         out +="; \n";
01107 }

void dumpOperand const CVPOperand op,
bool  destOperand,
std::string &  out
[static]
 

Definition at line 1053 of file vertex_program_parse.cpp.

References dumpSwizzle(), dumpWriteMask(), CVPOperand::Indexed, CVPOperand::Negate, nlassert, outputRegisterToName, CVPOperand::Swizzle, NLMISC::toString(), CVPOperand::Type, uint, CVPOperand::Value, and CVPOperand::WriteMask.

Referenced by dumpInstr().

01054 {
01055         out = op.Negate ? " -" : " ";
01056         switch(op.Type)
01057         {
01058                 case CVPOperand::Variable: out += "R" + NLMISC::toString(op.Value.VariableValue); break;
01059                 case CVPOperand::Constant: 
01060                         out += "c[";
01061                         if (op.Indexed)
01062                         {
01063                                 out += "A0.x + ";
01064                         }
01065                         out += NLMISC::toString(op.Value.ConstantValue) + "]"; 
01066                 break;
01067                 case CVPOperand::InputRegister: out += "v[" + NLMISC::toString((uint) op.Value.InputRegisterValue) + "]"; break;
01068                 case CVPOperand::OutputRegister:
01069                         nlassert(op.Value.OutputRegisterValue < CVPOperand::OutputRegisterCount);
01070                         out += "o[" + std::string(outputRegisterToName[op.Value.OutputRegisterValue]) + "]";
01071                 break;
01072                 case CVPOperand::AddressRegister:
01073                         out += "A0.x";
01074                 break;
01075         }
01076         std::string suffix;
01077         if (destOperand)
01078         {
01079                 dumpWriteMask(op.WriteMask, suffix);
01080         }
01081         else
01082         {
01083                 dumpSwizzle(op.Swizzle, suffix);
01084         }
01085         out += suffix;
01086 }

void dumpSwizzle const CVPSwizzle swz,
std::string &  out
[static]
 

Definition at line 1027 of file vertex_program_parse.cpp.

References CVPSwizzle::Comp, CVPSwizzle::isIdentity(), CVPSwizzle::isScalar(), nlassert, and uint.

Referenced by dumpOperand().

01028 {
01029         if (swz.isIdentity())
01030         {
01031                 out = "";
01032                 return;
01033         }
01034         out = ".";
01035         for(uint k = 0; k < 4; ++k)
01036         {
01037                 switch(swz.Comp[k])
01038                 {
01039                         case CVPSwizzle::X: out += "x"; break;
01040                         case CVPSwizzle::Y: out += "y"; break;
01041                         case CVPSwizzle::Z: out += "z"; break;
01042                         case CVPSwizzle::W: out += "w"; break;
01043                         default:
01044                                 nlassert(0);
01045                         break;
01046                 }
01047                 if (swz.isScalar() && k == 0) break;
01048         }
01049 
01050 }

void dumpWriteMask uint  mask,
std::string &  out
[static]
 

Definition at line 1012 of file vertex_program_parse.cpp.

References uint.

Referenced by dumpOperand().

01013 {
01014         if (mask == 0xf)
01015         {
01016                 out = "";
01017                 return;
01018         }
01019         out = ".";
01020         if (mask & 1) out +="x";
01021         if (mask & 2) out +="y";
01022         if (mask & 4) out +="z";
01023         if (mask & 8) out +="w";
01024 }

std::string getStringUntilCR const char *  src  )  [static]
 

Definition at line 908 of file vertex_program_parse.cpp.

References nlassert, and src.

Referenced by CVPParser::parse().

00909 {
00910         nlassert(src);
00911         std::string result;
00912         while (*src != '\n' && *src != '\r' && *src != '\0') 
00913         {
00914                 result += *src;
00915                 ++src;
00916         }
00917         return result;
00918 }

bool letterToSwizzleComp char  letter,
CVPSwizzle::EComp comp
[inline, static]
 

Definition at line 302 of file vertex_program_parse.cpp.

Referenced by CVPParser::parseSwizzle().

00303 {
00304         switch (letter)
00305         {
00306                 case 'x': comp = CVPSwizzle::X; return true;
00307                 case 'y': comp = CVPSwizzle::Y; return true;
00308                 case 'z': comp = CVPSwizzle::Z; return true;
00309                 case 'w': comp = CVPSwizzle::W; return true;
00310         }
00311         return false;
00312 }

const char* parseUInt const char *  src,
uint dest
[inline, static]
 

Definition at line 428 of file vertex_program_parse.cpp.

References index, src, and uint.

Referenced by CVPParser::parseConstantRegister(), and CVPParser::parseVariableRegister().

00429 {
00430         uint index = 0;
00431         while (isdigit(*src))
00432         {
00433                 index = 10 * index + *src - '0';
00434                 ++ src;
00435         }
00436         dest = index;
00437         return src;
00438 }


Variable Documentation

const char* instrToName[] [static]
 

Initial value:

{
        "MOV  ",
        "ARL  ",
        "MUL  ",
        "ADD  ",
        "MAD  ",
        "RSQ  ",
        "DP3  ",
        "DP4  ",
        "DST  ",
        "LIT  ",
        "MIN  ",
        "MAX  ",
        "SLT  ",
        "SGE  ",
        "EXPP ",
        "LOG  ",
        "RCP  "
}

Definition at line 969 of file vertex_program_parse.cpp.

Referenced by dumpInstr().

const char* outputRegisterToName[] [static]
 

Initial value:

{
        "HPOS",
        "COL0",
        "COL1",
        "BFC0",
        "BFC1",
        "FOGC",
        "PSIZ",
        "TEX0",
        "TEX1",
        "TEX2",
        "TEX3",
        "TEX4",
        "TEX5",
        "TEX6",
        "TEX7"
}

Definition at line 991 of file vertex_program_parse.cpp.

Referenced by dumpOperand().


Generated on Tue Mar 16 06:43:31 2004 for NeL by doxygen 1.3.6