Jump to content

  • Log In with Google      Sign In   
  • Create Account


GetSurfaceLevel or CreateRenderTarget - Performance


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 thmfrnk   Members   -  Reputation: 109

Like
0Likes
Like

Posted 30 March 2013 - 01:48 AM

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



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 29712

Like
0Likes
Like

Posted 30 March 2013 - 06:35 AM

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, 30 March 2013 - 06:40 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS