Virtual Texturing

Virtual texturing

Visualization of virtual texturing: sampling the cache texture through an indirection texture or page table

The name is derived from virtual memory in operating systems. This virtual memory allows software to access more memory than is physically present on a system. In the same fashion, virtual texturing allows the use of textures with much higher resolutions than what would normally fit in the video memory. Even when enough VRAM would be available, the resolution of conventional textures is limited to 16K by 16K; the limit set by modern graphics APIs. By using virtual texturing, texture sizes up to 256K by 256K can be used.

The technique subdivides textures into small texture tiles (e.g. 128x128 pixels). These tiles are loaded into a texture cache in the video memory by a tile-based texture streaming system. This cache contains a randomly ordered set of tiles that are part of a larger texture. Textures are sampled from this cache through a translation table. This table translates the virtual texture coordinate (UV) to the cache position to fetch the required texel.

Granite SDK, texture streaming middleware

In Granite SDK, our texture streaming middleware, this technique is also used to minimize the memory usage and loading times for more typical texture resolutions like 2K, 4K and 8K. This allows the resolution of these assets to be increased without an impact on the memory requirements. Virtual texturing is an evolved version of Megatexturing, the technique pioneered by id software. However, the latter assumed that every texel in the virtual world is unique. The virtual texturing technology in Granite handles any texture content, including tiling textures that are blended in the shader.

The technique relies heavily on the graphics API and shader language. Texture tile uploads need to be carefully timed and implemented to get the best performance out of the GPU drivers. Also, care must be taken to optimize the virtual texture sampling itself to minimize the needed shader instructions. Granite SDK contains optimized implementations for DirectX9, 11, 11.2 and OpenGL.

Hardware

Modern graphics APIs have added functionality to support the concept of virtual texturing. “Tiled Resources” introduced in DirectX 11.2 exposes hardware acceleration of the technique through the API. “Partially resident textures” provides similar functionality for OpenGL. Granite SDK supports both hardware and software virtual texturing.

Virtual texturing in Software

In software, texture filtering requires special care as the texture tiles are placed randomly in a 2D texture cache. Using standard hardware filtering would result in texture bleeding from neighboring tiles. In software mode, Granite will add pixel borders to each tile to ensure the correct hardware filtering behavior. Doing filtering in the shader would be an alternative solution but would be computationally expensive.

Virtual texturing in Hardware

In hardware, cross tile filtering is handled by the hardware correctly. This avoids the need to add extra pixel borders. Hardware virtual texturing also has the advantage that fewer shader instructions are needed per virtual texture sample. However, in most practical scenarios, the impact on the frame rate using software mode in Granite SDK is almost unmeasurable.

Watch our presentation on the use of Tiled Resources at the Microsoft //build/ conference below.

Leave your information

×