kevenvz Posted September 26, 2014 Share Posted September 26, 2014 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
kevenvz Posted September 26, 2014 Author Share Posted September 26, 2014 I've tested it and it renders as 1, much more frames then 5909255 renders(0 dropped so ) Link to comment
Moderators IIYAMA Posted September 26, 2014 Moderators Share Posted September 26, 2014 Afaik I it will be 1 thing. I was yesterday working with render targets. But if you want to be sure. You can use dxGetTexturePixels from that texture and set it back to a new texture. https://wiki.multitheftauto.com/wiki/DxGetTexturePixels So you also won't have problems losing the render target while using alt+tab. Link to comment
ixjf Posted September 26, 2014 Share Posted September 26, 2014 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
Moderators IIYAMA Posted September 26, 2014 Moderators Share Posted September 26, 2014 Not really lame, It has a lot of benefits: - You can speed up drawing. - You can edit the images. (and export them as images) - Never have to recreate those textures again. Link to comment
ixjf Posted September 26, 2014 Share Posted September 26, 2014 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 IIYAMA Posted September 26, 2014 Moderators Share Posted September 26, 2014 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
ixjf Posted September 26, 2014 Share Posted September 26, 2014 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now