不同硬件上的不同 OpenGL 行为

Different OpenGL behaviour on different hardware

我有一个使用 OpenGL 绘制输出图像的应用程序。出于测试目的,我尝试创建参考图像,然后使用精度哈希将它们与程序输出进行比较。虽然它在单台计算机的上下文中完美运行,但我在对 运行 不同 GPU 的计算机使用相同方法时遇到了奇怪的问题。虽然在不同 GPU 上生成的图像看起来与人眼完全相同,但在相互比较时它们无法通过精度哈希测试,并且每像素比较显示有几个像素“关闭”。几天来,我一直试图在我的代码中查找问题,但无济于事,这种行为在我使用的所有着色器上都有体现。这可能是由于不同硬件制造商在 OpenGL 实现上的差异造成的吗?将不同 GPU 上生成的图像与 phash 进行比较以进行测试是否是一种有效的方法?

Could this possibly be due to differences in OpenGL implementation from different hardware manufacturers? Is it a valid approach to compare images generated on different GPUs with phash for testing purposes?

不,不是。引用 OpenGL 4.6 core profile specification,附录 A“不变性”(强调我的):

The OpenGL specification is not pixel exact. It therefore does not guarantee an exact match between images produced by different GL implementations. However, the specification does specify exact matches, in some cases, for images produced by the same implementation. The purpose of this appendix is to identify and provide justification for those cases that require exact matches.

精确匹配的保证仅在相同的实现中,在非常严格的限制下进行,并且这些对于例如需要在不同的遍中获得完全相同的片段的多遍方法很有用。

请注意,其他 3D 渲染 API 也不是像素精确的。实际的硬件实现在各个 GPU 之间确实有所不同,规范通常只指定每个实现必须满足的更广泛的规则,您可以依赖。