A graphics processing unit (GPU) may be described as a microprocessor designed to render graphical images efficiently for display, speeding up the rendering process and relieving the central processing unit (CPU) of this task. A computer system having a GPU as well as a CPU can be expected to render graphical images faster than a computer system without a GPU and to be more efficient in performing other computational tasks because the CPU is not being burdened with rendering graphical images. In a multi-color image handed to a GPU for rendering, color shading is described by a color gradient which includes two parameters: a color shade, and a distance in number of pixels for which that shade is to be displayed.
The drawings illustrate by example implementations of the invention.
In the drawings and in this description, examples and details are used to illustrate principles of the invention. Other configurations may suggest themselves. Parameters are approximate. Terms of orientation such as up, down, top, and bottom are used only for convenience to indicate spatial relationships of components with respect to each other, and except as otherwise indicated, orientation with respect to external axes is not critical. Some known methods and structures have not been described in detail in order to avoid obscuring the invention.
Methods defined by the claims may comprise steps in addition to those listed, and except as indicated in the claims themselves the steps may be performed in another order than that given. The systems and methods described herein may be implemented in various forms of hardware, software, firmware, special purpose processors, or a combination thereof. At least a portion of the invention may be implemented as an application comprising program instructions that are tangibly embodied on one or more program storage devices, for example hard disks, floppy disks, CDROMs, RAM, and ROM, or that may be executed remotely over a network. Connections between system modules or the logic flow of method steps may differ depending on the manner in which the invention is programmed.
In light of the foregoing, the invention may be practiced without limitation to the details and arrangements as described. The invention is to be limited only by the claims, not by the drawings or this description.
Rendering images in a GPU typically requires creating a flattened linearly-sampled pixel map. Such a map may range from a one-dimensional list of 1,024 pixels or more to a full two-dimensional color gradient of thousands of pixels in each dimension. The map gives various color shades and, for each color shade, a distance in number of pixels. To render such a gradient for display, the GPU samples the gradient in increments of fixed size. This sampling can be inefficient because using a fixed sample size may result in taking more samples than are actually needed. Or, if the sample size is larger than some of the actual distances, the sampling can introduce artifacts and may even result in missing colors. Accordingly there is a need for a way to have a GPU render color gradients in a pixel map efficiently and without altering the image.
In some embodiments scaling the distances comprises dividing the value of each distance by the value of the largest distance.
In some embodiments the scaled distances are converted into fractions by using a Greatest Common Divisor (GCD) technique such as prime factorization and the Euclidean algorithm. The GCD of two numbers is the largest number that divides both of them without leaving a remainder.
Finding the GCD of numbers of the relatively manageable sizes that may be encountered as distances between color shades by prime factorization is relatively straightforward. One technique is simply to divide the distance repeatedly by prime integers, each no larger than the square root of the number into which it is being divided, until what is left is a set of prime integers.
Using the Euclidean algorithm to find the GCD is based on the principle that the greatest common divisor of two numbers does not change if the smaller number is subtracted from the larger number. For example, 21 is the GCD of 252 and 105 (252=21×12; 105=21×5); since 252−105=147, the GCD of 147 and 105 is also 21. Since the larger of the two numbers is reduced, repeating this process gives successively smaller numbers until one of them is zero. When that occurs, the GCD is the remaining nonzero number. This algorithm may be computationally more efficient that prime factorization.
Determining the largest common denominator may be accomplished by determining a Least Common Multiple (LCM), that is, the smallest integer that is a multiple of each of the denominators. The texture may be provided by linear interpolation between the samples.
For example, assume a color gradient in which a color of Shade A is between positions 0 and 1 and a color of Shade B is between positions 1 and 5. The distances between shades are {0, 1, 4}. Scaling these distances so the largest is one results in {0, 0.25, 1}. Converting these scaled distances into fractions results in {0, ¼, 1/1 }. The largest common denominator of these fractions is 4. Converting the fractions into fractions having this largest common denominator of 4 results in { 0/4, ¼, 4/4}. The numerators of these fractions are used to provide samples indicating color shades at intervals of the largest common denominator which is ¼. These samples include Shade A at position 0 and Shade B at positions 1, 2, 3, and 4. In this way, only five samples have been taken and there has been no loss of precision when compared with any procedure involving more samples. Linear interpolation may be used between the samples to provide the texture having more than 5 samples were taken. The texture is used to display a visual image on a visual display.
As another example, assume a color gradient in which:
shade A is between positions 0 and 200,
shade B is between positions 200 and 250,
shade C is between 250 and 700, and
shade D is between 700 and 1000.
The distances between shades are {0, 200, 50, 450, and 300}. Scaling these distances results in {0, 4/9, 1/9, 1, ⅔}. Converting these scaled distances into fractions results in { 0/9, 4/9, 1/9. 9/9, and 6/9}. The largest common denominator is 9. Using the numerators to provide samples results in a texture having Shade A at positions 0 and 111, Shade B at 222, Shade C at 333, 444, 555, and 666, and Shade D at 777, 888 and 999. Only 9 samples were needed even though there were 1000 possible positions.
As shown in
In some embodiments the memory may comprise a cache memory that may be integral with the graphics processor or included on a separate device.
A computer system in which visual images are displayed by fractional color gradient increments is shown in
The computer system may include any of a separate graphics memory 313, a storage unit 315 such as a hard disk, and a communication port 317. A bus (not shown) or other suitable arrangement interconnects the various components of the computer system. The instructions 311 are shown as residing in the memory 305, but in some embodiments the instructions may reside in one or more of the graphics memory 313, the storage unit 315, or a local or remote external location that the computer system communicates with through the communication port. Each of the memory 305 and the graphics memory 313 may be one or more of random access memory, read-only memory, or cache memory associated with one or both of the processing units.
Rendering gradients in a GPU according to the foregoing principles results in a compact rendition. This saves space and speeds up system performance. A smaller texture is more likely to remain in cache rather than in main memory or storage, further improving performance. Also, aliasing artifacts and missing colors are avoided.
Number | Name | Date | Kind |
---|---|---|---|
6879327 | Mathur et al. | Apr 2005 | B1 |
7466319 | Kirkland et al. | Dec 2008 | B1 |
7706633 | Chefd'hotel et al. | Apr 2010 | B2 |
7965289 | Green et al. | Jun 2011 | B1 |
8044956 | Kilgard | Oct 2011 | B1 |
20040164992 | Gangnet et al. | Aug 2004 | A1 |
20060119599 | Woodbury, Jr. | Jun 2006 | A1 |
20080055331 | Iourcha et al. | Mar 2008 | A1 |
20080198168 | Jiao et al. | Aug 2008 | A1 |
Number | Date | Country |
---|---|---|
WO-2010133007 | Nov 2010 | WO |
Entry |
---|
Lahabar,S. “Exploiting the Graphics Hardware to Solve Two Compute Intensive Problems . . . ”, Aug. 2010. |
Number | Date | Country | |
---|---|---|---|
20130106886 A1 | May 2013 | US |