Article index:
- 1 – Rasterization pattern
- 2 – Number of Processed Vertices
- 3 – Number of Processed Fragments
- 4 – Bugs…
- 5 – References
3 – Number of Processed Fragments
Another use of the atomic counters, similar to the previous one, is the counting of the number of fragments processed by the fragment/pixel shader stage. Let’s consider the following low resolution torus rendered with back face culling disabled:
There are 196028 processed pixels. Now if we enable the back face culling:
The number of processed pixels is now 98023. Half of the fragments have been discarded. This simple example shows how atomic counters can help us to optimize the rendering pipeline in any shader stage.
Here is a fragment shader that allows to count the number of processed fragments:
#version 420 out vec4 Out_Color; layout(binding=0, offset=0) uniform atomic_uint ac_frag; void main() { uint counter = atomicCounterIncrement(ac_frag); float r = (counter/255) / 255.f; Out_Color = vec4(r, 0, 0, 1); }
Article index:
nice work
GeForce 6xx have pattern like Radeon 6xxx had, while GeForce 5xx had messy pattern. Interesting