summaryrefslogtreecommitdiff
path: root/src/render/shaders
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-03-16 21:50:15 +0000
committerVaxry <vaxry@vaxry.net>2025-03-16 21:50:20 +0000
commit22154fa272201950a3d37e2a40d9dc3a9cc92329 (patch)
treef0d008819941e19412469edcc8c35ecb57cab722 /src/render/shaders
parent2ddd16ef28bfd3687d21f0052fe958af1914aa5f (diff)
opengl: simplify cm pipeline
fixes a few mistakes, and skips the CM shader in cpu instead of adding a costly branch ref #9641
Diffstat (limited to 'src/render/shaders')
-rw-r--r--src/render/shaders/CM.frag39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/render/shaders/CM.frag b/src/render/shaders/CM.frag
index dd695d44..aa26f97d 100644
--- a/src/render/shaders/CM.frag
+++ b/src/render/shaders/CM.frag
@@ -8,7 +8,6 @@ uniform sampler2D tex;
//uniform samplerExternalOES texture0;
uniform int texType; // eTextureType: 0 - rgba, 1 - rgbx, 2 - ext
-uniform int skipCM;
uniform int sourceTF; // eTransferFunction
uniform int targetTF; // eTransferFunction
uniform mat4x2 sourcePrimaries;
@@ -408,26 +407,28 @@ void main() {
if (discardAlpha == 1 && pixColor[3] <= discardAlphaValue)
discard;
- if (skipCM == 0) {
- pixColor.rgb /= max(pixColor.a, 0.001);
- pixColor.rgb = toLinearRGB(pixColor.rgb, sourceTF);
- mat3 srcxyz = primaries2xyz(sourcePrimaries);
- mat3 dstxyz;
- if (sourcePrimaries == targetPrimaries)
- dstxyz = srcxyz;
- else {
- dstxyz = primaries2xyz(targetPrimaries);
- pixColor = convertPrimaries(pixColor, srcxyz, sourcePrimaries[3], dstxyz, targetPrimaries[3]);
- }
- pixColor = toNit(pixColor, sourceTF);
- pixColor.rgb *= pixColor.a;
- pixColor = tonemap(pixColor, dstxyz);
- if (sourceTF == CM_TRANSFER_FUNCTION_SRGB && targetTF == CM_TRANSFER_FUNCTION_ST2084_PQ)
- pixColor = saturate(pixColor, srcxyz, sdrSaturation);
- pixColor *= sdrBrightnessMultiplier;
- pixColor = fromLinearNit(pixColor, targetTF);
+ pixColor.rgb /= max(pixColor.a, 0.001);
+ pixColor.rgb = toLinearRGB(pixColor.rgb, sourceTF);
+ mat3 srcxyz = primaries2xyz(sourcePrimaries);
+ mat3 dstxyz;
+
+ if (sourcePrimaries == targetPrimaries)
+ dstxyz = srcxyz;
+ else {
+ dstxyz = primaries2xyz(targetPrimaries);
+ pixColor = convertPrimaries(pixColor, srcxyz, sourcePrimaries[3], dstxyz, targetPrimaries[3]);
}
+ pixColor = toNit(pixColor, sourceTF);
+ pixColor.rgb *= pixColor.a;
+ pixColor = tonemap(pixColor, dstxyz);
+
+ if (sourceTF == CM_TRANSFER_FUNCTION_SRGB && targetTF == CM_TRANSFER_FUNCTION_ST2084_PQ)
+ pixColor = saturate(pixColor, srcxyz, sdrSaturation);
+
+ pixColor *= sdrBrightnessMultiplier;
+ pixColor = fromLinearNit(pixColor, targetTF);
+
if (applyTint == 1)
pixColor = vec4(pixColor.rgb * tint.rgb, pixColor[3]);