Move AdvanceVerts to GPUStateCache

This commit is contained in:
Henrik Rydgård committed 2026-07-14 15:28:21 +02:00
1 parent 3e393d99e1
commit 18a9de3eca
5 files changed
+39 -32

No files matched your search

+1 -1
View File
@@ -1243,7 +1243,7 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) {
// This is the normal case that pretty much always happens, the others are esoteric.
currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, inds, count, dec, vertType);
}
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void GPUCommon::Execute_MorphWeight(u32 op, u32 diff) {
-9
View File
@@ -320,15 +320,6 @@ protected:
// TODO: Unify this. Vulkan and OpenGL are different due to how they buffer data.
virtual void FinishDeferred() {}
void AdvanceVerts(u32 vertType, int count, int bytesRead) {
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const int indexShift = ((vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1;
gstate_c.indexAddr += count << indexShift;
} else {
gstate_c.vertexAddr += bytesRead;
}
}
virtual void BuildReportingInfo() = 0;
virtual void UpdateMSAALevel(Draw::DrawContext *draw) {}
+12 -10
View File
@@ -1051,7 +1051,7 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
AdvanceVerts(vertexType, count, bytesRead);
gstate_c.AdvanceVerts(vertexType, count, bytesRead);
int totalVertCount = count;
@@ -1132,7 +1132,7 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
drawEngineCommon_->SkipPrim(newPrim, count, decoder, &bytesRead);
canExtend = false;
}
AdvanceVerts(vertexType, count, bytesRead);
gstate_c.AdvanceVerts(vertexType, count, bytesRead);
totalVertCount += count;
break;
}
@@ -1301,7 +1301,8 @@ void GPUCommonHW::Execute_Bezier(u32 op, u32 diff) {
const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
const void *indices = NULL;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u32 vertType = gstate.vertType;
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG(Log::G3D, "Bad index address %08x!", gstate_c.indexAddr);
return;
@@ -1309,8 +1310,8 @@ void GPUCommonHW::Execute_Bezier(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", gstate.vertType, (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(gstate.vertType));
if (vertTypeIsSkinningEnabled(vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", vertType, (vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(vertType));
}
// Can't flush after setting gstate_c.submitType below since it'll be a mess - it must be done already.
@@ -1341,7 +1342,7 @@ void GPUCommonHW::Execute_Bezier(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
const int count = surface.num_points_u * surface.num_points_v;
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void GPUCommonHW::Execute_Spline(u32 op, u32 diff) {
@@ -1370,7 +1371,8 @@ void GPUCommonHW::Execute_Spline(u32 op, u32 diff) {
const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
const void *indices = NULL;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u32 vertType = gstate.vertType;
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG(Log::G3D, "Bad index address %08x!", gstate_c.indexAddr);
return;
@@ -1378,8 +1380,8 @@ void GPUCommonHW::Execute_Spline(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
WARN_LOG_ONCE(unusualcurve, Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", gstate.vertType, (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(gstate.vertType));
if (vertTypeIsSkinningEnabled(vertType)) {
WARN_LOG_ONCE(unusualcurve, Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", vertType, (vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(vertType));
}
// Can't flush after setting gstate_c.submitType below since it'll be a mess - it must be done already.
@@ -1412,7 +1414,7 @@ void GPUCommonHW::Execute_Spline(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = surface.num_points_u * surface.num_points_v;
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void GPUCommonHW::Execute_BlockTransferStart(u32 op, u32 diff) {
+10
View File
@@ -534,6 +534,16 @@ struct GPUStateCache {
bool IsDirty(u64 what) const {
return (dirty & what) != 0ULL;
}
void AdvanceVerts(u32 vertType, int count, int bytesRead) {
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const int indexShift = ((vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1;
indexAddr += count << indexShift;
} else {
vertexAddr += bytesRead;
}
}
void SetTextureSolidAlpha(bool solidAlpha) {
if (solidAlpha != textureSolidAlpha) {
textureSolidAlpha = solidAlpha;
+16 -12
View File
@@ -853,7 +853,9 @@ void SoftGPU::Execute_Prim(u32 op, u32 diff) {
const void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
const void *indices = NULL;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u32 vertType = gstate.vertType;
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG_REPORT(Log::G3D, "Software: Bad index address %08x!", gstate_c.indexAddr);
return;
@@ -864,7 +866,7 @@ void SoftGPU::Execute_Prim(u32 op, u32 diff) {
cyclesExecuted += EstimatePerVertexCost() * count;
int bytesRead;
drawEngine_->transformUnit.SetDirty(dirtyFlags_);
drawEngine_->transformUnit.SubmitPrimitive(verts, indices, prim, count, gstate.vertType, &bytesRead, drawEngine_);
drawEngine_->transformUnit.SubmitPrimitive(verts, indices, prim, count, vertType, &bytesRead, drawEngine_);
dirtyFlags_ = drawEngine_->transformUnit.GetDirty();
SoftGPUVRAMDirty mark = (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) != 0 ? SoftGPUVRAMDirty::DIRTY : SoftGPUVRAMDirty::DIRTY | SoftGPUVRAMDirty::REALLY_DIRTY;
@@ -873,7 +875,7 @@ void SoftGPU::Execute_Prim(u32 op, u32 diff) {
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
// Some games rely on this, they don't bother reloading VADDR and IADDR.
// The VADDR/IADDR registers are NOT updated.
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void SoftGPU::Execute_Bezier(u32 op, u32 diff) {
@@ -890,7 +892,8 @@ void SoftGPU::Execute_Bezier(u32 op, u32 diff) {
const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
const void *indices = NULL;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u32 vertType = gstate.vertType;
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG_REPORT(Log::G3D, "Bad index address %08x!", gstate_c.indexAddr);
return;
@@ -898,8 +901,8 @@ void SoftGPU::Execute_Bezier(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if ((gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) || vertTypeIsSkinningEnabled(gstate.vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", gstate.vertType, (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(gstate.vertType));
if ((vertType & GE_VTYPE_MORPHCOUNT_MASK) || vertTypeIsSkinningEnabled(vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", vertType, (vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(vertType));
}
Spline::BezierSurface surface;
@@ -924,7 +927,7 @@ void SoftGPU::Execute_Bezier(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = surface.num_points_u * surface.num_points_v;
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void SoftGPU::Execute_Spline(u32 op, u32 diff) {
@@ -941,7 +944,8 @@ void SoftGPU::Execute_Spline(u32 op, u32 diff) {
const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
const void *indices = NULL;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u32 vertType = gstate.vertType;
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG_REPORT(Log::G3D, "Bad index address %08x!", gstate_c.indexAddr);
return;
@@ -949,8 +953,8 @@ void SoftGPU::Execute_Spline(u32 op, u32 diff) {
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
}
if ((gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) || vertTypeIsSkinningEnabled(gstate.vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", gstate.vertType, (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(gstate.vertType));
if ((vertType & GE_VTYPE_MORPHCOUNT_MASK) || vertTypeIsSkinningEnabled(vertType)) {
DEBUG_LOG_REPORT(Log::G3D, "Unusual bezier/spline vtype: %08x, morph: %d, bones: %d", vertType, (vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT, vertTypeGetNumBoneWeights(vertType));
}
Spline::SplineSurface surface;
@@ -969,7 +973,7 @@ void SoftGPU::Execute_Spline(u32 op, u32 diff) {
int bytesRead = 0;
drawEngine_->transformUnit.SetDirty(dirtyFlags_);
drawEngineCommon_->SubmitCurve(control_points, indices, surface, gstate.vertType, &bytesRead, "spline");
drawEngineCommon_->SubmitCurve(control_points, indices, surface, vertType, &bytesRead, "spline");
dirtyFlags_ = drawEngine_->transformUnit.GetDirty();
SoftGPUVRAMDirty mark = (gstate_c.skipDrawReason & SKIPDRAW_SKIPFRAME) != 0 ? SoftGPUVRAMDirty::DIRTY : SoftGPUVRAMDirty::DIRTY | SoftGPUVRAMDirty::REALLY_DIRTY;
@@ -977,7 +981,7 @@ void SoftGPU::Execute_Spline(u32 op, u32 diff) {
// After drawing, we advance pointers - see SubmitPrim which does the same.
int count = surface.num_points_u * surface.num_points_v;
AdvanceVerts(gstate.vertType, count, bytesRead);
gstate_c.AdvanceVerts(vertType, count, bytesRead);
}
void SoftGPU::Execute_LoadClut(u32 op, u32 diff) {