Quantcast
Channel: Planet Object Pascal
Viewing all articles
Browse latest Browse all 1725

Castle Game Engine news: 1. GPU texture memory profiler was added to the engine. This allows to easily see which textures are...

$
0
0
1. GPU texture memory profiler was added to the engine. This allows to easily see which textures are loaded to GPU and eat texture memory. Optimizing this is especially important on mobile devices (Android, iOS) where texture memory is quite limited. The profile gives you the knowledge which textures are worth optimizing (maybe scale them down, maybe compress for GPU, maybe remove alpha channel or convert to grayscale...).

The profiler counts the real texture size on GPU, taking into account that some textures are resized to power of 2, that textures may be compressed on GPU, that some textures have mipmaps and so on. All kinds of textures (2D, 3D, cubemaps, float, depth etc.) are covered. Every type is reported --- loaded from files, generated (like by GeneratedCubeMapTexture), embedded in code (by embedding images or fonts in code)... The textures loaded from disk are described by URL, for other textures we invent special URLs like "embedded-font:/CastleTextureFont_CanterBold_120", "embedded-image:/PanelSeparator", "generated:/GeneratedCubeMapTexture(GenTex2)".

Enable the profiler by simple

  TextureMemoryProfiler.Enabled := true
 
at the very beginning of the application (e.g. in the main unit initialization clause). Then, after loading your game, get TextureMemoryProfiler.Summary, like this:

  WritelnLog('Textures', 'Textures using GPU memory:' + TextureMemoryProfiler.Summary);
 
You can also use the profiler from view3dscene, run it with "--debug-texture-memory" command-line option, load your 3D model and then use new menu option "Console -> Print Texture Memory Usage".

2. Other new engine API: new class to manage UI state (TCastleUIState), new types THorizontalPosition and TVerticalPosition and TRectangle.Align methods.

Enjoy new features:)

Viewing all articles
Browse latest Browse all 1725

Trending Articles