GS-hw: Use GSVector for rb ga masks in texture shuffle.

This commit is contained in:
lightningterror 2022-10-24 19:16:45 +02:00
parent e5964ae35b
commit 8771d3bc19
1 changed files with 11 additions and 12 deletions

View File

@ -2186,13 +2186,12 @@ void GSRendererHW::EmulateTextureShuffleAndFbmask()
// fbmask is converted to a 16bit version to represent the 2 32bit channels it's writing to. // fbmask is converted to a 16bit version to represent the 2 32bit channels it's writing to.
// The lower 8 bits represents the Red/Blue channels, the top 8 bits is Green/Alpha, depending on write_ba. // The lower 8 bits represents the Red/Blue channels, the top 8 bits is Green/Alpha, depending on write_ba.
const u32 fbmask = ((m >> 3) & 0x1F) | ((m >> 6) & 0x3E0) | ((m >> 9) & 0x7C00) | ((m >> 16) & 0x8000); const u32 fbmask = ((m >> 3) & 0x1F) | ((m >> 6) & 0x3E0) | ((m >> 9) & 0x7C00) | ((m >> 16) & 0x8000);
// FIXME GSVector will be nice here // r = rb mask, g = ga mask
const u8 rb_mask = fbmask & 0xFF; const GSVector2i rb_ga_mask = GSVector2i(fbmask & 0xFF, (fbmask >> 8) & 0xFF);
const u8 ga_mask = (fbmask >> 8) & 0xFF;
m_conf.colormask.wrgba = 0; m_conf.colormask.wrgba = 0;
// 2 Select the new mask (Please someone put SSE here) // 2 Select the new mask
if (rb_mask != 0xFF) if (rb_ga_mask.r != 0xFF)
{ {
if (write_ba) if (write_ba)
{ {
@ -2204,11 +2203,11 @@ void GSRendererHW::EmulateTextureShuffleAndFbmask()
GL_INS("Color shuffle %s => R", read_ba ? "B" : "R"); GL_INS("Color shuffle %s => R", read_ba ? "B" : "R");
m_conf.colormask.wr = 1; m_conf.colormask.wr = 1;
} }
if (rb_mask) if (rb_ga_mask.r)
m_conf.ps.fbmask = 1; m_conf.ps.fbmask = 1;
} }
if (ga_mask != 0xFF) if (rb_ga_mask.g != 0xFF)
{ {
if (write_ba) if (write_ba)
{ {
@ -2220,16 +2219,16 @@ void GSRendererHW::EmulateTextureShuffleAndFbmask()
GL_INS("Color shuffle %s => G", read_ba ? "A" : "G"); GL_INS("Color shuffle %s => G", read_ba ? "A" : "G");
m_conf.colormask.wg = 1; m_conf.colormask.wg = 1;
} }
if (ga_mask) if (rb_ga_mask.g)
m_conf.ps.fbmask = 1; m_conf.ps.fbmask = 1;
} }
if (m_conf.ps.fbmask && enable_fbmask_emulation) if (m_conf.ps.fbmask && enable_fbmask_emulation)
{ {
m_conf.cb_ps.FbMask.r = rb_mask; m_conf.cb_ps.FbMask.r = rb_ga_mask.r;
m_conf.cb_ps.FbMask.g = ga_mask; m_conf.cb_ps.FbMask.g = rb_ga_mask.g;
m_conf.cb_ps.FbMask.b = rb_mask; m_conf.cb_ps.FbMask.b = rb_ga_mask.r;
m_conf.cb_ps.FbMask.a = ga_mask; m_conf.cb_ps.FbMask.a = rb_ga_mask.g;
// No blending so hit unsafe path. // No blending so hit unsafe path.
if (!PRIM->ABE || !features.texture_barrier) if (!PRIM->ABE || !features.texture_barrier)