Jump to content
  • Advertisement

Archived

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

owl

Frame Rates

This topic is 5751 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
in windowed mode it does 56 fps... I have my desktop in 1152x864x32 at 75hz

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!