DXGL r116 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r115‎ | r116 | r117 >
Date:00:00, 8 March 2012
Author:admin
Status:new
Tags:
Comment:
Fix D3D object shutdown
Fix D3D memory leaks
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)
  • /ddraw/shadergen.h (modified) (history)
  • /ddraw/shaders.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -172,6 +172,9 @@
173173 }
174174 glDirect3DDevice7::~glDirect3DDevice7()
175175 {
 176+ for(int i = 0; i < lightsmax; i++)
 177+ if(lights[i]) delete lights[i];
 178+ delete lights;
176179 glD3D7->Release();
177180 glDDS7->Release();
178181 }
Index: ddraw/glDirectDraw.cpp
@@ -650,7 +650,6 @@
651651 if(riid == IID_IDirect3D7)
652652 {
653653 #ifdef _DEBUG
654 - this->AddRef();
655654 *ppvObj = new glDirect3D7(this);
656655 return DD_OK;
657656 #else
Index: ddraw/shadergen.cpp
@@ -101,6 +101,23 @@
102102 isbuiltin = true;
103103 }
104104
 105+void ClearShaders()
 106+{
 107+ for(int i = 0; i < shadercount; i++)
 108+ {
 109+ genshaders[i].id = 0;
 110+ ZeroMemory(genshaders[i].texids,8*sizeof(__int64));
 111+ if(genshaders[i].shader.prog) glDeleteProgram(genshaders[i].shader.prog);
 112+ if(genshaders[i].shader.fs) glDeleteShader(genshaders[i].shader.fs);
 113+ if(genshaders[i].shader.vs) glDeleteShader(genshaders[i].shader.vs);
 114+ if(genshaders[i].shader.fsrc) delete genshaders[i].shader.fsrc;
 115+ if(genshaders[i].shader.vsrc) delete genshaders[i].shader.vsrc;
 116+ ZeroMemory(&genshaders[i].shader,sizeof(_GENSHADER));
 117+ }
 118+ shadercount = 0;
 119+ genindex = 0;
 120+}
 121+
105122 void SetShader(__int64 id, TexState *texstate, bool builtin)
106123 {
107124 int shaderindex = -1;
Index: ddraw/shadergen.h
@@ -30,6 +30,7 @@
3131 __int64 TEX7;
3232 } TexState;
3333
 34+void ClearShaders();
3435 void SetShader(__int64 id, TexState *texstate, bool builtin);
3536 GLuint GetProgram();
3637 void ZeroShaderArray();
Index: ddraw/shaders.cpp
@@ -177,4 +177,5 @@
178178 shaders[i].fs = 0;
179179 }
180180 }
 181+ ClearShaders();
181182 }
\ No newline at end of file