Jump to content
  • Advertisement
Sign in to follow this  
Bangladesh

DX10 Should I save the ResourceView?

This topic is 3907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a texture-manager to load and store any texture I might need, but I have a problem: What is the best practice to save the resource in? For example, when storing a texture that is to be used as a sprite: First I load the texture from file into a Resource. Then I convert the Resource to a TextureResource. Then I convert the TextureResource into a ResourceView. What is the best practive here? 1. To save the Resource and on the fly create/convert to the other formats and release the temp when I don't need it anymore? 2. Save all three formats (and bloating the memory)? 3. Save only the TextureResource and create/convert to ResourceView on the fly? 4. Save only the ResourceView? What I'm asking is: Is it fast enough to convert on the fly to a temporary object, use it and then delete it, _or_ Save one, some, or all of the formats and convert, _or_ just save one final format (in that case; which one?) and ise it always.

Share this post


Link to post
Share on other sites
Advertisement
Rule for any Direct3D Version: Avoid calling methods with a Create in the name like plague inside your render loop. Creating anything is always an expensive operation.

I am not sure what you do to “convert” your objects. I assume the following

“Then I convert the Resource to a TextureResource”: You use QueryInterface.
“Then I convert the TextureResource into a ResourceView.”: You use CreateShaderResourceView.

As any method that takes a ID3D10Resource will take any of the ID3D10Texture interfaces too you don’t need to store the Resource interface. But as this are only interfaces to the same object you would not really save memory.
Every resource view will hold an reference on the resource that was used to create it. Therefore even if you release the texture interface the view will still hold it in memory.

As you should not create views in your loop on the fly you need to hold at least the view interface. But holding the texture interface too will you cost only the memory to store a single pointer. Compared to the size that the view and the texture itself needs that’s nothing.

Share this post


Link to post
Share on other sites
I would just store the view. The resource itself can be retrieved if needed with a call to GetResource, but most of the time you'll just need the view (binding inputs and outputs and the like).

Share this post


Link to post
Share on other sites
I also just save the shader resource views because I have thus far not needed the original resource interface directly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!