\hypertarget{a07228}{}\section{A\+CG\+:\+:G\+P\+U\+Cache\+Optimizer Class Reference}
\label{a07228}\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\+CG\+:\+:G\+P\+U\+Cache\+Optimizer\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=2.000000cm]{a07228}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{a07236}{Opt\+\_\+\+Tris}
\item 
struct \hyperlink{a07232}{Opt\+\_\+\+Vertex}
\end{DoxyCompactItemize}
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{a07228_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{a07228_a2866f3f0364be76b154f31b68ed802bb}{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{a07228_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\textquotesingle{}s param and stores the result in the given destination buffer. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{a07228_a30fb67871f7882ccd8ff2a65c461a2f3}\label{a07228_a30fb67871f7882ccd8ff2a65c461a2f3}} 
unsigned int \hyperlink{a07228_a30fb67871f7882ccd8ff2a65c461a2f3}{Compute\+Number\+Of\+Vertex\+Transformations} (unsigned int Vertex\+Cache\+Size=16)
\begin{DoxyCompactList}\small\item\em Returns the total number of vertex transforms performed with a certain Vertex\+Cache. \end{DoxyCompactList}\item 
float \hyperlink{a07228_a6bd316a54b84cdf4e0c2378c94773ba8}{Compute\+A\+C\+MR} (unsigned int Vertex\+Cache\+Size=16)
\begin{DoxyCompactList}\small\item\em Measures the efficiency use of the vertex cache. A\+C\+MR\+: Average Cache Miss Ratio. \end{DoxyCompactList}\item 
float \hyperlink{a07228_ae0a5461772ecb98a348d3cf8a80dc6e0}{Compute\+A\+T\+VR} (unsigned int Vertex\+Cache\+Size=16)
\begin{DoxyCompactList}\small\item\em Measures the efficiency use of the vertex cache. A\+T\+VR\+: Average Transform to Vertex Ratio similar to A\+C\+MR, 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{a07228_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{a07228_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 
\mbox{\Hypertarget{a07228_a5bdf631627d12a9cf95ca552e1f0c204}\label{a07228_a5bdf631627d12a9cf95ca552e1f0c204}} 
unsigned int {\bfseries Get\+Index} (unsigned int i) const
\item 
\mbox{\Hypertarget{a07228_a2fdbe36ba425bcb000a421c091a03d51}\label{a07228_a2fdbe36ba425bcb000a421c091a03d51}} 
virtual void {\bfseries Make\+Abstract} ()=0
\end{DoxyCompactItemize}
\subsection*{Static Protected Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{a07228_a55b14eadc34604faaebba46604e06d2d}\label{a07228_a55b14eadc34604faaebba46604e06d2d}} 
static unsigned int {\bfseries Get\+Index} (unsigned int i, unsigned int Index\+Size, const void $\ast$p\+IB)
\item 
\mbox{\Hypertarget{a07228_a4463f30ae7ed854b68b8fb6889149f04}\label{a07228_a4463f30ae7ed854b68b8fb6889149f04}} 
static void {\bfseries Set\+Index} (unsigned int i, unsigned int val, unsigned int Index\+Size, void $\ast$p\+IB)
\end{DoxyCompactItemize}
\subsection*{Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{a07228_afca806effc18331d1a40fcfe262e5e28}\label{a07228_afca806effc18331d1a40fcfe262e5e28}} 
unsigned int {\bfseries m\+\_\+\+Num\+Verts}
\item 
\mbox{\Hypertarget{a07228_ae485883db2f79398f7b9fccf025706a1}\label{a07228_ae485883db2f79398f7b9fccf025706a1}} 
unsigned int {\bfseries m\+\_\+\+Num\+Tris}
\item 
unsigned int $\ast$ \hyperlink{a07228_a3ecd15390abd83da79243692bbb5c34f}{m\+\_\+p\+Tri\+Map}
\end{DoxyCompactItemize}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{a07228_ace4d47499771929ceb822f87740ad00f}\label{a07228_ace4d47499771929ceb822f87740ad00f}} 
{\bfseries G\+P\+U\+Cache\+Optimizer} (const \hyperlink{a07228}{G\+P\+U\+Cache\+Optimizer} \&)
\item 
\mbox{\Hypertarget{a07228_ad698d66031a3d887a8425870eafe0d05}\label{a07228_ad698d66031a3d887a8425870eafe0d05}} 
\hyperlink{a07228}{G\+P\+U\+Cache\+Optimizer} \& {\bfseries operator=} (const \hyperlink{a07228}{G\+P\+U\+Cache\+Optimizer} \&)
\end{DoxyCompactItemize}
\subsection*{Private Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{a07228_afaae8d727f2293e35dd6cffb97e2c4ba}\label{a07228_afaae8d727f2293e35dd6cffb97e2c4ba}} 
unsigned int {\bfseries m\+\_\+\+Index\+Size}
\item 
\mbox{\Hypertarget{a07228_af572f821a309f373f68360fa03440806}\label{a07228_af572f821a309f373f68360fa03440806}} 
const void $\ast$ {\bfseries m\+\_\+p\+Indices}
\item 
\mbox{\Hypertarget{a07228_a4d31c8810ff4bbfb809da590a1fa45dc}\label{a07228_a4d31c8810ff4bbfb809da590a1fa45dc}} 
unsigned int {\bfseries m\+\_\+\+Num\+Transformations}
\end{DoxyCompactItemize}


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

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



\subsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{a07228_a06fb27456fd6c155c0fd8c59c403c685}\label{a07228_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{\texorpdfstring{G\+P\+U\+Cache\+Optimizer()}{GPUCacheOptimizer()}}
{\footnotesize\ttfamily 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})}



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 56 of file G\+P\+U\+Cache\+Optimizer.\+cc.



\subsection{Member Function Documentation}
\mbox{\Hypertarget{a07228_a6bd316a54b84cdf4e0c2378c94773ba8}\label{a07228_a6bd316a54b84cdf4e0c2378c94773ba8}} 
\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Compute\+A\+C\+MR@{Compute\+A\+C\+MR}}
\index{Compute\+A\+C\+MR@{Compute\+A\+C\+MR}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection{\texorpdfstring{Compute\+A\+C\+M\+R()}{ComputeACMR()}}
{\footnotesize\ttfamily float A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Compute\+A\+C\+MR (\begin{DoxyParamCaption}\item[{unsigned int}]{Vertex\+Cache\+Size = {\ttfamily 16} }\end{DoxyParamCaption})}



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

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


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

\mbox{\Hypertarget{a07228_ae0a5461772ecb98a348d3cf8a80dc6e0}\label{a07228_ae0a5461772ecb98a348d3cf8a80dc6e0}} 
\index{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}!Compute\+A\+T\+VR@{Compute\+A\+T\+VR}}
\index{Compute\+A\+T\+VR@{Compute\+A\+T\+VR}!A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer@{A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer}}
\subsubsection{\texorpdfstring{Compute\+A\+T\+V\+R()}{ComputeATVR()}}
{\footnotesize\ttfamily float A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::\+Compute\+A\+T\+VR (\begin{DoxyParamCaption}\item[{unsigned int}]{Vertex\+Cache\+Size = {\ttfamily 16} }\end{DoxyParamCaption})}



Measures the efficiency use of the vertex cache. A\+T\+VR\+: Average Transform to Vertex Ratio similar to A\+C\+MR, 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 264 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\mbox{\Hypertarget{a07228_a2866f3f0364be76b154f31b68ed802bb}\label{a07228_a2866f3f0364be76b154f31b68ed802bb}} 
\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{\texorpdfstring{Get\+Triangle\+Map()}{GetTriangleMap()}}
{\footnotesize\ttfamily 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]}}



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{a07228_a0638f2ebb9f6b55c82ee0f96ae18704c}{Write\+Index\+Buffer()} to get the result 

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

\mbox{\Hypertarget{a07228_aff03759d80975b255bfe76299ae59131}\label{a07228_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{\texorpdfstring{Optimize\+Vertices()}{OptimizeVertices()}}
{\footnotesize\ttfamily 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]}}



Reorders vertex buffer to minimize memory address jumps. 

for best performace, use A\+F\+T\+ER triangle remapping see description on \hyperlink{a07228_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\+TE\+: if a vertex is not referenced by any triangle, the value 0x\+F\+F\+F\+F\+F\+F\+FF 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 180 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\mbox{\Hypertarget{a07228_a6eb0034c30abb102007d888fec143615}\label{a07228_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{\texorpdfstring{Remap\+Vertices()}{RemapVertices()}}
{\footnotesize\ttfamily 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]}}



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{a07228_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 140 of file G\+P\+U\+Cache\+Optimizer.\+cc.

\mbox{\Hypertarget{a07228_a0638f2ebb9f6b55c82ee0f96ae18704c}\label{a07228_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{\texorpdfstring{Write\+Index\+Buffer()}{WriteIndexBuffer()}}
{\footnotesize\ttfamily 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})}



Applies the remapping on the initial p\+Indices constructor\textquotesingle{}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\textquotesingle{}s call N\+O\+TE\+: make sure p\+Indices is not modified/deleted between constructor\textquotesingle{}s and this call \\
\hline
\end{DoxyParams}


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



\subsection{Member Data Documentation}
\mbox{\Hypertarget{a07228_a3ecd15390abd83da79243692bbb5c34f}\label{a07228_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{\texorpdfstring{m\+\_\+p\+Tri\+Map}{m\_pTriMap}}
{\footnotesize\ttfamily unsigned int$\ast$ A\+C\+G\+::\+G\+P\+U\+Cache\+Optimizer\+::m\+\_\+p\+Tri\+Map\hspace{0.3cm}{\ttfamily [protected]}}

Tri\+Map\mbox{[}new tri index\mbox{]} = old tri index allocated in base class, computed in child class 

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



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