VideoCommon: merge triangle+list+point index buffers

We are used to render them out of order as long as everything else matches, but rendering order does matter, so we have to flush on primitive switch. This commit implements this flush.
Also as we flush on primitive switch, we don't have to create three different index buffers. All indices are now stored in one buffer.

This will slow down games which switch often primitive types (eg ztp), but it should be more accurate.
This commit is contained in:
degasus
2014-01-15 21:44:46 +01:00
parent 770485ad04
commit 6b01839525
7 changed files with 133 additions and 175 deletions

View File

@ -8,6 +8,12 @@
class NativeVertexFormat;
class PointerWrap;
enum PrimitiveType {
PRIMITIVE_POINTS,
PRIMITIVE_LINES,
PRIMITIVE_TRIANGLES,
};
class VertexManager
{
private:
@ -45,14 +51,14 @@ public:
virtual void DestroyDeviceObjects(){};
protected:
u16* GetTriangleIndexBuffer() { return &TIBuffer[0]; }
u16* GetLineIndexBuffer() { return &LIBuffer[0]; }
u16* GetPointIndexBuffer() { return &PIBuffer[0]; }
u16* GetIndexBuffer() { return &LocalIBuffer[0]; }
u8* GetVertexBuffer() { return &s_pBaseBufferPointer[0]; }
virtual void vDoState(PointerWrap& p) { DoStateShared(p); }
void DoStateShared(PointerWrap& p);
static PrimitiveType current_primitive_type;
private:
bool IsFlushed() const;
@ -63,9 +69,7 @@ private:
virtual void vFlush() = 0;
std::vector<u8> LocalVBuffer;
std::vector<u16> TIBuffer;
std::vector<u16> LIBuffer;
std::vector<u16> PIBuffer;
std::vector<u16> LocalIBuffer;
};
extern VertexManager *g_vertex_manager;