• entries
422
1540
• views
490101

My computer hates me

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 herepd3dDevice->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...

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."

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?

What happens if you release the render target, but not the depth stencil surface?

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.

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

Create an account

Register a new account