在一些IOS设备中采样GL_DEPTH24_STENCIL8深度纹理错误。

时间:2021-10-11 04:35:51

I have a depth texture which is GL_DEPTH24_STENCIL8( or GL_DEPTH_COMPONENT24), and I can correctly sample this texture on some devices(iPhone5s iPad1), but fail with some invalid pixels. Following is bound gpu texture (the depth) and the format info captured by xcode :

我有一个深度纹理,它是GL_DEPTH24_STENCIL8(或GL_DEPTH_COMPONENT24),我可以正确地在一些设备上(iPhone5s iPad1)上对这个纹理进行采样,但是没有使用一些无效的像素。下面是绑定gpu纹理(深度)和xcode捕获的格式信息:

在一些IOS设备中采样GL_DEPTH24_STENCIL8深度纹理错误。 在一些IOS设备中采样GL_DEPTH24_STENCIL8深度纹理错误。

Note that I've clip the value into [0.999, 1] since the homo depth are mostly in the set. I am sampling the texture and clip the value in my shader also.

请注意,我将这个值压缩到[0.999,1],因为homo深度主要集中在集合中。我正在对纹理进行采样,并在着色器中剪辑值。

uniform sampler2D tex0;
varying mediump vec2 TexCoord0;
void ps_main()
{
  float bias = 0.0;
  lowp vec4 zb = texture2D(tex0, TexCoord0, bias);
  const mediump float mag = 20.0;
  mediump float linearz = (zb - 0.999) / (1.0 - 0.999)
  gl_FragColor = vec4(linearz, linearz, linearz, 1.0);
}

And this shader gives a wrong result on the devices mentioned above: 在一些IOS设备中采样GL_DEPTH24_STENCIL8深度纹理错误。

这个着色器在上面提到的设备上给出了错误的结果:

The device and driver info is:

设备和驱动信息如下:

Driver: OpenGLES2
Description: Apple A8 GPU
Version: OpenGL ES 2.0 Apple A8 GPU - 77.14
Vendor: Apple Inc.
Width: 2048, Height: 1536, BitDepth: 32

Any clues to this problem? Or some other debug suggestions?

对这个问题有什么线索吗?或者其他一些调试建议?

1 个解决方案

#1


1  

You are relying on more precision than the API guarantees to provide. For example, the variable zb is lowp which would only guarantee 1 part in 256 accuracy, but you then try to use in a computation in which needs at least 1 part in 1000 in when computing the value of linearz.

您所依赖的比API保证提供的精度要高。例如,变量zb是lowp,它只保证了256精度中的1部分,但是在计算线性z的值时,你可以尝试在计算中使用至少1个部分。

Try increasing precision to highp to get above the critical precision threshold.

尝试将精度提高到highp以达到临界精度阈值。

#1


1  

You are relying on more precision than the API guarantees to provide. For example, the variable zb is lowp which would only guarantee 1 part in 256 accuracy, but you then try to use in a computation in which needs at least 1 part in 1000 in when computing the value of linearz.

您所依赖的比API保证提供的精度要高。例如,变量zb是lowp,它只保证了256精度中的1部分,但是在计算线性z的值时,你可以尝试在计算中使用至少1个部分。

Try increasing precision to highp to get above the critical precision threshold.

尝试将精度提高到highp以达到临界精度阈值。