I'm trying to do binary operations with integers in the hlsl code. For example:

int n = 10 & 15;

Binary value of 10 = 1010 and Binary value of 15 = 1111.

With this, n = 10, because (1010 & 1111) = 1010. This is what I need, but if I declare the int values before, I get an error. For example:

int n1 = 10;
int n2 = 15;
int n = n1 & n2;

this shows the error: "error X3535: Bitwise operations not supported on legacy targets."

I made this simple code to help understanding, because I have no idea what is causing this.

I already tried to change the variables type to uint, but the error remains.

I'm using deferred lighting in xna and I want to store the emissive light intensity together with the specular power.

  • 1
    \$\begingroup\$ Related (or duplicate?): gamedev.stackexchange.com/questions/30513/… What version are you targeting? \$\endgroup\$
    – House
    Commented Oct 3, 2014 at 19:59
  • \$\begingroup\$ vertex and pixel shader version 2_0, but I want to know why it works when the number is not declared. \$\endgroup\$
    – glz
    Commented Oct 3, 2014 at 20:10
  • \$\begingroup\$ It probably does the calculation at compile time when you're using constants, but I'm not sure. \$\endgroup\$
    – House
    Commented Oct 3, 2014 at 20:12


You must log in to answer this question.

Browse other questions tagged .