PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Dynamic Branching auf r300 & co


paul.muad.dib
2006-03-02, 10:48:29
Eine schon etwas ältere Grafikkdemo zeigt, dass sich ein dynamic Branching ähnlicher Effekt auch mit SM 2.0 realisieren lässt. Konkret geht es um einen Beleuchtungseffekt. Diese soll nur in einer gewissen Entfernung zu sehen sein, so dass sich die Karte die Rechnearbeit für weiter Entfernte Objekte einsparen lässt.
Tatsächlich zeigt die Zu- und Abschaltung des Features eine große Performance-Wirkung, ohne dass ich Unterschiede bei der BQ feststellen könnte.


http://www.humus.ca/index.php?page=3D&ID=50

One of the main features of pixel shader 3.0 is that is supports dynamic branching (also called data dependent branching), something that nVidia of course makes a big deal about. This demo however shows a way to implement dynamic branching without pixel shader 3.0, using basic graphics functionality such as alpha testing and stencil testing. Not only is it doable, but also gives every bit of the performance of real dynamic branching.
One scenario where dynamic branching comes in handy is when you have range-limited lights. Whenever a fragment is outside the range of the light, you can skip all the lighting math and just return zero immediately. With pixel shader 3.0 you'd simply implement this with an if-statement. Without pixel shader 3.0, you just move this check to another shader. This shader returns a truth value to alpha. The alpha test then kills all unlit fragments. Surviving fragments will write 1 to stencil. In the next pass you simply draw lighting as usual. The stencil test will remove any fragments that aren't tagged as lit. If the hardware performs the stencil test prior to shading you will save a lot of shading power. In fact, the shading workload is reduced to the same level of pixel shader 3.0, or in some cases even slightly below since the alpha test can do a compare that otherwise would have to be performed in the shader.
The result is that early-out speeds things up considerably. In this demo the speed-up is generally in the range of two to four times as fast than without early-out. And with more complex lighting, the gain would have been even larger.

micki
2006-03-02, 11:44:48
für eine lichtquelle ist das natürlich ok, aber wenn es darum geht mehrere lichtquellen im shader abzuarbeiten funzt der hack meines wissens nach nicht mehr (bzw nur für die lichtquellen als ganzes, nicht pro lichtquelle) und das ist auch ein sehr günstiges beispiel. aber oft brancht man von anderen dingen abhängig, z.b. texturesamples. dafür müßte man also voher die ganze geometrie mal durcharbeiten um stencilbits zu seten und danach nochmal um dann die tatsächlich gewünschte arbeit durchzuführen...

...paper dieser art sind auf der ATI seite, z.b. für simulation von flüssigkeiten oder hairrendering.

mapel110
2006-03-02, 11:54:26
http://www.forum-3dcenter.org/vbulletin/showthread.php?p=1975165#post1975165
wurde auch schon ab hier diskutiert.

paul.muad.dib
2006-03-02, 14:21:32
http://www.forum-3dcenter.org/vbulletin/showthread.php?p=1975165#post1975165
wurde auch schon ab hier diskutiert.

Gut, dann hat sich das wohl erledigt.