1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-06-25 22:09:35 +00:00

Draw backgrounds with TexrectDrawer.

This commit is contained in:
Sergey Lipskiy 2018-10-12 15:01:13 +07:00
parent 25bef0d805
commit a3613b42ae
5 changed files with 68 additions and 5 deletions

View File

@ -31,6 +31,7 @@ GraphicsDrawer::GraphicsDrawer()
, m_modifyVertices(0)
, m_maxLineWidth(1.0f)
, m_bFlatColors(false)
, m_bBGMode(false)
{
memset(m_rect, 0, sizeof(m_rect));
}
@ -1174,7 +1175,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
DisplayWindow & wnd = dwnd();
TextureCache & cache = textureCache();
const bool bUseBilinear = gDP.otherMode.textureFilter != 0;
const bool bUseTexrectDrawer = config.generalEmulation.enableNativeResTexrects != 0
const bool bUseTexrectDrawer = (config.generalEmulation.enableNativeResTexrects != 0 || m_bBGMode)
&& bUseBilinear
&& pCurrentCombiner->usesTexture()
&& (pCurrentBuffer == nullptr || !pCurrentBuffer->m_cfb)
@ -1356,8 +1357,14 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
m_rect[i].x *= scale;
}
if (bUseTexrectDrawer && m_texrectDrawer.add())
return;
if (bUseTexrectDrawer) {
if (m_bBGMode) {
m_texrectDrawer.addBackgroundRect();
return;
}
if (m_texrectDrawer.addRect())
return;
}
_updateScreenCoordsViewport(_params.pBuffer);
Context::DrawRectParameters rectParams;

View File

@ -155,6 +155,8 @@ public:
bool isTexrectDrawerMode() const { return !m_texrectDrawer.isEmpty(); }
void setBackgroundDrawingMode(bool _mode) { m_bBGMode = _mode; }
private:
friend class DisplayWindow;
friend TexrectDrawer;
@ -206,6 +208,7 @@ private:
u32 m_modifyVertices;
f32 m_maxLineWidth;
bool m_bFlatColors;
bool m_bBGMode;
TexrectDrawer m_texrectDrawer;
OSDMessages m_osdMessages;
};

View File

@ -187,7 +187,7 @@ bool TexrectDrawer::_lookAhead(bool _checkCoordinates) const
return false;
}
bool TexrectDrawer::add()
bool TexrectDrawer::addRect()
{
DisplayWindow & wnd = dwnd();
GraphicsDrawer & drawer = wnd.getDrawer();
@ -292,6 +292,54 @@ bool TexrectDrawer::add()
return true;
}
void TexrectDrawer::addBackgroundRect()
{
DisplayWindow & wnd = dwnd();
GraphicsDrawer & drawer = wnd.getDrawer();
RectVertex * pRect = drawer.m_rect;
if (m_numRects == 0) {
m_numRects = 1;
m_pBuffer = frameBufferList().getCurrent();
m_otherMode = gDP.otherMode._u64;
m_mux = gDP.combine.mux;
m_Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
m_scissor = gDP.scissor;
m_ulx = pRect[0].x;
m_uly = pRect[0].y;
m_lrx = m_max_lrx = pRect[3].x;
m_lry = m_max_lry = pRect[3].y;
CombinerInfo & cmbInfo = CombinerInfo::get();
cmbInfo.update();
cmbInfo.updateParameters();
gfxContext.enableDepthWrite(false);
gfxContext.enable(enable::DEPTH_TEST, false);
gfxContext.enable(enable::BLEND, false);
_setViewport();
gfxContext.setScissor((s32)gDP.scissor.ulx, (s32)gDP.scissor.uly, (s32)(gDP.scissor.lrx - gDP.scissor.ulx), (s32)(gDP.scissor.lry - gDP.scissor.uly));
gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, m_FBO);
} else {
++m_numRects;
}
m_lrx = pRect[3].x;
m_lry = pRect[3].y;
m_max_lrx = std::max(m_max_lrx, m_lrx);
m_max_lry = std::max(m_max_lry, m_lry);
Context::DrawRectParameters rectParams;
rectParams.mode = drawmode::TRIANGLE_STRIP;
rectParams.verticesCount = 4;
rectParams.vertices = pRect;
rectParams.combiner = currentCombiner();
gfxContext.drawRects(rectParams);
}
bool TexrectDrawer::draw()
{
if (m_numRects == 0)

View File

@ -17,7 +17,8 @@ public:
void init();
void destroy();
bool add();
bool addRect();
void addBackgroundRect();
bool draw();
bool isEmpty() const;
bool canContinue() const;

View File

@ -895,6 +895,8 @@ void BG1CycNew(u32 _bg)
gDP.otherMode.cycleType = G_CYC_1CYCLE;
gDP.changed |= CHANGED_CYCLETYPE;
RSP.LLE = true;
GraphicsDrawer & drawer = dwnd().getDrawer();
drawer.setBackgroundDrawingMode(true);
// auto runCommand = [](u32 w0, u32 w1)
// {
@ -1234,6 +1236,8 @@ void BG1CycNew(u32 _bg)
}
RSP.LLE = false;
drawer.flush();
drawer.setBackgroundDrawingMode(false);
}
void S2DEX_BG_1Cyc(u32 w0, u32 w1)