summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoCommon/PixelShaderGen.cpp')
-rw-r--r--Source/Core/VideoCommon/PixelShaderGen.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp
index ed3733d035..4413c6d9b6 100644
--- a/Source/Core/VideoCommon/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/PixelShaderGen.cpp
@@ -1006,17 +1006,22 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i
"z",
};
- // 0b11111000, 0b11100000, 0b11110000, 0b11111000
- static constexpr std::array<const char*, 4> tev_ind_alpha_mask{
- "248",
- "224",
- "240",
- "248",
+ // According to libogc, the bump alpha value is 5 bits, and comes from the bottom bits of the
+ // component byte, except in the case of ITF_8, which presumably uses the top bits with a
+ // mask.
+ // https://github.com/devkitPro/libogc/blob/bd24a9b3f59502f9b30d6bac0ae35fc485045f78/gc/ogc/gx.h#L3038-L3041
+ // https://github.com/devkitPro/libogc/blob/bd24a9b3f59502f9b30d6bac0ae35fc485045f78/gc/ogc/gx.h#L790-L800
+
+ static constexpr std::array<char, 4> tev_ind_alpha_shift{
+ '0', // ITF_8: 0bXXXXXYYY -> 0bXXXXX000? No shift?
+ '5', // ITF_5: 0bIIIIIAAA -> 0bAAA00000, shift of 5
+ '4', // ITF_4: 0bIIIIAAAA -> 0bAAAA0000, shift of 4
+ '3', // ITF_3: 0bIIIAAAAA -> 0bAAAAA000, shift of 3
};
- out.Write("alphabump = iindtex{}.{} & {};\n", tevind.bt.Value(),
+ out.Write("alphabump = (iindtex{}.{} << {}) & 248;\n", tevind.bt.Value(),
tev_ind_alpha_sel[u32(tevind.bs.Value())],
- tev_ind_alpha_mask[u32(tevind.fmt.Value())]);
+ tev_ind_alpha_shift[u32(tevind.fmt.Value())]);
}
else
{
@@ -1026,14 +1031,14 @@ static void WriteStage(ShaderCode& out, const pixel_shader_uid_data* uid_data, i
if (has_ind_stage && tevind.matrix_index != IndMtxIndex::Off)
{
// format
- static constexpr std::array<const char*, 4> tev_ind_fmt_mask{
- "255",
- "31",
- "15",
- "7",
+ static constexpr std::array<char, 4> tev_ind_fmt_shift{
+ '0', // ITF_8: 0bXXXXXXXX -> 0bXXXXXXXX, no shift
+ '3', // ITF_5: 0bIIIIIAAA -> 0b000IIIII, shift of 3
+ '4', // ITF_4: 0bIIIIAAAA -> 0b0000IIII, shift of 4
+ '5', // ITF_3: 0bIIIAAAAA -> 0b00000III, shift of 5
};
- out.Write("\tint3 iindtevcrd{} = iindtex{} & {};\n", n, tevind.bt.Value(),
- tev_ind_fmt_mask[u32(tevind.fmt.Value())]);
+ out.Write("\tint3 iindtevcrd{} = iindtex{} >> {};\n", n, tevind.bt.Value(),
+ tev_ind_fmt_shift[u32(tevind.fmt.Value())]);
// bias - TODO: Check if this needs to be this complicated...
// indexed by bias