为什么GLSL的算术函数在iPad上比在模拟器上产生如此不同的结果? [英] Why does GLSL's arithmetic functions yield so different results on the iPad than on the simulator?

查看:199
本文介绍了为什么GLSL的算术函数在iPad上比在模拟器上产生如此不同的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在iOS设备上运行的OpenGL ES 2.0片段着色器代码中查找一些错误。代码在模拟器中运行良好,但在iPad上有很大的问题,一些计算产生了大不相同的结果,例如iPad上的 0.0 和< c $ c> 4013.17 在模拟器上,所以我不是在谈论可能是一些舍入错误的结果小的差异。



我注意到的一件事是,在iPad上,

  float1 = pow(float2,2.0); 

可以产生与


$ b的结果大不相同的结果$ b

  float1 = float2 * float2; 

特别是当使用 pow(x,2.0) -8 ),它似乎返回一个满足条件的值if(powResult <= 0.0 )



另外,两个操作的结果( pow(x,2.0)以及 x * x )在模拟器中产生的结果与在iPad上的不同。

mediump ,但是我得到的东西与 highp

<对于这些差异,是否有一个简单的解释?



我正在缩小这个问题的范围,但这需要很多时间,所以也许有人可以帮我解释一下。

/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdfrel =noreferrer> GLSL ES文档指出pow是未定义的,如果x < 0或者如果x = 0和y≤0。


I'm currently chasing some bugs in my OpenGL ES 2.0 fragment shader code which is running on iOS devices. The code runs fine in the simulator, but on the iPad it has huge problems and some of the calculations yield vastly different results, I had for example 0.0 on the iPad and 4013.17 on the simulator, so I'm not talking about small differences which could be the result of some rounding errors.

One of the things I noticed is that, on the iPad,

float1 = pow(float2, 2.0);

can yield results which are very different from the results of

float1 = float2 * float2;

Specifically, when using pow(x, 2.0) on a variable containing a larger negative number like -8, it seemed to return a value which satified the condition if (powResult <= 0.0).

Also, the result of both operations (pow(x, 2.0) as well as x*x) yields different results in the simulator than on the iPad.

Used floats are mediump, but I get the same stuff with highp.

Is there a simple explanation for those differences?

I'm narrowing the problem down, but it takes so much time, so maybe someone can help me here with a simple explanation.

解决方案

The GLSL ES documentation says pow is undefined if x < 0 or if x = 0 and y ≤ 0.

这篇关于为什么GLSL的算术函数在iPad上比在模拟器上产生如此不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆