Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -632,6 +632,8 @@ |
633 | 633 | zbuffer_iface = iface;
|
634 | 634 | if (!zbuffer->attachcount) zbuffer->attachparent = this;
|
635 | 635 | zbuffer->attachcount++;
|
| 636 | + if (zbuffer && dxglcfg.primaryscale && (this->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
| 637 | + glRenderer_MakeTexturePrimary(ddInterface->renderer, zbuffer->texture, this->texture, TRUE);
|
636 | 638 | TRACE_EXIT(23,DD_OK);
|
637 | 639 | return DD_OK;
|
638 | 640 | }
|
— | — | @@ -795,6 +797,8 @@ |
796 | 798 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
797 | 799 | if(lpDDSAttachedSurface == (LPDIRECTDRAWSURFACE7)zbuffer)
|
798 | 800 | {
|
| 801 | + if (zbuffer && dxglcfg.primaryscale && (this->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
| 802 | + glRenderer_MakeTexturePrimary(ddInterface->renderer, zbuffer->texture, NULL, FALSE);
|
799 | 803 | if (zbuffer->attachparent == this) zbuffer->attachparent = NULL;
|
800 | 804 | if (zbuffer->attachcount) zbuffer->attachcount--;
|
801 | 805 | if (!zbuffer->attachcount) zbuffer->attachparent = NULL;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -842,8 +842,32 @@ |
843 | 843 | }
|
844 | 844 |
|
845 | 845 | /**
|
| 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 | +/**
|
846 | 869 | * 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).
|
848 | 872 | * @param This
|
849 | 873 | * Pointer to glRenderer object
|
850 | 874 | */
|
— | — | @@ -994,6 +1018,9 @@ |
995 | 1019 | glRenderer__SetTextureColorKey(This, (glTexture*)This->inputs[0], (DWORD)This->inputs[1],
|
996 | 1020 | (LPDDCOLORKEY)This->inputs[2], (GLint)This->inputs[3]);
|
997 | 1021 | break;
|
| 1022 | + case OP_MAKETEXTUREPRIMARY:
|
| 1023 | + glRenderer__MakeTexturePrimary(This, (glTexture*)This->inputs[0], (glTexture*)This->inputs[1], (DWORD)This->inputs[2]);
|
| 1024 | + break;
|
998 | 1025 | case OP_DXGLBREAK:
|
999 | 1026 | glRenderer__DXGLBreak(This);
|
1000 | 1027 | break;
|
— | — | @@ -2941,6 +2968,17 @@ |
2942 | 2969 | SetEvent(This->busy);
|
2943 | 2970 | }
|
2944 | 2971 |
|
| 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 | +
|
2945 | 2983 | void glRenderer__DXGLBreak(glRenderer *This)
|
2946 | 2984 | {
|
2947 | 2985 | if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
|
Index: ddraw/glRenderer.h |
— | — | @@ -105,6 +105,7 @@ |
106 | 106 | #define OP_SETVIEWPORT 22
|
107 | 107 | #define OP_DXGLBREAK 23
|
108 | 108 | #define OP_SETTEXTURECOLORKEY 24
|
| 109 | +#define OP_MAKETEXTUREPRIMARY 25
|
109 | 110 |
|
110 | 111 | extern const DWORD renderstate_default[153];
|
111 | 112 | extern const TEXTURESTAGE texstagedefault0;
|
— | — | @@ -182,6 +183,7 @@ |
183 | 184 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
184 | 185 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
185 | 186 | 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);
|
186 | 188 | void glRenderer_DXGLBreak(glRenderer *This);
|
187 | 189 | // In-thread APIs
|
188 | 190 | DWORD glRenderer__Entry(glRenderer *This);
|
— | — | @@ -217,6 +219,7 @@ |
218 | 220 | void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
219 | 221 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
220 | 222 | 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);
|
221 | 224 | void glRenderer__SetDepthComp(glRenderer *This);
|
222 | 225 | void glRenderer__DXGLBreak(glRenderer *This);
|
223 | 226 |
|
Index: ddraw/glTexture.cpp |
— | — | @@ -654,6 +654,34 @@ |
655 | 655 | if (repairfail) return FALSE;
|
656 | 656 | return TRUE;
|
657 | 657 | }
|
| 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 | +
|
658 | 686 | void glTexture__FinishCreate(glTexture *This)
|
659 | 687 | {
|
660 | 688 | int texformat = -1;
|
Index: ddraw/glTexture.h |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | void glTexture__Upload(glTexture *This, GLint level);
|
51 | 51 | void glTexture__Upload2(glTexture *This, int level, int width, int height, BOOL checkerror, BOOL dorealloc, glUtil *util);
|
52 | 52 | BOOL glTexture__Repair(glTexture *This, BOOL preserve);
|
| 53 | +void glTexture__SetPrimaryScale(glTexture *This, GLint bigwidth, GLint bigheight, BOOL scaling);
|
53 | 54 | void glTexture__FinishCreate(glTexture *This);
|
54 | 55 | void glTexture__Destroy(glTexture *This);
|
55 | 56 |
|
Index: ddraw/struct.h |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | BufferObject *pboUnpack;
|
283 | 283 | DWORD dirty;
|
284 | 284 | // dirty bits:
|
285 | | - // 1 - Surface was locked
|
| 285 | + // 1 - Surface buffer was locked and may have been written to by CPU
|
286 | 286 | // 2 - Texture was written to by GPU
|
287 | 287 | DWORD locked;
|
288 | 288 | FBO fbo;
|