XNAではどこまでポリゴン描けるの?
ってわけで、実験
新規プロジェクトを作成して
フィールドに変数を追加
BasicEffect effect; //デバグ用FPS表示 private SpriteFont _font; private double _fps; private double _updateInterval = 1.0; private double _timeSinceLastUpdate = 0.0; private double _framecount = 0.0; private double _elapsed; private Vector2 _position = Vector2.Zero; //ポリゴン表示用 private VertexPositionNormalTexture[] _data = { new VertexPositionNormalTexture(new Vector3(-0.5f, 0.5f, 0f), Vector3.Zero, new Vector2(0, 0)), new VertexPositionNormalTexture(new Vector3(0.5f, 0.5f, 0f), Vector3.Zero, new Vector2(1, 0)), new VertexPositionNormalTexture(new Vector3(-0.5f, -0.5f, 0f), Vector3.Zero, new Vector2(0, 1)) }; private short[] _indices = { 0, 1, 2 };
protected void FPS(GameTime gameTime) { _elapsed = gameTime.ElapsedGameTime.TotalSeconds; _framecount++; _timeSinceLastUpdate += _elapsed; if (_timeSinceLastUpdate > _updateInterval) { _fps = _framecount / _timeSinceLastUpdate; _timeSinceLastUpdate -= _updateInterval; _framecount = 0; // FPSをコンソールに出力 System.Diagnostics.Debug.WriteLine("FPS: " + _fps.ToString("00.000") + " RT: " + gameTime.ElapsedGameTime.TotalSeconds); } spriteBatch.Begin(); spriteBatch.DrawString(_font, "FPS: " + _fps.ToString("00.000"), _position, Color.White); spriteBatch.End(); }
LoadContentに追加
// TODO: this.Content クラスを使用して、ゲームのコンテンツを読み込みます。 _font = Content.Load<SpriteFont>("SpriteFont1"); effect = new BasicEffect(GraphicsDevice);
最後にDrawに追加
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: ここに描画コードを追加します。 //ワールド座標変換行列 Matrix world = Matrix.Identity; //ビュー座標変換行列 Matrix view = Matrix.CreateLookAt (new Vector3(3, 3, 3), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); //射影変換行列 Matrix projection = Matrix.CreatePerspectiveFieldOfView (MathHelper.ToRadians(45), GraphicsDevice.Viewport.AspectRatio, 0.1f, 1000f); //ワールド座標変換指定 effect.World = world; //ビュー座標変換指定 effect.View = view; //射影変換指定 effect.Projection = projection; for (int i = 0; i < 2250; i++) { foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture> (PrimitiveType.TriangleList, _data, 0, _data.Length, _indices, 0, 1); } } FPS(gameTime); base.Draw(gameTime); }
で、ループの回数をいじくってFPSが落ちない数字を探すと2200ぐらい。
FPS60の場合での値なのだが、GPUやらCPUの性能に依存してるんだろうけどなんとなく少ない気がする。
ってわけで、ゲーム機と比較
- プレイステーション 360,000ポリゴン/秒
- プレイステーション2 20,000,000ポリゴン/秒
- Xbox 125,000,000ポリゴン/秒
ポリゴン/秒に直すのなら2200の60倍で・・・13,200!?
プレステの27分の1ですか??
ポリゴン/秒に直すのなら2200の60倍で・・・132,000!?
プレステの3分の1ですか??
Athlon64X2(5400)とRadeon HD 4350のコンビが16年前のマシン負けた???
いくらなんでも、これはヒドイ、なにかオレのプログラムに問題があるはずなんだが・・・