diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2022-02-07 12:11:15 -0800 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2022-07-15 12:29:40 -0700 |
| commit | bed278d3b7d200e25527b2deb1a1e5f70ed3ff05 (patch) | |
| tree | 167f5020e67403d266883b3d2c553f9136111957 /Source/Core | |
| parent | dd41a72378ee45e2947fa65e6db03b5898272b45 (diff) | |
Create dedicated enum for EFB/XFB gamma correction
This also changes the behavior for the invalid gamma value, which was confirmed to behave the same as 2.2.
Note that currently, the gamma value is only used for XFB copies, even though hardware testing indicates it also works for EFB copies. This will be changed in a later commit.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/BPMemory.h | 32 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/BPStructs.cpp | 10 |
3 files changed, 23 insertions, 21 deletions
diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index a0c04765b6..b93fcf980a 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -593,7 +593,7 @@ void FifoPlayer::ClearEfb() copy.clamp_bottom = false; copy.unknown_bit = false; copy.target_pixel_format = static_cast<u32>(EFBCopyFormat::RGBA8) << 1; - copy.gamma = 0; + copy.gamma = GammaCorrection::Gamma1_0; copy.half_scale = false; copy.scale_invert = false; copy.clear = true; diff --git a/Source/Core/VideoCommon/BPMemory.h b/Source/Core/VideoCommon/BPMemory.h index 2a837c862b..38281d9493 100644 --- a/Source/Core/VideoCommon/BPMemory.h +++ b/Source/Core/VideoCommon/BPMemory.h @@ -2035,6 +2035,20 @@ struct fmt::formatter<FrameToField> : EnumFormatter<FrameToField::InterlacedOdd> constexpr formatter() : EnumFormatter(names) {} }; +enum class GammaCorrection : u32 +{ + Gamma1_0 = 0, + Gamma1_7 = 1, + Gamma2_2 = 2, + // Hardware testing indicates this behaves the same as Gamma2_2 + Invalid2_2 = 3, +}; +template <> +struct fmt::formatter<GammaCorrection> : EnumFormatter<GammaCorrection::Invalid2_2> +{ + constexpr formatter() : EnumFormatter({"1.0", "1.7", "2.2", "Invalid 2.2"}) {} +}; + union UPE_Copy { u32 Hex; @@ -2044,8 +2058,7 @@ union UPE_Copy BitField<2, 1, u32> unknown_bit; BitField<3, 4, u32> target_pixel_format; // realformat is (fmt/2)+((fmt&1)*8).... for some reason // the msb is the lsb (pattern: cycling right shift) - // gamma correction.. 0 = 1.0 ; 1 = 1.7 ; 2 = 2.2 ; 3 is reserved - BitField<7, 2, u32> gamma; + BitField<7, 2, GammaCorrection> gamma; // "mipmap" filter... false = no filter (scale 1:1) ; true = box filter (scale 2:1) BitField<9, 1, bool, u32> half_scale; BitField<10, 1, bool, u32> scale_invert; // if set vertical scaling is on @@ -2084,19 +2097,6 @@ struct fmt::formatter<UPE_Copy> else clamp = "None"; } - std::string_view gamma = "Invalid"; - switch (copy.gamma) - { - case 0: - gamma = "1.0"; - break; - case 1: - gamma = "1.7"; - break; - case 2: - gamma = "2.2"; - break; - } return fmt::format_to(ctx.out(), "Clamping: {}\n" @@ -2110,7 +2110,7 @@ struct fmt::formatter<UPE_Copy> "Copy to XFB: {}\n" "Intensity format: {}\n" "Automatic color conversion: {}", - clamp, copy.unknown_bit, copy.tp_realFormat(), gamma, + clamp, copy.unknown_bit, copy.tp_realFormat(), copy.gamma, no_yes[copy.half_scale], no_yes[copy.scale_invert], no_yes[copy.clear], copy.frame_to_field, no_yes[copy.copy_to_xfb], no_yes[copy.intensity_fmt], no_yes[copy.auto_conv]); diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 2e34ef6d9b..010dbf6abe 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -11,6 +11,7 @@ #include <fmt/format.h> #include "Common/CommonTypes.h" +#include "Common/EnumMap.h" #include "Common/Logging/Log.h" #include "Core/ConfigManager.h" @@ -42,7 +43,8 @@ using namespace BPFunctions; -static const float s_gammaLUT[] = {1.0f, 1.7f, 2.2f, 1.0f}; +static constexpr Common::EnumMap<float, GammaCorrection::Invalid2_2> s_gammaLUT = {1.0f, 1.7f, 2.2f, + 2.2f}; void BPInit() { @@ -276,9 +278,9 @@ static void BPWritten(const BPCmd& bp, int cycles_into_future) bool is_depth_copy = bpmem.zcontrol.pixel_format == PixelFormat::Z24; g_texture_cache->CopyRenderTargetToTexture( destAddr, PE_copy.tp_realFormat(), copy_width, copy_height, destStride, is_depth_copy, - srcRect, PE_copy.intensity_fmt && PE_copy.auto_conv, PE_copy.half_scale, 1.0f, 1.0f, - bpmem.triggerEFBCopy.clamp_top, bpmem.triggerEFBCopy.clamp_bottom, - bpmem.copyfilter.GetCoefficients()); + srcRect, PE_copy.intensity_fmt && PE_copy.auto_conv, PE_copy.half_scale, 1.0f, + s_gammaLUT[PE_copy.gamma], bpmem.triggerEFBCopy.clamp_top, + bpmem.triggerEFBCopy.clamp_bottom, bpmem.copyfilter.GetCoefficients()); } else { |
