Memory-Mapped Textures

mental ray supports memory mapping of textures on all platforms. Memory mapping means that the texture is not loaded into memory, but is accessed directly from disk when a shader accesses it. There is no special keyword or option for this; if a texture is memory-mappable, mental ray will recognize it and memory-map it automatically. Only the map image file format (standard extension .map, but mappable files are recognized even if they have an extension other than .map) can be mapped. See the Output Shaders chapter for a list of supported file formats.

Note that memory mapping is based on the concept that the image data on disk does not require decoding or data type conversion, but is available in the exact format that mental ray uses internally during rendering. Normally mental ray will attempt to auto-convert image data formats; for example if a color image file is given in a scalar texture construct, mental ray will silently convert the color pixels to scalars as the texture is read in. Most data types are auto-converted to most other data types. This does not work for memory-mapped textures because it would defeat the purpose. This also applies to the byte order.

Memory mapping requires several preparation steps:

If the textures and the scene are so large that they do not fit into physical memory, loading a texture is equivalent to loading the file into memory, decompressing it, and copying it out to swap. (The swap is a disk partition that acts as a low-speed extension of the physical memory that exists as RAM chips in the computer.) From then on, accessing a texture means accessing the swap. Memory mapping eliminates the read-decompress-write step and accesses the texture from the file system instead of from swap. This has the side effect that less swap space is needed. If the texture and scene are not large and fit into memory, and if the texture is accessed frequently, memory-mapped textures are slightly slower than regular textures because the swap would not have been used, but for textures that are larger than perhaps a hundred kilobytes (uncompressed), memory mapping is a much more efficient way of loading textures.

This is especially important for mental ray which manages memory as a cache. Large non-memory mapped textures are a big drain on the cache because they tend to take up large portions of cache memory. mental ray has a separate virtual cache manager that loads and unloads memory-mapped textures efficiently without blocking the regular cache.

Note: memory-mapping of large concrete textures is reducing the available adressable memory for mental ray. This may result in memory faults on 32bit systems with limited address space. In those cases it is recommended to utilize texture caching instead of memory mapping to optimize texture file access and memory usage.

Copyright © 1986-2011 by mental images GmbH