/* Compile with:
*
- * glsl_compiler --version 140 --dump-builder int64.glsl > builtin_int64.h
+ * glsl_compiler --version 400 --dump-builder int64.glsl > builtin_int64.h
*
- * Using version 1.40+ prevents built-in variables from being included.
+ * Version 4.00+ is required for umulExtended.
*/
#version 400
#extension GL_ARB_gpu_shader_int64: require
return negate ? unpackInt2x32(-int64_t(packUint2x32(quot))) : ivec2(quot);
}
+
+uvec2
+umod64(uvec2 n, uvec2 d)
+{
+ return udivmod64(n, d).zw;
+}
+
+ivec2
+imod64(ivec2 _n, ivec2 _d)
+{
+ const bool negate = (_n.y < 0) != (_d.y < 0);
+ uvec2 n = unpackUint2x32(uint64_t(abs(packInt2x32(_n))));
+ uvec2 d = unpackUint2x32(uint64_t(abs(packInt2x32(_d))));
+
+ uvec2 rem = udivmod64(n, d).zw;
+
+ return negate ? unpackInt2x32(-int64_t(packUint2x32(rem))) : ivec2(rem);
+}