\hypertarget{a00656}{\section{A\+C\+G\+:\+:G\+P\+U\+Cache\+Optimizer Class Reference}
\label{a00656}\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
}


{\ttfamily \#include $<$A\+C\+G/\+Scenegraph/\+Mesh\+Node\+T.\+hh$>$}

Inheritance diagram for A\+C\+G\+:\+:G\+P\+U\+Cache\+Optimizer\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{a00656}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{a00938}{Opt\+\_\+\+Tris}
\item 
struct \hyperlink{a00939}{Opt\+\_\+\+Vertex}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{a00656_a06fb27456fd6c155c0fd8c59c403c685}{G\+P\+U\+Cache\+Optimizer} (unsigned int Num\+Tris, unsigned int Num\+Verts, unsigned int Index\+Size, const void $\ast$p\+Indices)
\begin{DoxyCompactList}\small\item\em constructor \end{DoxyCompactList}\item 
const unsigned int $\ast$ \hyperlink{a00656_a4c3a70db077b9b37cbed2fc1fe0e9b1f}{Get\+Triangle\+Map} () const 
\begin{DoxyCompactList}\small\item\em Retrieves the map from dst triangle to src triangle. how to remap\+: for each triangle t in Dst\+Tri\+Buffer Dst\+Tri\+Buffer\mbox{[}t\mbox{]} = Src\+Tri\+Buffer\mbox{[}Triangle\+Map\mbox{[}t\mbox{]}\mbox{]}. \end{DoxyCompactList}\item 
void \hyperlink{a00656_a0638f2ebb9f6b55c82ee0f96ae18704c}{Write\+Index\+Buffer} (unsigned int Dst\+Index\+Size, void $\ast$p\+Dst)
\begin{DoxyCompactList}\small\item\em Applies the remapping on the initial p\+Indices constructor's param and stores the result in the given destination buffer. \end{DoxyCompactList}\item 
\hypertarget{a00656_a30fb67871f7882ccd8ff2a65c461a2f3}{unsigned int \hyperlink{a00656_a30fb67871f7882ccd8ff2a65c461a2f3}{Compute\+Number\+Of\+Vertex\+Transformations} (unsigned int Vertex\+Cache\+Size=16)}\label{a00656_a30fb67871f7882ccd8ff2a65c461a2f3}

\begin{DoxyCompactList}\small\item\em Returns the total number of vertex transforms performed with a certain Vertex\+Cache. \end{DoxyCompactList}\item 
float \hyperlink{a00656_a6bd316a54b84cdf4e0c2378c94773ba8}{Compute\+A\+C\+M\+R} (unsigned int Vertex\+Cache\+Size=16)
\begin{DoxyCompactList}\small\item\em Measures the efficiency use of the vertex cache. A\+C\+M\+R\+: Average Cache Miss Ratio. \end{DoxyCompactList}\item 
float \hyperlink{a00656_ae0a5461772ecb98a348d3cf8a80dc6e0}{Compute\+A\+T\+V\+R} (unsigned int Vertex\+Cache\+Size=16)
\begin{DoxyCompactList}\small\item\em Measures the efficiency use of the vertex cache. A\+T\+V\+R\+: Average Transform to Vertex Ratio similar to A\+C\+M\+R, but easier to interpret the optimal value is 1.\+0 given a mesh w/o duplicate vertices. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
static void \hyperlink{a00656_aff03759d80975b255bfe76299ae59131}{Optimize\+Vertices} (unsigned int Num\+Tris, unsigned int Num\+Verts, unsigned int Index\+Size, const void $\ast$p\+Indices, unsigned int $\ast$p\+Vert\+Map)
\begin{DoxyCompactList}\small\item\em Reorders vertex buffer to minimize memory address jumps. \end{DoxyCompactList}\item 
static void \hyperlink{a00656_a6eb0034c30abb102007d888fec143615}{Remap\+Vertices} (unsigned int Num\+Tris, unsigned int Num\+Verts, const unsigned int $\ast$p\+Vert\+Map, unsigned int Index\+Size, void $\ast$p\+In\+Out\+Indices, unsigned int Vertex\+Stride, void $\ast$p\+In\+Out\+Vertices)
\begin{DoxyCompactList}\small\item\em Applies the remap table of Optimize\+Vertices to a vertex and index buffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00656_a0ce0b1457db9257ccbf6b33da48434a6}{unsigned int {\bfseries Get\+Index} (unsigned int i) const }\label{a00656_a0ce0b1457db9257ccbf6b33da48434a6}

\item 
\hypertarget{a00656_a2fdbe36ba425bcb000a421c091a03d51}{virtual void {\bfseries Make\+Abstract} ()=0}\label{a00656_a2fdbe36ba425bcb000a421c091a03d51}

\end{DoxyCompactItemize}
\subsection*{Static Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00656_a55b14eadc34604faaebba46604e06d2d}{static unsigned int {\bfseries Get\+Index} (unsigned int i, unsigned int Index\+Size, const void $\ast$p\+I\+B)}\label{a00656_a55b14eadc34604faaebba46604e06d2d}

\item 
\hypertarget{a00656_a4463f30ae7ed854b68b8fb6889149f04}{static void {\bfseries Set\+Index} (unsigned int i, unsigned int val, unsigned int Index\+Size, void $\ast$p\+I\+B)}\label{a00656_a4463f30ae7ed854b68b8fb6889149f04}

\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00656_afca806effc18331d1a40fcfe262e5e28}{unsigned int {\bfseries m\+\_\+\+Num\+Verts}}\label{a00656_afca806effc18331d1a40fcfe262e5e28}

\item 
\hypertarget{a00656_ae485883db2f79398f7b9fccf025706a1}{unsigned int {\bfseries m\+\_\+\+Num\+Tris}}\label{a00656_ae485883db2f79398f7b9fccf025706a1}

\item 
unsigned int $\ast$ \hyperlink{a00656_a3ecd15390abd83da79243692bbb5c34f}{m\+\_\+p\+Tri\+Map}
\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00656_ace4d47499771929ceb822f87740ad00f}{{\bfseries G\+P\+U\+Cache\+Optimizer} (const \hyperlink{a00656}{G\+P\+U\+Cache\+Optimizer} \&)}\label{a00656_ace4d47499771929ceb822f87740ad00f}

\item 
\hypertarget{a00656_ad698d66031a3d887a8425870eafe0d05}{\hyperlink{a00656}{G\+P\+U\+Cache\+Optimizer} \& {\bfseries operator=} (const \hyperlink{a00656}{G\+P\+U\+Cache\+Optimizer} \&)}\label{a00656_ad698d66031a3d887a8425870eafe0d05}

\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\hypertarget{a00656_afaae8d727f2293e35dd6cffb97e2c4ba}{unsigned int {\bfseries m\+\_\+\+Index\+Size}}\label{a00656_afaae8d727f2293e35dd6cffb97e2c4ba}

\item 
\hypertarget{a00656_af572f821a309f373f68360fa03440806}{const void $\ast$ {\bfseries m\+\_\+p\+Indices}}\label{a00656_af572f821a309f373f68360fa03440806}

\item 
\hypertarget{a00656_a4d31c8810ff4bbfb809da590a1fa45dc}{unsigned int {\bfseries m\+\_\+\+Num\+Transformations}}\label{a00656_a4d31c8810ff4bbfb809da590a1fa45dc}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
This class optimizes a triangle list for efficient vertex cache usage. 

Definition at line 72 of file G\+P\+U\+Cache\+Optimizer.\+hh.



\subsection{Constructor \& Destructor Documentation}
\hypertarget{a00656_a06fb27456fd6c155c0fd8c59c403c685}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!G\+P\+U\+Cache\+Optimizer@{G\+P\+U\+Cache\+Optimizer}}
\index{G\+P\+U\+Cache\+Optimizer@{G\+P\+U\+Cache\+Optimizer}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{G\+P\+U\+Cache\+Optimizer}]{\setlength{\rightskip}{0pt plus 5cm}A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+G\+P\+U\+Cache\+Optimizer (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Num\+Tris, }
\item[{unsigned int}]{Num\+Verts, }
\item[{unsigned int}]{Index\+Size, }
\item[{const void $\ast$}]{p\+Indices}
\end{DoxyParamCaption}
)}}\label{a00656_a06fb27456fd6c155c0fd8c59c403c685}


constructor 

The constructor needs a mesh on which this node will work.


\begin{DoxyParams}{Parameters}
{\em Num\+Tris} & number of triangles \\
\hline
{\em Num\+Verts} & number of vertices \\
\hline
{\em Index\+Size} & size in bytes of one index\+: 1, 2, 4 supported \\
\hline
{\em p\+Indices} & \mbox{[}in\mbox{]} index buffer \\
\hline
\end{DoxyParams}


Definition at line 65 of file G\+P\+U\+Cache\+Optimizer.\+cc.



\subsection{Member Function Documentation}
\hypertarget{a00656_a6bd316a54b84cdf4e0c2378c94773ba8}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Compute\+A\+C\+M\+R@{Compute\+A\+C\+M\+R}}
\index{Compute\+A\+C\+M\+R@{Compute\+A\+C\+M\+R}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Compute\+A\+C\+M\+R}]{\setlength{\rightskip}{0pt plus 5cm}float A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Compute\+A\+C\+M\+R (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Vertex\+Cache\+Size = {\ttfamily 16}}
\end{DoxyParamCaption}
)}}\label{a00656_a6bd316a54b84cdf4e0c2378c94773ba8}


Measures the efficiency use of the vertex cache. A\+C\+M\+R\+: Average Cache Miss Ratio. 

\begin{DoxyReturn}{Returns}
ratio\+: \# vertex transformations / \# tris 
\end{DoxyReturn}


Definition at line 265 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\hypertarget{a00656_ae0a5461772ecb98a348d3cf8a80dc6e0}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Compute\+A\+T\+V\+R@{Compute\+A\+T\+V\+R}}
\index{Compute\+A\+T\+V\+R@{Compute\+A\+T\+V\+R}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Compute\+A\+T\+V\+R}]{\setlength{\rightskip}{0pt plus 5cm}float A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Compute\+A\+T\+V\+R (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Vertex\+Cache\+Size = {\ttfamily 16}}
\end{DoxyParamCaption}
)}}\label{a00656_ae0a5461772ecb98a348d3cf8a80dc6e0}


Measures the efficiency use of the vertex cache. A\+T\+V\+R\+: Average Transform to Vertex Ratio similar to A\+C\+M\+R, but easier to interpret the optimal value is 1.\+0 given a mesh w/o duplicate vertices. 

\begin{DoxyReturn}{Returns}
ratio\+: \# vertex transformations / \# verts 
\end{DoxyReturn}


Definition at line 273 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\hypertarget{a00656_a4c3a70db077b9b37cbed2fc1fe0e9b1f}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Get\+Triangle\+Map@{Get\+Triangle\+Map}}
\index{Get\+Triangle\+Map@{Get\+Triangle\+Map}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Get\+Triangle\+Map}]{\setlength{\rightskip}{0pt plus 5cm}const unsigned int$\ast$ A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Get\+Triangle\+Map (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
) const\hspace{0.3cm}{\ttfamily [inline]}}}\label{a00656_a4c3a70db077b9b37cbed2fc1fe0e9b1f}


Retrieves the map from dst triangle to src triangle. how to remap\+: for each triangle t in Dst\+Tri\+Buffer Dst\+Tri\+Buffer\mbox{[}t\mbox{]} = Src\+Tri\+Buffer\mbox{[}Triangle\+Map\mbox{[}t\mbox{]}\mbox{]}. 

you can also use \hyperlink{a00656_a0638f2ebb9f6b55c82ee0f96ae18704c}{Write\+Index\+Buffer()} to get the result 

Definition at line 100 of file G\+P\+U\+Cache\+Optimizer.\+hh.

\hypertarget{a00656_aff03759d80975b255bfe76299ae59131}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Optimize\+Vertices@{Optimize\+Vertices}}
\index{Optimize\+Vertices@{Optimize\+Vertices}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Optimize\+Vertices}]{\setlength{\rightskip}{0pt plus 5cm}void A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Optimize\+Vertices (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Num\+Tris, }
\item[{unsigned int}]{Num\+Verts, }
\item[{unsigned int}]{Index\+Size, }
\item[{const void $\ast$}]{p\+Indices, }
\item[{unsigned int $\ast$}]{p\+Vert\+Map}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{a00656_aff03759d80975b255bfe76299ae59131}


Reorders vertex buffer to minimize memory address jumps. 

for best performace, use A\+F\+T\+E\+R triangle remapping see description on \hyperlink{a00656_a6eb0034c30abb102007d888fec143615}{Remap\+Vertices()} on how to apply this map


\begin{DoxyParams}{Parameters}
{\em p\+Indices} & \mbox{[}in\mbox{]} index buffer \\
\hline
{\em p\+Vert\+Map} & \mbox{[}out\mbox{]} vertex remap, allocate Num\+Verts unsigned ints before calling dst vertex index = p\+Vert\+Map\mbox{[}src vertex index\mbox{]} N\+O\+T\+E\+: if a vertex is not referenced by any triangle, the value 0x\+F\+F\+F\+F\+F\+F\+F\+F will be stored as the destination index! \\
\hline
{\em Num\+Tris} & Number of triangles \\
\hline
{\em Num\+Verts} & Number of vertices \\
\hline
{\em Index\+Size} & Size of the index \\
\hline
\end{DoxyParams}


Definition at line 189 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\hypertarget{a00656_a6eb0034c30abb102007d888fec143615}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Remap\+Vertices@{Remap\+Vertices}}
\index{Remap\+Vertices@{Remap\+Vertices}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Remap\+Vertices}]{\setlength{\rightskip}{0pt plus 5cm}void A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Remap\+Vertices (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Num\+Tris, }
\item[{unsigned int}]{Num\+Verts, }
\item[{const unsigned int $\ast$}]{p\+Vert\+Map, }
\item[{unsigned int}]{Index\+Size, }
\item[{void $\ast$}]{p\+In\+Out\+Indices, }
\item[{unsigned int}]{Vertex\+Stride, }
\item[{void $\ast$}]{p\+In\+Out\+Vertices}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [static]}}}\label{a00656_a6eb0034c30abb102007d888fec143615}


Applies the remap table of Optimize\+Vertices to a vertex and index buffer. 

Pseudo code for manual remapping 
\begin{DoxyCode}
\textcolor{keywordflow}{for each} index i in IndexBuffer:
  IndexBuffer[i] = VertMap[IndexBuffer[i]]
TmpBuf = VertexBuffer
\textcolor{keywordflow}{for each} vertex v in TmpBuf
  \textcolor{keywordflow}{if} (VertMap[v] != 0xFFFFFFFF)
    VertexBuffer[VertMap[v]] = TmpBuf[v]
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em Num\+Verts} & Number of vertices \\
\hline
{\em p\+Vert\+Map} & vertex remap, result from \hyperlink{a00656_aff03759d80975b255bfe76299ae59131}{Optimize\+Vertices()} (input) \\
\hline
{\em Index\+Size} & size in bytes of one index\+: 1, 2, 4 supported \\
\hline
{\em p\+In\+Out\+Indices} & (triangle list) index buffer, remapped after call (input/output) \\
\hline
{\em Vertex\+Stride} & size in bytes of one vertex \\
\hline
{\em p\+In\+Out\+Vertices} & vertex buffer, remapped after call (input/output) \\
\hline
{\em Num\+Tris} & Number of triangles \\
\hline
\end{DoxyParams}


Definition at line 149 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\hypertarget{a00656_a0638f2ebb9f6b55c82ee0f96ae18704c}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Write\+Index\+Buffer@{Write\+Index\+Buffer}}
\index{Write\+Index\+Buffer@{Write\+Index\+Buffer}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{Write\+Index\+Buffer}]{\setlength{\rightskip}{0pt plus 5cm}void A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Write\+Index\+Buffer (
\begin{DoxyParamCaption}
\item[{unsigned int}]{Dst\+Index\+Size, }
\item[{void $\ast$}]{p\+Dst}
\end{DoxyParamCaption}
)}}\label{a00656_a0638f2ebb9f6b55c82ee0f96ae18704c}


Applies the remapping on the initial p\+Indices constructor's param and stores the result in the given destination buffer. 


\begin{DoxyParams}{Parameters}
{\em Dst\+Index\+Size} & size in bytes of one index in the dst buffer \\
\hline
{\em p\+Dst} & \mbox{[}out\mbox{]} index buffer to store the result may also be the same memory as p\+Indices of constructor's call N\+O\+T\+E\+: make sure p\+Indices is not modified/deleted between constructor's and this call \\
\hline
\end{DoxyParams}


Definition at line 116 of file G\+P\+U\+Cache\+Optimizer.\+cc.



\subsection{Member Data Documentation}
\hypertarget{a00656_a3ecd15390abd83da79243692bbb5c34f}{\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!m\+\_\+p\+Tri\+Map@{m\+\_\+p\+Tri\+Map}}
\index{m\+\_\+p\+Tri\+Map@{m\+\_\+p\+Tri\+Map}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection[{m\+\_\+p\+Tri\+Map}]{\setlength{\rightskip}{0pt plus 5cm}unsigned int$\ast$ A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::m\+\_\+p\+Tri\+Map\hspace{0.3cm}{\ttfamily [protected]}}}\label{a00656_a3ecd15390abd83da79243692bbb5c34f}
Tri\+Map\mbox{[}new tri index\mbox{]} = old tri index allocated in base class, computed in child class 

Definition at line 200 of file G\+P\+U\+Cache\+Optimizer.\+hh.



The documentation for this class was generated from the following files\+:\begin{DoxyCompactItemize}
\item 
A\+C\+G/\+Geometry/G\+P\+U\+Cache\+Optimizer.\+hh\item 
A\+C\+G/\+Geometry/G\+P\+U\+Cache\+Optimizer.\+cc\end{DoxyCompactItemize}
