Jump to content
  • Advertisement
Sign in to follow this  
sipickles

HLSL - function returning greater of two values?

This topic is 4500 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
Hi bud,

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

Hope that helps,

Dave

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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!