• Advertisement
Sign in to follow this  

HLSL - function returning greater of two values?

This topic is 4350 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement