2010-10-03 10:20:24 +02:00
|
|
|
|
|
|
|
#ifndef _VERTEXMANAGERBASE_H
|
|
|
|
#define _VERTEXMANAGERBASE_H
|
|
|
|
|
2010-11-26 10:25:08 +01:00
|
|
|
class NativeVertexFormat;
|
2012-01-04 09:42:22 +01:00
|
|
|
class PointerWrap;
|
2010-11-26 10:25:08 +01:00
|
|
|
|
2010-10-03 10:20:24 +02:00
|
|
|
class VertexManager
|
|
|
|
{
|
2013-02-22 06:12:53 +01:00
|
|
|
private:
|
|
|
|
// What are the actual values?
|
|
|
|
static const u32 SMALLEST_POSSIBLE_VERTEX = 1;
|
|
|
|
static const u32 LARGEST_POSSIBLE_VERTEX = 188;
|
|
|
|
|
|
|
|
static const u32 MAX_PRIMITIVES_PER_COMMAND = (u16)-1;
|
|
|
|
|
2010-10-03 10:20:24 +02:00
|
|
|
public:
|
2013-02-22 06:12:53 +01:00
|
|
|
// values from OGL backend
|
|
|
|
//static const u32 MAXVBUFFERSIZE = 0x1FFFF;
|
|
|
|
|
|
|
|
// values from DX9/11 backend
|
|
|
|
static const u32 MAXVBUFFERSIZE = MAX_PRIMITIVES_PER_COMMAND * LARGEST_POSSIBLE_VERTEX;
|
|
|
|
|
|
|
|
// We may convert triangle-fans to triangle-lists, almost 3x as many indices.
|
|
|
|
// Watching for a full index buffer would probably be smarter than this calculation.
|
|
|
|
static const u32 MAXIBUFFERSIZE = MAXVBUFFERSIZE * 3 / SMALLEST_POSSIBLE_VERTEX;
|
|
|
|
//static const u32 MAXIBUFFERSIZE = MAX_PRIMITIVES_PER_COMMAND * 3;
|
2010-10-03 10:20:24 +02:00
|
|
|
|
|
|
|
VertexManager();
|
2013-02-22 06:12:53 +01:00
|
|
|
// needs to be virtual for DX11's dtor
|
|
|
|
virtual ~VertexManager();
|
2010-10-03 10:20:24 +02:00
|
|
|
|
2013-02-22 02:10:00 +01:00
|
|
|
static void AddVertices(int _primitive, u32 _numVertices);
|
2010-10-03 10:20:24 +02:00
|
|
|
|
2013-02-21 12:36:29 +01:00
|
|
|
static u8 *s_pCurBufferPointer;
|
2013-02-22 08:41:52 +01:00
|
|
|
static u8 *s_pBaseBufferPointer;
|
2013-02-21 12:36:29 +01:00
|
|
|
static u8 *s_pEndBufferPointer;
|
2010-10-03 10:20:24 +02:00
|
|
|
|
|
|
|
static int GetRemainingSize();
|
2013-02-22 08:41:52 +01:00
|
|
|
|
|
|
|
//int GetRemainingVertices(int primitive);
|
2010-10-03 10:20:24 +02:00
|
|
|
|
|
|
|
static void Flush();
|
|
|
|
|
2010-11-26 10:25:08 +01:00
|
|
|
virtual ::NativeVertexFormat* CreateNativeVertexFormat() = 0;
|
|
|
|
|
2013-02-22 08:41:52 +01:00
|
|
|
// TODO: use these instead of TIBuffer, etc
|
|
|
|
|
|
|
|
// u16* GetTriangleIndexBuffer() { return TIBuffer; }
|
|
|
|
// u16* GetLineIndexBuffer() { return LIBuffer; }
|
|
|
|
// u16* GetPointIndexBuffer() { return PIBuffer; }
|
|
|
|
// u8* GetVertexBuffer() { return s_pBaseBufferPointer; }
|
2010-11-29 17:16:48 +01:00
|
|
|
|
2012-01-04 09:42:22 +01:00
|
|
|
static void DoState(PointerWrap& p);
|
2012-10-20 15:22:15 +02:00
|
|
|
virtual void CreateDeviceObjects(){};
|
|
|
|
virtual void DestroyDeviceObjects(){};
|
2013-02-22 08:41:52 +01:00
|
|
|
|
2010-10-03 10:20:24 +02:00
|
|
|
protected:
|
2013-02-22 08:41:52 +01:00
|
|
|
u16* TIBuffer;
|
|
|
|
u16* LIBuffer;
|
|
|
|
u16* PIBuffer;
|
2010-10-03 10:20:24 +02:00
|
|
|
|
2012-01-04 09:42:22 +01:00
|
|
|
virtual void vDoState(PointerWrap& p) { DoStateShared(p); }
|
|
|
|
void DoStateShared(PointerWrap& p);
|
|
|
|
|
2010-10-03 10:20:24 +02:00
|
|
|
private:
|
2013-02-22 08:41:52 +01:00
|
|
|
bool IsFlushed() const;
|
|
|
|
|
|
|
|
void ResetBuffer();
|
|
|
|
|
2010-10-20 00:24:27 +02:00
|
|
|
//virtual void Draw(u32 stride, bool alphapass) = 0;
|
|
|
|
// temp
|
2010-10-03 10:20:24 +02:00
|
|
|
virtual void vFlush() = 0;
|
2013-02-21 12:36:29 +01:00
|
|
|
|
2013-02-22 08:41:52 +01:00
|
|
|
u8* LocalVBuffer;
|
2010-10-03 10:20:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern VertexManager *g_vertex_manager;
|
|
|
|
|
|
|
|
#endif
|