Why/When should you call DiscardResource? https://msdn.microsoft.com/en-us/library/windows/desktop/hh404613(v=vs.85).aspx
What does this method buy you? Is it essentially like the free method in C?
Why/When should you call DiscardResource? https://msdn.microsoft.com/en-us/library/windows/desktop/hh404613(v=vs.85).aspx
What does this method buy you? Is it essentially like the free method in C?
This is more useful in conjunction of IDXGIAdapter3::QueryVideoMemoryInfo and other IDXGIAdapter3 function in regards to memory budget. When you are dealing with a memory budget, and with potentially other application that can lead to windows to ask you to reduce your footprint, Discard is a tool that let you say "hey, i do not need that resource for the moment but i may need later, if you need, you can get the memory back, but if you do not need, i prefer you to not".
This is an improvement over Destroy/Create, as it may give a harder time to the driver to manage allocations, it may also skip some life management, and conserve trace of what memory is better for your resource as the driver move things around based on usage and load.
Galop1n, you're thinking of OfferResources/ReclaimResources.
DiscardResource enables an optimization when rendering to the resource, particularly on tile-based deferred rasterizers. It's essentially saying that you're going to opaquely render to a region of a resource, so there's no need to read in those tiles next time you access it.
Galop1n, you're thinking of OfferResources/ReclaimResources.
DiscardResource enables an optimization when rendering to the resource, particularly on tile-based deferred rasterizers. It's essentially saying that you're going to opaquely render to a region of a resource, so there's no need to read in those tiles next time you access it.
Your use case described here does not work as intended, ( at least for AMD and nVidia ). The best when you do not care about the surface previous content is to clear, because it turns on the fast clear system that is the only one to save you gpu cycles by using an extra memory buffer to keep track of surface tile status, using things like depth buffer compression, fast clear elimination, ...
Discard is the ancestor dx11.1 of the offer/reclaim system in dx11.2.
Agreed, compression metadata serves a similar purpose, but Discard definitely does not have any implications on memory usage. In fact, offer/reclaim don't really have any impact on memory usage until IDXGIDevice4::OfferResources1 with the ALLOW_DECOMMIT flag.
Discard is intended for tile-based deferred rasterizers (TBDRs). See this StackOverflow post for more comments.
Oh, i miss interpret the "tile based deferred rasterizers" as a class of rendering technique, not hardware, ok, my comments where purely oriented PC and current gen consoles GPU, the last time i dealt with such a tile rasterizer was the Dreamcast, so i can't comment for that :)
galop1n is incorrect. DiscardResource has NOTHING to do with memory claiming.
DiscardResource has two purposes:
Edit: See http://developer.download.nvidia.com/assets/events/GDC15/GEFORCE/SLI_GDC15.pdf