Jump to content
  • Advertisement
Sign in to follow this  
Mehdi_H

Bitwise Operation in HLSL

This topic is 3418 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

Hi everybody it seems that HLSL supports bitwise operations like "&". For example the line below makes no errors: if( 0xffff & 0x8000 ){ //something } But when I'm using "int" or "uint" as the lines below, I've got the following error message : uniform extern uint gMtrlFlag; if( gMtrlFlag & 0x8000 ){ //something } Error X3535:Bitwise operations not supported on legacy targets. And I don't understand what the error message exactly trying to tell me! Thanx for advice.

Share this post


Link to post
Share on other sites
Advertisement
Are you trying to target D3D9 shader models? Bitwise operations and integer operations were new for SM 4.0/DX10

Share this post


Link to post
Share on other sites
Quote:
Original post by Mehdi_H
Yes. I'm using DX9.
Is there any way to use bitwise operation on DX9?


Unfortunately there isn't, since bitwise and integer ops require hardware support in the shaders.

Share this post


Link to post
Share on other sites
SM4 and above have integer instruction sets and thus you can do this sort of thing. D3D9 was far too vague or limited in the specification to allow a meaningful implementation of this.

If you search around (try things like the conference slidedecks and vendor websites) there are a few hacks for emulating bitwise-like behaviour and/or packing flags into colours and so on...



hth
Jack

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!