HLSL - function returning greater of two values?

Started by
3 comments, last by sipickles 18 years, 1 month ago
Hello, Can anyone suggest a HLSL function which returns the higher of two values, equivalent to this C function float myFunction( float a, float b ) { return ( ( a > b ) ? a : b ); } or can i just use ?: in HLSL Also is there a way to see the assembler that a HLSL shader generates, so I can see if it is efficient enough? Thanks Simon
Advertisement
Quote:Original post by sipickles
or can i just use ?: in HLSL

As far as I can tell, yes, you can use '?' in HLSL.
Hi bud,

There is an intrinsic in the HLSL language called max(). Here is a linky!

Hope that helps,

Dave
1) max(x,y)

which will turn into a single instruction in vs1.1 and above; a single instruction in ps2.0 and above; and about 2 instructions for ps1.x (though they're of course co-issuable if the values are only vector or only scalar).


2) Using FXC effect compiler, specify the "/Fc file" switch to generate an assembly listing to 'file'.


[edit: bah, late again![wink]]

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

DOH! max()

Thanks for the pointer

Si

This topic is closed to new replies.

Advertisement