Index: cfgmgr/cfgmgr.c |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2018 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 | // Portions copyright (C) 2018 Syahmi Azhar
|
5 | 5 |
|
6 | 6 | // This library is free software; you can redistribute it and/or
|
— | — | @@ -645,6 +645,7 @@ |
646 | 646 | cfg->aspect3d = ReadDWORD(hKey,cfg->aspect3d,&cfgmask->aspect3d,_T("AdjustAspectRatio"));
|
647 | 647 | cfg->LowColorRendering = ReadDWORD(hKey, cfg->LowColorRendering, &cfgmask->LowColorRendering, _T("LowColorRendering"));
|
648 | 648 | cfg->EnableDithering = ReadDWORD(hKey, cfg->EnableDithering, &cfgmask->EnableDithering, _T("EnableDithering"));
|
| 649 | + cfg->LimitTextureFormats = ReadDWORD(hKey, cfg->LimitTextureFormats, &cfgmask->LimitTextureFormats, _T("LimitTextureFormats"));
|
649 | 650 | cfg->primaryscale = ReadDWORD(hKey,cfg->primaryscale,&cfgmask->primaryscale,_T("AdjustPrimaryResolution"));
|
650 | 651 | cfg->primaryscalex = ReadFloat(hKey,cfg->primaryscalex,&cfgmask->primaryscalex,_T("PrimaryScaleX"));
|
651 | 652 | cfg->primaryscaley = ReadFloat(hKey,cfg->primaryscaley,&cfgmask->primaryscaley,_T("PrimaryScaleY"));
|
— | — | @@ -816,6 +817,7 @@ |
817 | 818 | WriteDWORD(hKey,cfg->aspect3d,cfgmask->aspect3d,_T("AdjustAspectRatio"));
|
818 | 819 | WriteDWORD(hKey, cfg->LowColorRendering, cfgmask->LowColorRendering, _T("LowColorRendering"));
|
819 | 820 | WriteDWORD(hKey, cfg->EnableDithering, cfgmask->EnableDithering, _T("EnableDithering"));
|
| 821 | + WriteDWORD(hKey, cfg->LimitTextureFormats, cfgmask->LimitTextureFormats, _T("LimitTextureFormats"));
|
820 | 822 | WriteDWORD(hKey,cfg->primaryscale,cfgmask->primaryscale,_T("AdjustPrimaryResolution"));
|
821 | 823 | WriteFloat(hKey,cfg->primaryscalex,cfgmask->primaryscalex,_T("PrimaryScaleX"));
|
822 | 824 | WriteFloat(hKey,cfg->primaryscaley,cfgmask->primaryscaley,_T("PrimaryScaleY"));
|
— | — | @@ -977,6 +979,7 @@ |
978 | 980 | cfg->WindowWidth = 640;
|
979 | 981 | cfg->WindowHeight = 480;
|
980 | 982 | cfg->HackPaletteDelay = 30;
|
| 983 | + cfg->LimitTextureFormats = TRUE;
|
981 | 984 | if (!cfg->Windows8Detected)
|
982 | 985 | {
|
983 | 986 | OSVERSIONINFO osver;
|
— | — | @@ -1129,6 +1132,7 @@ |
1130 | 1133 | if (!_stricmp(name, "D3DAspect")) cfg->aspect3d = INIIntValue(value);
|
1131 | 1134 | if (!_stricmp(name, "LowColorRendering")) cfg->LowColorRendering = INIIntValue(value);
|
1132 | 1135 | if (!_stricmp(name, "EnableDithering")) cfg->EnableDithering = INIIntValue(value);
|
| 1136 | + if (!_stricmp(name, "LimitTextureFormats")) cfg->LimitTextureFormats = INIIntValue(value);
|
1133 | 1137 | }
|
1134 | 1138 | if (!_stricmp(section, "advanced"))
|
1135 | 1139 | {
|
— | — | @@ -1548,6 +1552,7 @@ |
1549 | 1553 | INIWriteInt(file, "D3DAspect", cfg->aspect3d, mask->aspect3d, INISECTION_D3D);
|
1550 | 1554 | INIWriteInt(file, "LowColorRendering", cfg->LowColorRendering, mask->LowColorRendering, INISECTION_D3D);
|
1551 | 1555 | INIWriteInt(file, "EnableDithering", cfg->EnableDithering, mask->EnableDithering, INISECTION_D3D);
|
| 1556 | + INIWriteBool(file, "LimitTextureFormats", cfg->LimitTextureFormats, mask->LimitTextureFormats, INISECTION_D3D);
|
1552 | 1557 | // [advanced]
|
1553 | 1558 | INIWriteInt(file, "TextureFormat", cfg->TextureFormat, mask->TextureFormat, INISECTION_ADVANCED);
|
1554 | 1559 | INIWriteInt(file, "TexUpload", cfg->TexUpload, mask->TexUpload, INISECTION_ADVANCED);
|
Index: cfgmgr/cfgmgr.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2018 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 | // Portions copyright (C) 2018 Syahmi Azhar
|
5 | 5 |
|
6 | 6 | // This library is free software; you can redistribute it and/or
|
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | DWORD aspect3d;
|
69 | 69 | DWORD LowColorRendering;
|
70 | 70 | DWORD EnableDithering;
|
| 71 | + BOOL LimitTextureFormats;
|
71 | 72 | // [advanced]
|
72 | 73 | DWORD vsync;
|
73 | 74 | DWORD TextureFormat;
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -1016,7 +1016,7 @@ |
1017 | 1017 | DDPIXELFORMAT fmt;
|
1018 | 1018 | for(int i = 0; i < numtexformats; i++)
|
1019 | 1019 | {
|
1020 | | - if (i == 7) continue;
|
| 1020 | + if (i == 11) continue;
|
1021 | 1021 | if(::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
|
1022 | 1022 | //FIXME: Remove these line after implementing palette textures
|
1023 | 1023 | if(::texformats[i].dwFlags & DDPF_PALETTEINDEXED1) continue;
|
— | — | @@ -1030,6 +1030,35 @@ |
1031 | 1031 | TRACE_EXIT(23,D3D_OK);
|
1032 | 1032 | return D3D_OK;
|
1033 | 1033 | }
|
| 1034 | +
|
| 1035 | +HRESULT WINAPI glDirect3DDevice7::EnumTextureFormats2(LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc, LPVOID lpArg)
|
| 1036 | +{
|
| 1037 | + TRACE_ENTER(3, 14, this, 14, lpd3dEnumTextureProc, 14, lpArg);
|
| 1038 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 1039 | + HRESULT result;
|
| 1040 | + DDSURFACEDESC ddsd;
|
| 1041 | + ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
|
| 1042 | + ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| 1043 | + ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT;
|
| 1044 | + ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
| 1045 | + for (int i = 0; i < numtexformats; i++)
|
| 1046 | + {
|
| 1047 | + if (i == 11) continue;
|
| 1048 | + if (::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
|
| 1049 | + if (::texformats[i].dwFlags & DDPF_FOURCC) continue;
|
| 1050 | + //FIXME: Remove these line after implementing palette textures
|
| 1051 | + if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED1) continue;
|
| 1052 | + if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED2) continue;
|
| 1053 | + if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED4) continue;
|
| 1054 | + if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
|
| 1055 | + memcpy(&ddsd.ddpfPixelFormat, &::texformats[i], sizeof(DDPIXELFORMAT));
|
| 1056 | + result = lpd3dEnumTextureProc(&ddsd, lpArg);
|
| 1057 | + if (result != D3DENUMRET_OK) TRACE_RET(HRESULT, 23, D3D_OK);
|
| 1058 | + }
|
| 1059 | + TRACE_EXIT(23, D3D_OK);
|
| 1060 | + return D3D_OK;
|
| 1061 | +}
|
| 1062 | +
|
1034 | 1063 | HRESULT WINAPI glDirect3DDevice7::GetCaps(LPD3DDEVICEDESC7 lpD3DDevDesc)
|
1035 | 1064 | {
|
1036 | 1065 | TRACE_ENTER(2,14,this,14,lpD3DDevDesc);
|
— | — | @@ -3325,30 +3354,11 @@ |
3326 | 3355 | TRACE_RET(HRESULT,23,glD3DDev7->EndScene());
|
3327 | 3356 | }
|
3328 | 3357 |
|
3329 | | -HRESULT WINAPI EnumTex2(LPDDPIXELFORMAT ddpf, LPVOID lpUserArg)
|
3330 | | -{
|
3331 | | - if(ddpf->dwFlags & DDPF_LUMINANCE) return D3DENUMRET_OK;
|
3332 | | - if(ddpf->dwFlags & DDPF_ALPHA) return D3DENUMRET_OK;
|
3333 | | - int *args = (int*)lpUserArg;
|
3334 | | - LPD3DENUMTEXTUREFORMATSCALLBACK callback = (LPD3DENUMTEXTUREFORMATSCALLBACK)args[0];
|
3335 | | - DDSURFACEDESC ddsd;
|
3336 | | - ZeroMemory(&ddsd,sizeof(DDSURFACEDESC));
|
3337 | | - ddsd.dwSize = sizeof(DDSURFACEDESC);
|
3338 | | - ddsd.dwFlags = DDSD_CAPS|DDSD_PIXELFORMAT;
|
3339 | | - ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
|
3340 | | - ddsd.ddpfPixelFormat = *ddpf;
|
3341 | | - HRESULT ret = callback(&ddsd,(LPVOID)args[1]);
|
3342 | | - return ret;
|
3343 | | -}
|
3344 | | -
|
3345 | 3358 | HRESULT WINAPI glDirect3DDevice2::EnumTextureFormats(LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc, LPVOID lpArg)
|
3346 | 3359 | {
|
3347 | 3360 | TRACE_ENTER(3,14,this,14,lpd3dEnumTextureProc,14,lpArg);
|
3348 | 3361 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
3349 | | - LPVOID context[2];
|
3350 | | - context[0] = (LPVOID)lpd3dEnumTextureProc;
|
3351 | | - context[1] = lpArg;
|
3352 | | - TRACE_RET(HRESULT,23,glD3DDev7->EnumTextureFormats(EnumTex2,&context));
|
| 3362 | + TRACE_RET(HRESULT, 23, glD3DDev7->EnumTextureFormats2(lpd3dEnumTextureProc, lpArg));
|
3353 | 3363 | }
|
3354 | 3364 |
|
3355 | 3365 | HRESULT WINAPI glDirect3DDevice2::GetCaps(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc)
|
— | — | @@ -3618,10 +3628,7 @@ |
3619 | 3629 | {
|
3620 | 3630 | TRACE_ENTER(3,14,this,14,lpd3dEnumTextureProc,14,lpArg);
|
3621 | 3631 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
3622 | | - LPVOID context[2];
|
3623 | | - context[0] = (LPVOID)lpd3dEnumTextureProc;
|
3624 | | - context[1] = lpArg;
|
3625 | | - TRACE_RET(HRESULT,23,glD3DDev7->EnumTextureFormats(EnumTex2,&context));
|
| 3632 | + TRACE_RET(HRESULT, 23, glD3DDev7->EnumTextureFormats2(lpd3dEnumTextureProc, lpArg));
|
3626 | 3633 | }
|
3627 | 3634 | HRESULT WINAPI glDirect3DDevice1::Execute(LPDIRECT3DEXECUTEBUFFER lpDirect3DExecuteBuffer, LPDIRECT3DVIEWPORT lpDirect3DViewport, DWORD dwFlags)
|
3628 | 3635 | {
|
Index: ddraw/glDirect3DDevice.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2017 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -67,6 +67,7 @@ |
68 | 68 | HRESULT WINAPI EndScene();
|
69 | 69 | HRESULT WINAPI EndStateBlock(LPDWORD lpdwBlockHandle);
|
70 | 70 | HRESULT WINAPI EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg);
|
| 71 | + HRESULT WINAPI EnumTextureFormats2(LPD3DENUMTEXTUREFORMATSCALLBACK lpd3dEnumTextureProc, LPVOID lpArg);
|
71 | 72 | HRESULT WINAPI GetCaps(LPD3DDEVICEDESC7 lpD3DDevDesc);
|
72 | 73 | HRESULT WINAPI GetClipPlane(DWORD dwIndex, D3DVALUE *pPlaneEquation);
|
73 | 74 | HRESULT WINAPI GetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
|
Index: dxgl-example.ini |
— | — | @@ -411,6 +411,11 @@ |
412 | 412 | ; Default is 0
|
413 | 413 | EnableDithering=0
|
414 | 414 |
|
| 415 | +; LimitTextureFormats - Boolean
|
| 416 | +; Limits the available texture formats returned by EnumTextureFormats to
|
| 417 | +; avoid crashes in some games. Default is true.
|
| 418 | +LimitTextureFormats=true
|
| 419 | +
|
415 | 420 | [advanced]
|
416 | 421 | ; TextureFormat - Integer
|
417 | 422 | ; Determines the internal format to use for textures and DirectDraw
|
— | — | @@ -598,6 +603,18 @@ |
599 | 604 | ; Default is false
|
600 | 605 | DebugDisableErrors=true
|
601 | 606 |
|
| 607 | +; DebugTraceLevel - Boolean
|
| 608 | +; Sets the debug tracing level for DXGL. This can be used to diagnose bugs
|
| 609 | +; in DXGL. The log will be saved as dxgl.log and will be overwritten if it
|
| 610 | +; already exists.
|
| 611 | +; The following values are valid:
|
| 612 | +; 0 - Disable tracing.
|
| 613 | +; 1 - Log system info and errors only
|
| 614 | +; 2 - Log system info, errors, and certain informational messages
|
| 615 | +; 3 - Log system info, errors, and certain informational messages, and log
|
| 616 | +; a trace of API calls.
|
| 617 | +DebugTraceLevel=0
|
| 618 | +
|
602 | 619 | [hacks]
|
603 | 620 | ; Hacks are intended for specific scenarios, and may cause undesired effects
|
604 | 621 | ; if used with games they do not apply to or are combined.
|
Index: dxglcfg/dxglcfg.cpp |
— | — | @@ -1981,6 +1981,12 @@ |
1982 | 1982 | EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
1983 | 1983 | *dirty = TRUE;
|
1984 | 1984 | break;
|
| 1985 | + case IDC_LIMITTEXFORMATS:
|
| 1986 | + cfg->LimitTextureFormats = GetCheck(hWnd, IDC_SINGLEBUFFER, &cfgmask->LimitTextureFormats);
|
| 1987 | + EnableWindow(GetDlgItem(hDialog, IDC_APPLY), TRUE);
|
| 1988 | + *dirty = TRUE;
|
| 1989 | + break;
|
| 1990 | +
|
1985 | 1991 | default:
|
1986 | 1992 | break;
|
1987 | 1993 | }
|
— | — | @@ -2884,6 +2890,7 @@ |
2885 | 2891 | SendDlgItemMessage(hTabs[2], IDC_ASPECT3D, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
2886 | 2892 | SendDlgItemMessage(hTabs[2], IDC_LOWCOLORRENDER, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
2887 | 2893 | SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
| 2894 | + SendDlgItemMessage(hTabs[2], IDC_LIMITTEXFORMATS, BM_SETSTYLE, BS_AUTO3STATE, (LPARAM)TRUE);
|
2888 | 2895 | // Advanced tab
|
2889 | 2896 | SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
2890 | 2897 | SendDlgItemMessage(hTabs[3], IDC_TEXUPLOAD, CB_ADDSTRING, 0, (LPARAM)strdefault);
|
— | — | @@ -2942,6 +2949,7 @@ |
2943 | 2950 | SendDlgItemMessage(hTabs[2], IDC_LOWCOLORRENDER, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
2944 | 2951 | SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_DELETESTRING,
|
2945 | 2952 | SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
| 2953 | + SendDlgItemMessage(hTabs[2], IDC_LIMITTEXFORMATS, BM_SETSTYLE, BS_AUTOCHECKBOX, TRUE);
|
2946 | 2954 | // Advanced tab
|
2947 | 2955 | SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_DELETESTRING,
|
2948 | 2956 | SendDlgItemMessage(hTabs[3], IDC_TEXTUREFORMAT, CB_FINDSTRING, -1, (LPARAM)strdefault), 0);
|
— | — | @@ -3040,6 +3048,7 @@ |
3041 | 3049 | SetCombo(hTabs[2], IDC_ASPECT3D, cfg->aspect3d, cfgmask->aspect3d, tristate);
|
3042 | 3050 | SetCombo(hTabs[2], IDC_LOWCOLORRENDER, cfg->LowColorRendering, cfgmask->LowColorRendering, tristate);
|
3043 | 3051 | SetCombo(hTabs[2], IDC_DITHERING, cfg->EnableDithering, cfgmask->EnableDithering, tristate);
|
| 3052 | + SetCheck(hTabs[2], IDC_LIMITTEXFORMATS, cfg->LimitTextureFormats, cfgmask->LimitTextureFormats, tristate);
|
3044 | 3053 | // Advanced tab
|
3045 | 3054 | SetCombo(hTabs[3], IDC_TEXTUREFORMAT, cfg->TextureFormat, cfgmask->TextureFormat, tristate);
|
3046 | 3055 | SetCombo(hTabs[3], IDC_TEXUPLOAD, cfg->TexUpload, cfgmask->TexUpload, tristate);
|
— | — | @@ -3607,6 +3616,9 @@ |
3608 | 3617 | _tcscpy(buffer, _T("Always enabled, low color"));
|
3609 | 3618 | SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_ADDSTRING, 0, (LPARAM)buffer);
|
3610 | 3619 | SendDlgItemMessage(hTabs[2], IDC_DITHERING, CB_SETCURSEL, cfg->EnableDithering, 0);
|
| 3620 | + if (cfg->LimitTextureFormats) SendDlgItemMessage(hTabs[2], IDC_LIMITTEXFORMATS, BM_SETCHECK, BST_CHECKED, 0);
|
| 3621 | + else SendDlgItemMessage(hTabs[2], IDC_LIMITTEXFORMATS, BM_SETCHECK, BST_UNCHECKED, 0);
|
| 3622 | +
|
3611 | 3623 | // sort modes
|
3612 | 3624 | _tcscpy(buffer,_T("Use system order"));
|
3613 | 3625 | SendDlgItemMessage(hTabs[0], IDC_SORTMODES, CB_ADDSTRING, 0, (LPARAM)buffer);
|
Index: dxglcfg/dxglcfg.rc |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2018 William Feely
|
| 3 | +// Copyright (C) 2011-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -102,6 +102,7 @@ |
103 | 103 | COMBOBOX IDC_LOWCOLORRENDER, 7, 68, 102, 64, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
|
104 | 104 | LTEXT "Enable dithering", IDC_STATIC, 114, 58, 52, 9, SS_LEFT, WS_EX_LEFT
|
105 | 105 | COMBOBOX IDC_DITHERING, 114, 68, 102, 64, CBS_DROPDOWNLIST | CBS_HASSTRINGS, WS_EX_LEFT
|
| 106 | + AUTOCHECKBOX "Limit D3D Texture Formats", IDC_LIMITTEXFORMATS, 7, 86, 99, 8, 0, WS_EX_LEFT
|
106 | 107 | }
|
107 | 108 |
|
108 | 109 |
|
Index: dxglcfg/resource.h |
— | — | @@ -102,6 +102,7 @@ |
103 | 103 | #define IDC_MSAA 2203
|
104 | 104 | #define IDC_ASPECT3D 2204
|
105 | 105 | #define IDC_DITHERING 2205
|
| 106 | +#define IDC_LIMITTEXFORMATS 2206
|
106 | 107 |
|
107 | 108 | // Controls - Advanced Tab
|
108 | 109 | #define IDC_TEXTUREFORMAT 2301
|