Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualuser88

Posted 07 December 2012 - 09:39 AM

I found work around simply inverting sign bit. For those who are interested:
groupshared uint3 sMin;
...
uint3 InvertSignBit(uint3 value)
{
  return ((~value) & uint3(0x80000000, 0x80000000, 0x80000000)) | (value & uint3(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF));
}
...
InterlockedMin(sMin.x, InvertSignBit(asint(viewPosition).x);
...
GroupMemoryBarrierWithGroupSync();
uint3 signedSMin = InvertSignBit(sMin);
float3 minViewPosition = asfloat(signedSMin);

Edit:
No.. Unfortunately this is not a solution. Min for values with negative sing is wrong.

#3user88

Posted 07 December 2012 - 09:33 AM

I found work around simply inverting sign bit. For those who are interested:
groupshared uint3 sMin;
...
uint3 InvertSignBit(uint3 value)
{
  return ((~value) & uint3(0x80000000, 0x80000000, 0x80000000)) | (value & uint3(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF));
}
...
InterlockedMin(sMin.x, InvertSignBit(asint(viewPosition).x);
...
GroupMemoryBarrierWithGroupSync();
uint3 signedSMin = InvertSignBit(sMin);
float3 minViewPosition = asfloat(signedSMin);

#2user88

Posted 07 December 2012 - 09:32 AM

I found work around simply inverting sign bit. For those who are interested:
groupshared uint3 sMin;
...
uint3 InvertSignBit(uint3 value)
{
  return ((~value) & uint3(0x80000000, 0x80000000, 0x80000000)) | (value & uint3(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF));
}
...
InterlockedMin(sMin.x, InvertSignBit(asint(viewPosition).x);
...
GroupMemoryBarrierWithGroupSync();
uint3 signedSMin = InvertSignBit(sMin);
float3 minViewPosition = asfloat(signedSMin);

#1user88

Posted 07 December 2012 - 08:14 AM

I found work around simply inverting sign bit. For those who are interested:
groupshared uint3 sMin;
...
uint3 InvertSignBit(uint3 value)
{
return (~(value & uint3(0xF0000000, 0xF0000000, 0xF0000000))) | (value & uint3(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF));
}
...
InterlockedMin(sMin.x, InvertSignBit(asint(viewPosition).x);
...
GroupMemoryBarrierWithGroupSync();
uint3 signedSMin = InvertSignBit(sMin);
float3 minViewPosition = asfloat(signedSMin);

PARTNERS