mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Use software render to calculate frame buffer height.
This commit is contained in:
parent
483212f382
commit
c8e6644bd7
|
@ -660,13 +660,15 @@ void GraphicsDrawer::drawTriangles()
|
||||||
triParams.combiner = currentCombiner();
|
triParams.combiner = currentCombiner();
|
||||||
gfxContext.drawTriangles(triParams);
|
gfxContext.drawTriangles(triParams);
|
||||||
|
|
||||||
if (config.frameBufferEmulation.enable != 0 &&
|
if (config.frameBufferEmulation.enable != 0) {
|
||||||
config.frameBufferEmulation.copyDepthToRDRAM == Config::cdSoftwareRender &&
|
const f32 maxY = renderTriangles(triangles.vertices.data(), triangles.elements.data(), triangles.num);
|
||||||
gDP.otherMode.depthUpdate != 0) {
|
gDP.colorImage.height = std::max(gDP.colorImage.height, (u32)maxY);
|
||||||
renderTriangles(triangles.vertices.data(), triangles.elements.data(), triangles.num);
|
if (config.frameBufferEmulation.copyDepthToRDRAM == Config::cdSoftwareRender &&
|
||||||
FrameBuffer * pCurrentDepthBuffer = frameBufferList().findBuffer(gDP.depthImageAddress);
|
gDP.otherMode.depthUpdate != 0) {
|
||||||
if (pCurrentDepthBuffer != nullptr)
|
FrameBuffer * pCurrentDepthBuffer = frameBufferList().findBuffer(gDP.depthImageAddress);
|
||||||
pCurrentDepthBuffer->m_cleared = false;
|
if (pCurrentDepthBuffer != nullptr)
|
||||||
|
pCurrentDepthBuffer->m_cleared = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
triangles.num = 0;
|
triangles.num = 0;
|
||||||
|
@ -681,6 +683,7 @@ void GraphicsDrawer::drawScreenSpaceTriangle(u32 _numVtx)
|
||||||
for (u32 i = 0; i < _numVtx; ++i) {
|
for (u32 i = 0; i < _numVtx; ++i) {
|
||||||
SPVertex & vtx = m_dmaVertices[i];
|
SPVertex & vtx = m_dmaVertices[i];
|
||||||
vtx.modify = MODIFY_ALL;
|
vtx.modify = MODIFY_ALL;
|
||||||
|
gDP.colorImage.height = std::max(gDP.colorImage.height, (u32)vtx.y);
|
||||||
}
|
}
|
||||||
m_modifyVertices = MODIFY_ALL;
|
m_modifyVertices = MODIFY_ALL;
|
||||||
|
|
||||||
|
@ -715,13 +718,15 @@ void GraphicsDrawer::drawDMATriangles(u32 _numVtx)
|
||||||
triParams.combiner = currentCombiner();
|
triParams.combiner = currentCombiner();
|
||||||
gfxContext.drawTriangles(triParams);
|
gfxContext.drawTriangles(triParams);
|
||||||
|
|
||||||
if (config.frameBufferEmulation.enable != 0 &&
|
if (config.frameBufferEmulation.enable != 0) {
|
||||||
config.frameBufferEmulation.copyDepthToRDRAM == Config::cdSoftwareRender &&
|
const f32 maxY = renderTriangles(m_dmaVertices.data(), nullptr, _numVtx);
|
||||||
gDP.otherMode.depthUpdate != 0) {
|
gDP.colorImage.height = std::max(gDP.colorImage.height, (u32)maxY);
|
||||||
renderTriangles(m_dmaVertices.data(), nullptr, _numVtx);
|
if (config.frameBufferEmulation.copyDepthToRDRAM == Config::cdSoftwareRender &&
|
||||||
FrameBuffer * pCurrentDepthBuffer = frameBufferList().findBuffer(gDP.depthImageAddress);
|
gDP.otherMode.depthUpdate != 0) {
|
||||||
if (pCurrentDepthBuffer != nullptr)
|
FrameBuffer * pCurrentDepthBuffer = frameBufferList().findBuffer(gDP.depthImageAddress);
|
||||||
pCurrentDepthBuffer->m_cleared = false;
|
if (pCurrentDepthBuffer != nullptr)
|
||||||
|
pCurrentDepthBuffer->m_cleared = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <algorithm>
|
||||||
#include "DepthBufferRender/ClipPolygon.h"
|
#include "DepthBufferRender/ClipPolygon.h"
|
||||||
#include "DepthBufferRender/DepthBufferRender.h"
|
#include "DepthBufferRender/DepthBufferRender.h"
|
||||||
#include "gSP.h"
|
#include "gSP.h"
|
||||||
#include "SoftwareRender.h"
|
#include "SoftwareRender.h"
|
||||||
#include "DepthBuffer.h"
|
#include "DepthBuffer.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void clipTest(vertexclip & _vtx)
|
void clipTest(vertexclip & _vtx)
|
||||||
|
@ -162,16 +164,13 @@ int clipW(const SPVertex ** _vsrc, SPVertex * _vdst)
|
||||||
return dsti;
|
return dsti;
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _numElements)
|
f32 renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _numElements)
|
||||||
{
|
{
|
||||||
//Current depth buffer can be null if we are loading from a save state
|
|
||||||
if(depthBufferList().getCurrent() == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
vertexclip vclip[16];
|
vertexclip vclip[16];
|
||||||
vertexi vdraw[12];
|
vertexi vdraw[12];
|
||||||
const SPVertex * vsrc[4];
|
const SPVertex * vsrc[4];
|
||||||
SPVertex vdata[6];
|
SPVertex vdata[6];
|
||||||
|
f32 maxY = 0.0f;
|
||||||
for (u32 i = 0; i < _numElements; i += 3) {
|
for (u32 i = 0; i < _numElements; i += 3) {
|
||||||
u32 orbits = 0;
|
u32 orbits = 0;
|
||||||
if (_pElements != nullptr) {
|
if (_pElements != nullptr) {
|
||||||
|
@ -198,6 +197,7 @@ void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _nu
|
||||||
assert(numVertex == 3);
|
assert(numVertex == 3);
|
||||||
if ((gSP.geometryMode & G_CULL_BACK) != 0) {
|
if ((gSP.geometryMode & G_CULL_BACK) != 0) {
|
||||||
for (int k = 0; k < 3; ++k) {
|
for (int k = 0; k < 3; ++k) {
|
||||||
|
maxY = std::max(maxY, vclip[k].y);
|
||||||
vdraw[k].x = floatToFixed16(vclip[k].x);
|
vdraw[k].x = floatToFixed16(vclip[k].x);
|
||||||
vdraw[k].y = floatToFixed16(vclip[k].y);
|
vdraw[k].y = floatToFixed16(vclip[k].y);
|
||||||
vdraw[k].z = floatToFixed16(vclip[k].z);
|
vdraw[k].z = floatToFixed16(vclip[k].z);
|
||||||
|
@ -205,6 +205,7 @@ void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _nu
|
||||||
} else {
|
} else {
|
||||||
for (int k = 0; k < 3; ++k) {
|
for (int k = 0; k < 3; ++k) {
|
||||||
const u32 idx = 3 - k - 1;
|
const u32 idx = 3 - k - 1;
|
||||||
|
maxY = std::max(maxY, vclip[idx].y);
|
||||||
vdraw[k].x = floatToFixed16(vclip[idx].x);
|
vdraw[k].x = floatToFixed16(vclip[idx].x);
|
||||||
vdraw[k].y = floatToFixed16(vclip[idx].y);
|
vdraw[k].y = floatToFixed16(vclip[idx].y);
|
||||||
vdraw[k].z = floatToFixed16(vclip[idx].z);
|
vdraw[k].z = floatToFixed16(vclip[idx].z);
|
||||||
|
@ -218,6 +219,7 @@ void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _nu
|
||||||
|
|
||||||
if ((gSP.geometryMode & G_CULL_BACK) != 0) {
|
if ((gSP.geometryMode & G_CULL_BACK) != 0) {
|
||||||
for (int k = 0; k < numVertex; ++k) {
|
for (int k = 0; k < numVertex; ++k) {
|
||||||
|
maxY = std::max(maxY, vtx[k]->y);
|
||||||
vdraw[k].x = floatToFixed16(vtx[k]->x);
|
vdraw[k].x = floatToFixed16(vtx[k]->x);
|
||||||
vdraw[k].y = floatToFixed16(vtx[k]->y);
|
vdraw[k].y = floatToFixed16(vtx[k]->y);
|
||||||
vdraw[k].z = floatToFixed16(vtx[k]->z);
|
vdraw[k].z = floatToFixed16(vtx[k]->z);
|
||||||
|
@ -225,6 +227,7 @@ void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _nu
|
||||||
} else {
|
} else {
|
||||||
for (int k = 0; k < numVertex; ++k) {
|
for (int k = 0; k < numVertex; ++k) {
|
||||||
const u32 idx = numVertex - k - 1;
|
const u32 idx = numVertex - k - 1;
|
||||||
|
maxY = std::max(maxY, vtx[idx]->y);
|
||||||
vdraw[k].x = floatToFixed16(vtx[idx]->x);
|
vdraw[k].x = floatToFixed16(vtx[idx]->x);
|
||||||
vdraw[k].y = floatToFixed16(vtx[idx]->y);
|
vdraw[k].y = floatToFixed16(vtx[idx]->y);
|
||||||
vdraw[k].z = floatToFixed16(vtx[idx]->z);
|
vdraw[k].z = floatToFixed16(vtx[idx]->z);
|
||||||
|
@ -232,6 +235,11 @@ void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _nu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rasterize(vdraw, numVertex, dzdx);
|
//Current depth buffer can be null if we are loading from a save state
|
||||||
|
if (depthBufferList().getCurrent() != nullptr &&
|
||||||
|
config.frameBufferEmulation.copyDepthToRDRAM == Config::cdSoftwareRender &&
|
||||||
|
gDP.otherMode.depthUpdate != 0)
|
||||||
|
Rasterize(vdraw, numVertex, dzdx);
|
||||||
}
|
}
|
||||||
|
return maxY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
#include "gSP.h"
|
#include "gSP.h"
|
||||||
|
|
||||||
void renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _numElements);
|
f32 renderTriangles(const SPVertex * _pVertices, const u8 * _pElements, u32 _numElements);
|
||||||
|
|
||||||
#endif // SOFTWARE_RENDER_H
|
#endif // SOFTWARE_RENDER_H
|
||||||
|
|
19
src/gDP.cpp
19
src/gDP.cpp
|
@ -801,16 +801,10 @@ void gDPFillRectangle( s32 ulx, s32 uly, s32 lrx, s32 lry )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lrx == gDP.colorImage.width) {
|
if (lry > (u32)gDP.scissor.lry)
|
||||||
if (gDP.otherMode.cycleType == G_CYC_FILL) {
|
gDP.colorImage.height = max(gDP.colorImage.height, (u32)gDP.scissor.lry);
|
||||||
if (lry > (u32)gDP.scissor.lry)
|
else
|
||||||
gDP.colorImage.height = (u32)max(gDP.colorImage.height, (u32)gDP.scissor.lry);
|
gDP.colorImage.height = max(gDP.colorImage.height, (u32)lry);
|
||||||
else
|
|
||||||
gDP.colorImage.height = (u32)max((s32)gDP.colorImage.height, lry);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
gDP.colorImage.height = max(gDP.colorImage.height, (u32)gDP.scissor.lry);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED, "gDPFillRectangle( %i, %i, %i, %i );\n",
|
DebugMsg( DEBUG_HIGH | DEBUG_HANDLED, "gDPFillRectangle( %i, %i, %i, %i );\n",
|
||||||
|
@ -894,10 +888,7 @@ void gDPTextureRectangle(f32 ulx, f32 uly, f32 lrx, f32 lry, s32 tile, f32 s, f3
|
||||||
gSP.textureTile[1] = textureTileOrg[1];
|
gSP.textureTile[1] = textureTileOrg[1];
|
||||||
|
|
||||||
frameBufferList().setBufferChanged();
|
frameBufferList().setBufferChanged();
|
||||||
if (gDP.colorImage.width < 64)
|
gDP.colorImage.height = max(gDP.colorImage.height, (u32)lry);
|
||||||
gDP.colorImage.height = (u32)max( (f32)gDP.colorImage.height, lry );
|
|
||||||
else
|
|
||||||
gDP.colorImage.height = max( gDP.colorImage.height, (u32)gDP.scissor.lry );
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (flip)
|
if (flip)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user