mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-11-15 10:40:39 +01:00
gsdx tc: merge page coverage code
A function was already done for openCL. Use the same for others renderers
This commit is contained in:
1 parent
5c7c9452d6
commit
d67b9cba14
5 files changed
+42
-91
No files matched your search
@@ -1607,6 +1607,9 @@ GSTextureCache::Source::Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFR
|
||||
{
|
||||
m_p2t = r->m_mem.GetPage2TileMap(m_TEX0);
|
||||
}
|
||||
|
||||
GSOffset* off = m_renderer->m_context->offset.tex;
|
||||
m_pages_as_bit = off->GetPagesAsBits(m_TEX0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1987,13 +1990,10 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSOffset*
|
||||
return;
|
||||
}
|
||||
|
||||
// Remaining code will compute a list of pages that are dirty (in a similar fashion as GSOffset::GetPages)
|
||||
// (Maybe GetPages could be used instead, perf opt?)
|
||||
// The source pointer will be stored/duplicated in all m_map[array of pages]
|
||||
s->m_pages_ptr = GetPagesCoverage(TEX0, off);
|
||||
for(size_t i = 0; i < countof(m_pages); i++)
|
||||
{
|
||||
if(uint32 p = s->m_pages_ptr[i])
|
||||
if(uint32 p = s->m_pages_as_bit[i])
|
||||
{
|
||||
list<Source*>* m = &m_map[i << 5];
|
||||
auto* e = &s->m_erase_it[i << 5];
|
||||
@@ -2014,56 +2014,6 @@ void GSTextureCache::SourceMap::Add(Source* s, const GIFRegTEX0& TEX0, GSOffset*
|
||||
}
|
||||
}
|
||||
|
||||
uint32* GSTextureCache::SourceMap::GetPagesCoverage(const GIFRegTEX0& TEX0, GSOffset* off)
|
||||
{
|
||||
// Performance note:
|
||||
// GSOffset is a hash lookup of the following parameter TB0, TBW, PSM
|
||||
// Coverage adds TW and Th (8bits). Therefore GSOffset was extended with a small array.
|
||||
// Avoid the hash map overhead (memory and lookup)
|
||||
|
||||
int index = (TEX0.u64 >> 26) & 0xFF;
|
||||
|
||||
if (off->coverages[index])
|
||||
return off->coverages[index];
|
||||
|
||||
// Aligned on 64 bytes to store the full bitmap in a single cache line
|
||||
uint32* pages = (uint32*)_aligned_malloc(MAX_PAGES/8, 64);
|
||||
|
||||
off->coverages[index] = pages;
|
||||
|
||||
((GSVector4i*)pages)[0] = GSVector4i::zero();
|
||||
((GSVector4i*)pages)[1] = GSVector4i::zero();
|
||||
((GSVector4i*)pages)[2] = GSVector4i::zero();
|
||||
((GSVector4i*)pages)[3] = GSVector4i::zero();
|
||||
|
||||
// Remaining code will compute a list of pages that are dirty (in a similar fashion as GSOffset::GetPages)
|
||||
// (Maybe GetPages could be used instead, perf opt?)
|
||||
// The source pointer will be stored/duplicated in all m_map[array of pages]
|
||||
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM];
|
||||
|
||||
GSVector2i bs = (TEX0.TBP0 & 31) == 0 ? psm.pgs : psm.bs;
|
||||
|
||||
int tw = 1 << TEX0.TW;
|
||||
int th = 1 << TEX0.TH;
|
||||
|
||||
for(int y = 0; y < th; y += bs.y)
|
||||
{
|
||||
uint32 base = off->block.row[y >> 3];
|
||||
|
||||
for(int x = 0; x < tw; x += bs.x)
|
||||
{
|
||||
uint32 page = (base + off->block.col[x >> 3]) >> 5;
|
||||
|
||||
if(page < MAX_PAGES)
|
||||
{
|
||||
pages[page >> 5] |= 1 << (page & 31);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pages;
|
||||
}
|
||||
|
||||
void GSTextureCache::SourceMap::RemoveAll()
|
||||
{
|
||||
for_each(m_surfaces.begin(), m_surfaces.end(), delete_object());
|
||||
@@ -2092,10 +2042,9 @@ void GSTextureCache::SourceMap::RemoveAt(Source* s)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mirror of GetPagesCoverage
|
||||
for(size_t i = 0; i < countof(m_pages); i++)
|
||||
{
|
||||
if(uint32 p = s->m_pages_ptr[i])
|
||||
if(uint32 p = s->m_pages_as_bit[i])
|
||||
{
|
||||
list<Source*>* m = &m_map[i << 5];
|
||||
auto* e = &s->m_erase_it[i << 5];
|
||||
|
||||
Reference in new issue
Block a user