Loading Hardware Shaders

Deprecated

mental ray uses OpenGL not only for defining a scene, but also to load hardware shaders. Hardware shaders include the vertex and fragment shader, precompiled uniform variables, and additional parameters. Just as mental ray relies on external shared libraries (DSO)s containing precompiled C/C++ software shaders, it relies on external libraries containing hardware shaders. The libraries are created by external compilers such as NVIDIA's Cg compiler from source code provided by the shader writer:

The hardware shader pipeline mirrors mental ray's existing software pipeline, except that the end result is not a DSO executed within mental ray, but a Cg hardware shader library. Hardware shaders are collected, processed, compiled, and sent to OpenGL for installation on the graphics hardware where they are executed.

NVIDIA's Cg compiler is only one example of a shader compiler. It accepts a high-level source code format that is designed to look like C code, with various restrictions and extensions. It is primarily targeted at graphics hardware designed by NVIDIA, but can also generate code for other graphics architectures such as OpenGL ARB through the use of profiles. All graphics vendors accept shader source code written in a form of specialized low-level assembly language, all specific to the vendor's graphics hardware; in this case the Cg or other compiler is not required. The upcoming OpenGL 2.0 standard will accept shaders in a format common to all vendors, but at this time (March 2004) hardware shader libraries must be designed and compiled separately for each hardware vendor.

Since the hardware shader source code and libraries currently differ greatly from vendor to vendor, and from hardware generation to hardware generation, mental ray does not attempt to integrate a compiler. If it did, it would become subject to the rapid change in the hardware industry, and would have to be modified each time any graphics hardware vendor designed a new board or language feature. It is important to keep mental ray hardware-agnostic and compatible with all graphics hardware from any vendor.

Copyright © 1986-2010 by mental images GmbH