scissor test and fragment program

From the OpenGL specs, it seems that the scissor test happens after the fragment program.
But is there some optimization about this? For example, we can do an early scissor test before
the fragment program is executed?

The spec depicts the behaviour of the system, not necessarily the order of actual hardware operations. As long as an optimization doesn’t change the behaviour, it’s valid. Moving the scissor test to an earlier place in the processing pipeline can certainly be done.

I’m not sure if early scissor testing is implemented anywhere, but there definitely are implementations with early Z, and IMO that’s much more complex than early scissor testing would be. So IMO it’s quite likely that it’s done.

Anyway, you don’t need to (and actually can’t) control this type of thing. If your implementation does support early scissor testing, it’ll happen automatically.

I’ve just looked into the source code of Mesa3D. There the scissor test happens before the execution of the fragment program.

I’m doing a rendering performance measurement. I just want to know about this to conform the results I’ve got.

Thanks.

Yes, in all the real-life implementations I’m aware of, scissor happens very early in the pipe. Before fragment shading, for sure.