- Home /
Does enabling Read/Write on a texture double its memory usage?
Greetings,
I remember reading a while back somewhere on the forums that enabling read/write permissions on textures (to be able to perform GetPixels etc) will double its memory usage at runtime. Is this true? To me it doesn't make sense, the texture memory is there, why would being able to read the buffer require double the size?
Thanks
Answer by creganjordan292 · Jan 11, 2018 at 08:31 AM
The reason why it doubles the memory usage is that you need to keep two copies of the texture. One for the GPU (which you can't access directly without a performance penalty) and one for the CPU stored in local memory. IIRC, you can still access the texture without read/write enabled.
Ah I see. Sucks. Yeah I can still access/reference it but I need to read the pixels individually via GetPixels, and it doesn't let me do that without enabling read/write. Thanks for the answer.
Though keep in $$anonymous$$d if the content of the texture doesn't change you can enable read/write by default, read the content once into a Color32 array and then call Apply with "makeNoLongerReadable" set to true. This will release the RA$$anonymous$$ memory and the texture is no longer readable. Of course you have to keep your Color32 array but you need it anyways whenever you want to read the texture.
However if you actually need to change / update the texture at runtime you have to keep it readable.
Ah, perfect! Yeah I only need to read it once to generate another texture map based off of a color map at runtime. Bunny old friend, my hero!
Your answer
Follow this Question
Related Questions
Differentiating between first import and reimport in the TextureImporter 0 Answers
Reduce GPU Memory usage from textures 1 Answer
Setting isReadable for a procedurally created texture asset 1 Answer
Reset a Texture After GetPixels/SetPixels 0 Answers
EditorScript - Texture set isReadable, and yet not accessible 0 Answers