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.
An 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 of the presently disclosed invention, a method for rendering an image with a graphics processor driven by a multi-pass shader program including a predetermined set of default steps is disclosed. Through the method, the multi-pass shader program is pre-complied to generate binary execution code for execution by the graphics processor. A first parameter of the image is received. A first pass of the multi-pass shader program is executed utilizing the binary execution code and the first parameter to obtain a first data value. At least one default step corresponding to a second pass of the multi-pass shader program is modified based upon the first data value. A second pass of the multi-pass shader is executed utilizing the binary execution code including the at least one default step as modified based upon the first data value to obtain a second data value. An operation is performed on the first data value and the second data value to obtain image rendering data. The image is then rendered, a portion of the image based upon the image rendering data. The multi-pass shader program effectuates a photorealistic effect in the portion of the image through the alteration of a color based on the angle and distance of an object with respect to a light source in the portion of the image.
In a second embodiment a further method for rendering an image with a graphics processor driven by a multi-pass shader program including a predetermined set of default steps is provided. The method includes pre-compiling the multi-pass shader program to generate binary execution code for execution by the graphics processor, receiving a first parameter of the image, and executing a first pass of the multi-pass shader program utilizing the binary execution code and the first parameter to obtain a first data value. A second parameter of the image is received and at least one default step of a second pass of the multi-pass shader program is modified based upon the second parameter. A second pass of the multi-pass shader program is executed utilizing the binary execution code including the at least one default step as modified based upon the second parameter to obtain a second data value and an operation is performed on the first data value and the second data value to obtain image rendering data. The image is rendered, a portion of the image based upon the image rendering data. The multi-pass shader program effectuates a photorealistic effect in the portion of the image through the alteration of a color based on the angle and distance of an object with respect to a light source in the portion of the image.
In a third claimed embodiment, a graphics processor driven by a multi-pass shader program including a predetermined set of default steps is disclosed. The graphics processor is configured to receive a first parameter of the image, execute a first pass of the multi-pass shader program utilizing binary execution code pre-compiled by the multi-pass shader, and the first parameter to obtain a first data value. The processor is further configured to modify at least one default step of a second pass of the multi-pass shader program based upon the first data value and execute a second pass of the multi-pass shader program utilizing the binary execution code including the at least one default step as modified based upon the first data value to obtain a second data value. An image is rendered in response to execution of the graphics processor, a portion of the image based upon the image rendering data. The multi-pass shader program effectuates a photorealistic effect in the portion of the image through the alteration of a color based on the angle and distance of an object with respect to a light source in the portion of the image.
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.
The present application is a continuation and claims the priority benefit of U.S. patent application Ser. No. 10/959,695 entitled “Application Binary Interface for Multi-Pass Shaders” filed Oct. 6, 2004, the disclosure of which is incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
Parent | 10959695 | Oct 2004 | US |
Child | 12287317 | US |