Sign in to follow this  
Mehdi_H

Bitwise Operation in HLSL

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this