Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(win/video): don't offload chroma subsampling math to texture sampler when downscaling #3014

Merged
merged 5 commits into from
Sep 3, 2024

Conversation

ns6089
Copy link
Contributor

@ns6089 ns6089 commented Aug 13, 2024

Description

Don't offload math to texture sampler when subsampling chroma together with downscaling.
Fixes broken chroma when downscaling.
This makes chroma consistent with luma when downscaling, but luma itself is broken if the factor is >2x and half-broken with lesser factors (inconsistent filter radius, linear texture sampler alone can't be used for proper downscaling).
I'm hesitant to touch upscaling because of the potential performance hit.

Screenshot

Before
2024-08-17 16_10_31-dixi - Moonlight
After
2024-08-17 16_16_58-dixi - Moonlight

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

@ns6089 ns6089 changed the title Chroma downscale Don't offload math to texture sampler when subsampling chroma together with downscaling Aug 13, 2024
@ns6089 ns6089 force-pushed the chroma_downscale branch 2 times, most recently from 5f86e5e to 9329e90 Compare August 17, 2024 13:19
@ns6089 ns6089 changed the title Don't offload math to texture sampler when subsampling chroma together with downscaling fix(win/video): don't offload chroma subsampling math to texture sampler when downscaling Aug 17, 2024
@ns6089 ns6089 marked this pull request as ready for review August 17, 2024 13:21
Copy link

codecov bot commented Aug 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 54 lines in your changes missing coverage. Please review.

Project coverage is 9.83%. Comparing base (9d7e90e) to head (bc2bd06).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/platform/windows/display_vram.cpp 0.00% 50 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3014      +/-   ##
=========================================
+ Coverage    9.70%   9.83%   +0.12%     
=========================================
  Files          77     101      +24     
  Lines       14055   17988    +3933     
  Branches     6443    8410    +1967     
=========================================
+ Hits         1364    1769     +405     
- Misses      10071   13337    +3266     
- Partials     2620    2882     +262     
Flag Coverage Δ
Linux 7.26% <ø> (?)
Windows 5.06% <0.00%> (+<0.01%) ⬆️
macOS-12 10.76% <ø> (-0.02%) ⬇️
macOS-13 10.66% <ø> (-0.02%) ⬇️
macOS-14 10.97% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/windows/display_vram.cpp 1.84% <0.00%> (+0.17%) ⬆️

... and 56 files with indirect coverage changes

@ns6089
Copy link
Contributor Author

ns6089 commented Aug 25, 2024

The code in this pull request is Not a Contribution under LizardByte Individual Contributor License Agreement.
The code in this pull request is shared under GNU GENERAL PUBLIC LICENSE Version 3.

@ReenigneArcher ReenigneArcher marked this pull request as draft August 25, 2024 04:22
@cgutman
Copy link
Collaborator

cgutman commented Aug 28, 2024

Reopening now that the CLA has been revoked and this can now be accepted under the GPLv3 terms alone.

@cgutman cgutman reopened this Aug 28, 2024
@cgutman cgutman marked this pull request as ready for review August 30, 2024 05:12
return -1; \
}

const bool downscaling = display->width != width || display->height != height;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const bool downscaling = display->width != width || display->height != height;
const bool downscaling = display->width > width || display->height > height;

Comment on lines 21 to 27
float3 rgb = image.Sample(def_sampler, input.tex_right_center_left_top.xw).rgb; // top-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.yw).rgb; // top-center
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.zw).rgb; // top-left
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.xw).rgb; // bottom-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.yw).rgb; // bottom-center
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.zw).rgb; // bottom-left
rgb = CONVERT_FUNCTION(rgb * (1./6));
Copy link
Contributor Author

@ns6089 ns6089 Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float3 rgb = image.Sample(def_sampler, input.tex_right_center_left_top.xw).rgb; // top-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.yw).rgb; // top-center
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.zw).rgb; // top-left
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.xw).rgb; // bottom-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.yw).rgb; // bottom-center
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.zw).rgb; // bottom-left
rgb = CONVERT_FUNCTION(rgb * (1./6));
float3 rgb = image.Sample(def_sampler, input.tex_right_center_left_top.yw).rgb; // top-center
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.yw).rgb; // bottom-center
rgb *= 2;
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.xw).rgb; // top-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.zw).rgb; // top-left
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.xw).rgb; // bottom-right
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.zw).rgb; // bottom-left
rgb = CONVERT_FUNCTION(rgb * (1./8));

Also just realized we can sightly improve the quality and be consistent with what we do in no scaling path (#1621 (comment)) at pretty much no additional cost.

@ns6089
Copy link
Contributor Author

ns6089 commented Aug 31, 2024

Also fixed portrait rotation bug that's been there since that feature got first introduced ns6089@f41242f

Copy link

sonarcloud bot commented Sep 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
7 New issues
7 New Code Smells (required ≤ 0)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@cgutman cgutman merged commit 7ce8547 into LizardByte:master Sep 3, 2024
35 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants