Mercurial > hg > Papers > 2010 > yutaka-thesis
diff paper/rendering.tex @ 0:fd9154e03f46
thesis
author | e065725@kinjyo.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sat, 13 Feb 2010 21:38:25 +0900 |
parents | |
children | 641b358caa99 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/paper/rendering.tex Sat Feb 13 21:38:25 2010 +0900 @@ -0,0 +1,96 @@ +\chapter{レンダリングエンジンの高速化と高機能化} +\section{光源の実装} +レンダリングエンジンに光源処理の実装をした。光源は SceneGraph のオブジェクトとして実装され、SceneGraph 側から、操作できる。 +光源は点光源であり、光源数は4つに設定している。 + \subsection{実装手法} + +光源処理は DrawSpan タスク内で行う。描画対象となる Span は法線ベクトルの情報を持っている。 +光源の座標情報は、あらかじめ、各 SPE のローカルストアに確保している。 +描画対象のドット座標と光源の座標から光源ベクトルを求める。 +光源ベクトルと法線ベクトルとの内積を計算し、rgb値に乗算する。%以下に示すAPIで、ユーザ側から光源オブジェクトを取得することが +%できる。 + + %\subsubsection{光源操作のAPI} + %getLight(int id); + %\begin{verbatim} + %\end{verbatim} + + \subsubsection{光源座標のLoad,Update} + 光源座標のメモリ領域を各 SPE のローカルストアに確保するのは DataLoad タスクで行う。 + 確保された光源座標は DataUpdate タスクで、タスクに引数として渡された光源座標に更新される。 + SPE側でのメモリ領域の確保、参照には TaskManager のAPIを用いている。 + 以下にそのAPIと各タスクのコードを示す。%\cite{taskmanager_api} + +\begin{table}[htb] + \begin{center} + \caption{TaskManager API} + \label{tab:taskmanager_api} + \begin{tabular}{|l|l|} + \hline + get\_input & タスクに渡された引数のポインタを返す \\ + \hline + get\_param & タスクに渡された32ビットのデータを返す。\\ + \hline + global\_alloc & SPE 内で指定されたサイズの領域を確保する\\ + \hline + global\_get & SPE 内で確保された領域のポインタを返す\\ + \hline + \end{tabular} + \end{center} +\end{table} + + + \begin{itemize} + \item DataLoad + \end{itemize} + \begin{verbatim} + static int + run(SchedTask *s, void *rbuf, void *wbuf) + { + + int size = (int)s->get_param(0); + int load_id = (int)s->get_param(1); + + s->global_alloc(load_id, size); + + return 0; + } + + \end{verbatim} + \begin{itemize} + \item DataUpdate + \end{itemize} + \begin{verbatim} + static int + run(SchedTask *s, void *rbuf, void *wbuf) + { + + void *idata = (void*)s->get_input(rbuf, 0); + int size = (int)s->get_param(0); + int load_id = (int)s->get_param(1); + void *global_data = (void*)s->global_get(load_id); + + memcpy(global_data,idata,size); + + return 0; + } + \end{verbatim} + +DataLoadは レンダリングのはじめで各 SPE で実行される。DataUpdate タスクは SceneGraph を更新した後、DrawSpan タスクによって描画される前に実行される。 + +\newpage + +\begin{figure}[htb] + \begin{center} + \includegraphics[scale=0.7]{./images/Ceriumroutine1.pdf} + \end{center} + \caption{DataLoad,Update タスクの実行タイミング} + \label{fig:cerium_routine} +\end{figure} + +DataUpdate タスクには光源の座標情報が渡される。 + + + \subsection{光源処理のSIMD化} + 光源ベクトルや内積の算出をSIMD演算で実装した。これにより4つ分の光源の処理は、1つ分の光源処理の時に近い実行速度となった。 +