view resume/A-6-1-055734.tex @ 1:82281024ce1f

test
author tkaito@nw0534.st.ie.u-ryukyu.ac.jp
date Tue, 24 Feb 2009 19:07:54 +0900
parents
children 8922af1af05b
line wrap: on
line source

\documentclass[twocolumn,twoside,9.5pt]{jarticle}
% \usepackage[dvips]{graphicx}
\usepackage[dvipdfm]{graphicx}
\usepackage{fancyhdr,picins}
\pagestyle{fancy}
\lhead{\parpic{
\includegraphics[height=1zw,clip,keepaspectratio]{pic/emblem-bitmap.pdf}}
琉球大学主催 工学部情報工学科 卒業研究発表会}
\rhead{}
\cfoot{}

\setlength{\topmargin}{-1in \addtolength{\topmargin}{15mm}}
\setlength{\headheight}{0mm}
\setlength{\headsep}{5mm}
\setlength{\oddsidemargin}{-1in \addtolength{\oddsidemargin}{11mm}}
\setlength{\evensidemargin}{-1in \addtolength{\evensidemargin}{21mm}}
\setlength{\textwidth}{181mm}
\setlength{\textheight}{261mm}
\setlength{\footskip}{0mm}
\pagestyle{empty}

\begin{document}
\title{並列プログラミングを用いた \\\ ゲームフレームワークの設計と実装}
\author{055734A 多賀野海人 指導教員 : 河野真治}
\date{}
\maketitle
\thispagestyle{fancy}

\section{はじめに}
我々はこれまで、PlayStation2,PlayStation3等の家庭用ゲーム機を用いたゲームプログラミングを、
リアルタイムプログラム、ユーザインターフェイスの学生実験の一環として行ってきた。

しかし、Cell を用いる場合、データの転送やタスクの生成等のこれまで学んだことのない技術が多く存在する。
これにより、学生実験の短期間では新しい技術を学ぶことに多くの時間を取られ、ゲームの完成度が向上が困難である。

本研究では、PlayStation3上でゲームプログラミングを行う際に、Cellの性能を活かしながら、
アーキテクチャに依存する記述を排除した、並列プログラミングを目的としている。

\section{CELL BROADBAND ENGINE} \label{sec:cell}
Cell\cite{cell}はメインプロセッサである 1基の PowerPC Processor Element (PPE) 
と8基のデータ処理プロセッサアーキテクチャー Synergistic Processor Element (SPE)
からなる非対称なマルチコアプロセッサであり、高速リングバスで構成されている。

\begin{figure}[hbp]
  \begin{center}
    \includegraphics[scale=0.35]{image/Cell-main2.pdf}
    \caption{Cell の構成要素}
    \label{fig:cell-main}
  \end{center}
\end{figure}

PPE は 複数の SPU をコアプロセッサとして使用することができる汎用プロセッサである。
SPE は、 PPE のような複雑なプログラム制御よりも、計算を単純に繰り返すマルチメディア系の処理を得意とする
演算系プロセッサである。LS (Local Store) という256KBのメモリを持つ。
本研究で用いた PS3Linux では、6個の SPU を制御することができる。

\section{Cerium}

Cerium\cite{cerium} は、オブジェクトのデータやその振る舞い、
またはゲームのルールなどゲームを構成する場面 (Scene) を木構造で持つ
Scene Graph、OSMesa に代表される Rendering Engine、
そしてそれらの実行単位を Task とし、
動的に全てのコアが動作する様な割り振りを行うカーネル
TaskManager で構成されている。\cite{wataru}

\begin{figure}[hbp]
  \begin{center}
    \includegraphics[scale=0.5]{image/Cerium.pdf}
    \caption{Cell の構成要素}
    \label{fig:cerium}
  \end{center}
\end{figure}

ゲーム内で使用するオブジェクトの生成は Blender \cite{blender}というフリーの
3D モデリングツールを使用し、Cerium 独自の xml 形式で出力する。\cite{chiaki}

しかし、この xml ファイルの構成では、オブジェクトごとに Texture Image の情報 (base64)
が xml ファイルに出力されることになる。そうなると、同じ Texture Image が何度も使用される
xml ファイルの場合に無駄が生じることになる。将来的にネットワークの使用を考えているので、同じ Texture Image
を用いたオブジェクトが増えるほどファイルの容量が増えるのは好ましくない。

そこで、オブジェクトごとに出力される Texture Image の情報は名前のみ (image-flag) 
とし、xml ファイルの最後に base64 に変換された情報を重複しないよう出力する仕様に変更した。
ただし、同じ名前の別 Texture Image や別の名前が同じ Texture Image の判別はできない。

\section{Texture}

SPE を用いて計算を行う場合には、その処理(ソースコード)とデータを SPE の LS に転送して行う。
しかし、SPE の LS は 256KB しかないので、一度に Texture データを転送すると容量を超えてしまう可能性がある。

そこで、描画に必要な Texture データを分割して転送するという手法を用いる。
分割したデータを Tile とし、分割単位は 8 x 8 pixel とする。図\ref{fig:texture_split}
\cite{wataru}

\begin{figure}[htb]
  \begin{center}
    \includegraphics[scale=0.4]{image/cerium_rendering_tile.pdf}
    \caption{Texture の分割 (Tile) }
    \label{fig:texture_split}
  \end{center}
\end{figure}

図\ref{fig:cerium}の SpanPack に含まれる Texture のアドレスはこの配列を
指している。描画に必要な Tile を計算し、メインメモリから DMA 転送し、pixel の
情報を取り出す。

また、描画されるオブジェクトが遠くにある場合、そのままの大きさの Texture は必要ないので、
縮小サイズの Texture (Scale) を用意し、Span の長さによって描画に必要な Texture を取捨選択することにする。
これにより、DMA 転送の待ち時間が減少し、ゲームの実行速度が向上すると考えられる。
 \\

以下に分割、Scale 作成のプログラムの一部と実行速度の比較を示す。
{\scriptsize
\begin{verbatim}
makeTapestry(int tex_w, int tex_h, uint32 *tex_src,
	     int all_pixel_num, int scale_cnt) 
{
  uint32 *tex_dest;
  int t = 0;
  int diff = TEXTURE_SPLIT_PIXEL;
  int p_diff = 1;
  tex_dest = (uint32*)manager->allocate(sizeof(int)*all_pixel_num);

  while (scale_cnt) {
    for (int y = 0; y < tex_h; y += diff) {
      for (int x = 0; x < tex_w; x += diff) {
        for (int j = 0; j < diff; j += p_diff) {
          for (int i = 0; i < diff; i += p_diff) {
            tex_dest[t++]
             = tex_src[(x+i) + tex_w*(y+j)];
          }
        }
      }
    }		
    diff <<= 1;
    p_diff <<= 1;
    scale_cnt >>= 1;
  }
    
  return tex_dest;
}

\end{verbatim}
}
\begin{table}[htb]
  \begin{center}
    \caption{Scale を用いることによる実行速度の比較}
    \hbox to\hsize{\hfil
      \begin{tabular}{c|l|l} \hline \hline
         & Scaleなし(FPS) & Scaleあり (FPS)\\ \hline
        \hline
        Playstation 3 & 10.838925 & 13.514662 \\ \hline
        Mac OSX & 7.076905 & 8.532722\\ \hline
      \end{tabular}\hfil}
  \end{center}
\end{table}



\section{まとめと今後の課題}



\thispagestyle{fancy}
\begin{thebibliography}{9}

\bibitem{cell}Sony Corporation.

Cell BroadbandEngine \texttrademark アーキテクチャ, 2006

\bibitem{cerium} SourceForge.JP: Cerium Rendering Engine

\verb|https//sourceforge.jp/projects/cerium/|

\bibitem{wataru} Wataru MIYAGUNI.

Cell 用の Fine-Grain Task Manager の実装, 2009

\bibitem{blender} blender.org

\verb|http://www.blender.org/|

\bibitem{chiaki} Chiaki SUGIYAMA.

SceneGraph と StatePattern を用いたゲームフレームワークの設計と実装, 2008

\end{thebibliography}
\end{document}