Patent ID: 8581912

Claim:
One or more computer-storage memory devices having computer-executable instructions embodied thereon for executing a method allocating memory registers to shader instances, the method comprising: declaring one or more interfaces to define a shader template, wherein one or more classes of a shader depend from the one or more interfaces; defining a simple shader definition and a complex shader definition; defining a variable in a shader program for inlining an actual shader instance; at a point in the shader program where the one or more interfaces are used, inlining instances of the simple shader definition and the complex shader definition; providing a graphics processing unit (GPU) driver with one or more tables defining usage points and indicating definitions of the simple shader definition and the complex shader definition; upon execution, choosing a shader instance, the shader instance being either a simple shader instance of the simple shader definition or a complex shader instance of the complex shader definition; allocating memory for the shader instance, wherein a number of registers associated with the memory and allocated for the shader instance depends on a level of complexity for the shader instance; and binding the simple shader instance and complex shader instance to a pipeline, wherein binding comprises storing in a table by a function type and a call location each use of both the simple shader instance and the complex shader instance, wherein a new version of the function is emitted for each location in the a shader code associated with at least one of the simple shader instance or the complex shader instance that the function is called from.