Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scissor test: before or after ??!

Started by Woodchuck Oct 24, 2006 at 12:08 PM 10 replies 4.7k views
Original Post
Woodchuck
Woodchuck
According to the Directx9 documentation, the scissor test is done AFTER the pixel shader. That is incredible. A little quote from nvidia corp in the gpu gem 2 (cp30: GF6 archi):
Quote:
First, the scissor test rejects the fragment if it lies outside a specified subrectangle of the frame buffer. Although the popular graphics APIs define scissoring at this location in the pipeline, it is more efficient to perform the scissor test in the rasterizer. Scissoring in x and y actually happens in the rasterizer, before fragment processing, and z scissoring happens during z-cull.
So, whats the truth ( on a geforce 2 ? on a radeon 8500 ? on a geforce FX ? ) ?! Do all the graphics card perform it before pixel processing (assuming the card have one:). Note that i'm a little nervous. I do some research on the net, and this subject seems to pass to the trap door.
S1CA
S1CA
The pixel processing pipeline described in the DirectX documentation is abstract/conceptual.

An actual hardware implementation of that pipeline on a specific manufacturer's GPU can, and often will, be different to that abstraction.

The only requirement for the hardware manufacturer is that the pipeline produces the same results, at the same stages.


One GPU may scissor before the shader; another GPU may scissor after the shader; another GPU may not actually support scissoring at all and achieve the effect some other way; another may change how/where it performs scissoring depending on what other states are set (e.g. alpha test, stencil, etc).

All that /really/ matters is if the device caps say the device supports scissoring, and you set a scissor region, you get a scissored output.

The same applies to most other things in the pipeline - alpha test and scissor test happen before Z test in the conceptual model, but most modern GPUs have some form of hierarchical Z rejection that can happen before even the pixel shader.


Beware: GPU specific 'optimisation' advice from one manufacturer can often conflict with what's best for another manufacturer's GPU, or even previous generations of their own GPUs - when you average the advice over the years from all the manufacturers, funnily enough you end up with something remarkably similar to the conceptual pipeline in the documentation [wink]
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Woodchuck
Woodchuck
Damned.

Here is my problem:
I'm realizing a dynamic lightning system that perform a pass per light (it will remind you a certain game).
The idea (that was this game philosophy too) is that a light may just lit a little part of an object and of the screen - the large rest part of the screen being just lit by the ambient pass. It limit the area of expensive blinn shader. But you know that, this is well known - I hope^^.

So for me, there is two solutions:

1) a scissor test.
2) a viewport change (complicated way, and what about this change impact on the performance ?).

"I just don't know what to do..." (hum.. its a music lyrics that stay in my head..)

Quote:
Beware: GPU specific 'optimisation' advice from one manufacturer can often conflict with what's best for another manufacturer's GPU, or even previous generations of their own GPUs - when you average the advice over the years from all the manufacturers, funnily enough you end up with something remarkably similar to the conceptual pipeline in the documentation


^^ Haha, I like this explaination. That's exactly what i'm looking for, when that becomes complicated. So thank you for it.
Woodchuck
Woodchuck
Hey. I just did the test with a scissor rect. No doubt that it is perform before the pixel shader on my 6600. (All my tests are fully benchmarked:)
Woodchuck
Woodchuck
I will perform this test on a X700, and on a geforce FX too, pretty soon, and post here the results.
I feel that on this cards the scissor test will be well implemented. Because that's a shader consideration. Geforce 2 for exemple, may have this scissor test where it will (almost).

EDIT: Orthographe...

[Edited by - Woodchuck on October 26, 2006 2:53:55 AM]
Woodchuck
Woodchuck
I'll finaly use user-defined clip planes... =)
JasonBlochowiak
JasonBlochowiak
I'm a bit confused - scissor rectangles have been used to limit fill rate consumption for shadow volumes, but I'm not aware of them having been used to limit the application of expensive pixel shaders. Z Pre-pass and front-to-back ordering is more common for that sort of thing.

Are you trying save fill, or avoid expensive fragments?
Woodchuck
Woodchuck
...oops, forgot to login-in.
JasonBlochowiak
JasonBlochowiak
Quote:
Original post by Anonymous Poster
Quote:
Original post by JasonBlochowiak
Are you trying save fill, or avoid expensive fragments?


Take the example of an omni light that lit a part of a wall. The omni have an attenuation, then the most part of the wall will be "black". The blinn shader is very expensive then you have a real performance win to limit the action of the shader to the light radius.


Ok, I could see that would save PS ops, but is the extra setup and overhead really a win?
Woodchuck
Woodchuck
Quote:
Original post by JasonBlochowiak
Quote:
Original post by Anonymous Poster
Quote:
Original post by JasonBlochowiak
Are you trying save fill, or avoid expensive fragments?


Take the example of an omni light that lit a part of a wall. The omni have an attenuation, then the most part of the wall will be "black". The blinn shader is very expensive then you have a real performance win to limit the action of the shader to the light radius.


Ok, I could see that would save PS ops, but is the extra setup and overhead really a win?


Completely (I did the test). The condition is that the mesh must be "low poly". Like Doom3, for not quote it =)

[Edited by - Woodchuck on November 1, 2006 4:10:59 AM]
51mon
51mon
How do you performe Z-Scissoring in DirectX?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.