Vectorization of shaders
AssigneeMicrosoft Corporation
InventorsAndy Glaister, Blaise Pascal Tine, Blake Pelton, Derek Sessions, Mikhail Lyapunov, Yuri Dotsenko
Life of this patent
Estimating the term…
Abstract
Intermediate representation (IR) code is received as compiled from a shader in the form of shader language source code. The input IR code is first analyzed during an analysis pass, during which operations, scopes, parts of scopes, and if-statement scopes are annotated for predication, mask usage, and branch protection and predication. This analysis outputs vectorization information that is then used by various sets of vectorization transformation rules to vectorize the input IR code, thus producing vectorized output IR code.
Claims20
Method of vectorizing an input shader comprising shader code in a shading language using a central processing unit (CPU) with a vector width W, wherein the CPU is not a graphics processing unit (GPU), the method comprising:
- receiving input intermediate language code compiled from the shader code, the input intermediate language code comprising divergent flow control and N elements, where N is greater than W;
- and
- vectorizing independent elements in the input intermediate language code into output intermediate language code by analyzing the input intermediate language code to identify scopes of the input intermediate language code by inserting annotations in the input intermediate language code to annotate scopes as either predicated or non-predicated, and providing and managing scope masks for the predicated scopes, respectively, the providing including inserting looping mask variables into the output intermediate code, wherein the output intermediate language code, when compiled, is executed by the CPU such that the CPU concurrently processes W of the independent elements to produce vector values, and in accordance with the scope masks the CPU correctly merges the vector values.
One or more computer-readable physical storage media storing information not in the form of a signal or carrier wave, the information enabling a computing device to perform a process, the process comprising:
- transforming input intermediate representation (IR) code compiled from shader language source code to output IR code vectorized to fit a vector width of a central processing unit (CPU) that is not a graphics processing unit, the transforming comprising:
- performing an analysis pass comprising analyzing the input IR code to identify scopes and to annotate operations as either predicated or non-predicated by inserting annotations within the input IR code, where predicated operations are provided with a mask inserted in the input IR code to merge output thereof, where each scope is annotated by a respective annotation as to whether it needs to declare and use a scope mask, parts of each scope are annotated with respective annotations inserted into the input IR code as to whether they use a protective branch, and each scope corresponding to an if-statement is annotated with respective annotations inserted into the input IR code indicating whether to predicate true and/or false branches, and
- performing a vectorization pass using the scopes and annotations in the input IR code from the analysis pass, wherein some scopes are nested within other scopes that are parent scopes, and the scope mask of a scope is computed according to a corresponding type of the scope and according to a scope mask of a parent scope.
A computing device comprising a central processing unit (CPU) and storage storing information to perform a process of vectorizing an input shader comprising shader code in a shading language using the CPU with a vector width W, wherein the CPU is not a graphics processing unit (GPU), the process comprising:
- receiving input intermediate language code compiled from a shader comprising shader program code, the input intermediate language code comprising divergent flow control and N elements, where N is greater than W;
- and
- vectorizing the input intermediate language code into output intermediate language code by analyzing the input intermediate language code and inserting annotations into the intermediate language code, automatically identifying scopes of the input intermediate language code, where scopes are annotated by respective annotations as to whether a scope mask is to be used, and providing and managing scope masks for the annotated scopes, respectively, the providing and managing including inserting the scope masks into the intermediate language code, wherein the output intermediate language code including inserted scope masks, when compiled, is executed by the CPU such that the CPU concurrently processes W of the independent elements to produce vector values, and in accordance with the scope masks the CPU correctly merges the vector values.
Dependencies are inferred from the claim text.