VideoCommon: allow backends to set the buffer pointer as they want to

This commit is contained in:
degasus 2014-01-23 13:11:38 +01:00
parent 128fcdac26
commit 52feed04db
2 changed files with 15 additions and 12 deletions

View File

@ -24,6 +24,8 @@ u8 *VertexManager::s_pEndBufferPointer;
PrimitiveType VertexManager::current_primitive_type;
bool VertexManager::IsFlushed;
static const PrimitiveType primitive_from_gx[8] = {
PRIMITIVE_TRIANGLES, // GX_DRAW_QUADS
PRIMITIVE_TRIANGLES, // GX_DRAW_NONE
@ -43,14 +45,14 @@ VertexManager::VertexManager()
LocalIBuffer.resize(MAXIBUFFERSIZE);
ResetBuffer();
IsFlushed = true;
}
VertexManager::~VertexManager()
{
}
void VertexManager::ResetBuffer()
void VertexManager::ResetBuffer(u32 stride)
{
s_pCurBufferPointer = s_pBaseBufferPointer;
IndexGenerator::Start(GetIndexBuffer());
@ -84,11 +86,13 @@ void VertexManager::PrepareForAdditionalData(int primitive, u32 count, u32 strid
ERROR_LOG(VIDEO, "VertexManager: Buffer not large enough for all vertices! "
"Increase MAXVBUFFERSIZE or we need primitive breaking after all.");
}
}
bool VertexManager::IsFlushed() const
{
return s_pBaseBufferPointer == s_pCurBufferPointer;
// need to alloc new buffer
if(IsFlushed)
{
g_vertex_manager->ResetBuffer(stride);
IsFlushed = false;
}
}
u32 VertexManager::GetRemainingIndices(int primitive)
@ -160,8 +164,7 @@ void VertexManager::AddVertices(int primitive, u32 numVertices)
void VertexManager::Flush()
{
if (g_vertex_manager->IsFlushed())
return;
if (IsFlushed) return;
// loading a state will invalidate BP, so check for it
g_video_backend->CheckInvalidState();
@ -238,7 +241,7 @@ void VertexManager::Flush()
// TODO: need to merge more stuff into VideoCommon
g_vertex_manager->vFlush();
g_vertex_manager->ResetBuffer();
IsFlushed = true;
}
void VertexManager::DoState(PointerWrap& p)

View File

@ -59,10 +59,10 @@ protected:
static PrimitiveType current_primitive_type;
private:
bool IsFlushed() const;
virtual void ResetBuffer(u32 stride);
void ResetBuffer();
private:
static bool IsFlushed;
//virtual void Draw(u32 stride, bool alphapass) = 0;
// temp