Add count_{leading,trailing}_zeros() functions to stdlib.

(Documentation is still yet to be written.)
This commit is contained in:
Matt Pharr
2011-11-30 10:12:16 -08:00
parent 1703f2717c
commit 7a2561c429
9 changed files with 192 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = count_trailing_zeros(0xf0);
}
export void result(uniform float RET[]) {
RET[programIndex] = 4;
}

View File

@@ -0,0 +1,11 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = count_leading_zeros((int32)0xf0);
}
export void result(uniform float RET[]) {
RET[programIndex] = 24;
}

View File

@@ -0,0 +1,11 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
RET[programIndex] = count_leading_zeros((unsigned int64)0xf0);
}
export void result(uniform float RET[]) {
RET[programIndex] = 56;
}

View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
int32 i = (1 << programIndex);
RET[programIndex] = count_leading_zeros(i);
}
export void result(uniform float RET[]) {
RET[programIndex] = 31-programIndex;
}

View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
unsigned int64 i = ((unsigned int64)1 << (50+programIndex));
RET[programIndex] = count_trailing_zeros(i);
}
export void result(uniform float RET[]) {
RET[programIndex] = 50+programIndex;
}