US 6717599 B1 Abstract Method, system, and computer program product for implementing derivative operators at an interactive rate in computer graphics systems. In an embodiment, a data structure representing the operation of one or more computer program statements is received by a compiler and transformed into a tree data structure. Nodes of the tree data structure that determine derivative information are marked, and a transform rule is applied to the marked nodes to transform the tree data structure into a data structure that can be implemented with graphics hardware interface program statements. In one embodiment of the invention, the compiler transforms shading language statements into graphics application programming interface statements that can be implemented with multiple passes through a graphics pipeline. It is a feature of the present invention that it can be implemented on a wide range of computer graphics systems.
Claims(14) 1. A method for implementing derivative operators; comprising the steps of:
(a) receiving a data structure that represents the operation of one or more computer program statements that requires derivative information, and transforming the data structure into a first data tree having at least one substructure that is implemented with arithmetic operations;
(b) generating first and second copies of said at least one substructure;
(c) inserting the first and second copies into a second data tree corresponding to a transform rule;
(d) marking a node of the first data tree that determines derivative information by:
(i) traversing the tree data structure to identify one or more nodes that determine a derivative value; and
(ii) marking at least one node identified in step (c)(i) as determining a derivative value; and
(e) applying the second data tree to the node marked in step (d) to obtain a transformed data structure, wherein the operations represented by the transformed data structure can be implemented with graphics hardware interface program statements.
2. The method of
3. The method of
(iii) marking a variable of the tree data structure that serves as an input to a node marked in step (d) (ii).
4. The method of
5. The method of
6. A system for implementing derivative operators; comprising:
means for receiving a data structure that represents the operation of one or more computer program statements that requires derivative information, and transforming the data structure into a first data tree having at least one substructure that is implemented with arithmetic operations;
means for generating first and second copies of said at least one substructure;
means for inserting the first and second copies into a second data tree corresponding to a transform rule;
means for marking a node of the data structure that determines derivative information and traversing the first tree data structure to identify each node that determines a derivative value; and
means for applying the second data tree to the node marked by said means for marking to obtain a transformed data structure, wherein the operations represented by the transformed data structure can be implemented with graphics hardware interface program statements.
7. The system of
8. The system of
9. The system of
10. The system of
11. The system of
12. The system of
a vertex operations module;
a pixel operations module;
a rasterization module coupled to said vertex operations module and said pixel operations module;
a texture memory coupled to said pixel operations module and said rasterization module;
a fragment operation module coupled to said rasterization module; and
a frame buffer coupled to said fragment operation module and said pixel operations module.
13. A computer program product comprising a computer useable medium having computer program logic recorded thereon for enabling a processor to implementing derivative operations of a shading program language in graphics hardware, said computer program logic comprising:
a receiving procedure that enables the processor to receive a data structure that represents the operation of one or more computer program statements, and transform the data structure into a first data tree having at least one substructure that is implemented with arithmetic operations, wherein at least one of the computer program statements requires derivative information;
a generating procedure that enables the processor to generate first and second copies of said at least one substructure;
an insertion procedure that enables the processor to insert the first and second copies into a second data tree corresponding to a transform rule;
a marking procedure that enables the processor to mark a node of the data structure that determines derivative information by traversing the first tree data structure to identify one or more nodes that determine a derivative value; and
a transformation procedure that enables the processor to apply the second data tree to the node marked by said marking procedure to obtain a transformed data structure having at least one substructure that is implemented with arithmetic operations, wherein the operations represented by the transformed data structure can be implemented with graphics hardware interface program statements.
14. The computer program product of
Description 1. Field of the Invention The present invention relates to computer graphics. More particularly, it relates to implementing derivative operators with graphics hardware. 2. Related Art Computer graphics systems are used to render all kinds of objects for display. In general, it is important that objects rendered for display appear as realistic to a viewer as possible. This is particularly the case, for example, in computer graphics imagery (CGI) for use in motion pictures and animation. In many applications, it is also important that the computer graphics system used to render objects for display operate at an interactive rate. As would be known to a person skilled in the relevant art, programmable shading can be used to render objects that appear very realistic to a viewer, but programmable shading cannot be implemented at an interactive rate in most, if not all, available computer graphics systems. Programmable shading involves the use of a special programming language known in the relevant art as a shading language. A shading language is used to specify the appearance and surface characteristics of objects in an image or a scene. See Pat Hanrahan's and Jim Lawson's “A language for Shading and Lighting Calculations,” in A key feature of most shading languages is the ability to implement derivative operators. A derivative operator is a function that returns a derivative value. Derivative operators are used in computer graphics. For example, derivative operators are used for determining surface normals, for determining noise frequency limits, and for antialiasing. Implementing derivative operators can be a significant task in computer graphics. Calculating derivatives can consume a significant amount of the total processing time needed to render an image. Using a shading language to implement derivative operators, however, significantly simplifies the task. A typical application program accesses shading language procedures, including derivative operators, through a programmable interface extension of a graphics application programming interface (graphics API). As would be known to a person skilled in the relevant art, a shading language is basically a library of procedures, known in the relevant art as shaders, that can be called during the rendering of an image. A shading language procedure can have very general programing constructs such as loops, conditional statements, and functions. In some examples, shading language source files (i.e., procedures) are compiled to produce object files. When a scene description using a shading language is being rendered, an object file corresponding to a shader must be retrieved from a library and loaded into the memory of the computer graphics system being used to render the scene. The object file must then be executed by the graphics system's general purpose processor in order to produce the desired effects in the rendered scene. The known methods used to implement shading language procedures, including derivative operators, place a significant burden on the graphics hardware and driver software of computer graphics systems. Graphics hardware is generally designed to support a parametric appearance model. For example, Phong lighting is evaluated per vertex with one or more texture maps applied after Gouraud interpolation of the lighting results. Graphics hardware is not designed to support the general programming constructs of a shading language. Therefore, known shading language procedures such as, for example, shading language derivative operators are translated into a general purpose programing language and compiled to run on a general purpose processor. Because general purpose processors are not designed to process millions of pixels each second, as are special purpose graphics processors and graphics hardware, the known methods used to implement shading language procedures cannot be implemented at an interactive rate on most, if not all, available computer graphic systems. What is needed is a method, system, and computer program product for implementing derivative operators at an interactive rate in computer graphics systems. In particular, what is needed is a method, system, and computer program product for implementing derivative operators with graphics hardware. The present invention provides a method, system, and computer program product for implementing derivative operators at an interactive rate in computer graphics systems. In an embodiment, a data structure representing the operation of one or more computer program statements is received by a compiler and transformed into a tree data structure. Nodes of the tree data structure that determine derivative information are marked. A transform rule is applied to the marked nodes to transform the tree data structure into a data structure that can be implemented with graphics hardware interface program statements. In one embodiment of the invention, the compiler transforms shading language statements into graphics application programming interface statements that can be implemented with multiple passes through a graphics pipeline. It is a feature of the present invention that it can be implemented on a wide range of computer graphics systems. Further features and advantages of the present invention, as well as the structure and operation of various embodiments of the present invention, are described in detail below with reference to the accompanying drawings. The accompanying drawings, which are incorporated herein and form part of the specification, illustrate the present invention and, together with the description, further serve to explain the principles of the invention and to enable a person skilled in the relevant art(s) to make and use the invention. FIG. 1 illustrates an example embodiment of a computer architecture in which the present invention can be implemented. FIG. 2 illustrates a block diagram of an example compiler according to the present invention. FIG. 3 illustrates a flowchart of a method for implementing derivative operators with graphics hardware according to an embodiment of the present invention. FIG. 4 illustrates an example parametric patch primitive in accordance with the present invention. FIG. 5 illustrates an example source code having embedded derivative operators according to an embodiment of the present invention. FIG. 6 illustrates an example tree data structure according to an embodiment of the present invention. FIG. 7A illustrates an example derivative transform rule according to an embodiment of the present invention. FIG. 7B illustrates an example transformed tree data structure according to an embodiment of the present invention. FIG. 8 illustrates an example graphics system according to an embodiment of the present invention. FIG. 9 illustrates an example computer system that can implement embodiments of the present invention. The present invention is described with reference to the accompanying drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Additionally, the left-most digit of a reference number identifies the drawing in which the reference number first appears. The present invention provides a method, system, and computer program product for implementing derivative operators at an interactive rate in computer graphics systems. In one embodiment of the invention, a compiler transforms shading language statements into graphics API statements that can be implemented with multiple passes through a graphics pipeline. It is a feature of the present invention that it can be implemented on a wide range of available computer graphics systems including, but not limited to, a general purpose computer having a graphics processor (single chip or multiple chip), a specially designed graphics computer, a graphics machine, a parallel processing graphics machine, a graphics card, graphics hardware, a graphics accelerator, a computer network architecture, et cetera. As used herein, the term “interactive rate” refers to a rate at which images can be rendered without undue delay upon a user or application. This interactive rate can include, but is not limited to, a pixel fill rate of approximately 400 million pixels/sec or 6.66 million pixels/frame at 60 Hz. In an embodiment, this rate is equal to approximately 200 million pixels/sec or 3.33 million pixels/frame at 60 Hz. These example interactive rates are illustrative. Slower or faster interactive rates may be implemented. It is a feature of the present invention that it may be implemented in many different ways, in many environments, and on many different computers graphics systems. For example, FIG. 1 illustrates a block diagram of an example computer graphics architecture Architecture The application program layer comprises application The compiler layer comprises compiler The graphics toolkit layer comprises pass library The graphics API layer comprises graphics hardware interface The graphics hardware layer comprises graphics hardware FIG. 2 illustrates a block diagram of an example compiler As shown in FIG. 2, compiler In another embodiment, input In an embodiment of the present invention, where input In an embodiment, derivative transform rules Storing pattern match rules in a text file allows the match rules to be readily edited or changed. By changing the match rules, compiler In another embodiment of the present invention, derivative transform rules It is a feature of the present invention that it permits the continued use of shading language statements previously developed by application users. When an application It is another feature of the present invention that it permits the graphics hardware FIG. 3 illustrates a flowchart of a method Referring to FIG. 4, an example parametric patch primitive As would be known to a person skilled in the relevant art given the discussion herein, it is desirable that an object created using parametric patch primitive A typical shading language statement that implements derivative operators is a statement that returns a differential area value at a point p. The square root of a differential area is a length, which can be used as an approximation of the amount that a point p changes between adjacent points in a texture. This shading language statement, denoted herein as area(p), is commonly used to estimate the size of a filter that is needed to antialias a texture. The following shading language procedure or shader (expressed in pseudo-code), for example, would return a differential surface area at a point p, which could then be used to estimate the size of a filter that is needed to antialias a texture:
where: Du(p) returns the derivative at p in the u parametric direction; Dv(p) returns the derivative at p in the v parametric direction; Du(p)*du defines the amount that p changes between adjacent shading samples when moving in the u parametric direction; Dv(p)*dv defines the amount that p changes between adjacent shading samples when moving in the v parametric direction; (Du(p)*du){circumflex over ( )}(Dv(p)*dv) is the cross-product of the two vectors represented by (Du(p)*du) and (Dv(p)*dv); and length ( ) returns the length of a vector. As would be known by a person skilled in the relevant art, the cross-product of the two vectors produces a third vector that is mutually perpendicular to the two vectors and that has a length equal to the area of the parallelogram formed by the two vectors. This concept can be seen in FIG. 4, by noting that the surface normal at point As would be known to a person skilled in the relevant art given the discussion herein, many shading language statements implement derivative operators. These statements, however, can be expressed using combinations of the derivation operators Du(p), which returns the derivative at p in the u parametric direction, and Dv(p), which returns the derivative at p in the v parametric direction. As will become apparent to a person skilled in the relevant art given the discussion herein, implementation of the derivative operators Du(p) and Dv(p) in graphics hardware are very similar. Thus, the discussion that follows focuses primarily on implementing Du(p) in graphics hardware. It should be noted however, that the discussion that follows also teaches a person skilled in the relevant art how to use the present invention to implement any shading language statement that implements a derivative operator. More generally, the discussion that follows teaches a person skilled in the relevant art how to implement any derivative operator in graphics hardware, even derivative operators that are not implemented by or associated with a shading language. FIG. 5 illustrates an example source code Referring to FIG. 3, step FIG. 6 illustrates an example tree data structure As can be seen in FIG. 6, the value of “b” is a function of “a”, “u”, and “v”. The value of “b” is determined by implementing structure Referring to FIG. 3 again, in step In an embodiment of the invention, after the nodes in a tree data structure requiring derivative information are marked in accordance with step As would be known to a person skilled in the relevant art given the discussion herein, it is possible to calculate a derivative value, given a value “u”, using the following equation: where: F(u) is a specific function evaluated at the value u, and u+du is a value at an offset du from u. Representations of EQ. 1 can be used to form a part of derivative transform rules FIG. 7A illustrates an example derivative transform rule In an embodiment of the present invention, derivative transform rule FIG. 7B illustrates an example application of derivative transform rule In an embodiment of the present invention, several steps are taken to generate tree data structure In creating the tree data structure As would be known to a person skilled in the relevant art, most arithmetic operations can be performed with graphics hardware using blending operations. A blending operation is an operation according to EQ. 2. that typically involves, for example, combining a first pixel with a second pixel, which is stored in a frame buffer, to obtain a resultant pixel that is typically stored the frame buffer.
where: P P P bf Blending operations in graphics hardware are typically implemented using a hardware interface or graphics API such as, but not limited to, OPENGL. For example, the frame buffer blending mode of OPENGL supports the arithmetic operations of addition, subtraction, and multiplication, as well as other operation. A divide operation can also be implemented as multiplication by a reciprocal. More complex operation can also be implemented using combinations of the above arithmetic operations and other operations supported by graphics APIs such as OPENGL, as would be known to a person skilled in the relevant art given the discussion herein. For example, a dot product of two vectors can be computed in graphics hardware using component-wise multiplication followed by a pixel copy with a color matrix that sums three resultant vector components together. In an embodiment of the present invention, tree data structure FIG. 8 illustrates an example graphics system Graphics system Graphics pipeline Vertex operation module Rasterization module Fragment operation module Frame buffer The function of pixel operation module Display As described herein, the present invention can be implemented on a large number of graphics systems. Thus, graphics system Referring to FIG. 9, an example of a computer system Computer system Computer system In alternative embodiments, secondary memory In an embodiment, computer system Computer system Computer system The present invention can be implemented using software running (that is, executing) in an environment similar to that described above with respect to FIG. Computer programs (also called computer control logic) are stored in main memory In an embodiment where the invention is implemented using software, the software may be stored in a computer program product and loaded into computer system In another embodiment, the invention is implemented primarily in firmware and/or hardware using, for example, hardware components such as application specific integrated circuits (ASICs). Implementation of a hardware state machine so as to perform the functions described herein will be apparent to a person skilled in the relevant art. Various embodiments of the present invention have been described above, which are independent of image complexity and are capable of being implemented on an interactive graphics machine. It should be understood that these embodiments have been presented by way of example only, and not limitation. It will be understood by those skilled in the relevant art that various changes in form and details of the embodiments described above may be made without departing from the spirit and scope of the present invention as defined in the claims. Thus, the breadth and scope of the present invention should not be limited by any of the above-described exemplary embodiments, but should be defined only in accordance with the following claims and their equivalents. Patent Citations
Non-Patent Citations
Referenced by
Classifications
Legal Events
Rotate |