Graphics Reference
In-Depth Information
by the SPU jobs. Note that the sprites are rendered in additive blend mode
on top of the color buffer.
6. On the SPUs, each bokeh job analyzes the pixels and spawns a bokeh sprite
for each pixel passing the luminance threshold, scaled by the CoC factor.
The scale is clamped to a maximum bokeh scale size (in pixel space).
7. Each sprite is written in the vertex buffer ( x, y, z position in screen space
+ UVs + color) and the SetDrawArrays is patched with the correct number
of vertices. The rest of the reserved space is filled with NOPs.
void SetDrawArrays ( ContextData ￿ thisContext , const uint8_t
mode ,
const uint32 t first , const uint32 t count )
where mode = QUADS, first =0,and count = the number of pixels that
passed the luminance threshold with a valid CoC value.
8. The SPU patches the JTS so RSX can consume the graphic commands.
9. RSX draws each batch of bokeh sprites using additive blending.
10. Depth test is done in the pixel shader since we have the z position of the
sprite in the vertex buffer.
11. The blend amount is adjusted to respect energy conservation for the bokeh
sprite.
There are various ways to hide the luminance analysis and bokeh draw call
generation steps done by the SPUs. In my case I decided to kick the RSX transfer
right after the blended objects. This leaves enough time for the SPUs to analyze
the framebuffer and fill the vertex buffer that the RSX will use to display the
bokeh sprites on top of the framebuffer. The important thing to remember is to
be careful not to stall the RSX. One nice thing about all this is that by doing
the luminance computation on the SPUs you can have the total frame luminance
for free! Normally, a game will have some kind of luminance/tone mapping
adaptation of the framebuffer at the end of the frame. Adaptation effects usually
involve the GPU by adding the work of doing a cascade of downscale passes to
find the average luminance of the framebuffer. This obviously has some cost on
the GPU and can be removed if you analyze the framebuffer on the SPUs.
Search WWH ::




Custom Search