More fixes

This commit is contained in:
Henrik Rydgård committed 2024-12-28 23:50:42 +01:00
1 parent aec17d8829
commit 6d539cc5e0
6 files changed
+53 -39

No files matched your search

+4 -2
View File
@@ -15,7 +15,7 @@ struct DepthScreenVertex {
#endif
// We only need to support these three modes.
enum class ZCompareMode {
enum class ZCompareMode : u8 {
Greater, // Most common
Less, // Less common
Always, // Mostly used for clears
@@ -29,10 +29,12 @@ struct DepthScissor {
};
struct DepthDraw {
u32 depthAddr;
u16 depthStride;
u8 cullMode;
GEPrimitiveType prim;
ZCompareMode compareMode;
bool cullEnabled;
int cullMode;
DepthScissor scissor;
int vertexOffset;
int indexOffset;
+37 -30
View File
@@ -39,7 +39,7 @@
enum {
TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex),
DEPTH_TRANSFORMED_SIZE = VERTEX_BUFFER_MAX * 4,
DEPTH_TRANSFORMED_SIZE = VERTEX_BUFFER_MAX * 4 * sizeof(float),
DEPTH_SCREENVERTS_COMPONENT_COUNT = VERTEX_BUFFER_MAX,
DEPTH_SCREENVERTS_COMPONENT_SIZE = DEPTH_SCREENVERTS_COMPONENT_COUNT * sizeof(int) + 384,
DEPTH_SCREENVERTS_SIZE = DEPTH_SCREENVERTS_COMPONENT_SIZE * 3,
@@ -67,6 +67,9 @@ DrawEngineCommon::DrawEngineCommon() : decoderMap_(32) {
case DepthRasterMode::OFF:
useDepthRaster_ = false;
}
if (useDepthRaster_) {
depthDraws_.reserve(256);
}
}
DrawEngineCommon::~DrawEngineCommon() {
@@ -983,6 +986,8 @@ bool DrawEngineCommon::CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim,
return false;
}
draw->depthAddr = gstate.getDepthBufRawAddress() | 0x04000000;
draw->depthStride = gstate.DepthBufStride();
draw->vertexOffset = depthVertexCount_;
draw->indexOffset = depthIndexCount_;
draw->vertexCount = vertexCount;
@@ -1015,7 +1020,7 @@ void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder
return;
}
TimeCollector collectStat(&gpuStats.msRasterizingDepth, coreCollectDebugStats);
TimeCollector collectStat(&gpuStats.msPrepareDepth, coreCollectDebugStats);
// Decode.
int numDecoded = 0;
@@ -1035,9 +1040,11 @@ void DrawEngineCommon::DepthRasterTransform(GEPrimitiveType prim, VertexDecoder
// Commit
depthIndexCount_ += vertexCount;
depthVertexCount_ += numDec;
depthVertexCount_ += numDecoded;
depthDraws_.push_back(draw);
// FlushQueuedDepth();
}
void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *inVerts, int numDecoded, VertexDecoder *dec, int vertexCount) {
@@ -1050,7 +1057,7 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i
return;
}
TimeCollector collectStat(&gpuStats.msRasterizingDepth, coreCollectDebugStats);
TimeCollector collectStat(&gpuStats.msPrepareDepth, coreCollectDebugStats);
_dbg_assert_(prim != GE_PRIM_TRIANGLE_STRIP && prim != GE_PRIM_TRIANGLE_FAN);
@@ -1073,11 +1080,36 @@ void DrawEngineCommon::DepthRasterPredecoded(GEPrimitiveType prim, const void *i
depthVertexCount_ += numDecoded;
depthDraws_.push_back(draw);
// FlushQueuedDepth();
}
void DrawEngineCommon::FlushQueuedDepth() {
TimeCollector collectStat(&gpuStats.msRasterizeDepth, coreCollectDebugStats);
for (const auto &draw : depthDraws_) {
ExecuteDepthDraw(draw);
int *tx = depthScreenVerts_;
int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT;
float *tz = (float *)(depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT * 2);
int outVertCount = 0;
const float *vertices = depthTransformed_ + 4 * draw.vertexOffset;
const uint16_t *indices = depthIndices_ + draw.indexOffset;
switch (draw.prim) {
case GE_PRIM_RECTANGLES:
outVertCount = DepthRasterClipIndexedRectangles(tx, ty, tz, vertices, indices, draw);
break;
case GE_PRIM_TRIANGLES:
outVertCount = DepthRasterClipIndexedTriangles(tx, ty, tz, vertices, indices, draw);
break;
default:
_dbg_assert_(false);
break;
}
// TODO: Could potentially split into tasks here!
DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(draw.depthAddr), draw.depthStride, tx, ty, tz, outVertCount, draw);
}
// Reset queue
@@ -1085,28 +1117,3 @@ void DrawEngineCommon::FlushQueuedDepth() {
depthVertexCount_ = 0;
depthDraws_.clear();
}
void DrawEngineCommon::ExecuteDepthDraw(const DepthDraw &draw) {
int *tx = depthScreenVerts_;
int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT;
float *tz = (float *)(depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT * 2);
int outVertCount = 0;
const float *vertices = depthTransformed_ + 4 * draw.vertexOffset;
const uint16_t *indices = depthIndices_ + draw.indexOffset;
switch (draw.prim) {
case GE_PRIM_RECTANGLES:
outVertCount = DepthRasterClipIndexedRectangles(tx, ty, tz, vertices, indices, draw);
break;
case GE_PRIM_TRIANGLES:
outVertCount = DepthRasterClipIndexedTriangles(tx, ty, tz, vertices, indices, draw);
break;
default:
_dbg_assert_(false);
break;
}
DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(gstate.getDepthBufRawAddress() | 0x04000000), gstate.DepthBufStride(),
tx, ty, tz, outVertCount, draw);
}
-1
View File
@@ -179,7 +179,6 @@ protected:
void DepthRasterTransform(GEPrimitiveType prim, VertexDecoder *dec, uint32_t vertTypeID, int vertexCount);
void DepthRasterPredecoded(GEPrimitiveType prim, const void *inVerts, int numDecoded, VertexDecoder *dec, int vertexCount);
void ExecuteDepthDraw(const DepthDraw &draw);
bool CalculateDepthDraw(DepthDraw *draw, GEPrimitiveType prim, int vertexCount);
static inline int IndexSize(u32 vtype) {
+4 -2
View File
@@ -108,7 +108,8 @@ struct GPUStatistics {
numCachedReplacedTextures = 0;
numClutTextures = 0;
msProcessingDisplayLists = 0;
msRasterizingDepth = 0.0f;
msPrepareDepth = 0.0f;
msRasterizeDepth = 0.0f;
numDepthRasterPrims = 0;
numDepthRasterBackface = 0;
numDepthRasterNoPixels = 0;
@@ -153,7 +154,8 @@ struct GPUStatistics {
int numCachedReplacedTextures;
int numClutTextures;
double msProcessingDisplayLists;
double msRasterizingDepth;
double msPrepareDepth;
double msRasterizeDepth;
int vertexGPUCycles;
int otherGPUCycles;
int numDepthRasterPrims;
+5 -2
View File
@@ -987,8 +987,10 @@ void GPUCommon::Execute_Ret(u32 op, u32 diff) {
}
void GPUCommon::Execute_End(u32 op, u32 diff) {
if (flushOnParams_)
if (flushOnParams_) {
drawEngineCommon_->FlushQueuedDepth();
Flush();
}
const u32 prev = Memory::ReadUnchecked_U32(currentList->pc - 4);
UpdatePC(currentList->pc, currentList->pc);
@@ -1380,8 +1382,9 @@ void GPUCommon::FastLoadBoneMatrix(u32 target) {
}
if (!g_Config.bSoftwareSkinning) {
if (flushOnParams_)
if (flushOnParams_) {
Flush();
}
gstate_c.Dirty(uniformsToDirty);
} else {
gstate_c.deferredVertTypeDirty |= uniformsToDirty;
+3 -2
View File
@@ -1801,7 +1801,7 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) {
"replacer: tracks %d references, %d unique textures\n"
"Cpy: depth %d, color %d, reint %d, blend %d, self %d\n"
"GPU cycles: %d (%0.1f per vertex)\n"
"Depth raster: %0.2f ms, %d prim, %d nopix, %d small, %d back, %d zcull\n%s",
"Z-rast: %0.2f/%0.2f ms, %d prim, %d nopix, %d small, %d back, %d zcull\n%s",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawSyncs,
gpuStats.numListSyncs,
@@ -1838,7 +1838,8 @@ size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) {
gpuStats.numCopiesForSelfTex,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.msRasterizingDepth * 1000.0,
gpuStats.msPrepareDepth * 1000.0,
gpuStats.msRasterizeDepth * 1000.0,
gpuStats.numDepthRasterPrims,
gpuStats.numDepthRasterNoPixels,
gpuStats.numDepthRasterTooSmall,