Empty Project seems to have low FPS.

Started by
7 comments, last by Croc 18 years, 10 months ago
I've been playing around with empty DX projects, and for some reason, I just can't get my fps to be very high. So, here are my specs and results. Pentium 4 2.8 ghz Radeion 9600 SE card 8x agp 128 MB vram 512 ram Win XP 1600X1200 @ 32 bits I'm building an empty DX project in C# and MDX which loops as fast as it can and does the following: Checks device to see if it's lost (an if statement). Clears the target and z buffer, calls Device.BeginScene, sets a camera (two lines), calls Device.EndScene and Present, then calls Application.DoEvents. Really basic stuff, and I'm getting 85 fps, according to FRAPS and my own timing methods. Does this seem slow to anyone else? Any ideas? --Vic--
Advertisement
Try adding this into your D3DPRESENT_PARAMETERS structure when you initialize:

*INSERT YOUR STRUCTURE HERE*.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

If that works, I can almost guarantee your monitor's refresh rate is 85Hz.
Should have stated, no, my monitor's refresh rate is 75, and I'm already running immediate display.

--Vic--
Hmm, in that case, I guess it would be best to post some code so we can get a better look at exactly what is going on when you render, mainly in terms of the Application.DoEvents function.
A few thoughts:

1) if you're using a multi monitor set up, are any of the monitors at 85Hz refresh? (that frame rate is too spookily similar to a monitor refresh rate for me not to be suspicious).


2) ATIs display properties control panel lets you forcibly override what's specified in your D3DPRESENT_PARAMETERS structure. Take a look at:

Display Properties ->
Settings ->
Advanced ->
3D ->
3D Settings for Direct3D ->
"Wait for Vertical Sync"

That can be "Application Preference", "Always Off", and "Always On" - you want it at Application Preference or Always Off. There are similar settings under other tabs that you might want to take a look at.


3) Just to check:
a. Ensure there are 0 errors when running with the debug D3D runtime.

b. Ensure that you're using a Release build of your app when profiling.

c. Ensure that you're using the Retail runtimes for **ALL** DirectX components when profiling.

[The results of profiling are meaningless if there are errors, if any DirectX components are providing debug support or the program code hasn't been through the compilers optimisation stage]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

if you are using FRAPS that might slow it down a bit
So, wow, I feel like my computer's being taken over by the spirit of inefficiency. I did have 2 monitors, but disabled one, and am running only one to make sure that's not the problem. I went into ATI's display settings. It is at Application Setting. All DX is using Retail settings, and I'm compiling in Release. When in debug here is my output:

'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded.
'FRBTemplate': Loaded 'C:\Projects\LinkedTemplateForTests\bin\Release\FRBTemplate.exe', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\projects\linkedtemplatefortests\bin\release\frb.dll', Symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx.directinput\1.0.2902.0__31bf3856ad364e35\microsoft.directx.directinput.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx\1.0.2902.0__31bf3856ad364e35\microsoft.directx.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\microsoft.visualc\7.0.5000.0__b03f5f7f11d50a3a\microsoft.visualc.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx.direct3d\1.0.2902.0__31bf3856ad364e35\microsoft.directx.direct3d.dll', No symbols loaded.
'FRBTemplate.exe': Loaded 'c:\windows\assembly\gac\microsoft.directx.direct3dx\1.0.2905.0__31bf3856ad364e35\microsoft.directx.direct3dx.dll', No symbols loaded.
The thread '.NET SystemEvents' (0x1e4) has exited with code 0 (0x0).
The program '[2240] FRBTemplate.exe' has exited with code 0 (0x0).


It's not exactly 85 fps. Sometimes it's 84. . .83. And the grand finale, here's my code (removed timing so it's all done by fraps):

using System;using System.IO;using System.Drawing;using System.Windows.Forms;using Microsoft.DirectX.Direct3D;namespace GameName{	public class GameForm : Form	{		static Device device;		public GameForm()		{			ClientSize = new System.Drawing.Size(1600,1200);			System.Windows.Forms.Cursor.Hide();			FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;					WindowState = System.Windows.Forms.FormWindowState.Maximized;				PresentParameters presentParams = new PresentParameters();			presentParams.Windowed= true;			presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames 			presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencil			presentParams.AutoDepthStencilFormat = DepthFormat.D16; // And the stencil format			presentParams.PresentationInterval = PresentInterval.Immediate;			device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing , presentParams); //Create a device		}				protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)		{			if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape)			{					System.Windows.Forms.Cursor.Show();						Dispose(); 			}		}		static void Main()		{			GameForm frm = new GameForm();			frm.Show();			while(frm.Created)			{				device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);				device.BeginScene();				device.EndScene();				device.Present();				Application.DoEvents();			}		}	}}


I'm stumped.

--Vic--
To make things more funky, I tried it on a friend's computer, and he got 999 fps.
--Vic--
I have come across this problem before and eventually traced it back to certain graphics card drivers limiting the fps to the monitor refresh rate when there is nothing actually drawn each frame. To get around this, just draw a single primitive of any kind.

- Oscar [smile]

This topic is closed to new replies.

Advertisement