Application binary interface for multi-pass shaders
An application binary interface includes a descriptor specifying a binary shader for each pass of a multi-pass shader. The application binary interface also includes a graphics state of a graphics object for each pass of the multi-pass shader. The graphics state for the first pass is an initial graphics state of the graphics object. The graphics state for each subsequent pass specifies a change from the graphics state of a previous pass. The application binary interface further includes parameters for the binary shaders. The application binary interface links the binary shaders together based on the parameters. Further, the parameters of the binary shaders may be modified at run time to configure the multi-pass shader. The binary shader of each pass is then executed based on the graphics state and parameters of the pass to render the graphics object.
Latest Patents:
1. Field of the Invention
The present invention relates generally to computer graphics. More particularly, the present invention relates to systems and methods of controlling precompiled computer programs in computer graphics systems.
2. Background Art
Prior art computer graphics systems typically execute an application program, such as a computer video game program, to generate graphics images for display on a computer screen. One type of prior art computer graphics system includes an on-line compiler. In this type of computing system, the computer graphics system compiles portions of the application program while executing other portions of the application program in real time. In this way, a first portion of the application program executing in the computer graphics system can provide run time parameters for compiling a second portion of the application program.
In some situations, a portion of the application program written specifically for graphics hardware in the computer graphics system can be simplified by using run time parameters during compilation. For instance, a first portion of the application program may include a loop construct having a loop count parameter, and the compiler can unroll the loop construct based on a value of the loop count parameter provided by a second portion of the application program at run time. Including a compiler in the computer graphics system, however, increases the cost and complexity of the graphics computer system.
Another type of prior art computer graphics system executes precompiled application programs. In this type of computer graphics system, an application program is compiled into binary programs by using an off-line compiler. The binary programs are then provided to the computer graphics system, which executes the binary programs. Precompiling the application program avoids the need for an on-line compiler but may complicate portions of the application program written specifically for graphics hardware in the computer graphics system. Specifically, these portions of the application program may require fixed parameters at compile time.
One type of program typically found in an application program written for a computer graphics systems is a shader. A shader generates visual effects for graphics objects. In many computer graphics systems, the shader controls multiple texture units in the graphics hardware, each of which can access samples from a texture. Moreover, the shader generates colors for the graphics object based on the textures accessed from the texture units.
Some shaders require a greater number of textures for creating a visual effect than the number of texture units available in the graphics hardware of a computer graphics system. Consequently, some compilers cannot compile these application programs for these computer graphics systems. Other compilers generate a multi-pass shader by breaking up the task of creating a visual effect into passes such that each pass requires no more texture units than the number of texture units available in the computer graphics system. Each pass of the multi-pass shader performs an operation on a graphics to generate a result. In this way, a pass of the multi-pass shader may perform an operation based on a result generated in a previous pass.
In those types of computer graphics systems that compile programs on-line, an application program can modify parameters of a shader to configure the shader at run time, which may simplify the task of programming the shader. In contrast, those computer graphics systems that rely on an off-line compiler may need to fix some parameters of the shader at the time of compilation (i.e., compile time). Consequently, the shader (i.e., the precompiled shader) is not configurable at run time, which may complicate the task of programming the shader.
In light of the above, there exists a need to simplify the task of programming a multi-pass shader. Additionally, these exists a need for a precompiled multi-pass shader that is configurable at run time.
SUMMARY OF THE INVENTIONAn application binary interface addresses the need for simplifying the task of programming a multi-pass shader. Further, the application binary interface addresses the need for a precompiled multi-pass shader that is configurable at run time. For each pass of a multi-pass shader, the application binary interface specifies a binary shader, one or more parameters for the binary shader, and a graphics state. The graphics state for a first pass specifies an initial graphics state of a graphics object, and the graphics state of each subsequent pass specifies a change from the graphics state of a previous pass. The parameters link the binary shaders together so that a binary shader of a given pass can use a result generated by a binary shader of a previous pass. The binary application interface simplifies the task of programming the multi-pass shader by specifying the binary shaders, parameters for the binary shaders, and graphics states for the multi-pass shader in a binary file.
In one embodiment, a binary application program determines the binary shaders, parameters, and graphics states for the multi-pass shader based on the binary application interface. Further, the application program can modify the parameters of the application binary interface at run time to configure the multi-pass shader. The binary shader for each pass is then executed based on the parameters of the binary shader and the graphics state of the pass to render the graphics object.
The application binary interface, in accordance with one embodiment of the present invention, includes a descriptor for each pass of a multi-pass shader that specifies a binary shader for the pass. The binary application interface also includes one or more parameters for each binary shader. Further, the binary application interface includes a graphics state for each pass.
A system for generating an application binary interface, in accordance with one embodiment of the present invention includes a memory system that stores a computer program for rendering a graphics object and a compiler. The system further includes a computing processor that executes the compiler on the computer program to generate an application binary interface. The application binary interface includes a descriptor for each pass of the multi-pass shader that specifies a binary shader of the pass. The application binary interface also includes one or more parameters for the binary shader of each pass and a graphics state of each pass.
In a method of rendering a graphics object, in accordance with one embodiment of the present invention, a binary shader and a graphics state of a first pass of a multi-pass shader are identified based on an application binary interface. The binary shader of the first pass is then executed based on the graphics state of the first pass to generate a result for the first pass. A binary shader and a graphics state of a second pass of the multi-pass shader are also identified based on the application binary interface. The binary shader of the second pass is then executed based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass. This process may then be repeated for any additional passes. In one embodiment, the result of a final pass is a color of the graphics object.
A system for rendering a graphics object, in accordance with the present invention, includes a computing processor that identifies both a binary shader and a graphics state of a first pass of a multi-pass shader based on an application binary interface. The computing processor also identifies both a graphics state and a binary shader of a second pass of the multi-pass shader based on the application binary interface. The system further includes a graphics processor that executes the binary shader of the first pass based on the graphics state of the first pass to generate a result for the first pass. Additionally, the graphics processor executes the binary shader of the second pass based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass. This process may then be repeated for any additional passes. In one embodiment, the result of a final pass is a color of the graphics object.
A computer program product for rendering a graphics object, in accordance with the present invention, includes computer program code for identifying both a binary shader and a graphics state of a first pass of a multi-pass shader based on an application binary interface, and executing the binary shader of the first pass based on the graphics state of the first pass to generate a result for the first pass. The computer program product further includes computer program code for identifying both a binary shader and a graphics state of a second pass of the multi-pass shader based on the application binary interface, and executing the binary shader of the second pass based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass. This process may then be repeated for any additional passes. In one embodiment, the result of a final pass is a color of the graphics object.
BRIEF DESCRIPTION OF THE DRAWINGS
According to one embodiment of the present invention, an application binary interface includes a descriptor for each pass of a multi-pass shader specifying a binary shader for the pass. The application binary interface also includes one or more parameters for the binary shader of each pass. Further, the application binary interface includes a graphics state of each pass. The graphics state of the first pass is an initial graphics state of a graphics object, and the graphics state of each subsequent pass specifies a change from the graphics state of a previous pass. The parameters link the binary shaders together such that a binary shader of a given pass can use a result generated by a binary shader of a previous pass. The binary shader of each pass is then executed based on the graphics state and the parameters of the pass to render the graphics object.
In one embodiment, the computer program 110 is a video game program. In this embodiment, the computer graphics system 120 executes the binary program 125 to render graphics images for the video game program. In another embodiment, the computer system 105 includes the computer graphics system 120.
In one embodiment, the binary program 125 includes computer program code stored on a compact disc read-only memory (CD-ROM). In another embodiment, the binary program 125 includes computer program code stored on a digital versatile disc (DVD). In still another embodiment, the binary program 125 includes computer program code stored on a portable memory device, such as a flash memory device.
In one embodiment, the graphics pipeline 400 includes a plurality of texture units 415, each of which can access one or more textures. In this embodiment, each texture unit 415 concurrently generates an intermediate value for each pixel based on the texture accessed by the texture unit 415, and the raster unit 410 combines the intermediate values of the pixel to generate the value of the pixel. In another embodiment, the value of the pixel represents a color of the pixel.
In one embodiment, the compiler 115 (
In another embodiment, a graphics state can specify characteristics of the computer graphics system 120 (
According to an exemplary embodiment, the application 500 (
In another embodiment, the value of a variable is limited to a predetermined set of values in the application 500. In this embodiment, the compiler 115 generates a binary shader 605 for each value in the predetermined set by setting the parameter to the value. In this way, the parameter of each binary shaders 605 is fixed at compile time. The binary application 600 then determines the value of the variable at run time to select the binary shader 605 identified by the value of the variable. In this way, the binary application 600 configures a multi-pass shader at run time based on the value of the variable.
A representation of a shader, a multi-pass shader, and an exemplary application binary interface 610 for the multi-pass shader is depicted in Table 1. As depicted in Table 1, the shader is represented by the expression “output=cosine (texture_lookup(x,y))” in which “x” and “y” are input parameters and “output” represents an output value of the shader. The first pass of the multi-pass shader is represented by the subexpression “tmp=texture_lookup (x, y)” and the second pass is represented by the subexpression “output=cosine (tmp).” In the first pass, “x” and “y” are input parameters and “tmp” represents an output value of the first pass. In the second pass, “tmp” is an input parameter and “output” represents an output value of the second pass.
As is also depicted in table 1, the application binary interface 610 specifies the first pass and the second pass of the multi-pass shader. For the first pass, a descriptor is represented by “texture_lookup”, which identifies a binary shader for the first pass. Further, input parameters for the binary shader of the first pass are represented by “x” and “y”, and an output parameter for the binary shader of the first pass is represented by “tmp”. The output parameter “tmp” represents an output value for the binary shader of the first pass. Further, in this embodiment, the output value for the binary shader of the first pass is a result for the first pass. Additionally, an initial graphics state for a graphics object is represented by “texture unit 1”, which specifies that a first texture unit will access a texture for the binary shader of the first pass.
For the second pass, a descriptor is represented by “cosine”, which represents a binary shader for the second pass. Further, an input parameter for the binary shader of the second pass is represented by “tmp”, which is the output parameter of the first pass. Accordingly, the input parameter “tmp” for the binary shader of the second pass represents the output value of the binary shader of the first pass. Additionally, a graphics state of the second pass is represented by “frame buffer”, which specifies that the result of the second pass will be stored in a frame buffer. In this way, the graphics state of the second pass specifies a change from the graphics state of the first pass. Further, the parameter “tmp” links the binary shader of the second pass to the binary shader of the first pass such that the result of the first pass is an input parameter for the binary shader of the second pass. The output parameter “output” represents an output value for the binary shader of the second pass. Further, in this embodiment, the output value for the binary shader of the second pass is a result for the second pass.
In step 710, the compiler 115 compiles the shader 505 to generate the next binary shader 605 and the next graphics state for the next pass of a multi-pass shader. In one embodiment, the compiler 115 compiles the application 500 together with the shader 505 to generate the binary shader 605 and the graphics state for this next pass. It is to be appreciated that step 710 is optional in the present invention.
In another embodiment, the compiler 115 performs steps 705 and 710 concurrently to generate the binary shader 605 and the graphics state for each pass of the multi-pass shader. In a further embodiment, the compiler 115 also generates the binary application 600 (
In step 715, the compiler 115 determines whether the multi-pass shader includes additional passes. If the multi-pass shader includes additional passes, the method returns to step 710, otherwise the method proceeds to step 720. It is to be appreciated that step 715 is optional in the present invention.
In step 720, the compiler 115 generates a descriptor and one or more parameters for the first pass of the multi-pass shader. The descriptor of the first pass specifies the first binary shader. In one embodiment, the compiler 115 binds at least one parameter of the first pass to the first binary shader 605 at compile time. In another embodiment, the binary application 600 (
In step 725, the compiler 115 generates a descriptor and one or more parameters for the next pass of the multi-pass shader. The descriptor of this pass specifies the binary shader of this pass. In one embodiment, the compiler 115 binds at least one parameter of this pass to the binary shader 605 of this pass at compile time. In another embodiment, the binary application 600 binds at least one parameter of this pass to the binary shader 605 at run time. In still another embodiment, the compiler 115 binds some of the parameters of this pass to the binary shader at compile time and the binary application 605 binds some of the parameters of this pass to the binary shader at run time.
In step 730, the compiler 115 determines whether the multi-pass shader includes additional passes. If the multi-pass shader includes additional passes, the method returns to step 725, otherwise the method ends. It is to be appreciated the application binary interface 610 comprises the parameter(s) generated for each pass of the multi-pass shader.
In one embodiment, the compiler 115 can perform steps 720-730 concurrently to generate the parameters(s) for each pass of the multi-pass shader. In another embodiment of the present invention, the compiler 115 can perform steps 705-730 concurrently to generate the binary shader 605, the graphics state, and the parameter(s) for each pass of the multi-pass shader. In a further embodiment, the compiler can also generate the binary application 600. In still another embodiment, the compiler 115 can perform steps 705 and 720 concurrently. In yet another embodiment, the compiler can perform steps 710 and 725 concurrently.
In step 810, the binary application 600 identifies the binary shader 605 (
In step 815, the graphics processor 325 executes the first pass of the multi-pass shader by executing the first binary shader 605 based on the first graphics state to generate a result for the first pass. In one embodiment, the result for the first pass is a value of each pixel in the graphics object. In a further embodiment, the graphics processor 325 (
In step 820, the binary application 600 identifies the binary shader 605 and the graphics state for the next pass of the multi-pass shader based on the application binary interface 610. In one embodiment, the descriptor of this pass specifies the binary shader 605 of the pass. In this embodiment, the binary application 600 identifies the binary shader 605 of this pass based on the descriptor of this pass. In another embodiment, the descriptor specifies a plurality of binary shaders 605. In this embodiment, the binary application 600 selects the binary shader 605 of this pass from the plurality of binary shaders 605 at run time based on one or more parameters for the binary shader 605 of this pass in the application binary interface 610. In a further embodiment, some or all of the parameters for the binary shader 605 of this pass may be a result of a previous pass.
In step 825, the graphics processor 325 executes this next pass of the multi-pass shader by executing the binary shader 605 based on the graphics state to generate a result for this pass. In one embodiment, the result for this pass is a value of each pixel in the graphics object. In a further embodiment, the graphics processor 325 includes multiple texture units, each of which can access a texture. In this further embodiment, the graphics processor 325 executes the binary shader on the multiple texture units in the graphics processor 325 to generate the value for each pixel based on the textures accessed by the texture units.
In another embodiment, the graphics processor 325 generates the value of each pixel based on the value of the pixel generated in a previous pass. In this embodiment, the graphics state of this pass specifies the texture unit storing the intermediate color of each pixel generated in the previous pass. Consequently, the binary shader 605 of the current pass can access the value of the pixel generated in the previous pass to generate the value of the pixel for this pass. In a further embodiment, the value of the pixel generated for the last pass of the multi-pass shader is a color of the pixel. In another further embodiment, the graphics processor 325 stores the value of each pixel for each pass into the frame buffer 420 (
In step 830, the binary application 600 determines whether the multi-pass shader includes an additional pass based on the application binary interface 610. If the multi-pass shader includes an additional pass, the method returns to step 820, otherwise the method ends.
The embodiments discussed herein are illustrative of the present invention. As these embodiments of the present invention are described with reference to illustrations, various modifications or adaptations of the methods and/or specific structures described may become apparent to those skilled in the art. All such modifications, adaptations, or variations that rely upon the teachings of the present invention, and through which these teachings have advanced the art, are considered to be within the spirit and scope of the present invention. Hence, these descriptions and drawings should not be considered in a limiting sense, as it is understood that the present invention is in no way limited to only the embodiments illustrated.
Claims
1. An application binary interface for a multi-pass shader comprising a plurality of passes, the application binary interface comprising:
- a descriptor for each pass of the plurality of passes for specifying a binary shader of the pass;
- at least one parameter for the binary shader of each pass; and
- a graphics state of each pass.
2. The application binary interface of claim 1, wherein the plurality of passes are arranged in series, and the graphics state of a subsequent pass specifies a change from the graphics state of a previous pass.
3. The application binary interface of claim 1, wherein the plurality of passes comprises a first pass and a second pass, the at least one parameter for the binary shader of the first pass comprises an output parameter, and the at least one parameter for the binary shader of the second pass comprises an input parameter, the input parameter for the binary shader of the second pass being the output parameter for the binary shader of the first pass.
4. The application binary interface of claim 1, wherein the graphics state of a first pass of the plurality of passes is an initial graphics state for a graphics object.
5. The application binary interface of claim 4, wherein the graphics state of a second pass of the plurality of passes specifies a change from the graphics state of the first pass.
6. The application binary interface of claim 1, wherein the descriptor of each pass specifies the binary shader of the pass.
7. The application binary interface of claim 1, wherein the descriptor of each pass specifies a plurality of binary shaders, and the at least one parameter for the binary shader of the pass identifies the binary shader of the pass from the plurality of binary shaders.
8. The application binary interface of claim 7, wherein the at least one parameter for the binary shader of each pass is modifiable at run time to configure the multi-pass shader.
9. The application binary interface of claim 1, wherein the application binary interface is a binary file.
10. A system for generating an application binary interface for a multi-pass shader comprising a plurality of passess, the system comprising:
- a memory system configured to store a computer program for rendering a graphics object, the memory system further configured to store a compiler; and
- a computing processor configured to execute the compiler on the computer program to generate an application binary interface comprising a descriptor for each pass of the plurality of passes for specifying a binary shader of the pass, at least one parameter for the binary shader of each pass, and a graphics state of each pass.
11. The system of claim 10, wherein the computing processor is further configured to execute the compiler on the computer program to generate the binary shader of each pass.
12. The system of claim 10, wherein the plurality of passes are arranged in series, and the graphics state of a subsequent pass specifies a change from the graphics state of a previous pass.
13. The system of claim 10, wherein the plurality of passes comprises a first pass and a second pass, the at least one parameter for the binary shader of the first pass comprises an output parameter, and the at least one parameter for the binary shader of the second pass comprises an input parameter, the input parameter for the binary shader of the second pass being the output parameter for the binary shader of the first pass.
14. The system of claim 10, wherein the graphics state of a first pass of the plurality of passes is an initial graphics state for a graphics object.
15. The system of claim 14, wherein the graphics state of a second pass of the plurality of passes specifies a change from the graphics state of the first pass.
16. The system of claim 10, wherein the descriptor of each pass specifies the binary shader of the pass.
17. The system of claim 10, wherein the descriptor of each pass specifies a plurality of binary shaders, and the at least one parameter for the binary shader of the pass identifies the binary shader of the pass from the plurality of binary shaders.
18. The system of claim 17, wherein the computer processor is configured to modify the at least one parameter for the binary shader of each pass at run time to configure the multi-pass shader.
19. The system of claim 10, wherein the application binary interface is a binary file.
20. A method of rendering a graphics object, the method comprising:
- identifying a binary shader of a first pass of a multi-pass shader based on an application binary interface;
- identifying a graphics state of the first pass based on the application binary interface;
- executing the binary shader of the first pass based on the graphics state of the first pass to generate a result for the first pass;
- identifying a binary shader of a second pass of the multi-pass shader based on the application binary interface;
- identifying a graphics state of the second pass based on the application binary interface; and
- executing the binary shader of the second pass based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass.
21. The method of claim 20, wherein the result of the first pass comprises a first value of each pixel of a plurality of pixels of the graphics object, and the result of the second pass comprises a second value of each pixel of the plurality of pixels.
22. The method of claim 21, wherein the first value of each pixel in the plurality of pixels represents a color of the pixel.
23. The method of claim 21, wherein the second value of each pixel in the plurality of pixels represents a color of the pixel.
24. The method of claim 20, wherein the application binary interface comprises an output parameter for the binary shader of the first pass and an input parameter for the binary shader of the second pass, the output parameter for the binary shader of the first pass being the input parameter for the binary shader of the second pass.
25. The method of claim 24, wherein the output parameter for the binary shader of the first pass specifies the result of the first pass.
26. The method of claim 20, wherein the application binary interface comprises an output parameter for the binary shader of the second pass, the output parameter for the binary shader of the second pass specifying the result of the second pass.
27. The method of claim 20, wherein identifying the binary shader of the first pass of the multi-pass shader based on the application binary interface comprises selecting the binary shader of the first pass based on a descriptor of the first pass.
28. The method of claim 20, wherein identifying the binary shader of the first pass of the multi-pass shader based on the application binary interface comprises selecting the binary shader of the first pass based on a descriptor of the first pass and at least one parameter for the binary shader of the first pass.
29. A system for rendering a graphics object, the system comprising:
- a computing processor configured to identify a binary shader of a first pass of a multi-pass shader, a graphics state of the first pass, a binary shader of a second pass of the multi-pass shader, and a graphics state of the second pass, based on an application binary interface; and
- a graphics processor configured to execute the binary shader of the first pass based on the graphics state of the first pass to generate a result for the first pass, the graphics processor further configured to execute the binary shader of the second pass based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass.
30. The system of claim 29, wherein the graphics object comprises a plurality of pixels, the result of the first pass comprises a first value of each pixel in the plurality of pixels, and the result of the second pass comprises a second value of each pixel in the plurality of pixels.
31. The system of claim 30, wherein the first value of each pixel in the plurality of pixels represents a color of the pixel.
32. The system of claim 30, wherein the second value of each pixel in the plurality of pixels represents a color of the pixel.
33. The system of claim 29, wherein the application binary interface comprises an output parameter for the binary shader of the first pass and an input parameter for the binary shader of the second pass, the output parameter for the binary shader of the first pass being the input parameter for the binary shader of the second pass.
34. The system of claim 29, wherein the computing processor is further configured to select the binary shader of the first pass based on a descriptor of the first pass.
35. The system of claim 29, wherein the computing processor is further configured to select the binary shader of the first pass based on a descriptor of the first pass and at least one parameter for the binary shader of the first pass.
36. A computer program product comprising computer program code for performing a method of rendering a graphics object, the method comprising:
- identifying a binary shader of a first pass of a multi-pass shader based on an application binary interface;
- identifying a graphics state of the first pass based on the application binary interface;
- executing the binary shader of the first pass based on the graphics state of the first pass to generate a result for the first pass;
- identifying a binary shader of a second pass of the multi-pass shader based on the application binary interface;
- identifying a graphics state of the second pass based on the application binary interface; and
- executing the binary shader of the second pass based on the graphics state of the second pass and the result of the first pass to generate a result for the second pass.
37. The computer program product of claim 36, wherein the graphics state of the second pass specifies a change from the graphics state of the first pass.
Type: Application
Filed: Oct 6, 2004
Publication Date: Apr 6, 2006
Applicant:
Inventors: Robin Green (Redwood City, CA), Axel Mamode (Mountain View, CA), Roy Hashimoto (Redwood City, CA)
Application Number: 10/959,695
International Classification: G06T 15/50 (20060101); G06T 15/60 (20060101);