DXGL r661 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r660‎ | r661 | r662 >
Date:01:31, 7 June 2016
Author:admin
Status:new
Tags:
Comment:
Fix a regression regarding Blt to primary surface by tracking front buffer state in texture object.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1442,7 +1442,7 @@
14431443 glDD7->internalx = glDD7->screenx = dwWidth;
14441444 glDD7->internaly = glDD7->screeny = dwHeight;
14451445 if (glDD7->renderer && glDD7->primary) glRenderer_DrawScreen(glDD7->renderer, glDD7->primary->texture,
1446 - glDD7->primary->texture->palette, 0);
 1446+ glDD7->primary->texture->palette, 0, NULL);
14471447 }
14481448
14491449
@@ -1952,7 +1952,7 @@
19531953 if(dwFlags & 0xFFFFFFFA) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19541954 if(dwFlags == 5) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
19551955 if(!lastsync) lastsync = true;
1956 - else if(primary) primary->RenderScreen(primary->texture,1);
 1956+ else if(primary) primary->RenderScreen(primary->texture,1,NULL);
19571957 TRACE_EXIT(23,DD_OK);
19581958 return DD_OK;
19591959 }
Index: ddraw/glDirectDrawSurface.cpp
@@ -833,7 +833,8 @@
834834 {
835835 TRACE_ENTER(3,14,this,14,lpDDSurfaceTargetOverride,9,dwFlags);
836836 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
837 - HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags);
 837+ glTexture *previous;
 838+ HRESULT ret = Flip2(lpDDSurfaceTargetOverride,dwFlags,&previous);
838839 if (ret != DD_OK) TRACE_RET(HRESULT, 23, ret);
839840 if(ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
840841 {
@@ -842,12 +843,12 @@
843844 swapinterval++;
844845 ddInterface->lastsync = false;
845846 }
846 - RenderScreen(texture,swapinterval);
 847+ RenderScreen(texture,swapinterval,previous);
847848 }
848849 TRACE_EXIT(23,ret);
849850 return ret;
850851 }
851 -HRESULT glDirectDrawSurface7::Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags)
 852+HRESULT glDirectDrawSurface7::Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags, glTexture **previous)
852853 {
853854 TRACE_ENTER(3,14,this,14,lpDDSurfaceTargetOverride,9,dwFlags);
854855 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
@@ -856,6 +857,7 @@
857858 if(!overlay && ((dwFlags & DDFLIP_ODD) || (dwFlags & DDFLIP_EVEN))) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
858859 DWORD i;
859860 glDirectDrawSurface7 *tmp;
 861+ if(previous) *previous = this->texture;
860862 if(dwFlags & DDFLIP_NOVSYNC) swapinterval=0;
861863 else
862864 {
@@ -883,8 +885,8 @@
884886 if(!success) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
885887 for(DWORD x = 0; x < i; x++)
886888 {
887 - if(x == i-1) {TRACE_RET(HRESULT,23,Flip2(NULL,dwFlags));}
888 - else Flip2(NULL,0);
 889+ if(x == i-1) {TRACE_RET(HRESULT,23,Flip2(NULL,dwFlags,NULL));}
 890+ else Flip2(NULL,0,NULL);
889891 }
890892 }
891893 if(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)
@@ -1188,10 +1190,10 @@
11891191 {
11901192 if (ddInterface->lastsync)
11911193 {
1192 - RenderScreen(texture, 1);
 1194+ RenderScreen(texture, 1, NULL);
11931195 ddInterface->lastsync = false;
11941196 }
1195 - else RenderScreen(texture, 0);
 1197+ else RenderScreen(texture, 0, NULL);
11961198 }
11971199 TRACE_EXIT(23,error);
11981200 return error;
@@ -1391,10 +1393,10 @@
13921394 {
13931395 if(ddInterface->lastsync)
13941396 {
1395 - RenderScreen(texture,1);
 1397+ RenderScreen(texture,1,NULL);
13961398 ddInterface->lastsync = false;
13971399 }
1398 - else RenderScreen(texture,0);
 1400+ else RenderScreen(texture,0,NULL);
13991401 }
14001402 TRACE_EXIT(23, DD_OK);
14011403 return DD_OK;
@@ -1424,10 +1426,10 @@
14251427 ERR(DDERR_GENERIC);
14261428 }
14271429
1428 -void glDirectDrawSurface7::RenderScreen(glTexture *texture, int vsync)
 1430+void glDirectDrawSurface7::RenderScreen(glTexture *texture, int vsync, glTexture *previous)
14291431 {
14301432 TRACE_ENTER(3,14,this,14,texture,14,vsync);
1431 - glRenderer_DrawScreen(ddInterface->renderer,texture, texture->palette, vsync);
 1433+ glRenderer_DrawScreen(ddInterface->renderer,texture, texture->palette, vsync, previous);
14321434 TRACE_EXIT(0,0);
14331435 }
14341436 // ddraw 2+ api
Index: ddraw/glDirectDrawSurface.h
@@ -112,12 +112,12 @@
113113 ULONG WINAPI ReleaseColor();
114114 //void SetFilter(int level, GLint mag, GLint min, glExtensions *ext, glUtil *util);
115115 void Restore2();
116 - HRESULT Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags);
 116+ HRESULT Flip2(LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, DWORD dwFlags, glTexture **previous);
117117 HRESULT AddAttachedSurface2(LPDIRECTDRAWSURFACE7 lpDDSAttachedSurface, IUnknown *iface);
118118 void SetTexture(glTexture *newtexture){ texture = newtexture; };
119119 glDirectDrawSurface7 *GetBackbuffer(){return backbuffer;};
120120 glDirectDrawSurface7 *GetZBuffer(){return zbuffer;};
121 - void RenderScreen(glTexture *texture, int vsync);
 121+ void RenderScreen(glTexture *texture, int vsync, glTexture *previous);
122122 // Special ddraw2->ddraw7 api
123123 HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
124124 HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
Index: ddraw/glRenderer.cpp
@@ -388,12 +388,13 @@
389389 * @param vsync
390390 * Vertical sync count
391391 */
392 -void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync)
 392+void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous)
393393 {
394394 EnterCriticalSection(&This->cs);
395395 This->inputs[0] = texture;
396396 This->inputs[1] = paltex;
397397 This->inputs[2] = (void*)vsync;
 398+ This->inputs[3] = previous;
398399 This->opcode = OP_DRAWSCREEN;
399400 SetEvent(This->start);
400401 WaitForSingleObject(This->busy,INFINITE);
@@ -940,7 +941,7 @@
941942 break;
942943 case OP_DRAWSCREEN:
943944 glRenderer__DrawScreen(This,(glTexture*)This->inputs[0],(glTexture*)This->inputs[1],
944 - (GLint)This->inputs[2],true);
 945+ (GLint)This->inputs[2],(glTexture*)This->inputs[3],true);
945946 break;
946947 case OP_INITD3D:
947948 glRenderer__InitD3D(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2]);
@@ -1534,7 +1535,7 @@
15351536 (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
15361537 ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
15371538 !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
1538 - glRenderer__DrawScreen(This,cmd->dest,cmd->dest->palette,0,false);
 1539+ glRenderer__DrawScreen(This,cmd->dest,cmd->dest->palette,0,NULL,false);
15391540 This->outputs[0] = DD_OK;
15401541 SetEvent(This->busy);
15411542 }
@@ -1653,11 +1654,13 @@
16541655 glUtil_SetFBO(This->util, NULL);
16551656 }
16561657
1657 -void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, BOOL setsync)
 1658+void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous, BOOL setsync)
16581659 {
16591660 int progtype;
1660 - RECT r,r2;
 1661+ RECT r, r2;
16611662 glUtil_BlendEnable(This->util, FALSE);
 1663+ if (previous) previous->levels[0].ddsd.ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
 1664+ texture->levels[0].ddsd.ddsCaps.dwCaps |= DDSCAPS_FRONTBUFFER;
16621665 if((texture->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
16631666 {
16641667 GetClientRect(This->hWnd,&r);
Index: ddraw/glRenderer.h
@@ -162,7 +162,7 @@
163163 void glRenderer_DownloadTexture(glRenderer *This, glTexture *texture, GLint level);
164164 HRESULT glRenderer_Blt(glRenderer *This, BltCommand *cmd);
165165 void glRenderer_MakeTexture(glRenderer *This, glTexture *texture);
166 -void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync);
 166+void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous);
167167 void glRenderer_DeleteTexture(glRenderer *This, glTexture *texture);
168168 void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y);
169169 void glRenderer_Flush(glRenderer *This);
@@ -190,7 +190,7 @@
191191 void glRenderer__DownloadTexture(glRenderer *This, glTexture *texture, GLint level);
192192 void glRenderer__Blt(glRenderer *This, BltCommand *cmd);
193193 void glRenderer__MakeTexture(glRenderer *This, glTexture *texture);
194 -void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, BOOL setsync);
 194+void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous, BOOL setsync);
195195 void glRenderer__DeleteTexture(glRenderer *This, glTexture *texture);
196196 void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype);
197197 void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype);