Jump to content
  • Advertisement
Sign in to follow this  

OpenGL GetSurfaceLevel or CreateRenderTarget - Performance

This topic is 2031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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?




Share this post

Link to post
Share on other sites

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.

Edited by Hodgman

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!