Dynamic Linking

Graphics developers sometimes create large, general-purpose shaders that can be used by a wide variety of scene items. At runtime, the shader conditionally runs code appropriate for the given situation. Unfortunately, these large, general-purpose shaders use general-purpose registers (GPRs) inefficiently, and can be much slower than smaller, more targeted shaders.

Shader model 5 addresses this performance problem by introducing dynamic shader linking. Dynamic linking separates shader code fragments by using interfaces and virtual functions and allows the application to select the fragment to use at draw time. This improves performance by binding only the shader code needed and not the entire large, general-purpose shader.

In This Section

Item Description
Storing Variables and Types for Shaders to Share
Describes the class linkage object for storing variables and types that multiple shaders can share.
Interfaces and Classes
Describes using HLSL interfaces and classes to implement dynamic linking.
Interface Usage Restrictions
Describes restrictions on the use of interfaces in shader code.

HLSL