Skip to content

Instantly share code, notes, and snippets.

@nikvoronin
Created November 6, 2020 20:02
Show Gist options
  • Save nikvoronin/918cfb976d9512ee046cd2d12df2ed38 to your computer and use it in GitHub Desktop.
Save nikvoronin/918cfb976d9512ee046cd2d12df2ed38 to your computer and use it in GitHub Desktop.
__kernel void xorshift(
uint s1, // seed(base) 1
uint s2, // seed(base) 2
const int bufferSize,
__global float2* rngBuffer)
{
uint st;
for(int i = 0; i < bufferSize; i++) {
st = s1 ^ (s1 << 11);
s1 = s2;
s2 = s2 ^ (s2 >> 19) ^ ( st ^ (st >> 18));
rngBuffer[i] = (float2)((float)st / UINT_MAX, (float)s1 / UINT_MAX);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment