[vlc-commits] [Git][videolan/vlc][master] qt: use branching for crop rate in `SDFAARoundedTexture.frag`
Rémi Denis-Courmont (@Courmisch)
gitlab at videolan.org
Thu Nov 13 19:47:25 UTC 2025
Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC
Commits:
53e20e13 by Fatih Uzunoglu at 2025-11-13T21:11:00+02:00
qt: use branching for crop rate in `SDFAARoundedTexture.frag`
It is generally advised to avoid branching in fragment shader,
but in this case the condition is a uniform value, so it is
not terrible to do this. This way, we avoid the unnecessary
crop calculations.
An alternative to this would be generating new shaders with
preprocessor defines to avoid branching. Considering we already
have a branch for `borderRange`, we might as well have branches
for crop rates.
- - - - -
2 changed files:
- modules/gui/qt/shaders/SDFAARoundedTexture.frag
- modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
Changes:
=====================================
modules/gui/qt/shaders/SDFAARoundedTexture.frag
=====================================
@@ -97,7 +97,7 @@ void main()
#ifdef CROP_SUPPORT
vec2 texCoord;
- // if (cropRate.x > 0.0)
+ if (cropRate.x > 0.0)
{
float normalCropRate = qt_SubRect_source.z * cropRate.x;
@@ -106,9 +106,12 @@ void main()
texCoord.x = (k - l) / (qt_SubRect_source.z) * (qt_TexCoord0.x - qt_SubRect_source.x) + l;
}
- // else { texCoord.x = qt_TexCoord0.x; }
+ else
+ {
+ texCoord.x = qt_TexCoord0.x;
+ }
- // if (cropRate.y > 0.0)
+ if (cropRate.y > 0.0)
{
float normalCropRate = qt_SubRect_source.w * cropRate.y;
@@ -117,7 +120,10 @@ void main()
texCoord.y = (k - l) / (qt_SubRect_source.w) * (qt_TexCoord0.y - qt_SubRect_source.y) + l;
}
- // else { texCoord.y = qt_TexCoord0.y; }
+ else
+ {
+ texCoord.y = qt_TexCoord0.y;
+ }
vec4 texel = texture(source, texCoord);
#else
=====================================
modules/gui/qt/shaders/SDFAARoundedTexture_cropsupport_bordersupport.frag
=====================================
@@ -110,7 +110,7 @@ void main()
#ifdef CROP_SUPPORT
vec2 texCoord;
- // if (cropRate.x > 0.0)
+ if (cropRate.x > 0.0)
{
float normalCropRate = qt_SubRect_source.z * cropRate.x;
@@ -119,9 +119,12 @@ void main()
texCoord.x = (k - l) / (qt_SubRect_source.z) * (qt_TexCoord0.x - qt_SubRect_source.x) + l;
}
- // else { texCoord.x = qt_TexCoord0.x; }
+ else
+ {
+ texCoord.x = qt_TexCoord0.x;
+ }
- // if (cropRate.y > 0.0)
+ if (cropRate.y > 0.0)
{
float normalCropRate = qt_SubRect_source.w * cropRate.y;
@@ -130,7 +133,10 @@ void main()
texCoord.y = (k - l) / (qt_SubRect_source.w) * (qt_TexCoord0.y - qt_SubRect_source.y) + l;
}
- // else { texCoord.y = qt_TexCoord0.y; }
+ else
+ {
+ texCoord.y = qt_TexCoord0.y;
+ }
vec4 texel = texture(source, texCoord);
#else
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/53e20e13e02561dfcc796943015efc6b2a236f33
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/53e20e13e02561dfcc796943015efc6b2a236f33
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list