Graphics Reference
In-Depth Information
void insertSortedOA ( p , depth , data )
{
1
age =1;
uint
2
uint64_t record = OA_PACK ( age , depth , data );
3
int
iter =0;
4
while ( iter ++ < MAX_ITER )
{
5
=( p + offsets [ age ])% gBufSz ;
uvec2
h
6
uint64_t old = atomicMax (& buffer [ h ], record );
7
if ( old < record )
{
8
atomicMax (& A [ p ], age );
9
if ( old == 0 ) break ;
10
age = OA_GET_AGE ( old );
11
=( h + gBufSz
offsets [ age ]) % gBufSz ;
p
12
record = old ;
13
}
14
++ age ;
15
record = record + OA_INC_AGE ;
16
}}
17
Listing 1.5. Insertion-sort with open addressing.
1.4.1
Post-sort : Sorting in Local Memory
In the Post-sort method, the Build pass accumulates the fragments of each
pixel in a list, without sorting them. The Render pass should then sort the
fragments prior to accumulating their contributions. This is done in a pixel
shader invoked by rasterizing a fullscreen quad. The shader for a given pixel
p first gathers all the fragments associated with p in a small array allocated in
local memory. The array is then sorted using bubble-sort, in a manner similar
to [Crassin 10]. Insertion-sort could also be used and benefit cases where the
transparent fragments are rasterized roughly in back-to-front order.
In contrast to the Post-sort techniques, the Pre-sort approaches perform
sorting during the Build pass. This allows for early culling of unnecessary frag-
ments, as described in the next section.
1.4.2
Pre-sort : Early Culling
The Pre-sort method has the unique advantage of keeping the fragments sorted
at all times. In a transparency application, when a fragment is inserted in a sorted
list it is possible to accumulate the opacity of the fragments in front of it in the
list. If this opacity reaches a given threshold, we know that the color of fragment
f will contribute little to the final image and we can decide to simply discard
it. This early culling mechanism is possible only when the lists of fragments
are always sorted, and it provides an important performance improvement as
illustrated in Section 1.7.
Search WWH ::




Custom Search