Jump to content
  • Advertisement
  • entries
    422
  • comments
    1540
  • views
    490101

My computer hates me

Sign in to follow this  
jollyjeffers

186 views

I'm having one of those days...

My water rendering demo was running just fine at around 120fps. Dropped in a couple of bits of code and it plummetted to 18-20fps. I really, really do not understand why [headshake]:

LPDIRECT3DSURFACE9 pOriginalRT = NULL;
LPDIRECT3DSURFACE9 pOriginalDS = NULL;

pd3dDevice->GetRenderTarget( 0, &pOriginalRT );
pd3dDevice->GetDepthStencilSurface( &pOriginalDS );

// ... some stuff here

pd3dDevice->SetRenderTarget( 0, pOriginalRT );
SAFE_RELEASE( pOriginalRT );

pd3dDevice->SetDepthStencilSurface( pOriginalDS );
SAFE_RELEASE( pOriginalDS );


I've got 10's if not 100's of other projects that use an identical construct! Making a defensive copy of the implicit swap chain before doing any render-to-texture work isn't uncommon.

So after scratching my head and wondering why it was killing my performance I found out it was the two SAFE_RELEASE() calls. Comment those out and performance jumps back up to the original 120fps; but obviously I end up with a ridiculous number of memory leaks.

I fired up a couple of other projects that use the same construct and they dont seem to show the same characteristics. They're also line-for-line identical.

A real "WTF?!?!" moment.

I'm very sure I've done something silly and just not noticed, but for now I'm gonna let it be and drink beers whilst watching Copland. I'm very sceptical, but rumour has it the film contains proof that Sylvester Stallone can act. Either way a film with Robert De Niro, Ray Liotta and Harvey Keitel in support can't be that bad...
Sign in to follow this  


5 Comments


Recommended Comments

The SAFE_RELEASE() function ? macro is defined the same as the others, yes?

Demolition Man was way better than Copland because it had Rob Schneider in it!!

Erwin - "Greetings and salutations. Welcome to the emergency line of the San Angeles Police Department. If you prefer an automated response, press one, now."

Share this comment


Link to comment
Out of interest, what does Release() return? If it's something sensible (I'd expect 2 or 3), all is well (Or not, if you drop to such a low FPS [smile]). If it's 0, obviously the swapchain is being released - which would be A Bad Thing.

These are the debug runtimes, right? Any difference with release runtimes?

Share this comment


Link to comment
Thanks for the replies [smile]

Quote:
The SAFE_RELEASE() function ? macro is defined the same as the others, yes?
Yeah, nothing special about it. IIRC:

#define SAFE_RELEASE(p) {if(p){(p)->Release();(p)=NULL;}}

Quote:
Demolition Man was way better than Copland because it had Rob Schneider in it!!
[lol] I'd be inclined to agree. I wasn't overly impressed by Copland...

Quote:
These are the debug runtimes, right? Any difference with release runtimes?
With the debug runtimes, but no messages are coming through - just a silent slow-down. Switching over to the retail runtimes and it jumps back up to 150-160fps [oh]

Quote:
What happens if you release the render target, but not the depth stencil surface?
I got an extra 10fps by doing only one of the two operations (didn't matter which I kept or removed).

Very odd. I'll have a dig around again later today.

Share this comment


Link to comment
I've not found a solution yet, but it seems to be Visual Studio rather than DirectX thats breaking things.

Switching to a "release" build sorts things out code with or without the construct work at the same speed. I guess the "debug" build in VS is choking on something [headshake]

Cheers,
Jack

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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!