Jump to content

Question: DirectX Rendertarget


kevenvz

Recommended Posts

Hey,

I had a question. I had a question about render targets. Like for example if I draw 492858 rectangles in 1 frame it will render 492858 things. But if I put all those things in a render target and render the rendertarget, will it only render 1 thing(without updating the render target every frame)

Thanks!

Link to comment

Render targets are simply 2D textures that you can draw to, therefore drawing a thousand rectangles to it once and then drawing the render target instead will obviously only draw it once.

@IIYAMA, using dxGetTexturePixels is lame. There is onClientRestore, which is triggered whenever the game resets the D3D device (which is what causes specific types of resources to be destroyed - this includes render targets) to restore from a device lost state (e.g. minimize, loss of focus).

Link to comment

How can it possibly speed up drawing? Also I still don't understand how would it stop you from having to recreate resources, unless you copied the texture data back and forth between the system and the GPU memory every update, which is already a very expensive operation by itself, let alone be done 30-60 times a second.

Link to comment
  • Moderators
Also I still don't understand how would it stop you from having to recreate resources

huh? what do you mean? Resource?

It can speed up, because you can change the texture format.

It may will take extra time to load it when you use something else then 'argb', but after it is all loaded as a "dxt5" you can speed up drawing.

I am not sure if the rendertarget stay in to the GPU memory as you probably was trying to say.

But since it is variable it is already in to the lua memory, I don't think this texture is much different from other textures.

Link to comment
huh? what do you mean? Resource?

http://msdn.microsoft.com/en-us/library ... 27(v=vs.85).aspx

It can speed up, because you can change the texture format.

It may will take extra time to load it when you use something else then 'argb', but after it is all loaded as a "dxt5" you can speed up drawing.

Yes, indeed, that would slightly improve rendering speed if the render target isn't updated very often, or often but not often enough that a render target would not help. But a texture copy operation is still very expensive, so you have to decide whether a giant amount of draw calls plus a texture copy operation (and creating a new texture and copying the data to it, which could take longer because of compression) over a lot less work, slightly slower rendering speed but better quality, and recreating the texture whenever the device is restored (which is the usual way, and also the simplest), is actually worth it.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...