HLSL - function returning greater of two values?
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
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
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]]
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]]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement