panda3d icon indicating copy to clipboard operation
panda3d copied to clipboard

Textures embedded in a Bam file are kept in system RAM after being uploaded

Open lachbr opened this issue 3 years ago • 3 comments

Description

If a Bam file is written out that has textures embedded in it and loaded up into the game, the RAM images for those textures are not freed when uploaded to the graphics card. Currently it requires explicitly finding all the textures in the scene and calling set_keep_ram_image(false) on them.

I think this can be attributed to the _keep_ram_image property not being serialized to Bam files. When the Bam file is loaded and the Texture object is constructed, _keep_ram_image will have default value of true. This could be fixed by serializing _keep_ram_image so a Texture that ends up being embedded can remember whether or not it should keep its RAM image when loaded up into the game.

Steps to Reproduce

Write out and load up a Bam file with embedded textures. Notice texture memory in PStats.

Environment

  • Operating system: Windows 11
  • System architecture: x64
  • Panda3D version: latest
  • Installation method: built from source
  • Python version (if using Python): python 3.10
  • Compiler (if using C++): vs 2019

lachbr avatar Dec 07 '21 18:12 lachbr

I think we should probably always set this flag to false for externally-loaded textures, and true only for textures that are embedded in the bam file.

rdb avatar Oct 25 '22 09:10 rdb

Sorry, I just realised you are talking about embedded textures. Surely if you don't keep these in RAM, you will lose data, meaning you can't reproduce the texture data and write out the same bam file again? If that's your intent, then I'm happy to add this flag to the bam data.

rdb avatar Oct 25 '22 09:10 rdb

Dropping "good first issue" label until open questions are sorted.

Moguri avatar Nov 28 '23 05:11 Moguri