D3D: Fix spiky polygon junk

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4125 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-08-31 22:03:52 +00:00
parent d65fb1a30a
commit d149ac2be1

View File

@ -58,8 +58,8 @@ static Collection collection;
static u8 *fakeVBuffer; // format undefined - NativeVertexFormat takes care of the declaration. static u8 *fakeVBuffer; // format undefined - NativeVertexFormat takes care of the declaration.
static u16 *fakeIBuffer; // These are just straightforward 16-bit indices. static u16 *fakeIBuffer; // These are just straightforward 16-bit indices.
#define MAXVBUFFERSIZE 65536 #define MAXVBUFFERSIZE 65536*128
#define MAXIBUFFERSIZE 65536*3 #define MAXIBUFFERSIZE 65536*4
const Collection collectionTypeLUT[8] = const Collection collectionTypeLUT[8] =
{ {
@ -79,7 +79,7 @@ void DestroyDeviceObjects();
bool Init() bool Init()
{ {
collection = C_NOTHING; collection = C_NOTHING;
fakeVBuffer = new u8[MAXVBUFFERSIZE * 64]; fakeVBuffer = new u8[MAXVBUFFERSIZE];
fakeIBuffer = new u16[MAXIBUFFERSIZE]; fakeIBuffer = new u16[MAXIBUFFERSIZE];
CreateDeviceObjects(); CreateDeviceObjects();
VertexManager::s_pCurBufferPointer = fakeVBuffer; VertexManager::s_pCurBufferPointer = fakeVBuffer;
@ -121,7 +121,7 @@ void AddIndices(int _primitive, int _numVertices)
int GetRemainingSize() int GetRemainingSize()
{ {
return 60000; return fakeVBuffer + MAXVBUFFERSIZE - VertexManager::s_pCurBufferPointer;
} }
void AddVertices(int _primitive, int _numVertices) void AddVertices(int _primitive, int _numVertices)
@ -136,15 +136,16 @@ void AddVertices(int _primitive, int _numVertices)
DVSTARTPROFILE(); DVSTARTPROFILE();
_assert_msg_(type != C_NOTHING, "type == C_NOTHING!!", "WTF"); _assert_msg_(type != C_NOTHING, "type == C_NOTHING!!", "WTF");
if (indexGen.GetNumVerts() > 1000) // TODO(ector): Raise?
Flush();
ADDSTAT(stats.thisFrame.numPrims, _numVertices); ADDSTAT(stats.thisFrame.numPrims, _numVertices);
if (collection != type) if (collection != type)
{ {
//We are NOT collecting the right type. //We are NOT collecting the right type.
Flush(); Flush();
// Copy the extra verts that we lost.
memcpy(s_pCurBufferPointer, fakeVBuffer, _numVertices * g_nativeVertexFmt->GetVertexStride());
collection = type; collection = type;
u16 *ptr = 0; u16 *ptr = 0;
if (type != C_POINTS) if (type != C_POINTS)
@ -156,7 +157,7 @@ void AddVertices(int _primitive, int _numVertices)
if (_numVertices >= MAXVBUFFERSIZE) if (_numVertices >= MAXVBUFFERSIZE)
MessageBox(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK); MessageBox(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK);
} }
else //We are collecting the right type, keep going else // We are collecting the right type, keep going
{ {
_assert_msg_(vbufferwrite != 0, "collecting: vbufferwrite == 0!","WTF"); _assert_msg_(vbufferwrite != 0, "collecting: vbufferwrite == 0!","WTF");
INCSTAT(stats.thisFrame.numPrimitiveJoins); INCSTAT(stats.thisFrame.numPrimitiveJoins);
@ -211,7 +212,8 @@ void Flush()
if (tentry) { if (tentry) {
// texture loaded fine, set dims for pixel shader // texture loaded fine, set dims for pixel shader
if (tentry->isNonPow2) { if (tentry->isNonPow2)
{
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, tentry->mode.wrap_s, tentry->mode.wrap_t); PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, tentry->mode.wrap_s, tentry->mode.wrap_t);
nonpow2tex |= 1 << i; nonpow2tex |= 1 << i;
if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i); if (tentry->mode.wrap_s > 0) nonpow2tex |= 1 << (8 + i);
@ -230,7 +232,6 @@ void Flush()
} }
PixelShaderManager::SetTexturesUsed(nonpow2tex); PixelShaderManager::SetTexturesUsed(nonpow2tex);
int numVertices = indexGen.GetNumVerts(); int numVertices = indexGen.GetNumVerts();
if (numVertices) if (numVertices)
{ {