DXGL r370 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r369‎ | r370 | r371 >
Date:13:14, 11 May 2013
Author:admin
Status:new
Tags:
Comment:
Dynamically allocate shader cache buffer.
Remove unused parameter in glDirectDrawSurface7::glDirectDrawSurface7 constructor
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)
  • /ddraw/shadergen.cpp (modified) (history)
  • /ddraw/shadergen.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -831,7 +831,7 @@
832832 surfacecountmax += 1024;
833833 }
834834 HRESULT error;
835 - surfaces[surfacecount-1] = new glDirectDrawSurface7(this,lpDDSurfaceDesc2,lplpDDSurface,&error,false,NULL);
 835+ surfaces[surfacecount-1] = new glDirectDrawSurface7(this,lpDDSurfaceDesc2,&error,false,NULL);
836836 if(lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
837837 {
838838 primary = surfaces[surfacecount-1];
Index: ddraw/glDirectDrawSurface.cpp
@@ -37,9 +37,9 @@
3838
3939
4040 // DDRAW7 routines
41 -glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 *lplpDDSurface7, HRESULT *error, bool copysurface, glDirectDrawPalette *palettein)
 41+glDirectDrawSurface7::glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, bool copysurface, glDirectDrawPalette *palettein)
4242 {
43 - TRACE_ENTER(7,14,this,14,lpDD7,14,lpDDSurfaceDesc2,14,lplpDDSurface7,14,error,21,copysurface,14,palettein);
 43+ TRACE_ENTER(6,14,this,14,lpDD7,14,lpDDSurfaceDesc2,14,error,21,copysurface,14,palettein);
4444 hasstencil = false;
4545 dirty = 2;
4646 handle = 0;
@@ -335,14 +335,12 @@
336336 ddsdBack.dwBackBufferCount--;
337337 ddsdBack.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
338338 ddsdBack.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
339 - glDirectDrawSurface7 *tmp;
340 - backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,(LPDIRECTDRAWSURFACE7 *)&tmp,error,false,palette);
 339+ backbuffer = new glDirectDrawSurface7(ddInterface,&ddsdBack,error,false,palette);
341340 }
342341 else if (ddsd.dwFlags & DDSD_BACKBUFFERCOUNT){}
343342 else *error = DDERR_INVALIDPARAMS;
344343 }
345344 }
346 - TRACE_VAR("*lplpDDSurface7",14,*lplpDDSurface7);
347345 TRACE_VAR("*error",23,*error);
348346 TRACE_EXIT(-1,0);
349347 }
Index: ddraw/glDirectDrawSurface.h
@@ -39,7 +39,7 @@
4040 class glDirectDrawSurface7 : public IDirectDrawSurface7
4141 {
4242 public:
43 - glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 *lplpDDSurface7, HRESULT *error, bool copysurface, glDirectDrawPalette *palettein);
 43+ glDirectDrawSurface7(LPDIRECTDRAW7 lpDD7, LPDDSURFACEDESC2 lpDDSurfaceDesc2, HRESULT *error, bool copysurface, glDirectDrawPalette *palettein);
4444 virtual ~glDirectDrawSurface7();
4545 // ddraw 1+ api
4646 HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
Index: ddraw/shadergen.cpp
@@ -25,10 +25,11 @@
2626 #include "shadergen.h"
2727 #include "shaders.h"
2828
29 -GenShader genshaders[256];
 29+GenShader *genshaders = NULL;
3030 static __int64 current_shader = 0;
3131 static __int64 current_texid[8];
3232 static int shadercount = 0;
 33+static int maxshaders = 0;
3334 static int genindex = 0;
3435 static bool initialized = false;
3536 static bool isbuiltin = true;
@@ -103,6 +104,9 @@
104105 */
105106 void ZeroShaderArray()
106107 {
 108+ if(genshaders) free(genshaders);
 109+ maxshaders = 256;
 110+ genshaders = (GenShader*)malloc(256*sizeof(GenShader));
107111 ZeroMemory(genshaders,256*sizeof(GenShader));
108112 current_shader = 0;
109113 isbuiltin = true;
@@ -113,6 +117,7 @@
114118 */
115119 void ClearShaders()
116120 {
 121+ if(!genshaders) return;
117122 for(int i = 0; i < shadercount; i++)
118123 {
119124 genshaders[i].id = 0;
@@ -122,7 +127,7 @@
123128 if(genshaders[i].shader.vs) glDeleteShader(genshaders[i].shader.vs);
124129 if(genshaders[i].shader.fsrc) delete genshaders[i].shader.fsrc;
125130 if(genshaders[i].shader.vsrc) delete genshaders[i].shader.vsrc;
126 - ZeroMemory(&genshaders[i].shader,sizeof(_GENSHADER));
 131+ if(genshaders) free(genshaders);
127132 }
128133 current_genshader = -1;
129134 shadercount = 0;
Index: ddraw/shadergen.h
@@ -45,6 +45,6 @@
4646 GLuint GetProgram();
4747 void ZeroShaderArray();
4848 void CreateShader(int index, __int64 id, TEXTURESTAGE *texstate, int *texcoords);
49 -extern GenShader genshaders[256];
 49+extern GenShader *genshaders;
5050 extern int current_genshader;
5151 #endif
\ No newline at end of file