Bitwise Operation in HLSL
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.
Are you trying to target D3D9 shader models? Bitwise operations and integer operations were new for SM 4.0/DX10
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement