GPU: Implement dithering on OpenGL backend

This commit is contained in:
Connor McLaughlin
2019-11-01 22:47:32 +10:00
parent 1d1da1d82c
commit ac82383abe
5 changed files with 76 additions and 22 deletions

View File

@ -181,10 +181,22 @@ protected:
BitField<u32, bool, 28, 1> shading_enable; // 0 - flat, 1 = gouroud
BitField<u32, Primitive, 29, 21> primitive;
// Helper functions.
bool IsTextureEnabled() const { return (primitive != Primitive::Line && texture_enable); }
bool IsTextureBlendingEnabled() const { return (IsTextureEnabled() && !raw_texture_enable); }
bool IsTransparencyEnabled() const { return transparency_enable; }
// Returns true if dithering should be enabled. Depends on the primitive type.
bool IsDitheringEnabled() const
{
switch (primitive)
{
case Primitive::Polygon:
return shading_enable || !raw_texture_enable;
case Primitive::Line:
return true;
case Primitive::Rectangle:
default:
return false;
}
}
};
// TODO: Use BitField to do sign extending instead
@ -241,6 +253,12 @@ protected:
}
};
// 4x4 dither matrix.
static constexpr s32 DITHER_MATRIX[4][4] = {{-4, +0, -3, +1}, // row 0
{+2, -2, +3, -1}, // row 1
{-3, +1, -4, +0}, // row 2
{+4, -1, +2, -2}}; // row 3
void SoftReset();
// Sets dots per scanline