diff --git a/GPU/Directx9/TransformPipelineDX9.cpp b/GPU/Directx9/TransformPipelineDX9.cpp index 47b7dde2e..af9ddaf3f 100644 --- a/GPU/Directx9/TransformPipelineDX9.cpp +++ b/GPU/Directx9/TransformPipelineDX9.cpp @@ -69,9 +69,10 @@ int D3DPrimCount(D3DPRIMITIVETYPE prim, int size) { } enum { - DECODED_VERTEX_BUFFER_SIZE = 65536 * 48, - DECODED_INDEX_BUFFER_SIZE = 65536 * 20, - TRANSFORMED_VERTEX_BUFFER_SIZE = 65536 * sizeof(TransformedVertex) + VERTEX_BUFFER_MAX = 65536, + DECODED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 48, + DECODED_INDEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 20, + TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex) }; @@ -90,6 +91,7 @@ TransformDrawEngineDX9::TransformDrawEngineDX9() textureCache_(0), framebufferManager_(0), numDrawCalls(0), + vertexCountInDrawCalls(0), uvScale(0) { decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL; // Allocate nicely aligned memory. Maybe graphics drivers will @@ -914,7 +916,7 @@ void TransformDrawEngineDX9::SubmitPrim(void *verts, void *inds, GEPrimitiveType if (vertexCount == 0) return; // we ignore zero-sized draw calls. - if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS) + if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS || vertexCountInDrawCalls + vertexCount > VERTEX_BUFFER_MAX) Flush(); // TODO: Is this the right thing to do? @@ -951,6 +953,7 @@ void TransformDrawEngineDX9::SubmitPrim(void *verts, void *inds, GEPrimitiveType uvScale[numDrawCalls] = gstate_c.uv; } numDrawCalls++; + vertexCountInDrawCalls += vertexCount; } void TransformDrawEngineDX9::DecodeVerts() { @@ -1330,6 +1333,7 @@ rotateVBO: indexGen.Reset(); collectedVerts = 0; numDrawCalls = 0; + vertexCountInDrawCalls = 0; prevPrim_ = GE_PRIM_INVALID; #ifndef _XBOX diff --git a/GPU/Directx9/TransformPipelineDX9.h b/GPU/Directx9/TransformPipelineDX9.h index 352cb237d..ad4280369 100644 --- a/GPU/Directx9/TransformPipelineDX9.h +++ b/GPU/Directx9/TransformPipelineDX9.h @@ -186,6 +186,7 @@ private: enum { MAX_DEFERRED_DRAW_CALLS = 128 }; DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS]; int numDrawCalls; + int vertexCountInDrawCalls; int decimationCounter_; diff --git a/GPU/GLES/TransformPipeline.cpp b/GPU/GLES/TransformPipeline.cpp index 4a0927ef9..cea9ed579 100644 --- a/GPU/GLES/TransformPipeline.cpp +++ b/GPU/GLES/TransformPipeline.cpp @@ -99,9 +99,10 @@ const GLuint glprim[8] = { }; enum { - DECODED_VERTEX_BUFFER_SIZE = 65536 * 48, - DECODED_INDEX_BUFFER_SIZE = 65536 * 20, - TRANSFORMED_VERTEX_BUFFER_SIZE = 65536 * sizeof(TransformedVertex) + VERTEX_BUFFER_MAX = 65536, + DECODED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 48, + DECODED_INDEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 20, + TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex) }; #define QUAD_INDICES_MAX 32768 @@ -123,6 +124,7 @@ TransformDrawEngine::TransformDrawEngine() textureCache_(0), framebufferManager_(0), numDrawCalls(0), + vertexCountInDrawCalls(0), uvScale(0) { decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL; // Allocate nicely aligned memory. Maybe graphics drivers will @@ -914,7 +916,7 @@ void TransformDrawEngine::SubmitPrim(void *verts, void *inds, GEPrimitiveType pr if (vertexCount == 0) return; // we ignore zero-sized draw calls. - if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS) + if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS || vertexCountInDrawCalls + vertexCount > VERTEX_BUFFER_MAX) Flush(); // TODO: Is this the right thing to do? @@ -951,6 +953,7 @@ void TransformDrawEngine::SubmitPrim(void *verts, void *inds, GEPrimitiveType pr uvScale[numDrawCalls] = gstate_c.uv; } numDrawCalls++; + vertexCountInDrawCalls += vertexCount; } void TransformDrawEngine::DecodeVerts() { @@ -1326,6 +1329,7 @@ rotateVBO: indexGen.Reset(); collectedVerts = 0; numDrawCalls = 0; + vertexCountInDrawCalls = 0; prevPrim_ = GE_PRIM_INVALID; #ifndef USING_GLES2 diff --git a/GPU/GLES/TransformPipeline.h b/GPU/GLES/TransformPipeline.h index 0cb0866a0..12d48f94c 100644 --- a/GPU/GLES/TransformPipeline.h +++ b/GPU/GLES/TransformPipeline.h @@ -191,6 +191,7 @@ private: enum { MAX_DEFERRED_DRAW_CALLS = 128 }; DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS]; int numDrawCalls; + int vertexCountInDrawCalls; int decimationCounter_;