Discussion:
Device.SetRenderTarget
(too old to reply)
Armin Zingler
2007-08-23 23:25:30 UTC
Permalink
Hi group,

is there anything special to consider when using Device.SetRenderTarget? I
ask because I a get a huge memory occupation if I use it. Long story short:
The problem can simply be reproduced by modifying Tutorial1 from the SDKs
Samples\Managed\Direct3D\Tutorials\Tutorial1 folder:

In function "Render", add this statement before "device.Clear...":

device.SetRenderTarget(0,
device.GetSwapChain(0).GetBackBuffer(
0, BackBufferType.Mono
)
);

And in function InitializeGraphics, add this statement before "new
Device...":

presentParams.PresentationInterval = PresentInterval.Immediate;

Start it in the IDE, wait 5 seconds, then close the Form: It will take many
minutes until the application quits, so you will have to kill it in the task
manager. Why does this happen?

In this case, of course, setting the render target this way does not make
much sense, but it is only a reduced example. Though it works.

Nevertheless, I don't understand why this happens. The render target is the
first backbuffer anyways, so why does explicitly setting the RenderTarget
cause such a behavior?

If anybody is interested I can provide more details.


Armin
Armin Zingler
2007-08-25 01:16:36 UTC
Permalink
Post by Armin Zingler
Hi group,
is there anything special to consider when using Device.SetRenderTarget? I
The problem can simply be reproduced by modifying Tutorial1 from the SDKs
device.SetRenderTarget(0,
device.GetSwapChain(0).GetBackBuffer(
0, BackBufferType.Mono
)
);
Ok, found it: I have to assign the surface retrieved by .GetBackBuffer to a
variable and Dispose it after rendering is done. I didn't do this because I
thought this destroys the native Surface which would lead to an exception in
the next render loop. That's not true, so Dispose works well.


Armin

Loading...