1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +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:
Sergey Lipskiy 2018-06-29 19:10:27 +07:00
parent d4b770b2c1
commit e0418c3c34
3 changed files with 97 additions and 25 deletions

View File

@ -1339,31 +1339,29 @@ 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();
Context::DrawRectParameters rectParams; _updateScreenCoordsViewport();
rectParams.mode = drawmode::TRIANGLE_STRIP; Context::DrawRectParameters rectParams;
rectParams.verticesCount = 4; rectParams.mode = drawmode::TRIANGLE_STRIP;
rectParams.vertices = m_rect; rectParams.verticesCount = 4;
rectParams.combiner = currentCombiner(); rectParams.vertices = m_rect;
gfxContext.drawRects(rectParams); rectParams.combiner = currentCombiner();
if (g_debugger.isCaptureMode()) { gfxContext.drawRects(rectParams);
m_rect[0].x = _params.ulx; if (g_debugger.isCaptureMode()) {
m_rect[0].y = _params.uly; m_rect[0].x = _params.ulx;
m_rect[1].x = _params.lrx; m_rect[0].y = _params.uly;
m_rect[1].y = _params.uly; m_rect[1].x = _params.lrx;
m_rect[2].x = _params.ulx; m_rect[1].y = _params.uly;
m_rect[2].y = _params.lry; m_rect[2].x = _params.ulx;
m_rect[3].x = _params.lrx; m_rect[2].y = _params.lry;
m_rect[3].y = _params.lry; m_rect[3].x = _params.lrx;
g_debugger.addRects(rectParams); m_rect[3].y = _params.lry;
} g_debugger.addRects(rectParams);
gSP.changed |= CHANGED_GEOMETRYMODE | CHANGED_VIEWPORT;
} }
gSP.changed |= CHANGED_GEOMETRYMODE | CHANGED_VIEWPORT;
} }
void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params) void GraphicsDrawer::correctTexturedRectParams(TexturedRectParams & _params)

View File

@ -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()

View File

@ -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;