This application claims priority of Swedish Application No. 0700162-1, filed Jan. 24, 2007.
The present invention generally relates to digitally represented graphics and more particularly to improving the performance of generating digitally represented graphics.
Digitally represented graphics, such as computer graphics, is continuously improving in performance.
In the 1980's and 1990's, display adapters for computers and game consoles appeared with graphics accelerators, offloading the Central Processing Unit (CPU) in graphics generation. Initially, the display adapters offered acceleration of 2D graphics, but eventually these also included support for accelerated 3D graphics. Modern display adapters use a processing unit often named a graphics processing unit (GPU).
Due to the complexity of 3D graphics, GPU:s of today use a significant amount of their processing power to perform calculations related to 3D graphics.
A continuous problem with display adapters is performance. There are always new applications and games requiring higher frame rates (rendered screen images per second), higher resolutions and higher image quality, resulting in requirements that each screen image should be rendered in a short a time as possible. In other words, it is always important to increase performance.
Consequently, there is still a problem with insufficient abilities to improve performance in digitally represented graphics.
Some embodiments are described with respect to the following figures:
The present invention will now be described more fully hereinafter with reference to the accompanying drawings, in which certain embodiments of the invention are shown. This invention may, however, be embodied in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided by way of example so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art. Like numbers refer to like elements throughout.
The polygon setup block 102 is responsible for setting up polygons as instructed by a connected CPU 570 (
A hierarchical depth culling block 106 performs hierarchical depth culling, which is culling based on depth buffering. Here, a conservative test is performed to prove whether that tile is covered by the contents in the depth buffer. In other words, it is tested if there is another rendered object fully covering polygon in the tile, from the viewers perspective. If that is the case, the entire tile can be culled, i.e. singled out for less processing, e.g. skipped. This then results in performance gains. It is to be noted that the hierarchical depth culling may be performed either before or after the culling of a programmable culling unit 108. This unit is fixed function, which means that it does not execute a replaceable program.
In the programmable culling unit 108, culling is performed according to a replaceable culling program 118, also known as a replaceable culling module. The details of this culling program 118 and the effects are explained in more detail in conjunction with
In a fragment rasterizer 110, the tile processed by the programmable culling unit 108 is broken down into fragments, overlapping the polygon. Each of these fragments correspond to a pixel and contain data required to render the pixel and to test whether the pixel should be rendered on the screen. The fragment data includes raster position, depth, color, texture coordinates, stencil, alpha (used for blending), etc. For every pixel there may exist a plurality of fragment samples.
In the fragment program unit 112, the fragments output from the fragment rasterizer are processed using a fragment program 120. The purpose of this unit is to perform tasks such as combining previously evaluated color with textures, as well as to add effects such as fog, as well as to, when possible, identify fragments that do not need to be rendered, i.e. fragment culling.
A texture unit 114 is used for texture lookups, for example using one-dimensional, two-dimensional, three-dimensional, four-dimensional and cube map textures, and provides these to the programmable culling unit 108 and the fragment program unit 112 as required.
The blend/depth/alpha unit 116 uses the fragments provided from the fragment program unit 112 to perform depth testing, alpha testing, and blending before the fragments are written to target buffers.
The principle is that a combined program 222 can be used to automatically generate a culling program 218 for use in the programmable culling unit 108 and a fragment program 220 for use in the fragment program unit 112. Optionally, a programmer can write individual culling and fragment programs 218, 220.
As an example, consider the pseudo code segment (1) of a combined program 222, originally written for use as a fragment program:
This program performs basic diffuse lighting by computing the dot product between the light (l) and normal (n) vectors into a result (d) using the DP3 instruction. The n and l vectors varies per fragment. The KIL instruction terminates all fragments where the surface normal does not face the light, indicated by d being less than 0. The TEX2D instruction performs a lookup of a two dimensional texture into c. Finally, the result (d) is multiplied by a diffuse material coefficient (c).
In the novel manner proposed herein, the KIL instruction is an opportunity for culling a whole tile of fragments. But in order to do so, it should be conservatively proven that the condition for the KIL instruction is fulfilled for the whole tile. From this follows that, in this example, it must also be possible to conservatively evaluate the DP3 instruction, since the KIL instruction depends on the result of that instruction. Furthermore, it must be possible to find conservative bounds of the input (the vectors for the normal n and light l in this case) for a whole tile, since the DP3 instruction in turn depends on these values.
In order to implement this chain of conservative evaluations, the programmable culling unit is based on the same instruction set as the fragment program unit. However, instead of floating-point variables as source and destination registers to an instruction, as is typical when processing fragments, intervals are used and the instruction is implemented using principles of interval arithmetic. As a simple example, consider a standard ADD instruction:
ADD c,a,bc=a+b(2) (2)
For the corresponding programmable culling unit interval instruction, the operands are replaced by intervals, â, {circumflex over (b)}, ĉ where an interval, e.g. â, is defined as:
â=[a,ā]={x|a≤x≤ā} (3)
The programmable culling unit ADD instruction is then:
ADD ĉ,â,{circumflex over (b)}⇔ĉ=â+{circumflex over (b)} (4)
where the interval addition operation is implemented as:
â+{circumflex over (b)}=[a,ā]+[b,
As can be seen, the result of the interval addition contains all possible results of “normal” additions, or more formally, it holds that a+b∈â+{circumflex over (b)} given that a∈â and b∈{circumflex over (b)}. It is therefore conservatively correct. IN similar fashion, the behavior of every instruction in the fragment program instruction set is redefined. Full details of the resulting enhanced instructions are presented here.
s1 ·
s2,
src > 0
src ≤ 0
src > 0
src ≤ 0
s1 ≥
s1 ≥
In addition to using interval instructions, the input must also be defined as intervals. Therefore, it must be possible to compute conservative bounds for quantities interpolated over an entire tile of fragments. This is explained in more detail below. It is to be noted that although interval arithmetic is used herein, any suitable arithmetic representing the whole tile can be used. For example, affine arithmetic can equally well be used within the scope of the present invention.
With the reasoning above, the culling program 218 can in this situation automatically be derived from the combined program (1). Here follows the derived culling program:
DP3 {circumflex over (d)},{circumflex over (n)},{circumflex over (1)}
KIL {circumflex over (d)},<0 (6)
Furthermore, here the fragment program 220 is derived from the combined program (1), to be identical to the combined program 220. Here follows the fragment program:
DP3 d,n,l
KIL d<0
TEX2D c,t0,r1
MUL out.col,d,c (7)
For an entire tile of fragments, assume that it is determined that the input interval 334 of its normals 330 is {circumflex over (n)}=([−√3/2, −1/2], [1/2, √3/2]), and the interval 336 for its light vector 332 is {circumflex over (1)}=([1/√2, 1], [−1/√{square root over (2)}, 0]), as illustrated in
The culling program is then executed in the execute culling program step 452.
In this embodiment, when the culling program requests input values, the process continues to provide input values to culling program step 454a. The input values are values relating to a characteristic representing all fragments in the tile in some manner. For example, input values could be normals, position coordinates, light vectors, colors, texture coordinates, etc. The requested input values are calculated, in this embodiment, using interval arithmetic. In other words, the input values are only calculated when they are needed, according to a ‘pull’ mechanism, in contrast to the ‘push’ mechanism explained with reference to
When the culling program has finished processing, the process continues to a conditional culling condition true step 456. In this step, it is determined whether the culling should be performed for the currently processed tile or not according to the output of the culling program. If culling is to be performed, the process continues to an execute instruction set A step 458. Otherwise, the process continues to an execute instruction set B step 460. In one embodiment, if the culling condition is false, the tile is broken into several smaller tiles and the process returns to the select tile to process step 440. This can be repeated successively for smaller and smaller tiles, implementing a hierarchical, multilevel culling process.
It is to be noted that the culling program may also output other results than a culling condition. These results may be sent down the graphics pipeline for further processing. An example of such an embodiment would comprise reversing the order of the hierarchical depth culling unit 106 (
In the execute instruction set A step 458, an instruction set A is performed for a subset of the tile, typically fragments. The fragments typically collectively cover all pixels of the tile, that overlaps the triangle being processed.
In the execute instruction set B step 460, an instruction set B is performed for a subset of the tile, typically fragments. This is typically a conventional processing of rendering of the fragments after the tile stage.
The instruction set A is typically less demanding than the instruction set B, resulting in a reduced number of instructions processed for the tile when the culling condition is determined to be true, resulting in increased performance. In one embodiment, the instruction set A is empty, leading to a considerable reduction in processing, i.e. increased performance.
However, the provide input values to culling program step 454b is here processed before the culling program is executed. In this step, all relevant input values are calculated, in this embodiment using interval arithmetic, and provided so that the culling program can access these values. This implements a ‘push’ mechanism for the input value calculation.
It is to be noted that although a general purpose computer is described above to embody the invention, the invention can equally well be embodied in any environment where digital graphics, and in particular 3D graphics, is utilized, e.g. game consoles, mobile phones, MP3 players, etc.
Now follows a disclosure how input values may be calculated using interval arithmetic, given an implementation of the instruction set as described above. A culling program can then be executed for a whole tile of fragments. However, in order to do so, bounding intervals for the varying (or interpolated) inputs also need to be computed.
Initially, the value of the varying attribute is computed in all four corners of the tile using interpolation. Then the bounding interval of these four values is computed, and it is called âc└ac,
Finally, an exceptional case must be dealt with, which is illustrated in
This exceptional case is dealt with by setting a âtile to âtri as the bounding interval for tiles overlapping the projection line. One might argue that this interval is overly conservative, but these problematic tiles are so rare that it is hard to motivate more complex computations. In this embodiment, only tiles actually overlapping the triangle are traversed, and perspectively correct barycentric coordinates are used to do the interpolation. Barycentric coordinates are disclosed in MCCOOL, M. D., WALES, C., AND MOULE, K. 2002, “Incremental and Hierarchical Hilbert Order Edge Equation Polygon Rasterization”, in Graphics Hardware, 65-72.
The problematic tiles can easily be detected when computing perspectively correct barycentric coordinates for the corners of a tile. The perspectively correct barycentric coordinates are expressed as a rational function, and if the denominator is less than zero for any of the tile corners then the tile crosses the projection line.
Here now follows a disclosure of how N-dimensional texture lookups are performed. The interval instructions for performing N-dimensional texture lookups are an improvement over known approaches used for displacement map subdivision. The general idea is to provide a fast and efficient means of computing the bounding interval of the texture data over a given area. The remainder of this example will only consider two-dimensional textures, but generalization is straightforward.
We initially compute two mipmap pyramids for each texture that is subject to interval-based texture lookup. As shown in
When performing a texture lookup, we wish to compute the bounding interval of the texture data over an axis-aligned bounding box, which is the texture coordinate interval. First, we compute an appropriate mipmap level as:
|log2(max(
where {circumflex over (t)}=({circumflex over (t)}x, {circumflex over (t)}y) is a two-dimensional interval of the unnormalized integer texture coordinates (i.e., they include the dimensions of the texture). These are appropriately rounded such that ti is floored and
When transformed to this mipmap level, {circumflex over (t)} will never be more than one texel wide in any dimension, and will be at least ½ texels wide in the widest dimension. Thus, we get four possible cases of texture coordinate intervals as illustrated in
If more texturing units are available, it is possible to improve the bounds of the interval texture lookup. The normal texture lookup assumes that we can read a block of 2.times.2 texels at a time. If we have enough hardware resources to read a block of 4.times.4 texels instead, then we can move one level down in the mipmap hierarchy and get a more accurate result.
Another important observation is that we only need to create the mipmap levels that are actually used in the culling program. This optimization is particularly important for algorithms taking place in screen space such as, for instance, order independent transparency. In this case we know beforehand that we only need the texture at its base level, and the mipmap level that corresponds to a tile on the screen. Note that such tile information is already available in modern hardware and can be read “for free”. The minimum and maximum depth values can for instance be found in the hierarchical depth culling unit. It is also possible (but less likely) that the min and max colors are already computed for compression purposes, otherwise we need to compute them. Extensions for rendering to the base and tile mipmap level of a texture would greatly accelerate screen space algorithms.
We compute the min/max mipmap pyramid for the cube map, using the same approach as for two-dimensional textures. However, near edges and corners of the cube, special treatment is necessary. For the edges, we compute the mipmap color as the min or max of four texels on both sides of the edge, and for the corners we compute the mipmap color as the min or max of four texels on all three sides emanating from that corner. Texels on opposite sides of edges will therefore share the same colors in higher mipmap levels. Similarly, the three texels in a corner will also share a common color. It should be noted that the highest level mipmap will contain the min and max value over the full cube, as expected.
We can now use this mipmap pyramid to do conservative cube map lookups with accesses to only one side of the cube. First, we compute the interval based equivalent of the major axis. Given a texture coordinate interval {circumflex over (t)}=({circumflex over (t)}x,{circumflex over (t)}y, {circumflex over (t)}z), we define the major axis, i, as the axis where ti and
Once we have found a major axis, we conservatively project the texture coordinate interval on the corresponding side of the cube map. The projection is done by projecting the bounds of each of the two remaining axes separately. Let us consider an example where x is the major axis and y is the axis for which we want to project the bounds. There are then six possible cases of texture coordinate intervals (note that no interval may cross the y-axis since the x-axis would not be a major axis in that case), and the extreme points we have to project to compute the bounds. Fortunately, it is very easy to determine which these extreme points are. It is sufficient to look at the signs of the texture coordinate interval, and through a table lookup get the extreme points.
We project the extreme points for the remaining two axes to form a two-dimensional projected coordinate interval. This interval is used to compute a mipmap level and perform a two-dimensional texture lookup, identically to the method described in for the two-dimensional case above.
The invention has mainly been described above with reference to a few embodiments. However, as is readily appreciated by a person skilled in the art, other embodiments than the ones disclosed above are equally possible within the scope of the invention, as defined by the appended patent claims.
In view of the above, an objective of the invention is to solve or at least reduce the problems discussed above.
Generally, the above objectives are achieved by the attached independent patent claims.
According to a first aspect of the invention there has been provided a method for improving performance of generation of digitally represented graphics, comprising the steps of: selecting a tile comprising fragments to process; executing a culling program for the tile, the culling program being replaceable; and executing a set of instructions, selected from a plurality of sets of instructions based on an output value of the culling program, for each of a plurality of subsets of the fragments. It is therefore possible to create culling programs processing the tile, and let these be executed to improve the performance.
In the step of executing a culling program for said tile, arithmetic representing a whole tile may be used for at least part of instructions of the culling program. This allows processing of a plurality of fragments at a time which improves the performance.
In the step of executing a culling program, interval arithmetic may be used for at least part of instructions of the culling program. Interval arithmetic allows representation of a plurality of fragments and can be implemented relatively easily.
In the step of executing a culling program, affine arithmetic may be used for at least part of instructions of the culling program. Affine arithmetic allow a relatively accurate representation of a plurality of fragments.
The method may further comprise the step of: providing values representing at least one attribute of a plurality of fragments of the fragments to the culling program.
Each of the subsets of fragments of the tile may comprise one fragment. In other words, processing is performed for each fragment.
The step of executing a set of instructions may involve, when the output value satisfies a culling condition, executing a first set of instructions for each of a plurality of subsets of the fragments, and when the output value fails the culling condition, executing a second set of instructions for each of the plurality of subsets of fragments.
The first set of instructions may comprise fewer instructions than the second set of instructions.
The first set of instructions may comprise zero instructions. In other words, if the culling condition is true, no instructions are processed, resulting in improved performance.
In the step of executing a set of instructions, the culling condition may correspond to the fragments of the tile making no contribution to a finally rendered image. This is a source of performance improvement in the invention.
In the step of executing a set of instructions, the culling condition may correspond to the fragments of the tile making a contribution less than a threshold value to a finally rendered image. This will improve performance even further, with a tradeoff of reduced image quality. The threshold can be configured arbitrarily according to a desired balance of performance and image quality.
In the step of providing values, the values may be calculated using interval arithmetic, using a plurality of fragments of the tile as input.
In the step of providing values, the values may be calculated using affine arithmetic, using a plurality of fragments of the tile as input.
In the step of providing values, the values may be calculated as a result of the culling program requesting access to the values. In other words, a pull mechanism is used to provide values to the culling program.
In the step of providing values, the values may be calculated prior to executing the culling program. In other words, a push mechanism is used to provide values to the culling program.
The step of selecting a tile comprising fragments to process may involve selecting a tile which is at least partly overlapped by a polygon being processed. In other words, a tile with potential contribution from the polygon is selected.
The fragments may be fragments associated with the polygon. Consequently, only fragments of the polygon in the tile are processed.
The steps of selecting a tile, executing a culling program, and executing a set of instructions are repeated until all tiles which are at least partly overlapped by the specified polygon have been processed. When a polygon has been processed, the next polygon may be processed similarly, and so forth until all polygons of an image have been processed.
In the step of executing a set of instructions, at least one of values calculated by said culling program may be used in said selected set of instructions or in processing by subsequently used processing units. These valued may for example be used in a hierarchical depth culling performed at a later stage.
A second aspect of the invention is a display adapter adapted to generate digitally represented graphics comprising: means for selecting a tile comprising fragments to process; means for executing a culling program for the tile, the culling program being replaceable; and means for executing a set of instructions, selected from a plurality of sets of instructions based on an output value of the culling program, for each of a plurality of subsets of the fragments. It is to be noted that the second aspect of the invention can be embodied with any combination of features corresponding to any the features of the first aspect of the invention.
A third aspect of the invention is a computer program product comprising software instructions that, when executed in a controller, performs the method according to the first aspect of the invention.
Other objectives, features and advantages of the present invention will appear from the following detailed disclosure, from the attached dependent claims as well as from the drawings.
Generally, all terms used in the claims are to be interpreted according to their ordinary meaning in the technical field, unless explicitly defined otherwise herein. All references to “a/an/the [element, device, component, means, step, etc.]” are to be interpreted openly as referring to at least one instance of the element, device, component, means, step, etc., unless explicitly stated otherwise. The steps of any method disclosed herein do not have to be performed in the exact order disclosed, unless explicitly stated.
The graphics processing techniques described herein may be implemented in various hardware architectures. For example, graphics functionality may be integrated within a chipset. Alternatively, a discrete graphics processor may be used. As still another embodiment, the graphics functions may be implemented by a general purpose processor, including a multicore processor.
References throughout this specification to “one embodiment” or “an embodiment” mean that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one implementation encompassed within the present disclosure. Thus, appearances of the phrase “one embodiment” or “in an embodiment” are not necessarily referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be instituted in other suitable forms other than the particular embodiment illustrated and all such forms may be encompassed within the claims of the present application.
While a limited number of embodiments have been described, those skilled in the art will appreciate numerous modifications and variations therefrom. It is intended that the appended claims cover all such modifications and variations as fall within the true spirit and scope of this disclosure.
Number | Date | Country | Kind |
---|---|---|---|
0700162-1 | Jan 2007 | SE | national |
This application is a continuation of application Ser. No. 15/252,405 filed Aug. 31, 2016, which is a non-provisional application claiming priority to Ser. No. 12/523,894 filed Mar. 11, 2010, which is a 371 application of PCT/SE2008/00005 filed on Jan. 23, 2008, which claims priority of provisional application 60/900,084 filed Feb. 8, 2007, hereby expressly incorporated by reference herein.
Number | Date | Country | |
---|---|---|---|
60900084 | Feb 2007 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 15252405 | Aug 2016 | US |
Child | 16155314 | US | |
Parent | 12523894 | Mar 2010 | US |
Child | 15252405 | US |