When vertex shader has finished it's work then comes Primitive Assembly phase. In Primitive Assembly phase clipping is being done. Then after several phases comes Fragment Shader and after that come Per-Fragment operations. First operation is Pixel Ownership Test which I cannot understand why we need if we have already clipped the primitive based on viewport.
It is not the purpose of the pixel ownership to clip away primitives outside your window/viewport. According to the pipeline definition, that does indeed happen between vertex and fragment shader, around the time primitive assembly and rasterization are performed.
The pixel ownership test is used to eliminate pixels that are basically within your window rectangle, but are not visible on the screen. Common scenarios where this can happen is if your window is partially covered by another window, or your window extends beyond the edge of the display.
The pixel ownership test only really comes into play if the application renders directly to the framebuffer. I don't think that's common anymore with modern window systems. Your application will typically render to an off-screen buffer, and then there's a compositing step that combines the windows according to their relative positions, stacking order, etc. The only time you still get to render directly to the framebuffer is in full screen mode.
Another aspect to keep in mind is that the spec describes how an OpenGL implementation behaves. This does not mean that each implementation actually has to perform the various steps in exactly the order described in the spec. As long as it behaves as if it performed the steps in that order, it is still compliant. For example, if an implementation can perform the pixel ownership test before the fragment shader, it is at complete liberty to do that, as long as the final result does not change. It is in fact very common to perform some of the tests in the "per-fragment operations" section before the fragment shader for improved efficiency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With