Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

GetSurfaceLevel or CreateRenderTarget - Performance

4: Adsense

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   

167
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



#2 Hodgman   Moderators   

50606
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.