Game Development Reference
In-Depth Information
struct LinkedListEntry
{
float depth;
float alpha;
int next; // next element in linked list
int prev; // previos element in linked list
int right; // right neighbor link
int upper; // upper neighbor link
};
Listing 1.1. Linked list entry structure.
In this example the elements 1 and 6 (2 and 5, respectively) form a single linked
list, and the first elements 1 and 2 are stored in the head buffer.
Both structures (head buffer and list element buffer) are stored as Direct3D 11
( RW ) StructuredBuffers and filled by rendering the geometry once using interlocked
operations and the buffer counter in the pixel shader. InterlockedExchange is used
to exchange the head of the linked list to ensure that we do not face any problems
regarding parallelization.
The buffer counter is used to “allocate” linked list
0123
456
7
89
d
α
0000
2211
00
½½½½¾ ¾
¼¼
¾¾
next
-1
6
5
-1 -1
-1 -1
List element buffer
0
1
78
-1
2
3
-1
9
-1
4
-1
-1
-1
-1
-1
-1
-1
Head buffer
Figure 1.3. We implemented the DSMs as a two-level structure that consists of a per-
pixel buffer storing the head of each linked list (head buffer) and the list element buffer
for all incoming fragments. For each fragment, we store depth and alpha values, as well
as indices of the next and the previous elements, and nearest-depth neighbor links (only
the next index is shown here for brevity).
 
 
Search Nedrilad ::




Custom Search