1.23 Memory-mapped Textures
mental ray supports memory mapping of textures in UNIX environments. 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 (extension .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 thatmental 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.
Memory mapping requires several preparation steps:
The texturemust be converted to .map format using a utility likemental images? imf copy. The scene file must be changed to reference this texture. Note that mental ray recognizes .map textures even if they have an extension other than .map; this can be exploited by continuing to use the old file name with the ?wrong? extension.
Memory-mapped textures are automatically considered local by mental ray, as if the local keyword had been used in the scene file. This means that if the scene is rendered on multiple hosts, each will try to access the given path instead of transferring the texture across the network, which would defeat memory mapping. The given path must be valid on every host participating in the render.
The texture should not be on an NFS-mounted file system (one that is imported across the network from another host). Although this simplifies the requirement that the texture must exist on all hosts, the necessary network transfers reduce the effectiveness and can easilymakememory-mapping slower than regular textures.
Memory-mappingworks best if there are extremely large textures containing many tens ofmegabytes that are sampled infrequently because then most of the large texture file is never loaded into memory. 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 slower than regular textures because the swap would not have been used.
No comments:
Post a Comment