Jump to content
  • Advertisement

Archived

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

Legolas1681

Performance Woes with DX9

This topic is 5216 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've been working on a 2D game engine for some time now, and am at the point where I am blitting lots of things to the screen; however, once I began blitting many things, the FPS plummeted to around 28 to 30 FPS. When I render nothing but the FPS Counter, I get upwards of 1,080 FPS. I'm not sure what I can do to improve performance. I'm using D3DXLoadSurfaceFromSurface to blit the bitmaps to the backbuffer before presenting. I'm using D3DSWAPEFFECT_DISCARD, D3DPRESENT_INTERVAL_IMMEDIATE, and one backbuffer. Any help would be greatly appreciated. [edited by - Legolas1681 on June 7, 2004 9:01:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
Well, many means that they pretty much cover the entire screen (1152x864 resolution). And I'm running a GeForceFX 256MB AGP graphics card and I have 512MB of RAM, so I don't think it's my computer.

[edited by - Legolas1681 on June 7, 2004 9:53:52 PM]

Share this post


Link to post
Share on other sites
I could be wrong but I don''t think you can get good performance with DDraw-style surface copying. You really have to create some quads (two triangles) in the vertex buffer and apply your textures to them. All of the tutorials that I''ve seen on 2D in Direct3D do it in this manner, and AFAIK surface copies are more to set up your original images rather than something to do on a per-frame bases.

Please correct me if I''m wrong though...

Share this post


Link to post
Share on other sites
Okay, thanx for the input so far. One thing though, could someone give me a code sample of how to implement textured quads and/or the sprite interface. I''ve tried looking up some tutorials on textured quads, but they all used DirectDraw, which is not what I want. I want Direct3D9 code if possible.

Share this post


Link to post
Share on other sites
http://www.gamedev.net/reference/articles/article1972.asp

There is also a good book called "Focus on 2D in Direct3D" that will explain it all to you.

[edited by - AndyTX on June 7, 2004 11:35:29 PM]

Share this post


Link to post
Share on other sites
Well, I''ve been working with the tutorial on textured quads for quite awhile now and still can''t get it to work. I setup D3D, load a texture, create a vertex buffer, lock it, fill it with info, unlock it, call BeginScene, select the texture, call DrawPrimitive, EndScene, and then present the backbuffer. The FPS counter shows up and is less which mean it''s trying to do something, but the quad isn''t there. I''m not sure how to proceed. Help please.

Share this post


Link to post
Share on other sites
Okay, here's snippets of all the relevant code that I've been using, hopefully this will help.

const dword dwrdVertexType = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
.
.
.
struct SQMXVertex
{
float x;
float y;
float z;
float rhw;
D3DCOLOR color;
float u;
float v;
};
.
.
.
D3DXCreateTextureFromFileEx ( D3DDevice,
".\\Video\\Bitmaps\\image0002.png",
0,
0,
1,
0,
D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED,
D3DX_FILTER_NONE,
D3DX_DEFAULT,
D3DCOLOR_RGBA ( 255, 255, 0, 255 ),
NULL,
NULL,
&g_pTexture );
D3DDevice->SetVertexShader ( NULL );
D3DDevice->SetFVF ( dwrdVertexType );
D3DDevice->CreateVertexBuffer ( sizeof ( SQMXVertex ) * 4,
NULL,
dwrdVertexType,
D3DPOOL_MANAGED,
&g_pVertexBuffer,
NULL );
D3DDevice->SetStreamSource ( 0, g_pVertexBuffer, 0, sizeof ( SQMXVertex ) );
D3DDevice->SetRenderState ( D3DRS_LIGHTING, FALSE );
D3DDevice->SetRenderState ( D3DRS_ALPHABLENDENABLE, TRUE );
D3DDevice->SetRenderState ( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
D3DDevice->SetRenderState ( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
D3DDevice->SetTextureStageState ( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
.
.
.
SQMXVertex pVertices[ 4 ];
D3DDevice->BeginScene();
g_pVertexBuffer->Lock ( NULL, NULL, ( pVoid* ) &pVertices, NULL );
pVertices[ 0 ].x = 0.0f;
pVertices[ 0 ].y = 0.0f;
pVertices[ 0 ].z = 0.0f;
pVertices[ 0 ].rhw = 1.0f;
pVertices[ 0 ].color = D3DCOLOR_RGBA ( 255, 255, 255, 255 );
pVertices[ 0 ].u = 0.0f;
pVertices[ 0 ].v = 0.0f;
pVertices[ 1 ].x = 255.0f;
pVertices[ 1 ].y = 0.0f;
pVertices[ 1 ].z = 0.0f;
pVertices[ 1 ].rhw = 1.0f;
pVertices[ 1 ].color = D3DCOLOR_RGBA ( 255, 255, 255, 255 );
pVertices[ 1 ].u = 1.0f;
pVertices[ 1 ].v = 0.0f;
pVertices[ 2 ].x = 255.0f;
pVertices[ 2 ].y = 255.0f;
pVertices[ 2 ].z = 0.0f;
pVertices[ 2 ].rhw = 1.0f;
pVertices[ 2 ].color = D3DCOLOR_RGBA ( 255, 255, 255, 255 );
pVertices[ 2 ].u = 1.0f;
pVertices[ 2 ].v = 1.0f;
pVertices[ 3 ].x = 0.0f;
pVertices[ 3 ].y = 255.0f;
pVertices[ 3 ].z = 0.0f;
pVertices[ 3 ].rhw = 1.0f;
pVertices[ 3 ].color = D3DCOLOR_RGBA ( 255, 255, 255, 255 );
pVertices[ 3 ].u = 0.0f;
pVertices[ 3 ].v = 1.0f;
g_pVertexBuffer->Unlock();
D3DDevice->SetTexture ( 0, g_pTexture );
D3DDevice->DrawPrimitive ( D3DPT_TRIANGLEFAN, 0, 2 );
D3DDevice->EndScene();
D3DDevice->Present ( NULL, NULL, NULL, NULL );

Also, if it helps to know, I'm running in fullscreen mode.

[edited by - Legolas1681 on June 8, 2004 3:47:02 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!