DXGL r940 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r939‎ | r940 | r941 >
Date:00:22, 19 August 2019
Author:admin
Status:new
Tags:
Comment:
Implement limited texture formats.
Modified paths:
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)
  • /dxgl-example.ini (modified) (history)

Diff [purge]

Index: ddraw/glDirect3DDevice.cpp
@@ -1008,6 +1008,25 @@
10091009 ERR(DDERR_GENERIC);
10101010 }
10111011
 1012+// Use EXACTLY one line per entry. Don't change layout of the list.
 1013+// This list is a subset of the list found in glTexture to be used when limited
 1014+// texture support is enabled.
 1015+static const int START_LIMITEDTEXFORMATS = __LINE__;
 1016+const DDPIXELFORMAT limitedtexformats[] =
 1017+{ // Size Flags FOURCC bits R/Ymask G/U/Zmask B/V/STmask A/Zmask
 1018+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
 1019+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0x7c00, 0x3E0, 0x1F, 0x8000}, // 16-bit 1555
 1020+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0}, // 16 bit 565
 1021+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xF00, 0xF0, 0xF, 0xF000}, // 16-bit 4444
 1022+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0}, // 32 bit 888
 1023+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}, // 32-bit 8888
 1024+ {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
 1025+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
 1026+};
 1027+static const int END_LIMITEDTEXFORMATS = __LINE__ - 4;
 1028+int numlimitedtexformats;
 1029+
 1030+
10121031 HRESULT WINAPI glDirect3DDevice7::EnumTextureFormats(LPD3DENUMPIXELFORMATSCALLBACK lpd3dEnumPixelProc, LPVOID lpArg)
10131032 {
10141033 TRACE_ENTER(3,14,this,14,lpd3dEnumPixelProc,14,lpArg);
@@ -1014,19 +1033,37 @@
10151034 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
10161035 HRESULT result;
10171036 DDPIXELFORMAT fmt;
1018 - for(int i = 0; i < numtexformats; i++)
 1037+ if (dxglcfg.LimitTextureFormats >= 2)
10191038 {
1020 - if (i == 11) continue;
1021 - if(::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
1022 - //FIXME: Remove these line after implementing palette textures
1023 - if(::texformats[i].dwFlags & DDPF_PALETTEINDEXED1) continue;
1024 - if(::texformats[i].dwFlags & DDPF_PALETTEINDEXED2) continue;
1025 - if(::texformats[i].dwFlags & DDPF_PALETTEINDEXED4) continue;
1026 - if(::texformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
1027 - memcpy(&fmt,&::texformats[i],sizeof(DDPIXELFORMAT));
1028 - result = lpd3dEnumPixelProc(&fmt,lpArg);
1029 - if(result != D3DENUMRET_OK) TRACE_RET(HRESULT,23,D3D_OK);
 1039+ numlimitedtexformats = END_LIMITEDTEXFORMATS - START_LIMITEDTEXFORMATS;
 1040+ for (int i = 0; i < numlimitedtexformats; i++)
 1041+ {
 1042+ if (limitedtexformats[i].dwFlags & DDPF_ZBUFFER) continue;
 1043+ //FIXME: Remove this line after implementing palette textures
 1044+ if (limitedtexformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
 1045+ memcpy(&fmt, &limitedtexformats[i], sizeof(DDPIXELFORMAT));
 1046+ result = lpd3dEnumPixelProc(&fmt, lpArg);
 1047+ if (result != D3DENUMRET_OK) TRACE_RET(HRESULT, 23, D3D_OK);
 1048+ }
10301049 }
 1050+ else
 1051+ {
 1052+ for (int i = 0; i < numtexformats; i++)
 1053+ {
 1054+ //FIXME: Remove this line after implementing RGB3328 textures
 1055+ if (i == 11) continue;
 1056+ // Exclude Z buffer formats
 1057+ if (::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
 1058+ //FIXME: Remove these lines after implementing palette textures
 1059+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED1) continue;
 1060+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED2) continue;
 1061+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED4) continue;
 1062+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
 1063+ memcpy(&fmt, &::texformats[i], sizeof(DDPIXELFORMAT));
 1064+ result = lpd3dEnumPixelProc(&fmt, lpArg);
 1065+ if (result != D3DENUMRET_OK) TRACE_RET(HRESULT, 23, D3D_OK);
 1066+ }
 1067+ }
10311068 TRACE_EXIT(23,D3D_OK);
10321069 return D3D_OK;
10331070 }
@@ -1041,20 +1078,40 @@
10421079 ddsd.dwSize = sizeof(DDSURFACEDESC);
10431080 ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT;
10441081 ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE;
1045 - for (int i = 0; i < numtexformats; i++)
 1082+ if (dxglcfg.LimitTextureFormats >= 1)
10461083 {
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);
 1084+ numlimitedtexformats = END_LIMITEDTEXFORMATS - START_LIMITEDTEXFORMATS;
 1085+ for (int i = 0; i < numlimitedtexformats; i++)
 1086+ {
 1087+ // Exclude FOURCC formats
 1088+ if (limitedtexformats[i].dwFlags & DDPF_FOURCC) continue;
 1089+ //FIXME: Remove this line after implementing palette textures
 1090+ if (limitedtexformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
 1091+ memcpy(&ddsd.ddpfPixelFormat, &limitedtexformats[i], sizeof(DDPIXELFORMAT));
 1092+ result = lpd3dEnumTextureProc(&ddsd, lpArg);
 1093+ if (result != D3DENUMRET_OK) TRACE_RET(HRESULT, 23, D3D_OK);
 1094+ }
10581095 }
 1096+ else
 1097+ {
 1098+ for (int i = 0; i < numtexformats; i++)
 1099+ {
 1100+ //FIXME: Remove this line after implementing RGB3328 textures
 1101+ if (i == 11) continue;
 1102+ // Exclude Z buffer formats
 1103+ if (::texformats[i].dwFlags & DDPF_ZBUFFER) continue;
 1104+ // Exclude FOURCC formats
 1105+ if (::texformats[i].dwFlags & DDPF_FOURCC) continue;
 1106+ //FIXME: Remove these lines after implementing palette textures
 1107+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED1) continue;
 1108+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED2) continue;
 1109+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED4) continue;
 1110+ if (::texformats[i].dwFlags & DDPF_PALETTEINDEXED8) continue;
 1111+ memcpy(&ddsd.ddpfPixelFormat, &::texformats[i], sizeof(DDPIXELFORMAT));
 1112+ result = lpd3dEnumTextureProc(&ddsd, lpArg);
 1113+ if (result != D3DENUMRET_OK) TRACE_RET(HRESULT, 23, D3D_OK);
 1114+ }
 1115+ }
10591116 TRACE_EXIT(23, D3D_OK);
10601117 return D3D_OK;
10611118 }
Index: ddraw/glTexture.cpp
@@ -69,9 +69,9 @@
7070 static const int START_TEXFORMATS = __LINE__;
7171 const DDPIXELFORMAT texformats[] =
7272 { // Size Flags FOURCC bits R/Ymask G/U/Zmask B/V/STmask A/Zmask
73 - {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED1, 0, 1, 0, 0, 0, 0}, // 8-bit paletted
74 - {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED2, 0, 2, 0, 0, 0, 0}, // 8-bit paletted
75 - {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED4, 0, 4, 0, 0, 0, 0}, // 8-bit paletted
 73+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED1, 0, 1, 0, 0, 0, 0}, // 1-bit paletted
 74+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED2, 0, 2, 0, 0, 0, 0}, // 2-bit paletted
 75+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED4, 0, 4, 0, 0, 0, 0}, // 4-bit paletted
7676 {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
7777 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
7878 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
Index: dxgl-example.ini
@@ -413,7 +413,9 @@
414414
415415 ; LimitTextureFormats - Integer
416416 ; Limits the available texture formats returned by EnumTextureFormats to
417 -; avoid crashes in some games.
 417+; avoid crashes in some games. When limited, texture formats will be returned
 418+; in the same order as given in Wine 4.14, subject to the limitation of
 419+; currently implemented formats.
418420 ; The following values are valid:
419421 ; 0 - Don't limit formats regardless of API version
420422 ; 1 - Limit formats on API versions 2 and 1 (DirectX 5 and DirectX 3/2)