diff --git a/app/src/main/java/com/hinnka/mycamera/lut/LogInputGl.kt b/app/src/main/java/com/hinnka/mycamera/lut/LogInputGl.kt index 5847802f..3c41250d 100644 --- a/app/src/main/java/com/hinnka/mycamera/lut/LogInputGl.kt +++ b/app/src/main/java/com/hinnka/mycamera/lut/LogInputGl.kt @@ -65,10 +65,13 @@ internal class LogInputGl { uniform highp sampler2D uInverseAcr3Texture; float inverseAcr3(float value) { - int lastIndex = textureSize(uInverseAcr3Texture, 0).x - 1; + // Integer precision also controls int-to-float conversion precision. + // A mediump conversion can round 4095 to 4096, moving white beyond + // the texture and corrupting interpolation above the FP16 exact range. + highp int lastIndex = textureSize(uInverseAcr3Texture, 0).x - 1; float position = clamp(value, 0.0, 1.0) * float(lastIndex); - int lowerIndex = int(floor(position)); - int upperIndex = min(lowerIndex + 1, lastIndex); + highp int lowerIndex = int(floor(position)); + highp int upperIndex = min(lowerIndex + 1, lastIndex); float lower = texelFetch(uInverseAcr3Texture, ivec2(lowerIndex, 0), 0).r; float upper = texelFetch(uInverseAcr3Texture, ivec2(upperIndex, 0), 0).r; return mix(lower, upper, position - float(lowerIndex)); diff --git a/app/src/main/java/com/hinnka/mycamera/lut/PreviewColorShader.kt b/app/src/main/java/com/hinnka/mycamera/lut/PreviewColorShader.kt index c9c35f39..46307f80 100644 --- a/app/src/main/java/com/hinnka/mycamera/lut/PreviewColorShader.kt +++ b/app/src/main/java/com/hinnka/mycamera/lut/PreviewColorShader.kt @@ -25,7 +25,7 @@ internal object PreviewColorShader { in vec2 vOutputCoord; out vec4 fragColor; - uniform $sampler uCameraTexture; + uniform highp $sampler uCameraTexture; uniform mediump sampler3D uLutTexture; uniform float uLutSize; diff --git a/docs/gles-driver-compatibility.md b/docs/gles-driver-compatibility.md index 7b588abe..573232db 100644 --- a/docs/gles-driver-compatibility.md +++ b/docs/gles-driver-compatibility.md @@ -193,6 +193,17 @@ NDK 编译器可确认修复前的 LK 浮点读取带有 `RelaxedPrecision`, 已确认的源码精度契约缺失;没有反馈设备上的低/高精度读回对照时,不得将它写成某款 GPU 已复现的故障,也不得把 `lowp` 一律等同于实际 FP16。 +### 曲线查表索引的整数转浮点精度 + +Fragment 的 `precision highp float` 不覆盖默认 `mediump int`。用于曲线坐标缩放和 +插值权重的整数索引必须显式声明 `highp int`:`float(index)` 的转换本身可能携带 +低精度,之后赋给 highp 浮点变量不能恢复精度。4096 项表的末端索引 `4095` 在 +FP16 下会舍入为 `4096`,可能使白点取样越界;2048 以上的奇数索引也会影响插值权重。 + +`LogInputGl` 的 NDK 编译检查确认,修复前两处整数转浮点带有 `RelaxedPrecision`, +显式声明 highp 索引后标记消失。PMA110 / Adreno 840 的六种视频 Log 合成色阶读回 +在修复前后一致;三星高光伪色反馈尚未在对应设备复现,不将此记为三星驱动缺陷。 + ### `R16UI` 采样不代表可用于 image store GLES 3.1 可以通过 `usampler2D` 采样 `R16UI` texture,但核心 GLSL ES 3.10 image