The present disclosure relates generally to the field of frame buffer compression methods and more specifically to the field of frame buffer tile coverage mask compression methods.
A frame buffer is a common feature in many conventional graphics processing systems. A frame buffer may comprise one or more memory buffers that are used to contain at least one complete frame of data for communication to a video display device. As illustrated in
Graphics information stored in a frame buffer may be divided into tiles. Each tile comprises one or more display pixels. An exemplary tile may have a rectangular shape or a square shape. A tile may comprise a variety of different pixels quantities (e.g., 12 pixels/tile and 64 pixels/tile).
An exemplary tile 202 may be covered by any number of objects 206. Note, an object is a generic term and may represent triangles, layers, z-planes, or a collection of samples with a common property (e.g., color) that overlie pixels, etc. Rather than pixels, an exemplary tile 202 may also be referred to as comprising samples. An exemplary pixel may comprise one or more samples. An exemplary pixel may also comprise a multisample that is an average of all the color samples of the pixel.
As illustrated in
Such coverage information may be immediately available and requires no decoding. However, this method is not storage-efficient, as it requires N*K bits for the required storage masks (where N equals the quantity of samples/tile and K equals the quantity of objects/tile). For example, as illustrated in
This present invention provides a solution to the challenges inherent in compressing display information stored in a frame buffer, particularly compressing coverage information. In a method according to one embodiment of the present invention, a method for compressing graphics data is illustrated. The method comprises sorting a plurality of coverage masks for a plurality of objects into an order of descending number of samples covered by the plurality of coverage masks. A first coverage mask is identified. The first coverage mask comprises a greatest number of covered samples. Additional coverage masks of the plurality of coverage masks are compacted in the order of descending number of samples covered. Compacting additional coverage masks comprises removing samples from the coverage mask that are covered by any of the previous coverage masks.
In a system according to one embodiment of the present invention, a system comprises a processor and a memory. The memory comprises instructions that when executed by the processor implement a method for compressing graphics data. The method comprises sorting a plurality of coverage masks for a plurality of objects into an order of descending number of samples covered by the plurality of coverage masks. A first coverage mask is identified. The first coverage mask comprises a greatest number of covered samples. Additional coverage masks of the plurality of coverage masks are compacted in the order of descending number of samples covered. Compacting additional coverage masks comprises removing samples from the coverage mask that are covered by any of the previous coverage masks.
In a method according to one embodiment of the present invention, a method for compressing graphics data comprises sorting a plurality of coverage masks for a plurality of objects into an order of descending number of samples covered by the plurality of coverage masks. The method further comprises selecting a first compression procedure when a rate of descending number of samples is above a threshold. The first compression procedure comprises compacting the plurality of coverage masks in the order of descending number of samples. Compacting a first coverage mask removes those samples from the first coverage mask that were covered by a second coverage mask that was previously compacted. The method comprises selecting a second compression procedure when the rate of descending number of samples is below the threshold. The second compression procedure comprises replacing the plurality of coverage masks with a single coverage mask that indicates which object covers each sample in the single coverage mask.
The present invention will be better understood from the following detailed description, taken in conjunction with the accompanying drawing figures in which like reference characters designate like elements and in which:
Reference will now be made in detail to the preferred embodiments of the present invention, examples of which are illustrated in the accompanying drawings. While the invention will be described in conjunction with the preferred embodiments, it will be understood that they are not intended to limit the invention to these embodiments. On the contrary, the invention is intended to cover alternatives, modifications and equivalents, which may be included within the spirit and scope of the invention as defined by the appended claims. Furthermore, in the following detailed description of embodiments of the present invention, numerous specific details are set forth in order to provide a thorough understanding of the present invention. However, it will be recognized by one of ordinary skill in the art that the present invention may be practiced without these specific details. In other instances, well-known methods, procedures, components, and circuits have not been described in detail so as not to unnecessarily obscure aspects of the embodiments of the present invention. The drawings showing embodiments of the invention are semi-diagrammatic and not to scale and, particularly, some of the dimensions are for the clarity of presentation and are shown exaggerated in the drawing Figures. Similarly, although the views in the drawings for the ease of description generally show similar orientations, this depiction in the Figures is arbitrary for the most part. Generally, the invention can be operated in any orientation.
Some portions of the detailed descriptions, which follow, are presented in terms of procedures, steps, logic blocks, processing, and other symbolic representations of operations on data bits within a computer memory. These descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. A procedure, computer executed step, logic block, process, etc., is here, and generally, conceived to be a self-consistent sequence of steps or instructions leading to a desired result. The steps are those requiring physical manipulations of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated in a computer system. It has proven convenient at times, principally for reasons of common usage, to refer to these signals as bits, values, elements, symbols, characters, terms, numbers, or the like.
It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the following discussions, it is appreciated that throughout the present invention, discussions utilizing terms such as “processing” or “accessing” or “executing” or “storing” or “rendering” or the like, refer to the action and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's registers and memories and other computer readable media into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission or display devices. When a component appears in several embodiments, the use of the same reference numeral signifies that the component is the same component as illustrated in the original embodiment.
This present invention provides a solution to the increasing challenges inherent in compressing graphics content stored in a frame buffer, in particular, the compressing of coverage information. Various embodiments of the present disclosure provide a method where a plurality of coverage masks for a plurality of objects may be compacted. As discussed in detail below, after sorting the coverage masks in a descending order of the number of samples covered, each coverage mask is compacted by removing those samples from the coverage mask that have been covered in a previously coverage mask. Therefore, only those samples not yet covered by a previously coverage mask will be included in a compacted coverage mask.
As discussed herein, graphics information (e.g., coverage mask information) stored in a frame buffer may be compressed. Compressing data stored in a frame buffer allows a required bandwidth needed for reading and writing data to and from the frame buffer to be reduced. The more that the data stored in the frame buffer can be reduced, more bits will be available for storing object information (e.g., depth and color values).
In one method of coverage mask compression, coverage information for a tile may be compressed with the use of a coverage vector that associates every sample in the tile with an object. An exemplary coverage vector may be a coverage mask that is based upon the samples, rather than objects. A coverage vector may store for each sample which object is visible. For example, if there are four objects in an exemplary tile, then 2 bits will be needed per sample to identify the visible object in the sample. With 2 bits, up to 4 objects may be identified. 5 or more objects would require additional bits (e.g., 3 bits would allow the identification of up to 8 objects). If an exemplary tile comprises 64 samples (in an exemplary 8*8 grid) with 4 objects, then 128 bits will be needed for the coverage vector map because each object will be identified with 2 bits (2*64=128).
Such a representation may use less storage as it only requires N*[log2K] bits, but involves a decoding step to find which samples belong to a given object. For example, the coverage information illustrated back in Table 1 may be compressed with a coverage vector such as 0001|2001|0300, where each digit is encoded with 2 bits to cover 4 objects (e.g., 00 00 00 01|10 00 00 01|00 11 00 00). However, coverage information compression using a coverage vector still may consume a significant number of bits in the compressed representation of the tile. Reducing this storage amount further would leave more bits for storing the actual object information (e.g., depth and color values).
As also illustrated in
In one exemplary embodiment, when the display information is stored in the frame buffer 310, the display information (e.g., color, z data, and coverage) may also be compressed. In one exemplary embodiment, coverage information ready to be stored in the frame buffer 312 is compressed before storing in the frame buffer 312. Such compression methods may store information for multiple objects, where each object covers a subset of samples contained in the tile. Note, that an object, as described herein, is a generic term and may actually refer to triangles, z-planes, or a collection of samples with a common property such as color (e.g., a background). As described herein, an object's coverage mask defines which samples are covered by the object. Minimizing the number of bits required to store a coverage mask (e.g. through compression techniques) has an advantage in that it may leave more bits available to encode the objects. Using fewer bits for storing coverage information may leave more bits available for storing sample/pixel information.
As illustrated below in Table 2, a plurality of exemplary compacted coverage masks will vary according to the number of samples included in the individual compacted coverage masks. As illustrated in Table 2, and discussed herein, an identified first coverage mask is not compressed. In other words, a compacted coverage for the first coverage mask (identified as Object[0]) is identical to the first coverage mask. As illustrated in Table 2, the first coverage mask for a tile comprising 12 samples will comprise 12 bits. Thereafter, each additional coverage mask will be compacted such that each successive compacted coverage mask will only contain those samples that remain. As illustrated in Table 2, because the identified first coverage mask (Object[0]) covered 8 of the available samples, only 4 samples remain for the second compacted coverage mask (the second compacted coverage map will comprise 4 bits). As illustrated in Table 2, once a sample is covered by an object, it will not be included in subsequent compacted coverage masks.
In one exemplary embodiment, coverage compaction begins by looking at each of the objects and arranging them in a descending order of samples covered. Once the objects and their corresponding coverage masks are ordered, a coverage mask of the object with the highest quantity of covered samples is saved into the frame buffer (e.g., as illustrated in Table 2, an exemplary first object comprises 8 covered samples). An identified first coverage mask is not compressed, but is saved directly uncompressed. Now compacted coverage masks can be created for any additional objects in the plurality of ordered objects. As illustrated in Table 2, those samples that were covered in the first coverage mask will not be included in the compacted second coverage mask. Therefore, because 8 of the 12 exemplary samples were covered by the first coverage mask for the first object (object[0]), the compacted second coverage mask for the second object (object[1]) will comprise only 4 samples, as illustrated in Table 2. This compacted second coverage mask for the second object is therefore a map of only the remaining samples (those samples that were “0” in the previous coverage mask(s)). This compacted second coverage mask is also stored in the frame buffer. As illustrated in Table 2, when a compacted third coverage mask for a third object is created, the samples that were covered in the previous two compacted coverage masks will not be included. Because a total of 10 samples were covered in the previous two compacted coverage masks, only the two remaining samples will be included in the exemplary compacted third coverage mask. As illustrated in Table 2, the compacted third coverage mask covers an additional sample. Therefore, the compacted fourth and final coverage mask for the fourth object will contain only the last remaining sample.
As discussed in detail herein, if the first few objects cover a large portion of samples, then coverage compaction may be more efficient than either a conventional coverage mask or a coverage vector. Because a majority of the samples will be covered by a first and/or second object, the remaining number of uncovered samples will be few. Therefore the number of bits needed to store the remaining coverage masks for the last remaining objects will also be few.
In one exemplary embodiment, when it is known how many objects will be stored (e.g., 4 objects), a final compacted coverage mask for the final object need not be stored. As illustrated in Table 2, any samples in a compacted coverage mask for the last object will be covered by the final object. In other words, the final compacted coverage mask for the last object is merely all the samples that have not yet been covered by all the previous objects (and these remaining samples are all 1's). Therefore, the prior compacted coverage masks may be used to define what samples remain. These remaining samples would be considered to be covered by the last object without the need for a compacted coverage mask. In other words, if there are 4 objects, only the first 3 coverage masks (e.g., compacted coverage masks) will be stored
However, if the number of objects is unknown, a compacted coverage mask for a final object is needed. In one exemplary embodiment, a total number of objects for a tile may be determined by looking at the compacted coverage and looking for the coverage mask that has all l's (such that all the remaining samples were covered by that object (e.g., 11111)). Such an exemplary step may be necessary if a coverage format was used that allowed for a fixed number of coverage mask (e.g., 6), but not all of the slots were filed (e.g., there were only 4 objects). The unused slots may be identified by looking at the coverage masks and identifying the coverage mask for the object that contains all 1's in its coverage mask. In other words, the last compacted coverage mask (for object 4) completes the coverage mask. There are not any remaining uncovered samples. There are no uncovered samples left to be covered by the 5th or 6th slot. In another embodiment, while there are 6 available coverage mask slots, there might be only three objects, such that a third coverage mask will comprise all 1's (e.g., 1111), indicating it is the final coverage mask for the final object in the tile.
In one exemplary embodiment, a frame buffer may also store how many objects were present in a tile. In other words, if the frame buffer indicates that there are 4 objects, then there will only need to be three compacted coverage masks for the first three objects. In another embodiment, an exemplary frame buffer may store how many compacted coverage masks are stored, so that if three compacted coverage masks are stored, a fourth compacted coverage mask for a fourth object may be determined based on the remaining uncovered samples. In one exemplary embodiment, along with the stored compacted coverage masks, a flag indicating whether a last coverage mask is stored may also be stored.
As discussed herein, exemplary coverage information for a tile may be most efficiently compressed following exemplary coverage compaction in accordance with embodiments of the present invention, when the first few objects cover a majority of the samples of the tile. For example, coverage compaction may not be as efficient as a coverage vector, if each of the objects covering a tile cover about the same number of samples. In such a circumstance, the number of remaining samples that are not yet covered may diminish slowly, and such a tile may require a larger number of bits to store its coverage information utilizing coverage compaction. If on the other hand, the first few objects cover a majority of the samples, then the required bits for additional compacted coverage masks may diminish very quickly. Fewer bits would be needed for the remaining compacted coverage masks for the remaining objects to cover the few remaining samples.
Determining when Coverage Compaction is Most Efficient:
Table 3, below, illustrates an example of 4 objects covering a tile with 12 samples.
As the example demonstrates, coverage compaction may be more storage efficient than compressing with coverage vectors. Coverage compaction may be advantageous if the number of samples not covered is reduced quickly, i.e. if the first (few) objects are big and cover the majority of the samples. The worst case scenario for coverage compaction is when all objects cover the same number of samples, that is, the number of samples not covered decreases slowly. In that case, coverage compaction might not use fewer bits than using a coverage vector, as illustrated in the formula below (N: number of samples per tile, K: number of objects per tile).
For comparison, a coverage vector would use N log2 K bits which is always less than N(K+1)/2 for N,K>0.
To estimate for a more average case at what point coverage compaction becomes more storage efficient than a coverage vector, it is assumed that the number of samples covered by the (sorted) objects forms a geometric series, i.e. each object (except the last) covers the same percentage α (0≦α≦1) of the samples not yet covered. In that case the number of bits required for encoding with coverage compaction is:
The value of a at which coverage compaction uses fewer bits than a coverage vector occurs when:
While this equation may not be solved trivially for a for general values of K, the following table gives approximate values of α>0 for K=1 . . . 8.
Coverage compaction has a largest advantage if each object covers at least 30-40% (for 3 . . . 8 objects) or at least 25% (for >8 objects) of the remaining uncovered samples. Coverage compaction may also be most efficient when the number of objects is slightly larger than a power of 2. Under such circumstances, a coverage vector would not use all possible encodings for a per-sample object-ID.
In one exemplary scene, each object covering a tile covers a same percentage of available samples of the tile. For example, a first object covers 50% of the samples, while each of the following objects covers 50% of the remaining samples. In other words, the second object covers a quarter of the samples. Under these circumstances (with a geometric series), a threshold percentage may be calculated where coverage compaction will be most efficient.
Table 3 illustrates that depending on how many objects there are, there is a certain percentage threshold that needs to be met in order for compaction coverage to be most efficient. If there are more than a power of 2 number of objects in the tile, that is 9 or 5 (which is just one larger than the power of two), then the percentage that each object needs to cover is relatively small, because an additional bit would be needed to encode object IDs for a coverage vector. For example, if there are 5 objects, then at least 3 bits will be needed to store a coverage ID for a coverage vector. However, such an arrangement will be inefficient, because while up to 8 objects could be stored with a 3-bit ID, a lesser number of objects may also be stored. This means that a coverage vector may become less efficient when storing more coverage masks. Therefore, there may be even more leeway for the use of compacted coverage under those circumstances when a coverage vector would be more inefficient.
In step 404 of
In step 408 of
In step 412 of
As illustrated in
As illustrated in
As illustrated in
These exemplary diagrams are generalized for K objects/tile and N samples/tile. This is just one exemplary embodiment, and there are other ways to implement the coverage compaction methodologies that are within the scope of this present disclosure.
In one exemplary embodiment, the following algorithmic description may be used as a method for compacting a coverage vector:
As discussed herein, coverage compaction may be most efficient when a first object covers a large proportion of the samples. A scene that includes a silhouette edge with a background that covers a large part of the tile may be stored more efficiently under compacted coverage masks rather than with a coverage vector. Coverage compaction may also be more efficient when there are skinny or narrow objects over a background or when there is a single, large first object, and then one or more smaller objects. There may also be a single bit in the frame buffer (e.g., a flag) that stores an indication of which coverage information compression method is utilized.
In step 706 of
In other embodiments, there may be other methods for compressing the coverage information. In one exemplary embodiment, the methods and algorithms discussed herein may be generalized from coverage information (triangles over samples) to associations (objects in bins). For example, with bins that are associated with general objects, the following information may be stated:
One exemplary method to encode this data would be with a bit vector with all the bins pointing to the objects, such as:
In one exemplary embodiment, the pointer vector may have a length of 3*8=24 bits. In other words, the pointer stream may be compressed by performing a one-hot instead of a binary encoding. In one exemplary embodiment, the lower encodings were assigned to the more frequently occurring objects. So the vector may become:
Written another way, the values of Table 7 may be written as:
This exemplary arrangement, illustrated in Table 8, as yet has no compression. However, this bit vector may be compressed by recognizing that as soon as a 1 is reached, the MSB 0's aren't needed. Therefore, all the LSB's may be stored together, followed by whichever LSB+1's are still need to be stored (because the 1 hasn't been hit yet). For example:
So, by concatenating the valid bits in row-order the stored bit vector from Table 9 may become (while inserting “|” between the bit indices for the sake of clarity): 11010000|11100|1011. Now the compressed pointer vector has 8+5+2+1 bits=16 bits, compressed from the original 24 bits. Such a compression may be decompressible by knowing that the length and placement of the bits in subsequent rows corresponds to the positions of “0's” in a current row.
In a further embodiment, while one encoding of Table 9 results in 11010000|11100|10|1, an alternative encoding by concatenating the valid bits in column-order can result in an encoding of: 1|1|01|01|001|0001. Such an encoding may be easier to decode as any string of zeros followed by a 1, e.g. “01”, forms one bin.
Although certain preferred embodiments and methods have been disclosed herein, it will be apparent from the foregoing disclosure to those skilled in the art that variations and modifications of such embodiments and methods may be made without departing from the spirit and scope of the invention. It is intended that the invention shall be limited only to the extent required by the appended claims and the rules and principles of applicable law.