Archived

This topic is now archived and is closed to further replies.

owl

Frame Rates

Recommended Posts

I''m running on a: Pentium Celleron 466 Mother Soyo 6BA+ 196MB RAM Riva TNT2 64MB When I run a pretty basic Direct3D 8.1 2D program in 640x480x32bit fullscreen I get 60 frames per second. It has a semi-transparent surface occupying half of the screen and a scrolling background behind it. I think it''s a low frame rate, what do you think?

Share this post


Link to post
Share on other sites
In fullscreen mode, the frame rates of Direct3D programs are capped at the vertical synch rate of your monitor. This is to prevent funny artifacts from appearing because frames are being generated faster than the monitor can draw (I think). You can raise the frame rate by raising the refresh rate of your monitor. 60 Hz is pretty low, IMHO.

Share this post


Link to post
Share on other sites
My monitor can do 120hz in 640x480x32bit. How I do to raise the monitor''s refresh rate? Can I set it from direct3d?

In 640x480x16bit the program runs 90+ frames per second.

Share this post


Link to post
Share on other sites
Set the FullScreen_PresentationInterval in the D3DPRESENT_PARAMETERS structure to D3DPRESENT_INTERVAL_IMMEDIATE


D3DPRESENT_PARAMETERS pp;
pp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

Edit:
Theres also a FullScreen_RefreshRateInHz member.

[edited by - Ximmer on October 16, 2002 10:32:23 PM]

Share this post


Link to post
Share on other sites
Cool, thanks! I did set FullScreen_PresentationInterval to D3DPRESENT_INTERVAL_IMMEDIATE and now it does 80 FPS in 640x480x32.

FullScreen_RefreshRateInHz has only two posible values:
//d3d8types.h
/* RefreshRate pre-defines */
#define D3DPRESENT_RATE_DEFAULT 0x00000000
#define D3DPRESENT_RATE_UNLIMITED 0x7fffffff

When I set it to UNLIMITED the program crashes.

Is there any other tweak I can do before I start optimizing my code?

Wich performance you think my system is capable of in 640x480x32?
Remember that I'm doing alpha with a pretty large texture.

[edited by - xaxa on October 16, 2002 11:47:41 PM]

Share this post


Link to post
Share on other sites
I believe it is best to use the following flag:

FullScreen_RefreshRateInHz

and set it to something like 85 hz, or whatever you would like to be set at, and set

FullScreen_PresentationInterval

to D3DPRESENT_INTERVAL_DEFAULT.

Direct3D does not support D3DPRESENT_RATE_UNLIMITED, thus why your program is crashing.

¬_¬

Share this post


Link to post
Share on other sites
quote:
Original post by Fuzztrek
I believe it is best to use the following flag:

FullScreen_RefreshRateInHz

and set it to something like 85 hz, or whatever you would like to be set at, and set

FullScreen_PresentationInterval

to D3DPRESENT_INTERVAL_DEFAULT.

Direct3D does not support D3DPRESENT_RATE_UNLIMITED, thus why your program is crashing.

¬_¬


I tried to set:
FullScreen_RefreshRateInHz = 85;
FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT.

But program crashes...

quote:
Original post by KalvinB
You can get an app that will turn off the vsync lock for DX and OpenGL. Then you don't have to do it in your program. I have a full screen OGL app running at 326FPS. The DX version runs at 350FPS

HOW I DO THAT???

Here is my messy D3D initialization code:


  
m_pDirect3D=Direct3DCreate8(D3D_SDK_VERSION);
if (m_pDirect3D==NULL)
return FALSE;

CGameWindow Window;
Window.SetWidth(m_dwWidth);
Window.SetHeight(m_dwWidth);
Window.SetWindowed (m_bWindowed);
m_hWnd = Window.Initialize (hInst,WndProc);

if (!m_hWnd)
return FALSE;

if (m_bWindowed)
{
SetWindowPos(m_hWnd, NULL, 0, 0, m_dwWidth, m_dwHeight, SWP_NOZORDER);
SetWindowLong(m_hWnd, GWL_STYLE, WS_POPUP|WS_CAPTION|WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX);
}
else
{
// Set up main window to cover the screen

SetWindowLong(m_hWnd, GWL_STYLE, WS_POPUP);
SetWindowPos(m_hWnd, NULL, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_NOZORDER);
}
ShowWindow(m_hWnd, SW_SHOW);

if( FAILED( m_hResult = BuildDeviceList() ) )
{
SAFE_RELEASE( m_pDirect3D );
return DisplayErrorMsg( m_hResult, MSGERR_APPMUSTEXIT );
}

D3DAdapterInfo* pAdapterInfo = &m_Adapters[m_dwAdapter];
D3DDeviceInfo* pDeviceInfo = &pAdapterInfo->devices[pAdapterInfo->dwCurrentDevice];
D3DModeInfo* pModeInfo = NULL;

for(DWORD i=0;i<pDeviceInfo->dwNumModes;i++)
{
if ((pDeviceInfo->modes[i].Width==m_dwWidth)&&(pDeviceInfo->modes[i].Height==m_dwHeight))
{
pModeInfo = &pDeviceInfo->modes[i];
break;
}

}
if (!pModeInfo)
pModeInfo = &pDeviceInfo->modes[pDeviceInfo->dwCurrentMode];

D3DPRESENT_PARAMETERS presentParameters; // Used to explain to Direct3D how it will present things on the screen

memset(&presentParameters, 0, sizeof(D3DPRESENT_PARAMETERS)); // We need to fill it with 0's first


if( m_bWindowed )
presentParameters.MultiSampleType = pDeviceInfo->MultiSampleTypeWindowed;
else
presentParameters.MultiSampleType = pDeviceInfo->MultiSampleTypeFullscreen;

if (m_bWindowed)
{
presentParameters.BackBufferWidth = m_dwWidth;
presentParameters.BackBufferHeight = m_dwHeight;
presentParameters.BackBufferFormat = pAdapterInfo->d3ddmDesktop.Format;
}
else
{
presentParameters.BackBufferCount = 1;

presentParameters.BackBufferWidth = pModeInfo->Width;
presentParameters.BackBufferHeight = pModeInfo->Height;
presentParameters.BackBufferFormat = D3DFMT_X8R8G8B8; //pModeInfo->Format;


if( pDeviceInfo->d3dCaps.PrimitiveMiscCaps & D3DPMISCCAPS_NULLREFERENCE )
{
// Warn user about null ref device that can't render anything

DisplayErrorMsg( D3DAPPERR_NULLREFDEVICE, 0 );
}

presentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
presentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
}
presentParameters.Windowed = m_bWindowed;
presentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; // Tells Direct3D to present the graphics to the screen the quickest way possible. We don't care if it saves the data after or not.



m_hResult = m_pDirect3D->CreateDevice( m_dwAdapter, pDeviceInfo->DeviceType, m_hWnd, pModeInfo->dwBehavior, &presentParameters,
&m_pDevice );

if (FAILED(m_hResult)) // If it failed, return failure

return FALSE;

m_pFont = new CFont3D( "Arial", 10, D3DFONT_BOLD );

if (FAILED(m_pFont->InitDeviceObjects(m_pDevice)))
return FALSE;

// Part three, set the render flags.

m_pDevice->SetRenderState ( D3DRS_CULLMODE, D3DCULL_NONE);
m_pDevice->SetRenderState ( D3DRS_LIGHTING, FALSE);
m_pDevice->SetRenderState ( D3DRS_ZENABLE, TRUE);

// Set diffuse blending for alpha set in vertices.

m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

m_pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_pDevice->SetVertexShader( D3DFVF_CUSTOMVERTEX );


return TRUE;


[edited by - xaxa on October 16, 2002 12:32:50 AM]

Share this post


Link to post
Share on other sites
The program is NVMax

You can get it here

http://www.teamad.net/tweaks/geforce.html

It''s for the GeForce. I don''t know what you have so it may or may not work. You could probably get a similar program for any graphics card.

As for getting it to run blisteringly fast, the secret is rendering a couple textured quads and a bit of text. It''s ~350FPS at 1024x768x32bit. It''s 600FPS at 640x480x32bit.

That''s with a Duron 700 and a GeForce 2 MX.

It drops down to ~150 in 1024x768x32bit when I start getting a bunch of stuff on the screen.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]

Share this post


Link to post
Share on other sites
quote:
Original post by KalvinB
It''s for the GeForce. I don''t know what you have so it may or may not work. You could probably get a similar program for any graphics card.
Oh, ok. I just want to doit the right way, to avoid complications.

quote:
Original post by KalvinB
As for getting it to run blisteringly fast, the secret is rendering a couple textured quads and a bit of text. It''s ~350FPS at 1024x768x32bit. It''s 600FPS at 640x480x32bit.

That''s with a Duron 700 and a GeForce 2 MX.

It drops down to ~150 in 1024x768x32bit when I start getting a bunch of stuff on the screen.

Ben
Ok, that could mean I''m not so bad after all:

Celleron 400 / Duron 700
Riva TNT2 / GeForce 2 MX
With vsinc / Without vsinc
I: 80FPS / You: 450FPS

Share this post


Link to post
Share on other sites
quote:
Original post by xaxa


    

presentParameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
presentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;


[edited by - xaxa on October 16, 2002 12:32:50 AM]

It is failing because you are setting the presentation interval to D3DPRESENT_INTERVAL_IMMEDIATE, when you should be setting to D3DPRESENT_INTERVAL_DEFAULT. You should be setting D3DPRESENT_RATE_DEFAULT to a number, like 85. I am not sure if this is the exact problem as I did not look through all of your code.


The program the KevinB uses is not something that you should consider. It is not a practical program and it is just getting around the problem instead of solving it. This software can potentially harm your hardware and I would strongly advise against it. You may get high frame rates with this program, but this renders you useless as a programmer becuase everyone else you send your program to might be running at 50 fps.



¬_¬

Share this post


Link to post
Share on other sites
quote:
Original post by Fuzztrek
It is failing because you are setting the presentation interval to D3DPRESENT_INTERVAL_IMMEDIATE, when you should be setting to D3DPRESENT_INTERVAL_DEFAULT. You should be setting D3DPRESENT_RATE_DEFAULT to a number, like 85. I am not sure if this is the exact problem as I did not look through all of your code.


When I do this:

presentParameters.FullScreen_RefreshRateInHz = 85;
presentParameters.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;

The system hangs. Using INTERVAL_IMMEDIATE I increased the framerate in 20 units.

quote:
The program the KevinB uses is not something that you should consider. It is not a practical program and it is just getting around the problem instead of solving it. This software can potentially harm your hardware and I would strongly advise against it. You may get high frame rates with this program, but this renders you useless as a programmer becuase everyone else you send your program to might be running at 50 fps.

Thankyou for the warning... that program looks pretty obscure...



Share this post


Link to post
Share on other sites
Hmm.. I looked through your code and I can''t really see what would be causing it to hang. Here is what I do when I initialize my app:


  
// Get D3D object

if((pro_lpD3D = Direct3DCreate8(D3D_SDK_VERSION)) == NULL){

return E_FAIL;
}

// Clear out D3DPP structure

ZeroMemory(&pro_D3DPP, sizeof(D3DPRESENT_PARAMETERS));

if(Windowed == SS_WIND){

// Get D3DDM structure

if(FAILED(pro_lpD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &pro_D3DDM))){

return E_FAIL;
}

// Set presentation parameters

pro_D3DPP.Windowed = TRUE; // Set windowed to true

pro_D3DPP.SwapEffect = D3DSWAPEFFECT_DISCARD; // Set swap effect to discard

pro_D3DPP.BackBufferFormat = pro_D3DDM.Format; // Set color format to the same as D3DDM structure

pro_D3DPP.EnableAutoDepthStencil = TRUE;
pro_D3DPP.AutoDepthStencilFormat = D3DFMT_D16;

}else if(Windowed == SS_FULL){

// Fill out D3DDM structure

pro_D3DDM.Width = sWidth; // passed param. default: 800

pro_D3DDM.Height = sHeight; // passed param. default: 600

pro_D3DDM.Format = sBPP; // passed param. default: D3DFMT_A8R8G8B8 (32-bit true color)

pro_D3DDM.RefreshRate = sRFR; // passed param. default: 0 (D3D default)


// Set presentation parameters

pro_D3DPP.Windowed = FALSE; // Set windowed to false

pro_D3DPP.SwapEffect = D3DSWAPEFFECT_FLIP; // Set swap effect to flip

pro_D3DPP.FullScreen_RefreshRateInHz = sRFR; // Set refresh rate to passed param

pro_D3DPP.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; // Set presentation interval to default

pro_D3DPP.BackBufferFormat = pro_D3DDM.Format; // Set color format to the same as D3DDM structure

pro_D3DPP.BackBufferWidth = pro_D3DDM.Width;
pro_D3DPP.BackBufferHeight = pro_D3DDM.Height;
pro_D3DPP.EnableAutoDepthStencil = TRUE;
pro_D3DPP.AutoDepthStencilFormat = D3DFMT_D16;


}


That''s what I do. THe only thing that I see is different is taht you set your back buffer swap effect to discard, while i only set it to discard if I am in windowed mode, and to flip if i am in fullscreen. I''m not sure that this makes a difference at all, and I am by no means saying that my way is better. I just think that since it does not work one way that it should work, you should investigate a little bit. Your way might be perfectly correct, but if both ways don''t work something might be a miss.

Hope this helps!

Fuzztrek

¬_¬

Share this post


Link to post
Share on other sites
You should never set the refresh rate in your app unless a) you''re just playing around and do not plan on distributing, or b) you know how to set it correctly, based upon the actual card/monitor settings.

Hardcoding the refresh rate in an app is just as dangerous as using some third party utility and opens you and your company up to potential law suits. At least a third party utility would be used by the end user, so damage to their equipment would be their fault and not yours.

Share this post


Link to post
Share on other sites
"At least a third party utility would be used by the end user, so damage to their equipment would be their fault and not yours."

Yep. Not everyone is a big fan of tearing. The only reason you should ever uncap your framerate is for testing purposes. If you want to know how fast your app is really running you have to uncap it. Other than that, leave it alone.

If the EU wants to remove the limit, NVMax is the premier tool for doing it despite what less informed posters may tell you.

There's absolutly NO RISK to your system until you start trying to overclock you card. All it does is set flags already available in the Detonator driver.


Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]


[edited by - Jim Adams on October 21, 2002 4:47:36 PM]

Share this post


Link to post
Share on other sites
Anyway, if you check for frame rate support, is it still dangerous Darrell? I have never heard this, though I guess its just as dangerous as setting your monitor to a width or height that is unsupported. Do you recommend a better method?

¬_¬

[edited by - Fuzztrek on October 17, 2002 9:07:44 PM]

[edited by - Jim Adams on October 21, 2002 4:49:10 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Darrell L
You should never set the refresh rate in your app unless a) you''re just playing around and do not plan on distributing, or b) you know how to set it correctly, based upon the actual card/monitor settings.


XFree configuration file says that seting the refresh rate manually is pretty dangerous. I will follow this advice. Any way, when I try to set the refresh manually on my computer the app crashes. Thank you Darrell.

quote:
Original post by Fuzztrek
Hmm.. I looked through your code and I can''t really see what would be causing it to hang.


My app doesn''t hang, it only runs on a slow frame rate on my system. It only hangs when I set the refresh rate to 85hz. You should consider Darrell''s advice.

-o-o-o-o-o-o-o---o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o

I repeat:

Is there any other tweak I can do before I start optimizing my code?
Wich performance you think my system is capable of in 640x480x32?
Remember that I''m doing alpha with a pretty large texture.

I''m running on a:

Pentium Celleron 466
Mother Soyo 6BA+
196MB RAM
Riva TNT2 64MB

Here is a screenshot:

Share this post


Link to post
Share on other sites
"seting the refresh rate manually is pretty dangerous."

Yup. Turning off vsync isn't the same as changing the refresh rate. If a monitor only supports 60Hz and you force it to 85Hz it'll either start smoking or if you're lucky, turn off. Most new monitors have hardware checks in place to prevent you from making it go too fast. Some drivers will also check with the monitor before allowing you to set the refresh rate to prevent you from damaging the monitor.

Turning off vsync in fullscreen mode is no more dangerous than running your app in a window.

"Is there any other tweak I can do before I start optimizing my code?"

No. Turning off VSync is the only tweak you need before you start optimizing. Upping your refresh rate only increases the max frame rate it will display. It doesn't fix your problem.

Getting rid of VSync removes the limit completely as though the program were running in a window. DirectDraw supported this natively with a simple flag when you flipped the surface. I don't know why D3D doesn't have it. Maybe it does but I've never seen it.

"Pentium Celleron 466
Mother Soyo 6BA+
196MB RAM
Riva TNT2 64MB"

80FPS is probably lower than you should be able to get. I have an ATI Rage 8MB in my 400Mhz 64MB Ram laptop and my app hits 60FPS no problem. That may even be the refresh rate cap stopping it.

If you could get it to 150, that's great but really, unless it drops below 30FPS you're not going to have anyone complaining.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]


[edited by - KalvinB on October 17, 2002 9:29:43 PM]

[edited by - Jim Adams on October 21, 2002 4:49:51 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by KalvinB
"typical kalvin.. i''ll just ignore you from now on."

Typical me, telling you you''re wrong when you are and typical you bitching about it. Grow up.

Don''t fight kids. Let''s help us each other

quote:
Original post by KalvinB
No. Turning off VSync is the only tweak you need before you start optimizing. Upping your refresh rate only increases the max frame rate it will display. It doesn''t fix your problem.

I want to increase the frame rate for those people who don''t have the program you are telling me to use. I don''t want to turn of vsinc, I don''t want to set the refresh rate manually neither.

quote:
Original post by KalvinB
If you could get it to 150, that''s great but really, unless it drops below 30FPS you''re not going to have anyone complaining.

I guess the other 70 frames depends on optimizing my code, I don''t have a clue about where should I start, but I see I don''t have any other chance but start doing it, thank you.

Share this post


Link to post
Share on other sites
By relying on a third party program to tweak your hardware in order to make your game run properly you are extremely limiting your audience. You are not learning anything either.

I personally would not trust someone who has been frowned apon by various forum moderators, not to mention lots of other forum posters.

If your program is not achieving the high frame rates that it should be achieving, then I would suggest looking into your code a little more, instead of ignoring the problem and using a third party program to get the same effect.

¬_¬

Share this post


Link to post
Share on other sites
quote:
Original post by Fuzztrek
By relying on a third party program to tweak your hardware in order to make your game run properly you are extremely limiting your audience. You are not learning anything either.

I agree with you. I won''t go to that party

quote:
Original post by Fuzztrek
I personally would not trust someone who has been frowned apon by various forum moderators, not to mention lots of other forum posters.

That''s his problem. I always listen everybody, no matter what they did in the past.

quote:
Original post by Fuzztrek
If your program is not achieving the high frame rates that it should be achieving, then I would suggest looking into your code a little more, instead of ignoring the problem and using a third party program to get the same effect.

Yap, I guess is the only thing left to do. My app is actually taking 10% of my processor, I guess I should reduce the milliseconds my code takes between every frame. Thanks Fuzz

Share this post


Link to post
Share on other sites
"I want to increase the frame rate for those people who don't have the program you are telling me to use"

You're perfectly free to distribute NVmax with your project. People who care probably already know about it anyway and it's not worth the risk of damaging their monitor to give them an extra 15FPS.

"I don't want to turn of vsinc, I don't want to set the refresh rate manually neither."

The only alternative then is to give them the option to change the refresh rate of their monitor. They can already do that through windows or the software that came with their video card. It's a pointless feature to add to your own code and could make you liable for damage.

Joe Mass Market doesn't have a clue what a refresh rate is and doesn't care unless the program runs choppy and that doesn't happen until well under 30fps.

In short, there's no reason to worry about Joe User's frame rate due to the refresh rate. Vsync only matters to you because it keeps you from knowing how fast your app really is.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting | Tiberian Merchandise!!!! | GameShot ]


[edited by - Jim Adams on October 21, 2002 4:51:06 PM]

Share this post


Link to post
Share on other sites