mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Apply TexrectDrawer if next draw command is also texrect and those texrect is side-by-side with the current one.
It should fix performance issues with particles. Currently works only in HLE mode.
This commit is contained in:
parent
d4b770b2c1
commit
e0418c3c34
|
@ -1339,11 +1339,10 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
m_rect[i].x *= scale;
|
m_rect[i].x *= scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bUseTexrectDrawer)
|
if (bUseTexrectDrawer && m_texrectDrawer.add())
|
||||||
m_texrectDrawer.add();
|
return;
|
||||||
else {
|
|
||||||
_updateScreenCoordsViewport();
|
|
||||||
|
|
||||||
|
_updateScreenCoordsViewport();
|
||||||
Context::DrawRectParameters rectParams;
|
Context::DrawRectParameters rectParams;
|
||||||
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
rectParams.mode = drawmode::TRIANGLE_STRIP;
|
||||||
rectParams.verticesCount = 4;
|
rectParams.verticesCount = 4;
|
||||||
|
@ -1364,7 +1363,6 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
|
|
||||||
gSP.changed |= CHANGED_GEOMETRYMODE | CHANGED_VIEWPORT;
|
gSP.changed |= CHANGED_GEOMETRYMODE | CHANGED_VIEWPORT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params)
|
void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <Graphics/Parameters.h>
|
#include <Graphics/Parameters.h>
|
||||||
#include "DisplayWindow.h"
|
#include "DisplayWindow.h"
|
||||||
#include "Textures.h"
|
#include "Textures.h"
|
||||||
|
#include "RSP.h"
|
||||||
#include "VI.h"
|
#include "VI.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "TexrectDrawer.h"
|
#include "TexrectDrawer.h"
|
||||||
|
@ -114,7 +115,71 @@ void TexrectDrawer::_setDrawBuffer()
|
||||||
frameBufferList().setCurrentDrawBuffer();
|
frameBufferList().setCurrentDrawBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexrectDrawer::add()
|
bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
|
||||||
|
{
|
||||||
|
if (RSP.LLE)
|
||||||
|
return true;
|
||||||
|
switch (GBI.getMicrocodeType()) {
|
||||||
|
case Turbo3D:
|
||||||
|
case T3DUX:
|
||||||
|
case F5Rogue:
|
||||||
|
case F5Indi_Naboo:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 w1 = *(u32*)&RDRAM[pc + 4];
|
||||||
|
const u32 ulx_next = _SHIFTR(w1, 12, 12);
|
||||||
|
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) {
|
||||||
|
bool sbs = lry == uly_next;
|
||||||
|
sbs |= uly == lry_next;
|
||||||
|
return sbs;
|
||||||
|
}
|
||||||
|
if (uly == uly_next) {
|
||||||
|
bool sbs = lrx == ulx_next;
|
||||||
|
sbs |= ulx == lrx_next;
|
||||||
|
return sbs;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 pc = RSP.PC[RSP.PCi] + 8;
|
||||||
|
while (true) {
|
||||||
|
switch (_SHIFTR(*(u32*)&RDRAM[pc], 24, 8)) {
|
||||||
|
case G_RDPLOADSYNC:
|
||||||
|
case G_RDPPIPESYNC:
|
||||||
|
case G_RDPTILESYNC:
|
||||||
|
case G_LOADTLUT:
|
||||||
|
case G_SETTILESIZE:
|
||||||
|
case G_LOADBLOCK:
|
||||||
|
case G_LOADTILE:
|
||||||
|
case G_SETTILE:
|
||||||
|
case G_SETTIMG:
|
||||||
|
break;
|
||||||
|
case G_TEXRECT:
|
||||||
|
case G_TEXRECTFLIP:
|
||||||
|
if (_checkCoordinates)
|
||||||
|
return sideBySide(pc);
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pc += 8;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TexrectDrawer::add()
|
||||||
{
|
{
|
||||||
DisplayWindow & wnd = dwnd();
|
DisplayWindow & wnd = dwnd();
|
||||||
GraphicsDrawer & drawer = wnd.getDrawer();
|
GraphicsDrawer & drawer = wnd.getDrawer();
|
||||||
|
@ -148,6 +213,9 @@ void TexrectDrawer::add()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_numRects == 0) {
|
if (m_numRects == 0) {
|
||||||
|
if (!_lookAhead(true))
|
||||||
|
return false;
|
||||||
|
|
||||||
m_numRects = 1;
|
m_numRects = 1;
|
||||||
m_pBuffer = frameBufferList().getCurrent();
|
m_pBuffer = frameBufferList().getCurrent();
|
||||||
m_otherMode = gDP.otherMode._u64;
|
m_otherMode = gDP.otherMode._u64;
|
||||||
|
@ -201,6 +269,11 @@ void TexrectDrawer::add()
|
||||||
rectParams.vertices = pRect;
|
rectParams.vertices = pRect;
|
||||||
rectParams.combiner = currentCombiner();
|
rectParams.combiner = currentCombiner();
|
||||||
gfxContext.drawRects(rectParams);
|
gfxContext.drawRects(rectParams);
|
||||||
|
|
||||||
|
if (m_numRects > 1 && !_lookAhead(false))
|
||||||
|
draw();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TexrectDrawer::draw()
|
bool TexrectDrawer::draw()
|
||||||
|
|
|
@ -17,7 +17,7 @@ public:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void destroy();
|
void destroy();
|
||||||
void add();
|
bool add();
|
||||||
bool draw();
|
bool draw();
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
bool canContinue() const;
|
bool canContinue() const;
|
||||||
|
@ -25,6 +25,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void _setViewport() const;
|
void _setViewport() const;
|
||||||
void _setDrawBuffer();
|
void _setDrawBuffer();
|
||||||
|
bool _lookAhead(bool _checkCoordinates) const;
|
||||||
|
|
||||||
u32 m_numRects;
|
u32 m_numRects;
|
||||||
u64 m_otherMode;
|
u64 m_otherMode;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user