From ab1f4f99afce992dfad9cb00a8d9de644baa193d Mon Sep 17 00:00:00 2001 From: "ramapcsx2.code" Date: Sat, 25 Jan 2014 15:53:31 +0000 Subject: [PATCH] Small round of patches for various issues, #2. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5831 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GPURenderer.h | 2 +- plugins/GSdx/GS.cpp | 11 ++++++++--- plugins/GSdx/GSState.cpp | 12 ++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/GSdx/GPURenderer.h b/plugins/GSdx/GPURenderer.h index 5b51c68eac..43919a5a01 100644 --- a/plugins/GSdx/GPURenderer.h +++ b/plugins/GSdx/GPURenderer.h @@ -130,7 +130,7 @@ protected: } else // very bad! { - printf("GSdx: failed to allocate %d bytes for verticles. We will proceed to crash now.\n", sizeof(Vertex) * maxcount); + printf("GSdx: failed to allocate %d bytes for verticles.\n", sizeof(Vertex) * maxcount); } m_vertices = vertices; diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index c22cfcb806..c81e666a81 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1212,7 +1212,9 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow if(1) { - GSLocalMemory mem; + GSLocalMemory * pMem = new GSLocalMemory(); + GSLocalMemory& mem(*pMem); + static struct {int psm; const char* name;} s_format[] = { @@ -1360,13 +1362,15 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow } _aligned_free(ptr); + delete pMem; } // if(0) { - GSLocalMemory mem; + GSLocalMemory * pMem2 = new GSLocalMemory(); + GSLocalMemory& mem2(*pMem2); uint8* ptr = (uint8*)_aligned_malloc(1024 * 1024 * 4, 32); @@ -1397,7 +1401,8 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow int x = 0; int y = 0; - (mem.*wi)(x, y, ptr, trlen, BITBLTBUF, TRXPOS, TRXREG); + (mem2.*wi)(x, y, ptr, trlen, BITBLTBUF, TRXPOS, TRXREG); + delete pMem2; } // diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index b506d6fc8c..7e83cc2817 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -2300,19 +2300,27 @@ void GSState::GrowVertexBuffer() GSVertex* vertex = (GSVertex*)_aligned_malloc(sizeof(GSVertex) * maxcount, 32); uint32* index = (uint32*)_aligned_malloc(sizeof(uint32) * maxcount * 3, 32); // worst case is slightly less than vertex number * 3 - if(m_vertex.buff != NULL) + if (m_vertex.buff != NULL && vertex != NULL) { memcpy(vertex, m_vertex.buff, sizeof(GSVertex) * m_vertex.tail); _aligned_free(m_vertex.buff); } + else // very bad! + { + printf("GSdx: failed to allocate %d bytes for verticles.\n", sizeof(GSVertex) * maxcount); + } - if(m_index.buff != NULL) + if (m_index.buff != NULL && index != NULL) { memcpy(index, m_index.buff, sizeof(uint32) * m_index.tail); _aligned_free(m_index.buff); } + else // very bad! + { + printf("GSdx: failed to allocate %d bytes for indices.\n", sizeof(uint32) * maxcount * 3); + } m_vertex.buff = vertex; m_vertex.maxcount = maxcount - 3; // -3 to have some space at the end of the buffer before DrawingKick can grow it