mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
TexCache: Mix DXT colors using 2/3 not 3/8.
Hardware draws using 2/3. Adding this way matches rounding, too.
This commit is contained in:
parent
35a1d8a1ef
commit
11ab4e8634
1 changed files with 8 additions and 12 deletions
|
@ -348,9 +348,8 @@ static inline u32 makecol(int r, int g, int b, int a) {
|
|||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
static inline int mul_3_8(int c) {
|
||||
// This is 3/8 * c = 4/8 * c - 1/8 * c.
|
||||
return (c >> 1) - (c >> 3);
|
||||
static inline int mix_2_3(int c1, int c2) {
|
||||
return (c1 + c1 + c2) / 3;
|
||||
}
|
||||
|
||||
// This could probably be done faster by decoding two or four blocks at a time with SSE/NEON.
|
||||
|
@ -370,16 +369,13 @@ void DXTDecoder::DecodeColors(const DXT1Block *src, bool ignore1bitAlpha) {
|
|||
colors_[0] = makecol(red1, green1, blue1, alpha);
|
||||
colors_[1] = makecol(red2, green2, blue2, alpha);
|
||||
if (c1 > c2 || ignore1bitAlpha) {
|
||||
int red3 = mul_3_8(red2 - red1);
|
||||
int green3 = mul_3_8(green2 - green1);
|
||||
int blue3 = mul_3_8(blue2 - blue1);
|
||||
colors_[2] = makecol(red1 + red3, green1 + green3, blue1 + blue3, alpha);
|
||||
colors_[3] = makecol(red2 - red3, green2 - green3, blue2 - blue3, alpha);
|
||||
colors_[2] = makecol(mix_2_3(red1, red2), mix_2_3(green1, green2), mix_2_3(blue1, blue2), alpha);
|
||||
colors_[3] = makecol(mix_2_3(red2, red1), mix_2_3(green2, green1), mix_2_3(blue2, blue1), alpha);
|
||||
} else {
|
||||
// Average
|
||||
int red3 = (red1 + red2 + 1) / 2;
|
||||
int green3 = (green1 + green2 + 1) / 2;
|
||||
int blue3 = (blue1 + blue2 + 1) / 2;
|
||||
// Average - these are always left shifted, so no need to worry about ties.
|
||||
int red3 = (red1 + red2) / 2;
|
||||
int green3 = (green1 + green2) / 2;
|
||||
int blue3 = (blue1 + blue2) / 2;
|
||||
colors_[2] = makecol(red3, green3, blue3, 255);
|
||||
colors_[3] = makecol(0, 0, 0, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue