JLo*_*JLo 10 floating-point precision glsl vulkan
我尝试在 GLSL Vulkan 计算着色器中实现Alma College 的 Andrew Thall 所著的论文Extended-Precision Floating-Point Numbers for GPU Computation。我需要这个,因为我的一些设备不支持双精度。
我的问题出在 quickTwoSum 函数中
vec2 quickTwoSum( float a , float b) {
float s = a + b;
float t = s - a;
float e = b - t;
return vec2(s, e);
}
Run Code Online (Sandbox Code Playgroud)
例如
a = 114251.609
b = -0.00107500004
Run Code Online (Sandbox Code Playgroud)
然后发生这种情况
s = 114251.609 // this is correct because b is to small
t = -0.00107500004 // <= why? (s - a) should be 0
e = 0.0 // <= this is wrong because t is wrong
Run Code Online (Sandbox Code Playgroud)
为什么牛逼不正确?似乎 GPU 在后台存储的数据比 32 位浮点变量实际可以保存的更精确。
是GPU问题吗?我使用 NVIDIA GeForce GT 750M。在我的 CPU 上,它应该如何工作。
我发现有人为 OpenGL https://www.thasler.com/blog/blog/glsl-part2-emu实现了它。所以它也应该适用于 GPU。
如果有人可以帮助我,那就太好了。
更新:
这是我的程序文件
cbc.com:GLSL着色器
glsl_compiler_output.txt : glslangValidator的输出
cbc_comp.spv : 编译为 SPIR-V 的着色器
main.cpp:是一个 mandelbrot vulkan 计算示例,我根据我的需要对其进行了更改
vulkantest_output.txt:我的程序的输出