gsdx: use psm.bpp flag to improve code reading

This commit is contained in:
Gregory Hainaut 2016-04-22 19:46:44 +02:00
parent dd98a0b913
commit a149d6b26f
2 changed files with 10 additions and 7 deletions

View File

@ -398,11 +398,13 @@ void GSRendererHW::Draw()
if(PRIM->TME) if(PRIM->TME)
{ {
const GSLocalMemory::psm_t& tex_psm = GSLocalMemory::m_psm[m_context->TEX0.PSM];
/* /*
// m_tc->LookupSource will mess with the palette, should not, but we do this after, until it is sorted out // m_tc->LookupSource will mess with the palette, should not, but we do this after, until it is sorted out
if(GSLocalMemory::m_psm[context->TEX0.PSM].pal > 0) if(tex_psm.pal > 0)
{ {
m_mem.m_clut.Read32(context->TEX0, env.TEXA); m_mem.m_clut.Read32(context->TEX0, env.TEXA);
} }
@ -421,7 +423,7 @@ void GSRendererHW::Draw()
} }
// FIXME: Could be removed on openGL // FIXME: Could be removed on openGL
if(GSLocalMemory::m_psm[context->TEX0.PSM].pal > 0) if(tex_psm.pal > 0)
{ {
m_mem.m_clut.Read32(context->TEX0, env.TEXA); m_mem.m_clut.Read32(context->TEX0, env.TEXA);
} }
@ -430,7 +432,8 @@ void GSRendererHW::Draw()
// Initially code also tested the RT but it gives too much false-positive // Initially code also tested the RT but it gives too much false-positive
// //
// Both input and output are 16 bits and texture was initially 32 bits! // Both input and output are 16 bits and texture was initially 32 bits!
m_texture_shuffle = (context->FRAME.PSM & 0x2) && ((context->TEX0.PSM & 3) == 2) && (m_vt.m_primclass == GS_SPRITE_CLASS) && tex->m_32_bits_fmt; m_texture_shuffle = (GSLocalMemory::m_psm[context->FRAME.PSM].bpp == 16) && (tex_psm.bpp == 16)
&& (m_vt.m_primclass == GS_SPRITE_CLASS) && tex->m_32_bits_fmt;
// Texture shuffle is not yet supported with strange clamp mode // Texture shuffle is not yet supported with strange clamp mode
ASSERT(!m_texture_shuffle || (context->CLAMP.WMS < 3 && context->CLAMP.WMT < 3)); ASSERT(!m_texture_shuffle || (context->CLAMP.WMS < 3 && context->CLAMP.WMT < 3));
@ -439,7 +442,7 @@ void GSRendererHW::Draw()
// Be sure texture shuffle detection is properly propagated // Be sure texture shuffle detection is properly propagated
// Otherwise set or clear the flag (Code in texture cache only set the flag) // Otherwise set or clear the flag (Code in texture cache only set the flag)
// Note: it is important to clear the flag when RT is used as a real 16 bits target. // Note: it is important to clear the flag when RT is used as a real 16 bits target.
rt->m_32_bits_fmt = m_texture_shuffle || !(context->FRAME.PSM & 0x2); rt->m_32_bits_fmt = m_texture_shuffle || (GSLocalMemory::m_psm[context->FRAME.PSM].bpp != 16);
} }
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -282,7 +282,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
dst = t; dst = t;
dst->m_32_bits_fmt |= !(TEX0.PSM & 2); dst->m_32_bits_fmt |= (GSLocalMemory::m_psm[TEX0.PSM].bpp != 16);
dst->m_TEX0 = TEX0; dst->m_TEX0 = TEX0;
break; break;
@ -1028,7 +1028,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
} }
#endif #endif
if (TEX0.PSM < PSM_PSMT8 || TEX0.PSM > PSM_PSMT4HH) { if (GSLocalMemory::m_psm[TEX0.PSM].bpp > 8) {
src->m_32_bits_fmt = dst->m_32_bits_fmt; src->m_32_bits_fmt = dst->m_32_bits_fmt;
} }
src->m_target = true; src->m_target = true;
@ -1635,7 +1635,7 @@ GSTextureCache::Target::Target(GSRenderer* r, const GIFRegTEX0& TEX0, uint8* tem
, m_depth_supported(depth_supported) , m_depth_supported(depth_supported)
{ {
m_TEX0 = TEX0; m_TEX0 = TEX0;
m_32_bits_fmt |= !(TEX0.PSM & 2); m_32_bits_fmt |= (GSLocalMemory::m_psm[TEX0.PSM].bpp != 16);
m_dirty_alpha = (TEX0.PSM != PSM_PSMCT24) && (TEX0.PSM != PSM_PSMZ24); m_dirty_alpha = (TEX0.PSM != PSM_PSMCT24) && (TEX0.PSM != PSM_PSMZ24);
m_valid = GSVector4i::zero(); m_valid = GSVector4i::zero();