From 8139bd833d087a2e019bbbd3de2a5192498107e0 Mon Sep 17 00:00:00 2001 From: Luke Usher Date: Mon, 15 Jan 2018 22:19:21 +0000 Subject: [PATCH] Silent Hill 2 no longer overflows the g_IVBTable --- src/CxbxKrnl/EmuD3D8.cpp | 5 ----- src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp | 2 +- src/CxbxKrnl/EmuD3D8/VertexBuffer.h | 12 +++++++----- 3 files changed, 8 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp mode change 100644 => 100755 src/CxbxKrnl/EmuD3D8/VertexBuffer.h diff --git a/src/CxbxKrnl/EmuD3D8.cpp b/src/CxbxKrnl/EmuD3D8.cpp index 600fe65ae..a4c04715b 100644 --- a/src/CxbxKrnl/EmuD3D8.cpp +++ b/src/CxbxKrnl/EmuD3D8.cpp @@ -4678,11 +4678,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_Begin) g_IVBPrimitiveType = PrimitiveType; - if(g_IVBTable == nullptr) - { - g_IVBTable = (struct XTL::_D3DIVB*)g_VMManager.Allocate(sizeof(XTL::_D3DIVB)*IVB_TABLE_SIZE); - } - g_IVBTblOffs = 0; g_IVBFVF = 0; diff --git a/src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp b/src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp old mode 100644 new mode 100755 index 43225c780..548475600 --- a/src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp +++ b/src/CxbxKrnl/EmuD3D8/VertexBuffer.cpp @@ -53,7 +53,7 @@ XTL::DWORD *XTL::g_pIVBVertexBuffer = nullptr; XTL::X_D3DPRIMITIVETYPE XTL::g_IVBPrimitiveType = XTL::X_D3DPT_INVALID; UINT XTL::g_IVBTblOffs = 0; -struct XTL::_D3DIVB *XTL::g_IVBTable = nullptr; +struct XTL::_D3DIVB XTL::g_IVBTable[IVB_TABLE_SIZE]; extern DWORD XTL::g_IVBFVF = 0; extern XTL::X_D3DVertexBuffer *g_pVertexBuffer = NULL; diff --git a/src/CxbxKrnl/EmuD3D8/VertexBuffer.h b/src/CxbxKrnl/EmuD3D8/VertexBuffer.h old mode 100644 new mode 100755 index 91d79dfbf..83422dd61 --- a/src/CxbxKrnl/EmuD3D8/VertexBuffer.h +++ b/src/CxbxKrnl/EmuD3D8/VertexBuffer.h @@ -130,12 +130,13 @@ extern DWORD *g_pIVBVertexBuffer; extern X_D3DPRIMITIVETYPE g_IVBPrimitiveType; extern DWORD g_IVBFVF; -#define IVB_TABLE_SIZE 1024 -#define IVB_BUFFER_SIZE sizeof(_D3DIVB)*1024 +#define IVB_TABLE_SIZE ONE_MB // This should be more than enough.. Tweak as necessary if it overflows +#define IVB_BUFFER_SIZE sizeof(_D3DIVB) * IVB_TABLE_SIZE + // TODO : Enlarge IVB_TABLE_SIZE and IVB_BUFFER_SIZE // TODO : Calculate IVB_BUFFER_SIZE using sizeof(DWORD) -extern struct _D3DIVB +struct _D3DIVB { XTL::D3DXVECTOR3 Position; // Position FLOAT Rhw; // Rhw @@ -147,8 +148,9 @@ extern struct _D3DIVB XTL::D3DXVECTOR2 TexCoord2; // TexCoord2 XTL::D3DXVECTOR2 TexCoord3; // TexCoord3 XTL::D3DXVECTOR2 TexCoord4; // TexCoord4 -} -*g_IVBTable; +}; + +extern _D3DIVB g_IVBTable[IVB_TABLE_SIZE]; extern UINT g_IVBTblOffs;