PDA

View Full Version : NV30 Condition Codes



alexsok
09-07-2002, 06:52 AM
Firstable, I'd like to greet u all guys, I've just recently discovered this forum and the intresting discussions taking place here, so I thought I might join in! http://www.opengl.org/discussion_boards/ubb/smile.gif)

Anyway, after reading many nVidia papers about their new CineFX architecture (NV30), I was pleasantly suprised to see that NV30 will allow for condition codes in PS. One of their papers contains the statement that while there isn't any type of branching in PS, NV30 looks to support condition codes in the pixel shader pipelines that executes all branches, with the final value chosen at the end. This sort of format preserves the incredible predictability of dedicated 3D hardware, while adding significant flexibility.

I can definetly see why nVidia chose not to implement branching, but could u guys enlighten me in regards to what is/isn't possible with condition codes and in what particular situations would it be better to use branching?

Also, do u think it was wise on nVidia's side to implement condition codes instead of real flow control?

Any input is very much appreciated! http://www.opengl.org/discussion_boards/ubb/smile.gif

P.S
Humus - nice to see u here m8! http://www.opengl.org/discussion_boards/ubb/smile.gif

davepermen
09-07-2002, 07:32 AM
branching means to choose a way. that means jumps, normally. and that means without them you always have to execute the same (no if(not_needed) { dont_do_it() } optimizations) and you can not have loops.. loops would be very handy for me.. so i have to wait another generation http://www.opengl.org/discussion_boards/ubb/biggrin.gif

Nutty
09-07-2002, 09:21 AM
I dont think NV30 fragment program supports any branching, the condition codes seem to be only be for the kill instruction, and aditionally you can use the condition to mask register writes.


Killing the fragment stops the fragment processing dead in it's tracks, and moves onto the next fragment. Which is useful for gaining back performance. Masking register writes is kindof a hacky way to do;




if(<boolean expression> )
{ col = blah;
}
else
{ col = foo;
}


There doesn't seem to be any forms of branching mentioned in the spec.

Real flow control in the fragment processor will turn up eventually, but its a year or two away at best.

Nutty

P.S. I've only skimmed thruogh the spec, so I may be wrong on some stuff http://www.opengl.org/discussion_boards/ubb/smile.gif

alexsok
09-07-2002, 09:31 AM
Originally posted by Nutty:
I dont think NV30 fragment program supports any branching, the condition codes seem to be only be for the kill instruction, and aditionally you can use the condition to mask register writes.


Killing the fragment stops the fragment processing dead in it's tracks, and moves onto the next fragment. Which is useful for gaining back performance. Masking register writes is kindof a hacky way to do;




if(<boolean expression> )
{ col = blah;
}
else
{ col = foo;
}


There doesn't seem to be any forms of branching mentioned in the spec.

Real flow control in the fragment processor will turn up eventually, but its a year or two away at best.

Nutty

P.S. I've only skimmed thruogh the spec, so I may be wrong on some stuff http://www.opengl.org/discussion_boards/ubb/smile.gif

You're right m8, NV30 fragment program doesn't support any form of branching, but it does support condition codes, which according to nVidia can be used to do many things u could also do with branching.

mcraighead
09-07-2002, 03:31 PM
Right, the most obvious use for condition codes is to emulate branching. (Real branching _can_ be faster if it lets you skip a lot of instructions, and the branch is either almost always taken or almost always not taken.)

It can get annoying to write out all the code for using condition codes. Fortunately, the Cg compiler should be able to help you out here and compile your "if" statements with no trouble.

You can think of condition codes as being the rough equivalent to "CMOV" instructions in x86.

- Matt

alexsok
09-07-2002, 10:49 PM
Originally posted by mcraighead:
Right, the most obvious use for condition codes is to emulate branching. (Real branching _can_ be faster if it lets you skip a lot of instructions, and the branch is either almost always taken or almost always not taken.)

It can get annoying to write out all the code for using condition codes. Fortunately, the Cg compiler should be able to help you out here and compile your "if" statements with no trouble.

You can think of condition codes as being the rough equivalent to "CMOV" instructions in x86.

- Matt

Thx m8! http://www.opengl.org/discussion_boards/ubb/smile.gif

Just the answer I was looking for! http://www.opengl.org/discussion_boards/ubb/smile.gif

Nutty
09-08-2002, 01:48 AM
I dont recall there ever being a CMOV instruction on the 8086 cpu? Or was this added on some later cpu?

It's been a long time since I did pc asm tho..

Humus
09-08-2002, 02:07 AM
CMOV was introduced in the pentium. Then you also have the i386 instruction SET which can set a register to 0 or 1 depending on condition codes, not really the same but can be used as a replacement for branches too.

jwatte
09-08-2002, 02:17 PM
"Condition codes" is something more general and less powerful -- it's just bits telling you how some specific operations went.

What we DO with the condition codes is the interesting part. NV30 (and DX9, it seems) doesn't support branching (based on condition codes or no) but does support predication. So let's call this mechanism "predication" to be clear about what we're talking about.

mcraighead
09-08-2002, 05:08 PM
Predication, well, sort of. The important point is that you end up executing all the instructions on both sides of your "branch". Predication sometimes implies that this is not the case. (Less important when instructions are not capable of generating "faults".)

NV30 *does* support real (i.e. data-dependent) branching/looping/function calls in vertex programs. From the little I know of it, DX9 is quite a bit less general there. I also don't know if DX9 supports CC's.

Anyhow, CC's are quite a nice improvement over the whole "SGE/MUL/MAD" mess.

- Matt

jwatte
09-08-2002, 05:48 PM
> Anyhow, CC's are quite a nice improvement
> over the whole "SGE/MUL/MAD" mess.

You get no argument from me there :-) I was actually very pleased when I first learned that there's predication in the pixel pipe, too.

Now, any hints on when the NV30-2-Go is due? :-) :-)

Tim Stirling
09-10-2002, 11:18 PM
Better still, when is the NV30 out... Its going to be an interesting xmas anyway.


Tim