Delete redundant implementation of vertex preview in SoftGpu

This commit is contained in:
Henrik Rydgård
2026-06-02 15:43:11 +02:00
parent 79328a99b3
commit 0dc6e36d19
6 changed files with 3 additions and 138 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ public:
virtual bool GetOutputFramebuffer(GPUDebugBuffer &buffer) { return false; }
bool GetCurrentDisplayList(DisplayList &list) const;
virtual bool GetCurrentDrawAsDebugVertices(GEPrimitiveType prim, GEPrimitiveType *outPrim, int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int *lowerIndexBound, TransformStats *stats, DebugVertexFlags flags) const;
bool GetCurrentDrawAsDebugVertices(GEPrimitiveType prim, GEPrimitiveType *outPrim, int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int *lowerIndexBound, TransformStats *stats, DebugVertexFlags flags) const;
int GetCurrentPrimCount(GEPrimitiveType *prim) const;
// FinishInitOnMainThread runs on the main thread, of course.
-9
View File
@@ -1440,15 +1440,6 @@ bool SoftGPU::GetCurrentClut(GPUDebugBuffer &buffer) {
return true;
}
bool SoftGPU::GetCurrentDrawAsDebugVertices(GEPrimitiveType prim, GEPrimitiveType *outPrim, int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int *lowerIndexBound, TransformStats *stats, DebugVertexFlags flags) const {
gstate_c.UpdateUVScaleOffset();
// We just pad out the vertex array here.
*lowerIndexBound = 0;
*outPrim = prim;
return drawEngine_->transformUnit.GetCurrentDrawAsDebugVertices(count, vertices, indices, flags);
}
bool SoftGPU::DescribeCodePtr(const u8 *ptr, std::string &name) {
std::string subname;
if (Sampler::DescribeCodePtr(ptr, subname)) {
-1
View File
@@ -172,7 +172,6 @@ public:
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
bool GetCurrentClut(GPUDebugBuffer &buffer) override;
bool GetCurrentDrawAsDebugVertices(GEPrimitiveType prim, GEPrimitiveType *outPrim, int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int *lowerIndexBound, TransformStats *stats, DebugVertexFlags flags) const override;
bool DescribeCodePtr(const u8 *ptr, std::string &name) override;
-123
View File
@@ -908,126 +908,3 @@ void TransformUnit::FlushIfOverlap(GPUCommon *common, const char *reason, bool m
void TransformUnit::NotifyClutUpdate(const void *src) {
binner_->UpdateClut(src);
}
// We should try to merge this into the similar function in SoftwareTransformCommon. It's really backend-independent (or should be...)
bool TransformUnit::GetCurrentDrawAsDebugVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, DebugVertexFlags flags) {
// This is always for the current vertices.
u16 indexLowerBound = 0;
u16 indexUpperBound = count - 1;
if (!Memory::IsValidAddress(gstate_c.vertexAddr) || count == 0)
return false;
if (count > 0 && (gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
const u8 *inds = Memory::GetPointer(gstate_c.indexAddr);
const u16_le *inds16 = (const u16_le *)inds;
const u32_le *inds32 = (const u32_le *)inds;
if (inds) {
GetIndexBounds(inds, count, gstate.vertType, &indexLowerBound, &indexUpperBound);
indices.resize(count);
switch (gstate.vertType & GE_VTYPE_IDX_MASK) {
case GE_VTYPE_IDX_8BIT:
for (int i = 0; i < count; ++i) {
indices[i] = inds[i];
}
break;
case GE_VTYPE_IDX_16BIT:
for (int i = 0; i < count; ++i) {
indices[i] = inds16[i];
}
break;
case GE_VTYPE_IDX_32BIT:
WARN_LOG_REPORT_ONCE(simpleIndexes32, Log::G3D, "SimpleVertices: Decoding 32-bit indexes");
for (int i = 0; i < count; ++i) {
// These aren't documented and should be rare. Let's bounds check each one.
if (inds32[i] != (u16)inds32[i]) {
ERROR_LOG_REPORT_ONCE(simpleIndexes32Bounds, Log::G3D, "SimpleVertices: Index outside 16-bit range");
}
indices[i] = (u16)inds32[i];
}
break;
}
} else {
indices.clear();
}
} else {
indices.clear();
}
static std::vector<u32> temp_buffer;
static std::vector<SimpleVertex> simpleVertices;
temp_buffer.resize(std::max((int)indexUpperBound, 8192) * 128 / sizeof(u32));
simpleVertices.resize(indexUpperBound + 1);
VertexDecoder vdecoder;
VertexDecoderOptions options{};
u32 vertTypeID = GetVertTypeID(gstate.vertType, gstate.getUVGenMode(), true);
vdecoder.SetVertexType(vertTypeID, options);
if (!Memory::IsValidRange(gstate_c.vertexAddr, (indexUpperBound + 1) * vdecoder.VertexSize()))
return false;
::NormalizeVertices(&simpleVertices[0], (u8 *)(&temp_buffer[0]), Memory::GetPointer(gstate_c.vertexAddr), indexLowerBound, indexUpperBound, &vdecoder, gstate.vertType);
float world[16];
float view[16];
float worldview[16];
float worldviewproj[16];
ConvertMatrix4x3To4x4(world, gstate.worldMatrix);
ConvertMatrix4x3To4x4(view, gstate.viewMatrix);
Matrix4ByMatrix4(worldview, world, view);
Matrix4ByMatrix4(worldviewproj, worldview, gstate.projMatrix);
const float zScale = gstate.getViewportZScale();
const float zCenter = gstate.getViewportZCenter();
vertices.resize(indexUpperBound + 1);
for (int i = indexLowerBound; i <= indexUpperBound; ++i) {
const SimpleVertex &vert = simpleVertices[i];
if (gstate.isModeThrough()) {
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = vert.pos.x;
vertices[i].y = vert.pos.y;
vertices[i].z = vert.pos.z;
} else {
Vec4f clipPos = Vec3ByMatrix44(vert.pos, worldviewproj);
bool outsideRangeFlag;
ScreenCoords screenPos = ClipToScreen(clipPos, &outsideRangeFlag);
float z = clipPos.z * zScale / clipPos.w + zCenter;
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0] * (float)gstate.getTextureWidth(0);
vertices[i].v = vert.uv[1] * (float)gstate.getTextureHeight(0);
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = (float)screenPos.x / SCREEN_SCALE_FACTOR;
vertices[i].y = (float)screenPos.y / SCREEN_SCALE_FACTOR;
vertices[i].z = screenPos.z <= 0 || screenPos.z >= 0xFFFF ? z : (float)screenPos.z;
}
if (gstate.vertType & GE_VTYPE_COL_MASK) {
memcpy(vertices[i].c0, vert.color, sizeof(vertices[i].c0));
} else {
memset(vertices[i].c0, 0, sizeof(vertices[i].c0));
}
vertices[i].nx = vert.nrm.x;
vertices[i].ny = vert.nrm.y;
vertices[i].nz = vert.nrm.z;
}
// The GE debugger expects these to be set.
gstate_c.curTextureWidth = gstate.getTextureWidth(0);
gstate_c.curTextureHeight = gstate.getTextureHeight(0);
return true;
}
-2
View File
@@ -132,8 +132,6 @@ public:
void SubmitPrimitive(const void* vertices, const void* indices, GEPrimitiveType prim_type, int vertex_count, u32 vertex_type, int *bytesRead, SoftwareDrawEngine *drawEngine);
void SubmitImmVertex(const ClipVertexData &vert, SoftwareDrawEngine *drawEngine);
static bool GetCurrentDrawAsDebugVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, DebugVertexFlags flags);
void Flush(GPUCommon *common, const char *reason);
void FlushIfOverlap(GPUCommon *common, const char *reason, bool modifying, uint32_t addr, uint32_t stride, uint32_t w, uint32_t h);
void NotifyClutUpdate(const void *src);
+2 -2
View File
@@ -231,9 +231,9 @@ void CGEDebugger::UpdatePrimPreview(u32 op, int which) {
}
if (indices.empty()) {
glDrawArrays(glprim[prim], 0, vertices.size());
glDrawArrays(glprim[prim], 0, (GLsizei)vertices.size());
} else {
glDrawElements(glprim[prim], indices.size(), GL_UNSIGNED_SHORT, texPreviewVao != 0 ? 0 : indices.data());
glDrawElements(glprim[prim], (GLsizei)indices.size(), GL_UNSIGNED_SHORT, texPreviewVao != 0 ? 0 : indices.data());
}
if (texPreviewVao == 0) {