D3D: Fix bugs in the shader cache, fixes crashes on x64. added some debugging stuff (only active in debug builds). assorted code cleanup.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4145 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-09-01 19:48:45 +00:00
parent b15320bc02
commit 2599659022
12 changed files with 151 additions and 127 deletions

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "FileUtil.h"
#include "D3DBase.h"
@ -81,6 +82,8 @@ bool Init()
collection = C_NOTHING;
fakeVBuffer = new u8[MAXVBUFFERSIZE];
fakeIBuffer = new u16[MAXIBUFFERSIZE];
memset(fakeVBuffer, 0, MAXVBUFFERSIZE);
memset(fakeIBuffer, 0, MAXIBUFFERSIZE * 2);
CreateDeviceObjects();
VertexManager::s_pCurBufferPointer = fakeVBuffer;
return true;
@ -143,9 +146,6 @@ void AddVertices(int _primitive, int _numVertices)
//We are NOT collecting the right type.
Flush();
// Copy the extra verts that we lost.
memcpy(s_pCurBufferPointer, fakeVBuffer, _numVertices * g_nativeVertexFmt->GetVertexStride());
collection = type;
u16 *ptr = 0;
if (type != C_POINTS)
@ -247,14 +247,23 @@ void Flush()
if (collection != C_POINTS)
{
int numPrimitives = indexGen.GetNumPrims();
D3D::dev->DrawIndexedPrimitiveUP(pts[(int)collection],
0,
numVertices,
numPrimitives,
fakeIBuffer,
D3DFMT_INDEX16,
fakeVBuffer,
stride);
if (FAILED(D3D::dev->DrawIndexedPrimitiveUP(
pts[(int)collection],
0,
numVertices,
numPrimitives,
fakeIBuffer,
D3DFMT_INDEX16,
fakeVBuffer,
stride))) {
#ifdef _DEBUG
std::string error_shaders;
error_shaders.append(VertexShaderCache::GetCurrentShaderCode());
error_shaders.append(PixelShaderCache::GetCurrentShaderCode());
File::WriteStringToFile(true, error_shaders, "bad_shader_combo.txt");
PanicAlert("DrawIndexedPrimitiveUP failed. Shaders written to shaders.txt.");
#endif
}
}
else
{