diff --git a/src/d3d9/shaders/d3d9_convert_common.h b/src/d3d9/shaders/d3d9_convert_common.h new file mode 100644 index 00000000..b29bf59f --- /dev/null +++ b/src/d3d9/shaders/d3d9_convert_common.h @@ -0,0 +1,13 @@ +float unormalize(uint value, int bits) { + const int range = (1 << bits) - 1; + + return float(value) / float(range); +} + +float snormalize(int value, int bits) { + const int range = (1 << (bits - 1)) - 1; + + // Min because, -32 and -31 map to -1.0f, and we + // divide by 31. + return max(float(value) / float(range), -1.0f); +} \ No newline at end of file diff --git a/src/d3d9/shaders/d3d9_convert_l6v5u5.comp b/src/d3d9/shaders/d3d9_convert_l6v5u5.comp index 122d2957..e7ee25a9 100644 --- a/src/d3d9/shaders/d3d9_convert_l6v5u5.comp +++ b/src/d3d9/shaders/d3d9_convert_l6v5u5.comp @@ -1,4 +1,7 @@ #version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "d3d9_convert_common.h" layout( local_size_x = 8, @@ -15,20 +18,6 @@ uniform u_info_t { uvec2 extent; } u_info; -float unormalize(uint value, int bits) { - const int range = (1 << bits) - 1; - - return float(value) / float(range); -} - -float snormalize(int value, int bits) { - const int range = (1 << (bits - 1)) - 1; - - // Min because, -32 and -31 map to -1.0f, and we - // divide by 31. - return max(float(value) / float(range), -1.0f); -} - void main() { ivec3 thread_id = ivec3(gl_GlobalInvocationID);