mirror of https://github.com/PCSX2/pcsx2.git
GS: improve GSDirtyRect psm conv., add bw field.
This commit is contained in:
parent
be0932f538
commit
44d0966892
|
@ -16,47 +16,46 @@
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "GSDirtyRect.h"
|
#include "GSDirtyRect.h"
|
||||||
|
|
||||||
GSDirtyRect::GSDirtyRect()
|
GSDirtyRect::GSDirtyRect() :
|
||||||
: psm(PSM_PSMCT32)
|
r(GSVector4i::zero()),
|
||||||
|
psm(PSM_PSMCT32),
|
||||||
|
bw(1)
|
||||||
{
|
{
|
||||||
left = top = right = bottom = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GSDirtyRect::GSDirtyRect(const GSVector4i& r, u32 psm)
|
GSDirtyRect::GSDirtyRect(const GSVector4i& r, const u32 psm, const u32 bw) :
|
||||||
: psm(psm)
|
r(r),
|
||||||
|
psm(psm),
|
||||||
|
bw(bw)
|
||||||
{
|
{
|
||||||
left = r.left;
|
|
||||||
top = r.top;
|
|
||||||
right = r.right;
|
|
||||||
bottom = r.bottom;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const GSVector4i GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0) const
|
const GSVector4i GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0) const
|
||||||
{
|
{
|
||||||
GSVector4i r;
|
GSVector4i _r;
|
||||||
|
|
||||||
const GSVector2i src = GSLocalMemory::m_psm[psm].bs;
|
const GSVector2i& src = GSLocalMemory::m_psm[psm].bs;
|
||||||
|
|
||||||
if (psm != TEX0.PSM)
|
if (psm != TEX0.PSM)
|
||||||
{
|
{
|
||||||
const GSVector2i dst = GSLocalMemory::m_psm[TEX0.PSM].bs;
|
const GSVector2i& dst = GSLocalMemory::m_psm[TEX0.PSM].bs;
|
||||||
|
_r.left = (r.left * dst.x) / src.x;
|
||||||
r.left = left * dst.x / src.x;
|
_r.top = (r.top * dst.y) / src.y;
|
||||||
r.top = top * dst.y / src.y;
|
_r.right = (r.right * dst.x) / src.x;
|
||||||
r.right = right * dst.x / src.x;
|
_r.bottom = (r.bottom * dst.y) / src.y;
|
||||||
r.bottom = bottom * dst.y / src.y;
|
_r = _r.ralign<Align_Outside>(src);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = GSVector4i(left, top, right, bottom).ralign<Align_Outside>(src);
|
_r = r.ralign<Align_Outside>(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return _r;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
const GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size)
|
const GSVector4i GSDirtyRectList::GetDirtyRect(const GIFRegTEX0& TEX0, const GSVector2i& size) const
|
||||||
{
|
{
|
||||||
if (!empty())
|
if (!empty())
|
||||||
{
|
{
|
||||||
|
@ -67,8 +66,6 @@ const GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, c
|
||||||
r = r.runion(dirty_rect.GetDirtyRect(TEX0));
|
r = r.runion(dirty_rect.GetDirtyRect(TEX0));
|
||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
|
||||||
|
|
||||||
const GSVector2i bs = GSLocalMemory::m_psm[TEX0.PSM].bs;
|
const GSVector2i bs = GSLocalMemory::m_psm[TEX0.PSM].bs;
|
||||||
|
|
||||||
return r.ralign<Align_Outside>(bs).rintersect(GSVector4i(0, 0, size.x, size.y));
|
return r.ralign<Align_Outside>(bs).rintersect(GSVector4i(0, 0, size.x, size.y));
|
||||||
|
@ -76,3 +73,10 @@ const GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, c
|
||||||
|
|
||||||
return GSVector4i::zero();
|
return GSVector4i::zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size)
|
||||||
|
{
|
||||||
|
const GSVector4i r = GetDirtyRect(TEX0, size);
|
||||||
|
clear();
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
|
@ -19,16 +19,13 @@
|
||||||
|
|
||||||
class GSDirtyRect
|
class GSDirtyRect
|
||||||
{
|
{
|
||||||
int left;
|
|
||||||
int top;
|
|
||||||
int right;
|
|
||||||
int bottom;
|
|
||||||
|
|
||||||
u32 psm;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
const GSVector4i r;
|
||||||
|
const u32 psm;
|
||||||
|
const u32 bw;
|
||||||
|
|
||||||
GSDirtyRect();
|
GSDirtyRect();
|
||||||
GSDirtyRect(const GSVector4i& r, u32 psm);
|
GSDirtyRect(const GSVector4i& r, const u32 psm, const u32 bw);
|
||||||
const GSVector4i GetDirtyRect(const GIFRegTEX0& TEX0) const;
|
const GSVector4i GetDirtyRect(const GIFRegTEX0& TEX0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,5 +33,6 @@ class GSDirtyRectList : public std::vector<GSDirtyRect>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GSDirtyRectList() {}
|
GSDirtyRectList() {}
|
||||||
|
const GSVector4i GetDirtyRect(const GIFRegTEX0& TEX0, const GSVector2i& size) const;
|
||||||
const GSVector4i GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size);
|
const GSVector4i GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size);
|
||||||
};
|
};
|
||||||
|
|
|
@ -561,7 +561,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||||
// h is likely smaller than w (true most of the time). Reduce the upload size (speed)
|
// h is likely smaller than w (true most of the time). Reduce the upload size (speed)
|
||||||
max_h = std::min<int>(max_h, TEX0.TBW * 64);
|
max_h = std::min<int>(max_h, TEX0.TBW * 64);
|
||||||
|
|
||||||
dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, max_h), TEX0.PSM));
|
dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, max_h), TEX0.PSM, TEX0.TBW));
|
||||||
dst->Update();
|
dst->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,7 +672,7 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
|
||||||
// Code is more or less an equivalent of the SW renderer
|
// Code is more or less an equivalent of the SW renderer
|
||||||
//
|
//
|
||||||
// Option is hidden and not enabled by default to avoid any regression
|
// Option is hidden and not enabled by default to avoid any regression
|
||||||
dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, real_h), TEX0.PSM));
|
dst->m_dirty.push_back(GSDirtyRect(GSVector4i(0, 0, TEX0.TBW * 64, real_h), TEX0.PSM, TEX0.TBW));
|
||||||
dst->Update();
|
dst->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -877,8 +877,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
|
||||||
GL_CACHE("TC: Dirty Target(%s) %d (0x%x) r(%d,%d,%d,%d)", to_string(type),
|
GL_CACHE("TC: Dirty Target(%s) %d (0x%x) r(%d,%d,%d,%d)", to_string(type),
|
||||||
t->m_texture ? t->m_texture->GetID() : 0,
|
t->m_texture ? t->m_texture->GetID() : 0,
|
||||||
t->m_TEX0.TBP0, r.x, r.y, r.z, r.w);
|
t->m_TEX0.TBP0, r.x, r.y, r.z, r.w);
|
||||||
t->m_dirty.push_back(GSDirtyRect(r, psm));
|
|
||||||
t->m_TEX0.TBW = bw;
|
t->m_TEX0.TBW = bw;
|
||||||
|
t->m_dirty.push_back(GSDirtyRect(r, psm, bw));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -917,8 +917,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
|
||||||
t->m_texture ? t->m_texture->GetID() : 0,
|
t->m_texture ? t->m_texture->GetID() : 0,
|
||||||
t->m_TEX0.TBP0);
|
t->m_TEX0.TBP0);
|
||||||
// TODO: do not add this rect above too
|
// TODO: do not add this rect above too
|
||||||
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), psm));
|
|
||||||
t->m_TEX0.TBW = bw;
|
t->m_TEX0.TBW = bw;
|
||||||
|
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), psm, bw));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -945,8 +945,8 @@ void GSTextureCache::InvalidateVideoMem(const GSOffset& off, const GSVector4i& r
|
||||||
t->m_TEX0.TBP0, t->m_end_block,
|
t->m_TEX0.TBP0, t->m_end_block,
|
||||||
r.left, r.top + y, r.right, r.bottom + y, bw);
|
r.left, r.top + y, r.right, r.bottom + y, bw);
|
||||||
|
|
||||||
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top + y, r.right, r.bottom + y), psm));
|
|
||||||
t->m_TEX0.TBW = bw;
|
t->m_TEX0.TBW = bw;
|
||||||
|
t->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top + y, r.right, r.bottom + y), psm, bw));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue