DXGL r173 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r172‎ | r173 | r174 >
Date:00:11, 23 June 2012
Author:admin
Status:new
Tags:
Comment:
Fix race conditions
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -675,7 +675,8 @@
676676 break;
677677 case OP_CREATE:
678678 outputs[0] = (void*)_MakeTexture((GLint)inputs[0],(GLint)inputs[1],(GLint)inputs[2],(GLint)inputs[3],
679 - (DWORD)inputs[4],(DWORD)inputs[5],(GLint)inputs[6],(GLint)inputs[7],(GLint)inputs[8],true);
 679+ (DWORD)inputs[4],(DWORD)inputs[5],(GLint)inputs[6],(GLint)inputs[7],(GLint)inputs[8]);
 680+ SetEvent(busy);
680681 break;
681682 case OP_UPLOAD:
682683 _UploadTexture((char*)inputs[0],(char*)inputs[1],(GLuint)inputs[2],(int)inputs[3],
@@ -693,7 +694,7 @@
694695 _DeleteTexture((GLuint)inputs[0]);
695696 break;
696697 case OP_BLT:
697 - outputs[0] = (void*)_Blt((LPRECT)inputs[0],(glDirectDrawSurface7*)inputs[1],(glDirectDrawSurface7*)inputs[2],
 698+ _Blt((LPRECT)inputs[0],(glDirectDrawSurface7*)inputs[1],(glDirectDrawSurface7*)inputs[2],
698699 (LPRECT)inputs[3],(DWORD)inputs[4],(LPDDBLTFX)inputs[5]);
699700 break;
700701 case OP_DRAWSCREEN:
@@ -830,7 +831,7 @@
831832 return TRUE;
832833 }
833834
834 -HRESULT glRenderer::_Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
 835+void glRenderer::_Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
835836 glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
836837 {
837838 LONG sizes[6];
@@ -974,11 +975,11 @@
975976 (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
976977 ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
977978 !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))_DrawScreen(dest->texture,dest->paltex,dest,dest,false);
 979+ outputs[0] = DD_OK;
978980 SetEvent(busy);
979 - return DD_OK;
980981 }
981982
982 -GLuint glRenderer::_MakeTexture(GLint min, GLint mag, GLint wraps, GLint wrapt, DWORD width, DWORD height, GLint texformat1, GLint texformat2, GLint texformat3, bool setsync)
 983+GLuint glRenderer::_MakeTexture(GLint min, GLint mag, GLint wraps, GLint wrapt, DWORD width, DWORD height, GLint texformat1, GLint texformat2, GLint texformat3)
983984 {
984985 GLuint texture;
985986 glGenTextures(1,&texture);
@@ -988,7 +989,6 @@
989990 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,(GLfloat)wraps);
990991 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,(GLfloat)wrapt);
991992 glTexImage2D(GL_TEXTURE_2D,0,texformat3,width,height,0,texformat1,texformat2,NULL);
992 - if(setsync) SetEvent(busy);
993993 return texture;
994994 }
995995
@@ -998,7 +998,7 @@
999999 SetActiveTexture(0);
10001000 if(!backbuffer)
10011001 {
1002 - backbuffer = _MakeTexture(GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,x,y,GL_BGRA,GL_UNSIGNED_BYTE,GL_RGBA8,false);
 1002+ backbuffer = _MakeTexture(GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,x,y,GL_BGRA,GL_UNSIGNED_BYTE,GL_RGBA8);
10031003 backx = x;
10041004 backy = y;
10051005 }
Index: ddraw/glRenderer.h
@@ -105,9 +105,9 @@
106106 BOOL _InitGL(int width, int height, int bpp, int fullscreen, HWND hWnd, glDirectDraw7 *glDD7);
107107 void _UploadTexture(char *buffer, char *bigbuffer, GLuint texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int texformat, int texformat2, int texformat3);
108108 void _DownloadTexture(char *buffer, char *bigbuffer, GLuint texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int texformat, int texformat2);
109 - HRESULT _Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
 109+ void _Blt(LPRECT lpDestRect, glDirectDrawSurface7 *src,
110110 glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
111 - GLuint _MakeTexture(GLint min, GLint mag, GLint wraps, GLint wrapt, DWORD width, DWORD height, GLint texformat1, GLint texformat2, GLint texformat3, bool setsync);
 111+ GLuint _MakeTexture(GLint min, GLint mag, GLint wraps, GLint wrapt, DWORD width, DWORD height, GLint texformat1, GLint texformat2, GLint texformat3);
112112 void _DrawScreen(GLuint texture, GLuint paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, bool setsync);
113113 void _DeleteTexture(GLuint texture);
114114 void _DrawBackbuffer(GLuint *texture, int x, int y);