reinterpret a texture as a different format?

Started by
3 comments, last by そら 2 years, 1 month ago

So, I already have a 1024x768 A8R8G8B8 texture that I'm using very late in the frame… and I find myself in need of using a 2048x1536 D16 depth texture at early stages of the frame.

I wouldn't want to add more memory footprint to my application so was thinking if it would be possible to somehow reinterpret the texture I'm using as a depth texture at the beginning and then use it as it is right now.

or what other alternatives would you recommend?

"lots of shoulddas, coulddas, woulddas in the air, thinking about things they shouldda couldda wouldda donne, however all those shoulddas coulddas woulddas ran away when they saw the little did to come"
Advertisement

Never heard of being able to do that, but you are talking about very low memory textures. What is causing you to be worried about memory?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

You certainly can't reinterpret the texture like that and expect to keep the contents of the previous texture. Since those two formats are unrelated it is very possible that they use a different physical memory layout under the hood. Also since the latter is a depth format, it is almost 100% guaranteed that the memory layout is different and that additional metadata would be required.

If you really want to save memory, the way to do that is by aliasing two textures onto the same location within a ID3D12Heap. This won't let you preserve the contents between the two textures, but they will occupy the same memory region. You'll need to take care to use an aliasing barrier when “switching” from one texture to another, and also be sure to “initialize” the contents of any render target or depth target textures by calling Clear or Discard. That last step is required to initialize the metadata of the texture for video cards that have such a thing.

@MJP awesome!… thanks!

I don't need to keep t he contents of the previous texture, so def aliasing two textures does sound like what I'm looking for, will take a look.

Thanks!

"lots of shoulddas, coulddas, woulddas in the air, thinking about things they shouldda couldda wouldda donne, however all those shoulddas coulddas woulddas ran away when they saw the little did to come"

This topic is closed to new replies.

Advertisement