有办法了解特定供应商的GPU光栅化差异吗?

huangapple go评论54阅读模式
英文:

Is there a way to know vendor specific GPU rasterization differences?

问题

让我澄清一下。假设我只想渲染一条线(或三角形),让它在不同的GPU上看起来完全相同。如果这条线稍微倾斜,它可能会以稍微不同的方式进行光栅化,具有略微不同的“阶梯”效果(让我们忽略所有抗锯齿/插值等等)。

基本上,有没有办法确保这条线的所有片段都会放置在不同GPU上的相同像素位置?

我知道,例如,硬件计算到“像素中心”的距离可能存在差异,可能以不同的方式近似,例如,“0.499999...9”或“0.500000...1”粗略地说。

对于某些特定用例,我当然可以通过一些非常小的偏移来微调坐标,但是否可以自动完成呢?也许这种事情在某些文档/规格中有描述?我提出这个问题不仅是为了使渲染在像素级别相同,还要确保这不是由于我遇到的其他错误导致的。

英文:

Let me clarify a bit. Let's say I just want to render 1 line (or triangle) that would look identical on several different GPUs. If this line is somewhat diagonal, it might be rasterized slightly different, with slightly different "ladder" (let's omit all the antialiasing/interpolation/etc.).

Basically, is there a way to make sure that all the fragments of this line would be placed in the same pixels on different GPUs?

I know for example that there might be differences in how the hardware calculates the distance to the "pixel center", which might be approximated differently, e.g. "0.499999...9" or "0.500000...1" roughly speaking.

For some specific use-case, I can of course tweak the coordinates by some very small offset, but could it be done somewhat automatically? Maybe this kind of thing is described in some docs/specifications? I'm asking this not only to make the rendering identical pixel-wise, but also to make sure this happens not because of some other bug I've got.

答案1

得分: 3

OpenGL标准没有规定实现你所需的任何特定光栅化基元的方法(甚至浮点数的表示方法),因此不能保证两个实现将产生相同的图像。

OpenGL只要求在相同实现中,相同状态下的相同命令会产生相同的结果。

OpenGL 4.6规范的附录A明确说明了这一点:
> OpenGL规范不是像素精确的。因此,它不保证不同GL实现产生的图像完全相同。但是,在某些情况下,规范确实为同一实现产生的图像指定了精确匹配。

英文:

There is no way to achieve what you want. The OpenGL Standard doesn't mandate any specific method to rasterize primitives (or even how floating pointer numbers are represented), there is no guarantee that two implementations will result in the same image.

OpenGL only mandates that the same command in the same state gives the same result *on the same implementation.

Appendix A of the OpenGL 4.6 Spec states this explicitly:

> 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.

huangapple
  • 本文由 发表于 2023年7月20日 19:44:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定