diff options
Diffstat (limited to 'docs/doxygen/nel/vertex__program__parse_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/vertex__program__parse_8cpp-source.html | 1166 |
1 files changed, 1166 insertions, 0 deletions
diff --git a/docs/doxygen/nel/vertex__program__parse_8cpp-source.html b/docs/doxygen/nel/vertex__program__parse_8cpp-source.html new file mode 100644 index 00000000..56f9bf70 --- /dev/null +++ b/docs/doxygen/nel/vertex__program__parse_8cpp-source.html @@ -0,0 +1,1166 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>vertex_program_parse.cpp</h1><a href="vertex__program__parse_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00006 <font class="comment">/* Copyright, 2000, 2001, 2002 Nevrax Ltd.</font> +00007 <font class="comment"> *</font> +00008 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00009 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00010 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00011 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00012 <font class="comment"> * any later version.</font> +00013 <font class="comment"></font> +00014 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00015 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00016 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00017 <font class="comment"> * General Public License for more details.</font> +00018 <font class="comment"></font> +00019 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00020 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00021 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00022 <font class="comment"> * MA 02111-1307, USA.</font> +00023 <font class="comment"> */</font> +00024 +00025 <font class="preprocessor">#include "<a class="code" href="std3d_8h.html">std3d.h</a>"</font> +00026 <font class="preprocessor">#include "<a class="code" href="vertex__program__parse_8h.html">vertex_program_parse.h</a>"</font> +00027 +00028 +00029 +00030 <font class="comment">//=====================================</font> +<a name="l00031"></a><a class="code" href="classCVPParser.html#c7">00031</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c7">CVPParser::parseWriteMask</a>(uint &mask, std::string &errorOutput) +00032 { +00033 <font class="comment">// parse output mask</font> +00034 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'.'</font>) +00035 { +00036 <font class="comment">// no output masks</font> +00037 mask = 0xf; <font class="comment">//output 4 coordinates</font> +00038 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00039 } +00040 <font class="keywordflow">else</font> +00041 { +00042 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00043 mask = 0; +00044 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +00045 { +00046 uint maskIndex; +00047 <font class="keywordflow">switch</font>(*_CurrChar) +00048 { +00049 <font class="keywordflow">case</font> <font class="charliteral">'x'</font>: maskIndex = 0; <font class="keywordflow">break</font>; +00050 <font class="keywordflow">case</font> <font class="charliteral">'y'</font>: maskIndex = 1; <font class="keywordflow">break</font>; +00051 <font class="keywordflow">case</font> <font class="charliteral">'z'</font>: maskIndex = 2; <font class="keywordflow">break</font>; +00052 <font class="keywordflow">case</font> <font class="charliteral">'w'</font>: maskIndex = 3; <font class="keywordflow">break</font>; +00053 <font class="keywordflow">default</font>: +00054 <font class="keywordflow">if</font> (k >= 1) <font class="keywordflow">return</font> <font class="keyword">true</font>; +00055 <font class="keywordflow">else</font> +00056 { +00057 errorOutput = <font class="stringliteral">"Can't parse output mask."</font>; +00058 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00059 } +00060 <font class="keywordflow">break</font>; +00061 } +00062 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00063 <font class="keywordflow">if</font> (mask & (1 << maskIndex)) +00064 { +00065 errorOutput = <font class="stringliteral">"Duplicated output mask component."</font>; +00066 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00067 } +00068 mask |= 1 << maskIndex; +00069 } +00070 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00071 } +00072 } +00073 +00074 <font class="comment">//=====================================</font> +<a name="l00077"></a><a class="code" href="classCVPParser.html#c12">00077</a> <font class="comment"></font><font class="keywordtype">void</font> <a class="code" href="classCVPParser.html#c12">CVPParser::skipSpacesAndComments</a>() +00078 { +00079 <font class="keywordtype">bool</font> stop = <font class="keyword">false</font>; +00080 <font class="keywordflow">do</font> +00081 { +00082 <font class="keywordflow">switch</font>(*_CurrChar) +00083 { +00084 <font class="keywordflow">case</font> <font class="charliteral">'\t'</font>: +00085 <font class="keywordflow">case</font> <font class="charliteral">'\r'</font>: +00086 <font class="keywordflow">case</font> <font class="charliteral">' '</font> : +00087 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00088 <font class="keywordflow">break</font>; +00089 <font class="comment">//</font> +00090 <font class="keywordflow">case</font> <font class="charliteral">'\n'</font>: +00091 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00092 ++<a class="code" href="classCVPParser.html#o2">_LineIndex</a>; +00093 <a class="code" href="classCVPParser.html#o1">_LineStart</a> = <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00094 <font class="keywordflow">break</font>; +00095 <font class="keywordflow">case</font> <font class="charliteral">'#'</font>: <font class="comment">// comment go till end of line</font> +00096 <font class="keywordflow">while</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'\n'</font> && *<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'\0'</font>) ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00097 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00098 <font class="keywordflow">break</font>; +00099 <font class="keywordflow">default</font>: +00100 stop = <font class="keyword">true</font>; +00101 <font class="keywordflow">break</font>; +00102 } +00103 } +00104 <font class="keywordflow">while</font> (!stop); +00105 } +00106 +00107 <font class="comment">//=================================================================================================</font> +<a name="l00108"></a><a class="code" href="structCVPInstruction.html#a1">00108</a> uint <a class="code" href="structCVPInstruction.html#a1">CVPInstruction::getNumUsedSrc</a>()<font class="keyword"> const</font> +00109 <font class="keyword"></font>{ +00110 <font class="keywordflow">switch</font>(Opcode) +00111 { +00112 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s1">CVPInstruction::ARL</a>: +00113 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s5">CVPInstruction::RSQ</a>: +00114 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s14">CVPInstruction::EXPP</a>: +00115 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s15">CVPInstruction::LOG</a>: +00116 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s16">CVPInstruction::RCP</a>: +00117 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s0">CVPInstruction::MOV</a>: +00118 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s9">CVPInstruction::LIT</a>: +00119 <font class="keywordflow">return</font> 1; +00120 <font class="comment">//</font> +00121 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s4">CVPInstruction::MAD</a>: +00122 <font class="keywordflow">return</font> 3; +00123 <font class="comment">//</font> +00124 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s2">CVPInstruction::MUL</a>: +00125 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s3">CVPInstruction::ADD</a>: +00126 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s6">CVPInstruction::DP3</a>: +00127 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s7">CVPInstruction::DP4</a>: +00128 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s8">CVPInstruction::DST</a>: +00129 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s10">CVPInstruction::MIN</a>: +00130 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s11">CVPInstruction::MAX</a>: +00131 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s12">CVPInstruction::SLT</a>: +00132 <font class="keywordflow">case</font> <a class="code" href="structCVPInstruction.html#s18s13">CVPInstruction::SGE</a>: +00133 <font class="keywordflow">return</font> 2; +00134 <font class="comment">//</font> +00135 <font class="keywordflow">default</font>: +00136 <a class="code" href="debug_8h.html#a12">nlstop</a>; +00137 } +00138 <font class="keywordflow">return</font> 0; +00139 } +00140 +00141 <font class="comment">//=================================================================================================</font> +<a name="l00142"></a><a class="code" href="classCVPParser.html#c0">00142</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c0">CVPParser::parseOperand</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, <font class="keywordtype">bool</font> outputOperand, std::string &errorOutput) +00143 { +00144 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00145 <font class="keywordtype">bool</font> result; +00146 <font class="keywordflow">if</font> (outputOperand) +00147 { +00148 operand.<a class="code" href="structCVPOperand.html#m8">Negate</a> = <font class="keyword">false</font>; +00149 <font class="keywordflow">switch</font>(*_CurrChar) +00150 { +00151 <font class="keywordflow">case</font> <font class="charliteral">'o'</font>: result = <a class="code" href="classCVPParser.html#c2">parseOutputRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00152 <font class="keywordflow">case</font> <font class="charliteral">'R'</font>: +00153 result = <a class="code" href="classCVPParser.html#c4">parseVariableRegister</a>(operand, errorOutput); +00154 <font class="keywordflow">break</font>; +00155 <font class="keywordflow">case</font> <font class="charliteral">'A'</font>: result = <a class="code" href="classCVPParser.html#c5">parseAddressRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00156 <font class="keywordflow">case</font> <font class="charliteral">'-'</font>: +00157 errorOutput = <font class="stringliteral">"Negation not allowed on ouput register."</font>; +00158 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00159 <font class="keywordflow">default</font>: +00160 errorOutput = <font class="stringliteral">"Output, Address, or Temporary register expected as an output operand."</font>; +00161 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00162 } +00163 <font class="keywordflow">if</font> (!result) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00164 +00165 <font class="comment">// parse the write mask</font> +00166 <font class="keywordflow">return</font> <a class="code" href="classCVPParser.html#c7">parseWriteMask</a>(operand.<a class="code" href="structCVPOperand.html#m7">WriteMask</a>, errorOutput); +00167 } +00168 <font class="keywordflow">else</font> +00169 { +00170 operand.<a class="code" href="structCVPOperand.html#m8">Negate</a> = <font class="keyword">false</font>; +00171 <font class="keywordflow">switch</font>(*_CurrChar) +00172 { +00173 <font class="keywordflow">case</font> <font class="charliteral">'v'</font>: result = <a class="code" href="classCVPParser.html#c1">parseInputRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00174 <font class="keywordflow">case</font> <font class="charliteral">'R'</font>: result = <a class="code" href="classCVPParser.html#c4">parseVariableRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00175 <font class="keywordflow">case</font> <font class="charliteral">'c'</font>: result = <a class="code" href="classCVPParser.html#c3">parseConstantRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00176 <font class="keywordflow">case</font> <font class="charliteral">'a'</font>: result = <a class="code" href="classCVPParser.html#c5">parseAddressRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00177 <font class="keywordflow">case</font> <font class="charliteral">'-'</font>: +00178 { +00179 operand.<a class="code" href="structCVPOperand.html#m8">Negate</a> = <font class="keyword">true</font>; +00180 <font class="comment">// negation</font> +00181 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00182 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00183 <font class="keywordflow">switch</font>(*_CurrChar) +00184 { +00185 <font class="keywordflow">case</font> <font class="charliteral">'v'</font>: result = <a class="code" href="classCVPParser.html#c1">parseInputRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00186 <font class="keywordflow">case</font> <font class="charliteral">'R'</font>: result = <a class="code" href="classCVPParser.html#c4">parseVariableRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00187 <font class="keywordflow">case</font> <font class="charliteral">'c'</font>: result = <a class="code" href="classCVPParser.html#c3">parseConstantRegister</a>(operand, errorOutput); <font class="keywordflow">break</font>; +00188 <font class="keywordflow">default</font>: +00189 errorOutput = <font class="stringliteral">"Negation must be followed by an input register, a variable register, or a constant."</font>; +00190 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00191 <font class="keywordflow">break</font>; +00192 } +00193 } +00194 <font class="keywordflow">break</font>; +00195 <font class="keywordflow">default</font>: +00196 errorOutput = <font class="stringliteral">"Syntax error."</font>; +00197 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00198 <font class="keywordflow">break</font>; +00199 } +00200 <font class="keywordflow">if</font> (!result) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00201 <font class="keywordflow">if</font> (operand.<a class="code" href="structCVPOperand.html#m0">Type</a> != <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a>) +00202 { +00203 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c6">parseSwizzle</a>(operand.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00204 <font class="keywordflow">if</font> (operand.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s0">CVPOperand::Variable</a>) +00205 { +00206 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +00207 { +00208 <font class="keywordflow">if</font> (!(<a class="code" href="classCVPParser.html#o3">_RegisterMask</a>[operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.VariableValue] & (1 << operand.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[k]))) +00209 { +00210 errorOutput = <font class="stringliteral">"Can't read a register component before writing to it."</font>; +00211 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00212 } +00213 } +00214 } +00215 } +00216 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00217 } +00218 +00219 +00220 } +00221 +00222 +00223 <font class="comment">//=================================================================================================</font> +<a name="l00224"></a><a class="code" href="classCVPParser.html#c1">00224</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c1">CVPParser::parseInputRegister</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, std::string &errorOutput) +00225 { +00226 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00227 operand.<a class="code" href="structCVPOperand.html#m0">Type</a> = <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>; +00228 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'['</font>) +00229 { +00230 errorOutput = <font class="stringliteral">"'[' expected when parsing an input register."</font>; +00231 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00232 } +00233 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00234 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00235 <font class="keywordflow">if</font> (isdigit(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00236 { +00237 <font class="comment">// The input register is expressed as an index</font> +00238 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = *<a class="code" href="classCVPParser.html#o0">_CurrChar</a> - <font class="charliteral">'0'</font>; +00239 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00240 <font class="keywordflow">if</font> (isdigit(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00241 { +00242 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 10 * <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> + (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> - <font class="charliteral">'0'</font>); +00243 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00244 } +00245 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> > 15) +00246 { +00247 errorOutput = <font class="stringliteral">"Invalid index for input register, must be in [0, 15]."</font>; +00248 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00249 } +00250 operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = (CVPOperand::EInputRegister) <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +00251 } +00252 <font class="keywordflow">else</font> +00253 { +00254 <font class="comment">// The input register is expressed as a string</font> +00255 uint32 strValue = 0; +00256 <font class="comment">// read the 4 letters</font> +00257 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +00258 { +00259 <font class="keywordflow">if</font> (!isalnum(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00260 { +00261 errorOutput = <font class="stringliteral">"Can't parse index for input register."</font>; +00262 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00263 } +00264 strValue |= ((uint32) *<a class="code" href="classCVPParser.html#o0">_CurrChar</a>) << (8 * (3 - k)); +00265 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00266 } +00267 <font class="keywordflow">switch</font> (strValue) +00268 { +00269 <font class="keywordflow">case</font> 'OPOS': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s6">CVPOperand::IPosition</a>; <font class="keywordflow">break</font>; +00270 <font class="keywordflow">case</font> 'WGHT': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s7">CVPOperand::IWeight</a>; <font class="keywordflow">break</font>; +00271 <font class="keywordflow">case</font> 'NRML': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s8">CVPOperand::INormal</a>; <font class="keywordflow">break</font>; +00272 <font class="keywordflow">case</font> 'COL0': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s9">CVPOperand::IPrimaryColor</a>; <font class="keywordflow">break</font>; +00273 <font class="keywordflow">case</font> 'COL1': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s10">CVPOperand::ISecondaryColor</a>; <font class="keywordflow">break</font>; +00274 <font class="keywordflow">case</font> 'FOGC': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = <a class="code" href="structCVPOperand.html#s41s11">CVPOperand::IFogCoord</a>; <font class="keywordflow">break</font>; +00275 <font class="comment">// texture argument</font> +00276 <font class="keywordflow">case</font> 'TEX0': +00277 <font class="keywordflow">case</font> 'TEX1': +00278 <font class="keywordflow">case</font> 'TEX2': +00279 <font class="keywordflow">case</font> 'TEX3': +00280 <font class="keywordflow">case</font> 'TEX4': +00281 <font class="keywordflow">case</font> 'TEX5': +00282 <font class="keywordflow">case</font> 'TEX6': +00283 <font class="keywordflow">case</font> 'TEX7': +00284 operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue = (CVPOperand::EInputRegister) (<a class="code" href="structCVPOperand.html#s41s14">CVPOperand::ITex0</a> + strValue & 0xff - <font class="charliteral">'0'</font>); +00285 <font class="keywordflow">break</font>; +00286 <font class="keywordflow">default</font>: +00287 errorOutput = <font class="stringliteral">"Can't parse index for input register."</font>; +00288 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00289 } +00290 } +00291 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00292 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">']'</font>) +00293 { +00294 errorOutput = <font class="stringliteral">"']' expected when parsing an input register."</font>; +00295 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00296 } +00297 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00298 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00299 } +00300 +00301 <font class="comment">//=================================================================================================</font> +<a name="l00302"></a><a class="code" href="vertex__program__parse_8cpp.html#a2">00302</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keywordtype">bool</font> <a class="code" href="vertex__program__parse_8cpp.html#a2">letterToSwizzleComp</a>(<font class="keywordtype">char</font> letter, <a class="code" href="structCVPSwizzle.html#s4">CVPSwizzle::EComp</a> &comp) +00303 { +00304 <font class="keywordflow">switch</font> (letter) +00305 { +00306 <font class="keywordflow">case</font> <font class="charliteral">'x'</font>: comp = <a class="code" href="structCVPSwizzle.html#s4s0">CVPSwizzle::X</a>; <font class="keywordflow">return</font> <font class="keyword">true</font>; +00307 <font class="keywordflow">case</font> <font class="charliteral">'y'</font>: comp = <a class="code" href="structCVPSwizzle.html#s4s1">CVPSwizzle::Y</a>; <font class="keywordflow">return</font> <font class="keyword">true</font>; +00308 <font class="keywordflow">case</font> <font class="charliteral">'z'</font>: comp = <a class="code" href="structCVPSwizzle.html#s4s2">CVPSwizzle::Z</a>; <font class="keywordflow">return</font> <font class="keyword">true</font>; +00309 <font class="keywordflow">case</font> <font class="charliteral">'w'</font>: comp = <a class="code" href="structCVPSwizzle.html#s4s3">CVPSwizzle::W</a>; <font class="keywordflow">return</font> <font class="keyword">true</font>; +00310 } +00311 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00312 } +00313 +00314 <font class="comment">//=================================================================================================</font> +<a name="l00315"></a><a class="code" href="classCVPParser.html#c6">00315</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c6">CVPParser::parseSwizzle</a>(<a class="code" href="structCVPSwizzle.html">CVPSwizzle</a> &swizzle,std::string &errorOutput) +00316 { +00317 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'.'</font>) +00318 { +00319 <font class="comment">// no swizzle</font> +00320 swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[0] = <a class="code" href="structCVPSwizzle.html#s4s0">CVPSwizzle::X</a>; +00321 swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[1] = <a class="code" href="structCVPSwizzle.html#s4s1">CVPSwizzle::Y</a>; +00322 swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[2] = <a class="code" href="structCVPSwizzle.html#s4s2">CVPSwizzle::Z</a>; +00323 swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[3] = <a class="code" href="structCVPSwizzle.html#s4s3">CVPSwizzle::W</a>; +00324 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00325 } +00326 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00327 <font class="comment">// 4 letters case</font> +00328 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +00329 { +00330 <font class="keywordflow">if</font> (!isalpha(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00331 { +00332 <font class="keywordflow">if</font> (k == 1) <font class="comment">// 1 letter case</font> +00333 { +00334 <font class="keywordflow">switch</font>(*_CurrChar) +00335 { +00336 <font class="keywordflow">case</font> <font class="charliteral">','</font>: +00337 <font class="keywordflow">case</font> <font class="charliteral">';'</font>: +00338 <font class="keywordflow">case</font> <font class="charliteral">' '</font>: +00339 <font class="keywordflow">case</font> <font class="charliteral">'\t'</font>: +00340 <font class="keywordflow">case</font> <font class="charliteral">'\r'</font>: +00341 <font class="keywordflow">case</font> <font class="charliteral">'\n'</font>: +00342 <font class="keywordflow">case</font> <font class="charliteral">'#'</font>: +00343 swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[1] = swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[2] = swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[3] = swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[0]; +00344 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00345 <font class="keywordflow">break</font>; +00346 <font class="keywordflow">default</font>: +00347 errorOutput = <font class="stringliteral">"Can't parse swizzle."</font>; +00348 +00349 } +00350 } +00351 <font class="keywordflow">else</font> +00352 { +00353 errorOutput = <font class="stringliteral">"Invalid swizzle value."</font>; +00354 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00355 } +00356 } +00357 +00358 <font class="keywordflow">if</font> (!<a class="code" href="vertex__program__parse_8cpp.html#a2">letterToSwizzleComp</a>(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>, swizzle.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[k])) +00359 { +00360 errorOutput = <font class="stringliteral">"Invalid swizzle value."</font>; +00361 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00362 } +00363 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00364 } +00365 +00366 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00367 } +00368 +00369 <font class="comment">//=================================================================================================</font> +<a name="l00370"></a><a class="code" href="classCVPParser.html#c2">00370</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c2">CVPParser::parseOutputRegister</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, std::string &errorOutput) +00371 { +00372 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00373 operand.<a class="code" href="structCVPOperand.html#m0">Type</a> = <a class="code" href="structCVPOperand.html#s40s3">CVPOperand::OutputRegister</a>; +00374 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'['</font>) +00375 { +00376 errorOutput = <font class="stringliteral">"'[' expected when parsing an ouput register."</font>; +00377 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00378 } +00379 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00380 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00381 <font class="comment">// The input register is expressed as a string</font> +00382 uint32 strValue = 0; +00383 <font class="comment">// read the 4 letters</font> +00384 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +00385 { +00386 <font class="keywordflow">if</font> (!isalnum(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00387 { +00388 errorOutput = <font class="stringliteral">"Can't parse index for output register."</font>; +00389 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00390 } +00391 strValue |= ((uint32) *<a class="code" href="classCVPParser.html#o0">_CurrChar</a>) << (8 * (3 - k)); +00392 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00393 } +00394 <font class="comment">// convert to enum</font> +00395 <font class="keywordflow">switch</font>(strValue) +00396 { +00397 <font class="keywordflow">case</font> 'HPOS': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s24">CVPOperand::OHPosition</a>; <font class="keywordflow">break</font>; +00398 <font class="keywordflow">case</font> 'COL0': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s25">CVPOperand::OPrimaryColor</a>; <font class="keywordflow">break</font>; +00399 <font class="keywordflow">case</font> 'COL1': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s26">CVPOperand::OSecondaryColor</a>; <font class="keywordflow">break</font>; +00400 <font class="keywordflow">case</font> 'BFC0': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s27">CVPOperand::OBackFacePrimaryColor</a>; <font class="keywordflow">break</font>; +00401 <font class="keywordflow">case</font> 'BFC1': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s28">CVPOperand::OBackFaceSecondaryColor</a>; <font class="keywordflow">break</font>; +00402 <font class="keywordflow">case</font> 'FOGC': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s29">CVPOperand::OFogCoord</a>; <font class="keywordflow">break</font>; +00403 <font class="keywordflow">case</font> 'PSIZ': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s30">CVPOperand::OPointSize</a>; <font class="keywordflow">break</font>; +00404 <font class="keywordflow">case</font> 'TEX0': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s31">CVPOperand::OTex0</a>; <font class="keywordflow">break</font>; +00405 <font class="keywordflow">case</font> 'TEX1': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s32">CVPOperand::OTex1</a>; <font class="keywordflow">break</font>; +00406 <font class="keywordflow">case</font> 'TEX2': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s33">CVPOperand::OTex2</a>; <font class="keywordflow">break</font>; +00407 <font class="keywordflow">case</font> 'TEX3': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s34">CVPOperand::OTex3</a>; <font class="keywordflow">break</font>; +00408 <font class="keywordflow">case</font> 'TEX4': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s35">CVPOperand::OTex4</a>; <font class="keywordflow">break</font>; +00409 <font class="keywordflow">case</font> 'TEX5': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s36">CVPOperand::OTex5</a>; <font class="keywordflow">break</font>; +00410 <font class="keywordflow">case</font> 'TEX6': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s37">CVPOperand::OTex6</a>; <font class="keywordflow">break</font>; +00411 <font class="keywordflow">case</font> 'TEX7': operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue = <a class="code" href="structCVPOperand.html#s42s38">CVPOperand::OTex7</a>; <font class="keywordflow">break</font>; +00412 <font class="keywordflow">default</font>: +00413 errorOutput = <font class="stringliteral">"Can't read index for output register."</font>; +00414 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00415 <font class="keywordflow">break</font>; +00416 } +00417 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00418 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">']'</font>) +00419 { +00420 errorOutput = <font class="stringliteral">"']' expected when parsing an output register."</font>; +00421 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00422 } +00423 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00424 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00425 } +00426 +00427 <font class="comment">//=================================================================================================</font> +<a name="l00428"></a><a class="code" href="vertex__program__parse_8cpp.html#a3">00428</a> <font class="keyword">static</font> <font class="keyword">inline</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="vertex__program__parse_8cpp.html#a3">parseUInt</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, uint &dest) +00429 { +00430 uint <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 0; +00431 <font class="keywordflow">while</font> (isdigit(*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>)) +00432 { +00433 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 10 * <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> + *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> - <font class="charliteral">'0'</font>; +00434 ++ <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00435 } +00436 dest = <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>; +00437 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00438 } +00439 +00440 +00441 <font class="comment">//=================================================================================================</font> +<a name="l00442"></a><a class="code" href="classCVPParser.html#c3">00442</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c3">CVPParser::parseConstantRegister</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, std::string &errorOutput) +00443 { +00444 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00445 operand.<a class="code" href="structCVPOperand.html#m0">Type</a> = <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>; +00446 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">'['</font>) +00447 { +00448 errorOutput = <font class="stringliteral">"'[' expected when parsing a constant register."</font>; +00449 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00450 } +00451 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00452 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00453 uint &<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue; +00454 <font class="keywordflow">if</font> (isdigit(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00455 { +00456 <font class="comment">// immediat case : c[0] to c[95]</font> +00457 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> = <a class="code" href="vertex__program__parse_8cpp.html#a3">parseUInt</a>(<a class="code" href="classCVPParser.html#o0">_CurrChar</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00458 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> > 95) +00459 { +00460 errorOutput = <font class="stringliteral">"Constant register index must range from 0 to 95."</font>; +00461 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00462 } +00463 operand.<a class="code" href="structCVPOperand.html#m6">Indexed</a> = <font class="keyword">false</font>; +00464 } +00465 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> == <font class="charliteral">'A'</font>) +00466 { +00467 <font class="comment">// indexed case : c[A0.x + 0] to c[A0.x + 95]</font> +00468 operand.<a class="code" href="structCVPOperand.html#m6">Indexed</a> = <font class="keyword">true</font>; +00469 <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = 0; +00470 <font class="keywordflow">if</font> (<a class="code" href="classCVPParser.html#o0">_CurrChar</a>[1] == <font class="charliteral">'0'</font> +00471 && <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[2] == <font class="charliteral">'.'</font> +00472 && <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[3] == <font class="charliteral">'x'</font>) +00473 { +00474 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> += 4; +00475 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00476 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> == <font class="charliteral">'+'</font>) +00477 { +00478 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00479 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00480 <font class="keywordflow">if</font> (isdigit(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00481 { +00482 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> = <a class="code" href="vertex__program__parse_8cpp.html#a3">parseUInt</a>(<a class="code" href="classCVPParser.html#o0">_CurrChar</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00483 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> > 95) +00484 { +00485 errorOutput = <font class="stringliteral">"Constant register index must range from 0 to 95."</font>; +00486 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00487 } +00488 } +00489 <font class="keywordflow">else</font> +00490 { +00491 errorOutput = <font class="stringliteral">"Can't parse offset for constant register."</font>; +00492 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00493 } +00494 } +00495 } +00496 <font class="keywordflow">else</font> +00497 { +00498 errorOutput = <font class="stringliteral">"Can't parse constant register index."</font>; +00499 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00500 } +00501 } +00502 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00503 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">']'</font>) +00504 { +00505 errorOutput = <font class="stringliteral">"']' expected when parsing an input register."</font>; +00506 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00507 } +00508 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00509 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00510 } +00511 +00512 <font class="comment">//=================================================================================================</font> +<a name="l00513"></a><a class="code" href="classCVPParser.html#c4">00513</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c4">CVPParser::parseVariableRegister</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, std::string &errorOutput) +00514 { +00515 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00516 operand.<a class="code" href="structCVPOperand.html#m0">Type</a> = <a class="code" href="structCVPOperand.html#s40s0">CVPOperand::Variable</a>; +00517 <font class="keywordflow">if</font> (!isdigit(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00518 { +00519 errorOutput = <font class="stringliteral">"Can't parse variable register."</font>; +00520 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00521 } +00522 uint &<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> = operand.<a class="code" href="structCVPOperand.html#m5">Value</a>.VariableValue; +00523 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> = <a class="code" href="vertex__program__parse_8cpp.html#a3">parseUInt</a>(<a class="code" href="classCVPParser.html#o0">_CurrChar</a>, <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>); +00524 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a> > 11) +00525 { +00526 errorOutput = <font class="stringliteral">"Variable register index must range from 0 to 11."</font>; +00527 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00528 } +00529 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00530 } +00531 +00532 <font class="comment">//=================================================================================================</font> +<a name="l00533"></a><a class="code" href="classCVPParser.html#c5">00533</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c5">CVPParser::parseAddressRegister</a>(<a class="code" href="structCVPOperand.html">CVPOperand</a> &operand, std::string &errorOutput) +00534 { +00535 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00536 operand.<a class="code" href="structCVPOperand.html#m0">Type</a> = <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a>; +00537 <font class="keywordflow">if</font> (<a class="code" href="classCVPParser.html#o0">_CurrChar</a>[0] != <font class="charliteral">'0'</font> || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[1] != <font class="charliteral">'.'</font> || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[2] != <font class="charliteral">'x'</font>) +00538 { +00539 errorOutput = <font class="stringliteral">"Can't parse address register."</font>; +00540 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00541 } +00542 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> += 3; +00543 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00544 } +00545 +00546 <font class="comment">//=================================================================================================</font> +<a name="l00547"></a><a class="code" href="classCVPParser.html#c9">00547</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c9">CVPParser::parseOp2</a>(<a class="code" href="structCVPInstruction.html">CVPInstruction</a> &instr,std::string &errorOutput) +00548 { +00549 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00550 <font class="comment">// parse ouput</font> +00551 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c0">parseOperand</a>(instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>, <font class="keyword">true</font>, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00552 <font class="comment">// Can't write in input or consant register</font> +00553 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a> || instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>) +00554 { +00555 errorOutput = <font class="stringliteral">"Can't write to a constant or input register"</font>; +00556 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00557 } +00558 <font class="comment">//</font> +00559 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00560 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">','</font>) +00561 { +00562 errorOutput = <font class="stringliteral">"',' expected."</font>; +00563 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00564 } +00565 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00566 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00567 <font class="comment">// parse src1</font> +00568 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c0">parseOperand</a>(instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>, <font class="keyword">false</font>, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00569 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a> +00570 || instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s3">CVPOperand::OutputRegister</a>) +00571 { +00572 errorOutput = <font class="stringliteral">"Src1 must be constant, variable, or input register."</font>; +00573 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00574 } +00575 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00576 } +00577 +00578 <font class="comment">//=================================================================================================</font> +<a name="l00579"></a><a class="code" href="classCVPParser.html#c10">00579</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c10">CVPParser::parseOp3</a>(<a class="code" href="structCVPInstruction.html">CVPInstruction</a> &instr, std::string &errorOutput) +00580 { +00581 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00582 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00583 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">','</font>) +00584 { +00585 errorOutput = <font class="stringliteral">"',' expected."</font>; +00586 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00587 } +00588 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00589 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00590 <font class="comment">// parse src2</font> +00591 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c0">parseOperand</a>(instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>, <font class="keyword">false</font>, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00592 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a> +00593 || instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s3">CVPOperand::OutputRegister</a>) +00594 { +00595 errorOutput = <font class="stringliteral">"Src2 must be constant, variable, or input register."</font>; +00596 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00597 } +00598 <font class="comment">// make sure we do not have 2 =/= contant register as src (or in put register)</font> +00599 +00600 <font class="comment">// 2 constant registers ?</font> +00601 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a> +00602 && instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>) +00603 { +00604 <font class="comment">// the index must be the same</font> +00605 <font class="keywordflow">if</font> (! +00606 ( +00607 instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> == instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> +00608 && instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue == instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue +00609 ) +00610 ) +00611 { +00612 errorOutput = <font class="stringliteral">"Can't read 2 different constant registers in a single instruction."</font>; +00613 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00614 } +00615 } +00616 +00617 <font class="comment">// 2 input registers ?</font> +00618 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a> +00619 && instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>) +00620 { +00621 <font class="comment">// the index must be the same</font> +00622 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue != instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue) +00623 { +00624 errorOutput = <font class="stringliteral">"Can't read 2 different input registers in a single instruction."</font>; +00625 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00626 } +00627 } +00628 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00629 } +00630 +00631 <font class="comment">//=================================================================================================</font> +<a name="l00632"></a><a class="code" href="classCVPParser.html#c11">00632</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c11">CVPParser::parseOp4</a>(<a class="code" href="structCVPInstruction.html">CVPInstruction</a> &instr, std::string &errorOutput) +00633 { +00634 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00635 <font class="comment">// parse src 3</font> +00636 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00637 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">','</font>) +00638 { +00639 errorOutput = <font class="stringliteral">"',' expected."</font>; +00640 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00641 } +00642 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00643 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00644 <font class="comment">// parse src4</font> +00645 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c0">parseOperand</a>(instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>, <font class="keyword">false</font>, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00646 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a> +00647 || instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s3">CVPOperand::OutputRegister</a>) +00648 { +00649 errorOutput = <font class="stringliteral">"Src3 must be constant, variable, or input register."</font>; +00650 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00651 } +00652 +00654 <font class="comment">// check for different contant / input registers //</font> +00656 <font class="comment"></font> +00657 <font class="comment">// Duplicated constant register</font> +00658 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>) +00659 { +00660 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>) +00661 { +00662 <font class="keywordflow">if</font> (! +00663 ( +00664 instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> == instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> +00665 && instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue == instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue +00666 ) +00667 ) +00668 { +00669 errorOutput = <font class="stringliteral">"Can't read 2 different constant registers in a single instruction."</font>; +00670 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00671 } +00672 } +00673 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>) +00674 { +00675 <font class="keywordflow">if</font> (! +00676 ( +00677 instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> == instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m6">Indexed</a> +00678 && instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue == instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue +00679 ) +00680 ) +00681 { +00682 errorOutput = <font class="stringliteral">"Can't read 2 different constant registers in a single instruction."</font>; +00683 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00684 } +00685 } +00686 } +00687 +00688 <font class="comment">// Duplicated input register</font> +00689 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>) +00690 { +00691 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>) +00692 { +00693 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue != instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue) +00694 { +00695 errorOutput = <font class="stringliteral">"Can't read 2 different input registers in a single instruction."</font>; +00696 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00697 } +00698 } +00699 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>) +00700 { +00701 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m3">Src2</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue != instr.<a class="code" href="structCVPInstruction.html#m4">Src3</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue) +00702 { +00703 errorOutput = <font class="stringliteral">"Can't read 2 different input registers in a single instruction."</font>; +00704 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00705 } +00706 } +00707 } +00708 +00709 +00710 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00711 } +00712 +00713 <font class="comment">//=================================================================================================</font> +<a name="l00714"></a><a class="code" href="classCVPParser.html#c8">00714</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#c8">CVPParser::parseInstruction</a>(<a class="code" href="structCVPInstruction.html">CVPInstruction</a> &instr, std::string &errorOutput, <font class="keywordtype">bool</font> &endEncountered) +00715 { +00716 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00717 endEncountered = <font class="keyword">false</font>; +00718 uint32 instrStr = 0; +00719 uint k; +00720 <font class="keywordflow">for</font>(k = 0; k < 4; ++k) +00721 { +00722 <font class="keywordflow">if</font> (!isalnum(*<a class="code" href="classCVPParser.html#o0">_CurrChar</a>)) +00723 { +00724 <font class="keywordflow">if</font> (k < 3) <font class="comment">// at least 3 letter in an instruction</font> +00725 { +00726 errorOutput = <font class="stringliteral">"Syntax error : can't read opcode."</font>; +00727 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00728 } +00729 <font class="keywordflow">else</font> <font class="keywordflow">break</font>; +00730 } +00731 instrStr |= ((uint) *<a class="code" href="classCVPParser.html#o0">_CurrChar</a>) << (8 * (3 - k)); +00732 ++ <a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00733 } +00734 <font class="keywordflow">if</font> (k != 4) +00735 { +00736 instrStr |= (uint32) <font class="charliteral">' '</font>; +00737 } +00738 <font class="keywordflow">switch</font> (instrStr) +00739 { +00740 <font class="keywordflow">case</font> 'ARL ': +00741 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s1">CVPInstruction::ARL</a>; +00742 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00743 <font class="keywordflow">if</font> (!instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>()) +00744 { +00745 errorOutput = <font class="stringliteral">"ARL need a scalar src value."</font>; +00746 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00747 } +00748 <font class="keywordflow">break</font>; +00749 <font class="keywordflow">case</font> 'RSQ ': +00750 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s5">CVPInstruction::RSQ</a>; +00751 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00752 <font class="keywordflow">if</font> (!instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>()) +00753 { +00754 errorOutput = <font class="stringliteral">"RSQ need a scalar src value."</font>; +00755 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00756 } +00757 <font class="keywordflow">break</font>; +00758 <font class="keywordflow">case</font> 'EXP ': +00759 <font class="keywordflow">case</font> 'EXPP': +00760 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s14">CVPInstruction::EXPP</a>; +00761 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00762 <font class="keywordflow">if</font> (!instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>()) +00763 { +00764 errorOutput = <font class="stringliteral">"EXP need a scalar src value."</font>; +00765 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00766 } +00767 <font class="comment">/*</font> +00768 <font class="comment"> if (instr.Src1.Swizzle.Comp[0] != CVPSwizzle.W)</font> +00769 <font class="comment"> {</font> +00770 <font class="comment"> errorOutput = "EXPP input scalar must be w";</font> +00771 <font class="comment"> return false;</font> +00772 <font class="comment"> }*/</font> +00773 <font class="keywordflow">break</font>; +00774 <font class="keywordflow">case</font> 'LOG ': +00775 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s15">CVPInstruction::LOG</a>; +00776 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00777 <font class="keywordflow">if</font> (!instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>()) +00778 { +00779 errorOutput = <font class="stringliteral">"LOG need a scalar src value."</font>; +00780 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00781 } +00782 <font class="comment">/*</font> +00783 <font class="comment"> if (instr.Src1.Swizzle.Comp[0] != CVPSwizzle.W)</font> +00784 <font class="comment"> {</font> +00785 <font class="comment"> errorOutput = "LOG input scalar must be w";</font> +00786 <font class="comment"> return false;</font> +00787 <font class="comment"> }</font> +00788 <font class="comment"> */</font> +00789 <font class="keywordflow">break</font>; +00790 <font class="keywordflow">case</font> 'RCP ': +00791 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s16">CVPInstruction::RCP</a>; +00792 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00793 <font class="keywordflow">if</font> (!instr.<a class="code" href="structCVPInstruction.html#m2">Src1</a>.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>()) +00794 { +00795 errorOutput = <font class="stringliteral">"RCP need a scalar src value."</font>; +00796 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00797 } +00798 <font class="keywordflow">break</font>; +00800 <font class="keywordflow">case</font> 'MOV ': +00801 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s0">CVPInstruction::MOV</a>; +00802 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00803 +00804 <font class="keywordflow">break</font>; +00805 <font class="keywordflow">case</font> 'LIT ': +00806 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s9">CVPInstruction::LIT</a>; +00807 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c9">parseOp2</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00808 <font class="keywordflow">break</font>; +00810 <font class="keywordflow">case</font> 'MAD ': +00811 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s4">CVPInstruction::MAD</a>; +00812 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c11">parseOp4</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00813 <font class="keywordflow">break</font>; +00815 <font class="keywordflow">case</font> 'ADD ': +00816 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s3">CVPInstruction::ADD</a>; +00817 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00818 <font class="keywordflow">break</font>; +00820 <font class="keywordflow">case</font> 'MUL ': +00821 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s2">CVPInstruction::MUL</a>; +00822 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00823 <font class="keywordflow">break</font>; +00824 <font class="keywordflow">case</font> 'DP3 ': +00825 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s6">CVPInstruction::DP3</a>; +00826 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00827 <font class="keywordflow">break</font>; +00828 <font class="keywordflow">case</font> 'DP4 ': +00829 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s7">CVPInstruction::DP4</a>; +00830 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00831 <font class="keywordflow">break</font>; +00832 <font class="keywordflow">case</font> 'DST ': +00833 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s8">CVPInstruction::DST</a>; +00834 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00835 <font class="keywordflow">break</font>; +00836 <font class="keywordflow">case</font> 'MIN ': +00837 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s10">CVPInstruction::MIN</a>; +00838 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00839 <font class="keywordflow">break</font>; +00840 <font class="keywordflow">case</font> 'MAX ': +00841 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s11">CVPInstruction::MAX</a>; +00842 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00843 <font class="keywordflow">break</font>; +00844 <font class="keywordflow">case</font> 'SLT ': +00845 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s12">CVPInstruction::SLT</a>; +00846 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00847 <font class="keywordflow">break</font>; +00848 <font class="keywordflow">case</font> 'SGE ': +00849 instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> = <a class="code" href="structCVPInstruction.html#s18s13">CVPInstruction::SGE</a>; +00850 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c10">parseOp3</a>(instr, errorOutput)) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00851 <font class="keywordflow">break</font>; +00853 <font class="keywordflow">case</font> 'END ': +00854 endEncountered = <font class="keyword">true</font>; +00855 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00856 <font class="keywordflow">break</font>; +00857 <font class="keywordflow">default</font>: +00858 errorOutput = <font class="stringliteral">"Syntax error : unknow opcode."</font>; +00859 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00860 <font class="keywordflow">break</font>; +00861 } +00862 +00863 +00864 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s0">CVPOperand::Variable</a>) +00865 { +00866 <a class="code" href="classCVPParser.html#o3">_RegisterMask</a>[instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m5">Value</a>.VariableValue] |= instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m7">WriteMask</a>; +00867 } +00868 +00869 <font class="comment">// it is not allowed to write to an adress register except for ARL</font> +00870 <font class="keywordflow">if</font> (instrStr != 'ARL ') +00871 { +00872 <font class="keywordflow">if</font> (instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>.<a class="code" href="structCVPOperand.html#m0">Type</a> == <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a>) +00873 { +00874 errorOutput = <font class="stringliteral">"Can't write to address register."</font>; +00875 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00876 } +00877 } +00878 +00879 <font class="comment">// parse semi-colon</font> +00880 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00881 <font class="comment">//</font> +00882 <font class="keywordflow">if</font> (*<a class="code" href="classCVPParser.html#o0">_CurrChar</a> != <font class="charliteral">';'</font>) +00883 { +00884 errorOutput = <font class="stringliteral">"';' expected."</font>; +00885 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00886 } +00887 ++<a class="code" href="classCVPParser.html#o0">_CurrChar</a>; +00888 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00889 } +00890 +00891 +00892 <font class="comment">//=================================================================================================</font> +<a name="l00893"></a><a class="code" href="vertex__program__parse_8cpp.html#a4">00893</a> <font class="keyword">static</font> std::string <a class="code" href="vertex__program__parse_8cpp.html#a4">getStringUntilCR</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>) +00894 { +00895 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>); +00896 std::string result; +00897 <font class="keywordflow">while</font> (*<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> != <font class="charliteral">'\n'</font> && *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> != <font class="charliteral">'\r'</font> && *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a> != <font class="charliteral">'\0'</font>) +00898 { +00899 result += *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00900 ++<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00901 } +00902 <font class="keywordflow">return</font> result; +00903 } +00904 +00905 <font class="comment">//=================================================================================================</font> +<a name="l00906"></a><a class="code" href="classCVPParser.html#a0">00906</a> <font class="keywordtype">bool</font> <a class="code" href="classCVPParser.html#a0">CVPParser::parse</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>, <a class="code" href="classCVPParser.html#s0">CVPParser::TProgram</a> &result, std::string &errorOutput) +00907 { +00908 <font class="keywordflow">if</font> (!<a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>) <font class="keywordflow">return</font> <font class="keyword">false</font>; +00909 <font class="comment">//</font> +00910 std::fill(<a class="code" href="classCVPParser.html#o3">_RegisterMask</a>, <a class="code" href="classCVPParser.html#o3">_RegisterMask</a> + 96, 0); +00911 +00912 <font class="comment">//</font> +00913 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00914 <a class="code" href="classCVPParser.html#o1">_LineStart</a> = <a class="code" href="driver__opengl__extension__def_8h.html#a409">src</a>; +00915 <a class="code" href="classCVPParser.html#o2">_LineIndex</a> = 1; +00916 <font class="comment">//</font> +00917 <a class="code" href="classCVPParser.html#c12">skipSpacesAndComments</a>(); +00918 +00919 <font class="comment">// parse version</font> +00920 <font class="keywordflow">if</font> ( <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[0] != <font class="charliteral">'!'</font> +00921 || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[1] != <font class="charliteral">'!'</font> +00922 || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[2] != <font class="charliteral">'V'</font> +00923 || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[3] != <font class="charliteral">'P'</font> +00924 || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[4] != <font class="charliteral">'1'</font> +00925 || <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[5] != <font class="charliteral">'.'</font> +00926 || (<a class="code" href="classCVPParser.html#o0">_CurrChar</a>[6] != <font class="charliteral">'0'</font> && <a class="code" href="classCVPParser.html#o0">_CurrChar</a>[6] != <font class="charliteral">'1'</font>)) +00927 { +00928 errorOutput = <font class="stringliteral">"Can't parse version."</font>; +00929 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00930 } +00931 <a class="code" href="classCVPParser.html#o0">_CurrChar</a> += 7; +00932 +00933 errorOutput.clear(); +00934 <font class="comment">// parse instructions</font> +00935 <font class="keywordtype">bool</font> endEncoutered = <font class="keyword">false</font>; +00936 +00937 std::string errorMess; +00938 <font class="keywordflow">for</font>(;;) +00939 { +00940 <a class="code" href="structCVPInstruction.html">CVPInstruction</a> instr; +00941 <font class="keywordflow">if</font> (!<a class="code" href="classCVPParser.html#c8">parseInstruction</a>(instr, errorMess, endEncoutered)) +00942 { +00943 errorOutput = std::string(<font class="stringliteral">"CVPParser::parse : Error encountered at line "</font>) + <a class="code" href="namespaceNLMISC.html#a243">NLMISC::toString</a>(<a class="code" href="classCVPParser.html#o2">_LineIndex</a>) + std::string(<font class="stringliteral">" : "</font>) + errorMess + std::string(<font class="stringliteral">" Text : "</font>) + <a class="code" href="vertex__program__parse_8cpp.html#a4">getStringUntilCR</a>(<a class="code" href="classCVPParser.html#o1">_LineStart</a>); +00944 <font class="keywordflow">return</font> <font class="keyword">false</font>; +00945 } +00946 <font class="keywordflow">if</font> (endEncoutered) <font class="keywordflow">break</font>; +00947 result.push_back(instr); +00948 } +00949 <font class="keywordflow">return</font> <font class="keyword">true</font>; +00950 } +00951 +00952 +00953 <font class="comment">//=================================================================================================</font> +<a name="l00954"></a><a class="code" href="vertex__program__parse_8cpp.html#a0">00954</a> <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="vertex__program__parse_8cpp.html#a0">instrToName</a>[] = +00955 { +00956 <font class="stringliteral">"MOV "</font>, +00957 <font class="stringliteral">"ARL "</font>, +00958 <font class="stringliteral">"MUL "</font>, +00959 <font class="stringliteral">"ADD "</font>, +00960 <font class="stringliteral">"MAD "</font>, +00961 <font class="stringliteral">"RSQ "</font>, +00962 <font class="stringliteral">"DP3 "</font>, +00963 <font class="stringliteral">"DP4 "</font>, +00964 <font class="stringliteral">"DST "</font>, +00965 <font class="stringliteral">"LIT "</font>, +00966 <font class="stringliteral">"MIN "</font>, +00967 <font class="stringliteral">"MAX "</font>, +00968 <font class="stringliteral">"SLT "</font>, +00969 <font class="stringliteral">"SGE "</font>, +00970 <font class="stringliteral">"EXPP "</font>, +00971 <font class="stringliteral">"LOG "</font>, +00972 <font class="stringliteral">"RCP "</font> +00973 }; +00974 +00975 <font class="comment">//=================================================================================================</font> +<a name="l00976"></a><a class="code" href="vertex__program__parse_8cpp.html#a1">00976</a> <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="vertex__program__parse_8cpp.html#a1">outputRegisterToName</a>[] = +00977 { +00978 <font class="stringliteral">"HPOS"</font>, +00979 <font class="stringliteral">"COL0"</font>, +00980 <font class="stringliteral">"COL1"</font>, +00981 <font class="stringliteral">"BFC0"</font>, +00982 <font class="stringliteral">"BFC1"</font>, +00983 <font class="stringliteral">"FOGC"</font>, +00984 <font class="stringliteral">"PSIZ"</font>, +00985 <font class="stringliteral">"TEX0"</font>, +00986 <font class="stringliteral">"TEX1"</font>, +00987 <font class="stringliteral">"TEX2"</font>, +00988 <font class="stringliteral">"TEX3"</font>, +00989 <font class="stringliteral">"TEX4"</font>, +00990 <font class="stringliteral">"TEX5"</font>, +00991 <font class="stringliteral">"TEX6"</font>, +00992 <font class="stringliteral">"TEX7"</font> +00993 }; +00994 +00995 +00996 <font class="comment">//=================================================================================================</font> +<a name="l00997"></a><a class="code" href="vertex__program__parse_8cpp.html#a5">00997</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="vertex__program__parse_8cpp.html#a5">dumpWriteMask</a>(uint mask, std::string &out) +00998 { +00999 <font class="keywordflow">if</font> (mask == 0xf) +01000 { +01001 out = <font class="stringliteral">""</font>; +01002 <font class="keywordflow">return</font>; +01003 } +01004 out = <font class="stringliteral">"."</font>; +01005 <font class="keywordflow">if</font> (mask & 1) out +=<font class="stringliteral">"x"</font>; +01006 <font class="keywordflow">if</font> (mask & 2) out +=<font class="stringliteral">"y"</font>; +01007 <font class="keywordflow">if</font> (mask & 4) out +=<font class="stringliteral">"z"</font>; +01008 <font class="keywordflow">if</font> (mask & 8) out +=<font class="stringliteral">"w"</font>; +01009 } +01010 +01011 <font class="comment">//=================================================================================================</font> +<a name="l01012"></a><a class="code" href="vertex__program__parse_8cpp.html#a6">01012</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="vertex__program__parse_8cpp.html#a6">dumpSwizzle</a>(<font class="keyword">const</font> <a class="code" href="structCVPSwizzle.html">CVPSwizzle</a> &swz, std::string &out) +01013 { +01014 <font class="keywordflow">if</font> (swz.<a class="code" href="structCVPSwizzle.html#a1">isIdentity</a>()) +01015 { +01016 out = <font class="stringliteral">""</font>; +01017 <font class="keywordflow">return</font>; +01018 } +01019 out = <font class="stringliteral">"."</font>; +01020 <font class="keywordflow">for</font>(uint k = 0; k < 4; ++k) +01021 { +01022 <font class="keywordflow">switch</font>(swz.<a class="code" href="structCVPSwizzle.html#m0">Comp</a>[k]) +01023 { +01024 <font class="keywordflow">case</font> <a class="code" href="structCVPSwizzle.html#s4s0">CVPSwizzle::X</a>: out += <font class="stringliteral">"x"</font>; <font class="keywordflow">break</font>; +01025 <font class="keywordflow">case</font> <a class="code" href="structCVPSwizzle.html#s4s1">CVPSwizzle::Y</a>: out += <font class="stringliteral">"y"</font>; <font class="keywordflow">break</font>; +01026 <font class="keywordflow">case</font> <a class="code" href="structCVPSwizzle.html#s4s2">CVPSwizzle::Z</a>: out += <font class="stringliteral">"z"</font>; <font class="keywordflow">break</font>; +01027 <font class="keywordflow">case</font> <a class="code" href="structCVPSwizzle.html#s4s3">CVPSwizzle::W</a>: out += <font class="stringliteral">"w"</font>; <font class="keywordflow">break</font>; +01028 <font class="keywordflow">default</font>: +01029 <a class="code" href="debug_8h.html#a6">nlassert</a>(0); +01030 <font class="keywordflow">break</font>; +01031 } +01032 <font class="keywordflow">if</font> (swz.<a class="code" href="structCVPSwizzle.html#a0">isScalar</a>() && k == 0) <font class="keywordflow">break</font>; +01033 } +01034 +01035 } +01036 +01037 <font class="comment">//=================================================================================================</font> +<a name="l01038"></a><a class="code" href="vertex__program__parse_8cpp.html#a7">01038</a> <font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="vertex__program__parse_8cpp.html#a7">dumpOperand</a>(<font class="keyword">const</font> <a class="code" href="structCVPOperand.html">CVPOperand</a> &op, <font class="keywordtype">bool</font> destOperand, std::string &out) +01039 { +01040 out = op.<a class="code" href="structCVPOperand.html#m8">Negate</a> ? <font class="stringliteral">" -"</font> : <font class="stringliteral">" "</font>; +01041 <font class="keywordflow">switch</font>(op.<a class="code" href="structCVPOperand.html#m0">Type</a>) +01042 { +01043 <font class="keywordflow">case</font> <a class="code" href="structCVPOperand.html#s40s0">CVPOperand::Variable</a>: out += <font class="stringliteral">"R"</font> + <a class="code" href="namespaceNLMISC.html#a243">NLMISC::toString</a>(op.<a class="code" href="structCVPOperand.html#m5">Value</a>.VariableValue); <font class="keywordflow">break</font>; +01044 <font class="keywordflow">case</font> <a class="code" href="structCVPOperand.html#s40s1">CVPOperand::Constant</a>: +01045 out += <font class="stringliteral">"c["</font>; +01046 <font class="keywordflow">if</font> (op.<a class="code" href="structCVPOperand.html#m6">Indexed</a>) +01047 { +01048 out += <font class="stringliteral">"A0.x + "</font>; +01049 } +01050 out += <a class="code" href="namespaceNLMISC.html#a243">NLMISC::toString</a>(op.<a class="code" href="structCVPOperand.html#m5">Value</a>.ConstantValue) + <font class="stringliteral">"]"</font>; +01051 <font class="keywordflow">break</font>; +01052 <font class="keywordflow">case</font> <a class="code" href="structCVPOperand.html#s40s2">CVPOperand::InputRegister</a>: out += <font class="stringliteral">"v["</font> + <a class="code" href="namespaceNLMISC.html#a243">NLMISC::toString</a>((uint) op.<a class="code" href="structCVPOperand.html#m5">Value</a>.InputRegisterValue) + <font class="stringliteral">"]"</font>; <font class="keywordflow">break</font>; +01053 <font class="keywordflow">case</font> <a class="code" href="structCVPOperand.html#s40s3">CVPOperand::OutputRegister</a>: +01054 <a class="code" href="debug_8h.html#a6">nlassert</a>(op.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue < <a class="code" href="structCVPOperand.html#s42s39">CVPOperand::OutputRegisterCount</a>); +01055 out += <font class="stringliteral">"o["</font> + std::string(<a class="code" href="vertex__program__parse_8cpp.html#a1">outputRegisterToName</a>[op.<a class="code" href="structCVPOperand.html#m5">Value</a>.OutputRegisterValue]) + <font class="stringliteral">"]"</font>; +01056 <font class="keywordflow">break</font>; +01057 <font class="keywordflow">case</font> <a class="code" href="structCVPOperand.html#s40s4">CVPOperand::AddressRegister</a>: +01058 out += <font class="stringliteral">"A0.x"</font>; +01059 <font class="keywordflow">break</font>; +01060 } +01061 std::string suffix; +01062 <font class="keywordflow">if</font> (destOperand) +01063 { +01064 <a class="code" href="vertex__program__parse_8cpp.html#a5">dumpWriteMask</a>(op.<a class="code" href="structCVPOperand.html#m7">WriteMask</a>, suffix); +01065 } +01066 <font class="keywordflow">else</font> +01067 { +01068 <a class="code" href="vertex__program__parse_8cpp.html#a6">dumpSwizzle</a>(op.<a class="code" href="structCVPOperand.html#m9">Swizzle</a>, suffix); +01069 } +01070 out += suffix; +01071 } +01072 +01073 <font class="comment">//=================================================================================================</font> +<a name="l01076"></a><a class="code" href="vertex__program__parse_8cpp.html#a8">01076</a> <font class="comment"></font><font class="keyword">static</font> <font class="keywordtype">void</font> <a class="code" href="vertex__program__parse_8cpp.html#a8">dumpInstr</a>(<font class="keyword">const</font> <a class="code" href="structCVPInstruction.html">CVPInstruction</a> &instr, std::string &out) +01077 { +01078 <a class="code" href="debug_8h.html#a6">nlassert</a>(instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a> < <a class="code" href="structCVPInstruction.html#s18s17">CVPInstruction::OpcodeCount</a>) +01079 out = <a class="code" href="vertex__program__parse_8cpp.html#a0">instrToName</a>[instr.<a class="code" href="structCVPInstruction.html#m0">Opcode</a>]; +01080 uint nbOp = instr.<a class="code" href="structCVPInstruction.html#a1">getNumUsedSrc</a>(); +01081 std::string destOperand; +01082 <a class="code" href="vertex__program__parse_8cpp.html#a7">dumpOperand</a>(instr.<a class="code" href="structCVPInstruction.html#m1">Dest</a>, <font class="keyword">true</font>, destOperand); +01083 out += destOperand; +01084 <font class="keywordflow">for</font>(uint k = 0; k < nbOp; ++k) +01085 { +01086 out += <font class="stringliteral">", "</font>; +01087 std::string srcOperand; +01088 <a class="code" href="vertex__program__parse_8cpp.html#a7">dumpOperand</a>(instr.<a class="code" href="structCVPInstruction.html#a0">getSrc</a>(k), <font class="keyword">false</font>, srcOperand); +01089 out += srcOperand; +01090 } +01091 out +=<font class="stringliteral">"; \n"</font>; +01092 } +01093 +01094 <font class="comment">//=================================================================================================</font> +<a name="l01095"></a><a class="code" href="classCVPParser.html#d0">01095</a> <font class="keywordtype">void</font> <a class="code" href="classCVPParser.html#d0">CVPParser::dump</a>(<font class="keyword">const</font> TProgram &prg, std::string &dest) +01096 { +01097 dest = <font class="stringliteral">"!!VP1.0 \n"</font>; +01098 <font class="keywordflow">for</font>(uint k = 0; k < prg.size(); ++k) +01099 { +01100 std::string instr; +01101 <a class="code" href="vertex__program__parse_8cpp.html#a8">dumpInstr</a>(prg[k], instr); +01102 dest += instr; +01103 } +01104 dest +=<font class="stringliteral">"END"</font>; +01105 } +01106 +01107 +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |