GetSurfaceLevel or CreateRenderTarget - Performance

Started by
0 comments, last by Hodgman 11 years ago

Hey,

I have to render a lot of textures as a prepass for my lighting pipeline. So in OpenGL I was creating one FBO and just attaching new textures, this is much faster than always binding an another FBO. In DX9 I know I have two posibilities.. First is just binding the Surface of the Texture to the Pipeline using SetRenderTarget(0, tex.GetSurfaceLevel(0)).. The other one is to Create a seperate RenderTarget and using StretchRectangle to blit it the result on a texture.. Which one would be faster? Or is there an another way?

Thanks,

Thomas

Advertisement

GetSurfaceLevel or CreateRenderTarget

These are two different ways to create a render target -- you can make a texture with the render target flag, and then get it's surface, or you can use create render target.

Usually you use the first method, because this way you have a VRAM allocation that's aliased as both a texture and a surface (i.e. you can read and write to the allocation).

With CreateRenderTarget, the allocation is only accessible as a surface, and not as a texture, so you can't directly read from it (the only way to read from them is StretchRect).

You generally only use these kinds of render-targets when you're using MSAA (i.e. if you're using CreateRenderTarget with D3DMULTISAMPLE_NONE, then you may as well be using CreateTexture with D3DUSAGE_RENDERTARGET, followed by GetSurfaceLevel).

1) binding the Surface to the Pipeline using SetRenderTarget(0, surface)..

2) using StretchRectangle to blit the result

You can use either of these with either of the above two methods for creating a render target.

#1 is preferable because you're rendering directly to the render-target.

With #2, you're rendering first to an intermediate render target, and then copying it to your destination, which is unnecessary work.

This topic is closed to new replies.

Advertisement