DXGL r671 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r670‎ | r671 | r672 >
Date:21:47, 23 July 2016
Author:admin
Status:new
Tags:
Comment:
Scale z-buffer attachment when primary scaling is enabled.
Modified paths:
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)
  • /ddraw/glTexture.h (modified) (history)
  • /ddraw/struct.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawSurface.cpp
@@ -632,6 +632,8 @@
633633 zbuffer_iface = iface;
634634 if (!zbuffer->attachcount) zbuffer->attachparent = this;
635635 zbuffer->attachcount++;
 636+ if (zbuffer && dxglcfg.primaryscale && (this->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
 637+ glRenderer_MakeTexturePrimary(ddInterface->renderer, zbuffer->texture, this->texture, TRUE);
636638 TRACE_EXIT(23,DD_OK);
637639 return DD_OK;
638640 }
@@ -795,6 +797,8 @@
796798 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
797799 if(lpDDSAttachedSurface == (LPDIRECTDRAWSURFACE7)zbuffer)
798800 {
 801+ if (zbuffer && dxglcfg.primaryscale && (this->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
 802+ glRenderer_MakeTexturePrimary(ddInterface->renderer, zbuffer->texture, NULL, FALSE);
799803 if (zbuffer->attachparent == this) zbuffer->attachparent = NULL;
800804 if (zbuffer->attachcount) zbuffer->attachcount--;
801805 if (!zbuffer->attachcount) zbuffer->attachparent = NULL;
Index: ddraw/glRenderer.cpp
@@ -842,8 +842,32 @@
843843 }
844844
845845 /**
 846+* Sets whether a texure has primary scaling
 847+* @param This
 848+* Pointer to glRenderer object
 849+* @param texture
 850+* Texture to set primary scaling
 851+* @param parent
 852+* Parent texture this one is attached to, needed only if primary is TRUE
 853+* @param primary
 854+* TRUE if texture should have primary scaling, FALSE to remove scaling
 855+*/
 856+void glRenderer_MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary)
 857+{
 858+ EnterCriticalSection(&This->cs);
 859+ This->inputs[0] = texture;
 860+ This->inputs[1] = parent;
 861+ This->inputs[2] = (void*)primary;
 862+ This->opcode = OP_MAKETEXTUREPRIMARY;
 863+ SetEvent(This->start);
 864+ WaitForSingleObject(This->busy, INFINITE);
 865+ LeaveCriticalSection(&This->cs);
 866+}
 867+
 868+/**
846869 * Generates a glFrameTerminatorGREMEDY command in OpenGL if the
847 - * glFrameTerminatorGREMEDY command is available (i.e. running under gDebugger).
 870+ * glFrameTerminatorGREMEDY command is available
 871+ * (i.e. running under gDebugger or CodeXL).
848872 * @param This
849873 * Pointer to glRenderer object
850874 */
@@ -994,6 +1018,9 @@
9951019 glRenderer__SetTextureColorKey(This, (glTexture*)This->inputs[0], (DWORD)This->inputs[1],
9961020 (LPDDCOLORKEY)This->inputs[2], (GLint)This->inputs[3]);
9971021 break;
 1022+ case OP_MAKETEXTUREPRIMARY:
 1023+ glRenderer__MakeTexturePrimary(This, (glTexture*)This->inputs[0], (glTexture*)This->inputs[1], (DWORD)This->inputs[2]);
 1024+ break;
9981025 case OP_DXGLBREAK:
9991026 glRenderer__DXGLBreak(This);
10001027 break;
@@ -2941,6 +2968,17 @@
29422969 SetEvent(This->busy);
29432970 }
29442971
 2972+void glRenderer__MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary)
 2973+{
 2974+ if (primary)
 2975+ {
 2976+ if (!parent) return;
 2977+ glTexture__SetPrimaryScale(texture, parent->bigwidth, parent->bigheight, TRUE);
 2978+ }
 2979+ else glTexture__SetPrimaryScale(texture, 0, 0, FALSE);
 2980+ SetEvent(This->busy);
 2981+}
 2982+
29452983 void glRenderer__DXGLBreak(glRenderer *This)
29462984 {
29472985 if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
Index: ddraw/glRenderer.h
@@ -105,6 +105,7 @@
106106 #define OP_SETVIEWPORT 22
107107 #define OP_DXGLBREAK 23
108108 #define OP_SETTEXTURECOLORKEY 24
 109+#define OP_MAKETEXTUREPRIMARY 25
109110
110111 extern const DWORD renderstate_default[153];
111112 extern const TEXTURESTAGE texstagedefault0;
@@ -182,6 +183,7 @@
183184 void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
184185 void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
185186 void glRenderer_SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
 187+void glRenderer_MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
186188 void glRenderer_DXGLBreak(glRenderer *This);
187189 // In-thread APIs
188190 DWORD glRenderer__Entry(glRenderer *This);
@@ -217,6 +219,7 @@
218220 void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
219221 void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
220222 void glRenderer__SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
 223+void glRenderer__MakeTexturePrimary(glRenderer *This, glTexture *texture, glTexture *parent, BOOL primary);
221224 void glRenderer__SetDepthComp(glRenderer *This);
222225 void glRenderer__DXGLBreak(glRenderer *This);
223226
Index: ddraw/glTexture.cpp
@@ -654,6 +654,34 @@
655655 if (repairfail) return FALSE;
656656 return TRUE;
657657 }
 658+
 659+void glTexture__SetPrimaryScale(glTexture *This, GLint bigwidth, GLint bigheight, BOOL scaling)
 660+{
 661+ if (This->miplevel > 1) return; // Function is not for mipmapped texture, primary and attachment only
 662+ if (This->levels[0].dirty & 2) glTexture__Download(This, 0);
 663+ if (This->levels[0].bigbuffer)
 664+ {
 665+ free(This->levels[0].bigbuffer);
 666+ This->levels[0].bigbuffer = NULL;
 667+ }
 668+ if (scaling)
 669+ {
 670+
 671+ This->bigwidth = bigwidth;
 672+ This->bigheight = bigheight;
 673+ This->levels[0].bigbuffer = (char *)malloc(NextMultipleOf4((This->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount *
 674+ This->bigwidth) / 8) * This->bigheight);
 675+ glTexture__Upload2(This, 0, bigwidth, bigheight, FALSE, TRUE, This->renderer->util);
 676+ }
 677+ else
 678+ {
 679+ This->bigwidth = This->levels[0].ddsd.dwWidth;
 680+ This->bigheight = This->levels[0].ddsd.dwHeight;
 681+ glTexture__Upload2(This, 0, This->levels[0].ddsd.dwWidth, This->levels[0].ddsd.dwHeight,
 682+ FALSE, TRUE, This->renderer->util);
 683+ }
 684+}
 685+
658686 void glTexture__FinishCreate(glTexture *This)
659687 {
660688 int texformat = -1;
Index: ddraw/glTexture.h
@@ -49,6 +49,7 @@
5050 void glTexture__Upload(glTexture *This, GLint level);
5151 void glTexture__Upload2(glTexture *This, int level, int width, int height, BOOL checkerror, BOOL dorealloc, glUtil *util);
5252 BOOL glTexture__Repair(glTexture *This, BOOL preserve);
 53+void glTexture__SetPrimaryScale(glTexture *This, GLint bigwidth, GLint bigheight, BOOL scaling);
5354 void glTexture__FinishCreate(glTexture *This);
5455 void glTexture__Destroy(glTexture *This);
5556
Index: ddraw/struct.h
@@ -281,7 +281,7 @@
282282 BufferObject *pboUnpack;
283283 DWORD dirty;
284284 // dirty bits:
285 - // 1 - Surface was locked
 285+ // 1 - Surface buffer was locked and may have been written to by CPU
286286 // 2 - Texture was written to by GPU
287287 DWORD locked;
288288 FBO fbo;