mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
TexrectDrawer fixes:
* fix issues in _lookAhead * use integer coordinates to rects side-by-side detection. Fixed #1856, #1859
This commit is contained in:
parent
5186a50597
commit
1b17e98941
|
@ -21,6 +21,9 @@ TexrectDrawer::TexrectDrawer()
|
||||||
, m_lrx(0)
|
, m_lrx(0)
|
||||||
, m_uly(0)
|
, m_uly(0)
|
||||||
, m_lry(0)
|
, m_lry(0)
|
||||||
|
, m_ulx_i(0)
|
||||||
|
, m_uly_i(0)
|
||||||
|
, m_lry_i(0)
|
||||||
, m_Z(0)
|
, m_Z(0)
|
||||||
, m_max_lrx(0)
|
, m_max_lrx(0)
|
||||||
, m_max_lry(0)
|
, m_max_lry(0)
|
||||||
|
@ -115,6 +118,18 @@ void TexrectDrawer::_setDrawBuffer()
|
||||||
frameBufferList().setCurrentDrawBuffer();
|
frameBufferList().setCurrentDrawBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TexrectDrawer::iRect TexrectDrawer::_getiRect(u32 w0, u32 w1) const
|
||||||
|
{
|
||||||
|
iRect rect;
|
||||||
|
rect.ulx = _SHIFTR(w1, 12, 12);
|
||||||
|
rect.uly = _SHIFTR(w1, 0, 12);
|
||||||
|
rect.lrx = _SHIFTR(w0, 12, 12);
|
||||||
|
rect.lry = _SHIFTR(w0, 0, 12);
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COMPARE_COORDS(a, b) std::abs(a - b) <= 4
|
||||||
|
|
||||||
bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
|
bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
|
||||||
{
|
{
|
||||||
if (RSP.LLE)
|
if (RSP.LLE)
|
||||||
|
@ -127,33 +142,25 @@ bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sideBySide = [](u32 pc) ->bool {
|
auto sideBySide = [&](u32 pc) ->bool {
|
||||||
const u32 ulx = _SHIFTR(RSP.w1, 12, 12);
|
|
||||||
const u32 uly = _SHIFTR(RSP.w1, 0, 12);
|
|
||||||
const u32 lrx = _SHIFTR(RSP.w0, 12, 12);
|
|
||||||
const u32 lry = _SHIFTR(RSP.w0, 0, 12);
|
|
||||||
|
|
||||||
const u32 w0 = *(u32*)&RDRAM[pc];
|
const u32 w0 = *(u32*)&RDRAM[pc];
|
||||||
const u32 w1 = *(u32*)&RDRAM[pc + 4];
|
const u32 w1 = *(u32*)&RDRAM[pc + 4];
|
||||||
const u32 ulx_next = _SHIFTR(w1, 12, 12);
|
const iRect nextRect = _getiRect(w0, w1);
|
||||||
const u32 uly_next = _SHIFTR(w1, 0, 12);
|
|
||||||
const u32 lrx_next = _SHIFTR(w0, 12, 12);
|
|
||||||
const u32 lry_next = _SHIFTR(w0, 0, 12);
|
|
||||||
|
|
||||||
if (ulx == ulx_next) {
|
if (COMPARE_COORDS(m_curRect.ulx, nextRect.ulx)) {
|
||||||
bool sbs = lry == uly_next;
|
bool sbs = COMPARE_COORDS(m_curRect.lry, nextRect.uly);
|
||||||
sbs |= uly == lry_next;
|
sbs |= COMPARE_COORDS(m_curRect.uly, nextRect.lry);
|
||||||
return sbs;
|
return sbs;
|
||||||
}
|
}
|
||||||
if (uly == uly_next) {
|
if (COMPARE_COORDS(m_curRect.uly, nextRect.uly)) {
|
||||||
bool sbs = lrx == ulx_next;
|
bool sbs = COMPARE_COORDS(m_curRect.lrx, nextRect.ulx);
|
||||||
sbs |= ulx == lrx_next;
|
sbs |= COMPARE_COORDS(m_curRect.ulx, nextRect.lrx);
|
||||||
return sbs;
|
return sbs;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 pc = RSP.PC[RSP.PCi] + 8;
|
u32 pc = RSP.PC[RSP.PCi];
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (_SHIFTR(*(u32*)&RDRAM[pc], 24, 8)) {
|
switch (_SHIFTR(*(u32*)&RDRAM[pc], 24, 8)) {
|
||||||
case G_RDPLOADSYNC:
|
case G_RDPLOADSYNC:
|
||||||
|
@ -185,20 +192,20 @@ bool TexrectDrawer::add()
|
||||||
GraphicsDrawer & drawer = wnd.getDrawer();
|
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||||
RectVertex * pRect = drawer.m_rect;
|
RectVertex * pRect = drawer.m_rect;
|
||||||
|
|
||||||
|
m_curRect = _getiRect(RSP.w0, RSP.w1);
|
||||||
|
|
||||||
bool bDownUp = false;
|
bool bDownUp = false;
|
||||||
if (m_numRects != 0) {
|
if (m_numRects != 0) {
|
||||||
bool bContinue = false;
|
bool bContinue = false;
|
||||||
if (m_otherMode == gDP.otherMode._u64 && m_mux == gDP.combine.mux) {
|
if (m_otherMode == gDP.otherMode._u64 && m_mux == gDP.combine.mux) {
|
||||||
const float scaleY = (m_pBuffer != nullptr ? m_pBuffer->m_height : VI.height) / 2.0f;
|
if (COMPARE_COORDS(m_ulx_i, m_curRect.ulx)) {
|
||||||
if (m_ulx == pRect[0].x) {
|
bContinue = COMPARE_COORDS(m_lry_i, m_curRect.uly);
|
||||||
// bContinue = m_lry == pRect[0].y;
|
bDownUp = COMPARE_COORDS(m_uly_i, m_curRect.lry);
|
||||||
bContinue = fabs((m_lry - pRect[0].y) * scaleY) < 1.1f; // Fix for Mario Kart
|
|
||||||
bDownUp = m_uly == pRect[3].y;
|
|
||||||
bContinue |= bDownUp;
|
bContinue |= bDownUp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (auto iter = m_vecRectCoords.crbegin(); iter != m_vecRectCoords.crend(); ++iter) {
|
for (auto iter = m_vecRectCoords.crbegin(); iter != m_vecRectCoords.crend(); ++iter) {
|
||||||
if (iter->x == pRect[0].x && iter->y == pRect[0].y) {
|
if (COMPARE_COORDS(iter->x, m_curRect.ulx) && COMPARE_COORDS(iter->y, m_curRect.uly)) {
|
||||||
bContinue = true;
|
bContinue = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -207,8 +214,7 @@ bool TexrectDrawer::add()
|
||||||
}
|
}
|
||||||
if (!bContinue) {
|
if (!bContinue) {
|
||||||
draw();
|
draw();
|
||||||
drawer._updateTextures();
|
drawer._updateStates(DrawingState::TexRect);
|
||||||
CombinerInfo::get().updateParameters();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +234,10 @@ bool TexrectDrawer::add()
|
||||||
m_lrx = m_max_lrx = pRect[3].x;
|
m_lrx = m_max_lrx = pRect[3].x;
|
||||||
m_lry = m_max_lry = pRect[3].y;
|
m_lry = m_max_lry = pRect[3].y;
|
||||||
|
|
||||||
|
m_ulx_i = m_curRect.ulx;
|
||||||
|
m_uly_i = m_curRect.uly;
|
||||||
|
m_lry_i = m_curRect.lry;
|
||||||
|
|
||||||
CombinerInfo & cmbInfo = CombinerInfo::get();
|
CombinerInfo & cmbInfo = CombinerInfo::get();
|
||||||
cmbInfo.update();
|
cmbInfo.update();
|
||||||
cmbInfo.updateParameters();
|
cmbInfo.updateParameters();
|
||||||
|
@ -247,20 +257,22 @@ bool TexrectDrawer::add()
|
||||||
if (bDownUp) {
|
if (bDownUp) {
|
||||||
m_ulx = pRect[0].x;
|
m_ulx = pRect[0].x;
|
||||||
m_uly = pRect[0].y;
|
m_uly = pRect[0].y;
|
||||||
}
|
m_ulx_i = m_curRect.ulx;
|
||||||
else {
|
m_uly_i = m_curRect.uly;
|
||||||
|
} else {
|
||||||
m_lrx = pRect[3].x;
|
m_lrx = pRect[3].x;
|
||||||
m_lry = pRect[3].y;
|
m_lry = pRect[3].y;
|
||||||
m_max_lrx = std::max(m_max_lrx, m_lrx);
|
m_max_lrx = std::max(m_max_lrx, m_lrx);
|
||||||
m_max_lry = std::max(m_max_lry, m_lry);
|
m_max_lry = std::max(m_max_lry, m_lry);
|
||||||
|
m_lry_i = m_curRect.lry;
|
||||||
}
|
}
|
||||||
|
|
||||||
RectCoords coords;
|
RectCoords coords;
|
||||||
coords.x = pRect[1].x;
|
coords.x = m_curRect.lrx;
|
||||||
coords.y = pRect[1].y;
|
coords.y = m_curRect.uly;
|
||||||
m_vecRectCoords.push_back(coords);
|
m_vecRectCoords.push_back(coords);
|
||||||
coords.x = pRect[3].x;
|
coords.x = m_curRect.lrx;
|
||||||
coords.y = pRect[3].y;
|
coords.y = m_curRect.lry;
|
||||||
m_vecRectCoords.push_back(coords);
|
m_vecRectCoords.push_back(coords);
|
||||||
|
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
u64 m_otherMode;
|
u64 m_otherMode;
|
||||||
u64 m_mux;
|
u64 m_mux;
|
||||||
f32 m_ulx, m_lrx, m_uly, m_lry, m_Z;
|
f32 m_ulx, m_lrx, m_uly, m_lry, m_Z;
|
||||||
|
s32 m_ulx_i, m_uly_i, m_lry_i;
|
||||||
f32 m_max_lrx, m_max_lry;
|
f32 m_max_lrx, m_max_lry;
|
||||||
f32 m_stepY;
|
f32 m_stepY;
|
||||||
f32 m_stepX;
|
f32 m_stepX;
|
||||||
|
@ -42,9 +43,15 @@ private:
|
||||||
std::unique_ptr<graphics::ShaderProgram> m_programClear;
|
std::unique_ptr<graphics::ShaderProgram> m_programClear;
|
||||||
|
|
||||||
struct RectCoords {
|
struct RectCoords {
|
||||||
f32 x, y;
|
s32 x, y;
|
||||||
};
|
};
|
||||||
std::vector<RectCoords> m_vecRectCoords;
|
std::vector<RectCoords> m_vecRectCoords;
|
||||||
|
|
||||||
|
struct iRect {
|
||||||
|
s32 ulx, uly, lrx, lry;
|
||||||
|
};
|
||||||
|
iRect _getiRect(u32 w0, u32 w1) const;
|
||||||
|
iRect m_curRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEXRECTDRAWER_H
|
#endif // TEXRECTDRAWER_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user