Sign in to follow this  
acid2

Rendering to texture... strange 'lag'...

Recommended Posts

Hey, Im making a game in Managed DirectX and I'm trying to add render to texture to it. When i call "RTS.EndScene(Filter.none)" my program freezes for about 2-3 seconds.... any ideas? RTS is an instance of "RenderToSurface" Thanks, - aCiD2

Share this post


Link to post
Share on other sites
What is the format and pool of your render target? If it is not a compatable render target RTS will create a compatable target and copy it to your surface when you call EndScene, this couls account for the lag. NOTE: a compatable render target must be created in the Default pool and be of a size and format supported by your graphics hardware.

Share this post


Link to post
Share on other sites
its a 512x512 texture created in the default render pool. Im using the format X8R8B8G8 - quite standard. My card is an ATi Radeon 9800, pretty sure it supports that format...

Share this post


Link to post
Share on other sites
I have had trouble getting RenderToSurface to work correctly myself and simply use Device.SetRenderTarget().

Here is what I do.

tex = new Texture(device,flatSize.X,flatSize.Y,1,Usage.RenderTarget,texFormat,Pool.Default);
//...
device.BeginScene();
device.SetRenderTarget(0,tex.GetSurfaceLevel(0));
device.Clear(ClearFlags.Target, clearColor.ToArgb(), 1.0f, 0);
device.DrawUserPrimitives(PrimitiveType.TriangleStrip,2,geom);
device.EndScene();
device.Present();
device.SetRenderTarget(0,device.GetSwapChain(0).GetBackBuffer(0,0));


It may not be totaly correct, but it works without lag on my 9600.

Share this post


Link to post
Share on other sites
Hey, cool solution! Works perfectly, but I'm not totally sure with it - is this solution just as reliable as using an actual RenderToSurface?

Share this post


Link to post
Share on other sites
Just a stab in the dark here,


If i remember correctly, a 'surface' is considered to exist in system memory, not video memory.

This would explain the lag of having to pass the data from the video card over to main memory.

wherein setting a render target, specifies a video memory rendering surface, that is no need to communicate back to sram.

again, just a thought =)

Share this post


Link to post
Share on other sites
RenderToSurface has worked just as well before - it is meant to be the prefered method. I jsut can't understand why I am now getting this lag...

Share this post


Link to post
Share on other sites
Quote:
Original post by acid2
Hey, cool solution! Works perfectly, but I'm not totally sure with it - is this solution just as reliable as using an actual RenderToSurface?


I imagine that RenderToSurface is doing very a similar thing inside.

Share this post


Link to post
Share on other sites

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

Sign in to follow this