| Index: dxglcfg/surfacegen.cpp |
| — | — | @@ -1682,8 +1682,33 @@ |
| 1683 | 1683 | _T("32-bit Z/st.rev")
|
| 1684 | 1684 | };
|
| 1685 | 1685 | static const int END_SURFACEFORMATS = __LINE__ - 4;
|
| 1686 | | -static const int numsurfaceformats = END_SURFACEFORMATS - START_SURFACEFORMATS;
|
| | 1686 | +const int numsurfaceformats = END_SURFACEFORMATS - START_SURFACEFORMATS;
|
| 1687 | 1687 |
|
| | 1688 | +const DDPIXELFORMAT surfaceformats[] =
|
| | 1689 | +{
|
| | 1690 | + {0, 0, 0, 0, 0, 0, 0, 0}, // reserved
|
| | 1691 | + {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
|
| | 1692 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
|
| | 1693 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
|
| | 1694 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0}, // 16 bit 565
|
| | 1695 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 24, 0xFF0000, 0xFF00, 0xFF, 0}, // 24 bit 888
|
| | 1696 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0}, // 32 bit 888
|
| | 1697 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF, 0xFF00, 0xFF0000, 0}, // 32 bit 888 RGB
|
| | 1698 | + {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xE0, 0x1C, 0x3, 0xFF00}, // 16-bit 8332
|
| | 1699 | + {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xF00, 0xF0, 0xF, 0xF000}, // 16-bit 4444
|
| | 1700 | + {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0x7c00, 0x3E0, 0x1F, 0x8000}, // 16-bit 1555
|
| | 1701 | + {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0xFF000000}, // 32-bit 8888
|
| | 1702 | + {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE, 0, 8, 0xFF, 0, 0, 0}, // 8-bit luminance
|
| | 1703 | + {sizeof(DDPIXELFORMAT), DDPF_ALPHA, 0, 8, 0, 0, 0, 0}, // 8-bit alpha
|
| | 1704 | + {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE|DDPF_ALPHAPIXELS,0, 16, 0xFF, 0, 0, 0xFF00}, // 8-bit luminance alpha
|
| | 1705 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 16, 0, 0xFFFF, 0, 0}, // 16 bit Z buffer
|
| | 1706 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer
|
| | 1707 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space
|
| | 1708 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0}, // 32 bit Z buffer
|
| | 1709 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0}, // 32 bit Z buffer with stencil
|
| | 1710 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0} // 32 bit Z buffer with stencil, reversed
|
| | 1711 | +};
|
| | 1712 | +
|
| 1688 | 1713 | static const LPTSTR strErrorMessages[] =
|
| 1689 | 1714 | {
|
| 1690 | 1715 | _T("Unknown error"),
|
| — | — | @@ -1707,6 +1732,7 @@ |
| 1708 | 1733 | HFONT newfont;
|
| 1709 | 1734 | RECT r;
|
| 1710 | 1735 | TCHAR buffer[256];
|
| | 1736 | + TCHAR number[34];
|
| 1711 | 1737 | int oldbk;
|
| 1712 | 1738 | SIZE charsize;
|
| 1713 | 1739 | int rows, cols;
|
| — | — | @@ -1714,6 +1740,7 @@ |
| 1715 | 1741 | int posx, posy;
|
| 1716 | 1742 | int formatposy;
|
| 1717 | 1743 | int formatfirst, formatlast;
|
| | 1744 | + int i;
|
| 1718 | 1745 | err = surface->GetDC(&hdc);
|
| 1719 | 1746 | if (FAILED(err)) return;
|
| 1720 | 1747 | if (y < 350)
|
| — | — | @@ -1773,20 +1800,98 @@ |
| 1774 | 1801 | TextOutShadow(hdc, posx, posy, buffer, _tcslen(buffer), RGB(0, 0, 192));
|
| 1775 | 1802 | // List source formats
|
| 1776 | 1803 | formatposy = posy + charsize.cy;
|
| | 1804 | + posy = formatposy;
|
| 1777 | 1805 | SetBkMode(hdc, TRANSPARENT);
|
| 1778 | 1806 | formatrows = rows - (formatposy / charsize.cy) - 1;
|
| 1779 | 1807 | if (formatrows > numsurfaceformats)
|
| 1780 | 1808 | {
|
| | 1809 | + formatfirst = 0;
|
| | 1810 | + formatlast = numsurfaceformats - 1;
|
| | 1811 | + }
|
| | 1812 | + else
|
| | 1813 | + {
|
| | 1814 | + if (srcformat < formatrows / 2)
|
| | 1815 | + {
|
| | 1816 | + formatfirst = 0;
|
| | 1817 | + formatlast = formatrows;
|
| | 1818 | + }
|
| | 1819 | + else if (srcformat+2 > (numsurfaceformats - (formatrows / 2)))
|
| | 1820 | + {
|
| | 1821 | + formatlast = numsurfaceformats - 1;
|
| | 1822 | + formatfirst = formatlast - (formatrows);
|
| | 1823 | + }
|
| | 1824 | + else
|
| | 1825 | + {
|
| | 1826 | + formatfirst = srcformat - (formatrows / 2);
|
| | 1827 | + formatlast = srcformat + (formatrows / 2) + (formatrows % 2);
|
| | 1828 | + }
|
| | 1829 | + }
|
| | 1830 | + for (i = formatfirst; i < formatlast; i++)
|
| | 1831 | + {
|
| | 1832 | + if (i == srcformat)
|
| | 1833 | + {
|
| | 1834 | + posx = 0;
|
| | 1835 | + SetTextColor(hdc, RGB(255, 255, 255));
|
| | 1836 | + TextOutShadow(hdc, posx, posy, _T("-->"), 3, RGB(0, 0, 192));
|
| | 1837 | + posx = 3 * charsize.cx;
|
| | 1838 | + TextOutShadow(hdc, posx, posy, strSurfaceFormats[i + 1], _tcslen(strSurfaceFormats[i + 1]), RGB(0, 0, 192));
|
| | 1839 | + }
|
| | 1840 | + else
|
| | 1841 | + {
|
| | 1842 | + SetTextColor(hdc, RGB(192, 192, 192));
|
| | 1843 | + posx = 3 * charsize.cx;
|
| | 1844 | + TextOut(hdc, posx, posy, strSurfaceFormats[i + 1], _tcslen(strSurfaceFormats[i + 1]));
|
| | 1845 | + }
|
| | 1846 | + posy += charsize.cy;
|
| | 1847 | + }
|
| | 1848 | + // List destination formats
|
| | 1849 | + posy = formatposy;
|
| | 1850 | + SetBkMode(hdc, TRANSPARENT);
|
| | 1851 | + formatrows = rows - (formatposy / charsize.cy) - 1;
|
| | 1852 | + if (formatrows >= numsurfaceformats)
|
| | 1853 | + {
|
| 1781 | 1854 | formatfirst = -1;
|
| 1782 | | - formatlast = numsurfaceformats - 2;
|
| | 1855 | + formatlast = numsurfaceformats - 1;
|
| 1783 | 1856 | }
|
| 1784 | 1857 | else
|
| 1785 | 1858 | {
|
| 1786 | | -
|
| | 1859 | + if (destformat < formatrows / 2)
|
| | 1860 | + {
|
| | 1861 | + formatfirst = 0;
|
| | 1862 | + formatlast = formatrows;
|
| | 1863 | + }
|
| | 1864 | + else if (destformat + 2 > (numsurfaceformats - (formatrows / 2)))
|
| | 1865 | + {
|
| | 1866 | + formatlast = numsurfaceformats - 1;
|
| | 1867 | + formatfirst = formatlast - (formatrows);
|
| | 1868 | + }
|
| | 1869 | + else
|
| | 1870 | + {
|
| | 1871 | + formatfirst = destformat - (formatrows / 2);
|
| | 1872 | + formatlast = destformat + (formatrows / 2) + (formatrows % 2);
|
| | 1873 | + }
|
| 1787 | 1874 | }
|
| | 1875 | + for (i = formatfirst; i < formatlast; i++)
|
| | 1876 | + {
|
| | 1877 | + if (i == destformat)
|
| | 1878 | + {
|
| | 1879 | + posx = (cols / 2) * charsize.cx;
|
| | 1880 | + SetTextColor(hdc, RGB(255, 255, 255));
|
| | 1881 | + TextOutShadow(hdc, posx, posy, _T("-->"), 3, RGB(0, 0, 192));
|
| | 1882 | + posx = ((cols / 2) + 3) * charsize.cx;
|
| | 1883 | + TextOutShadow(hdc, posx, posy, strSurfaceFormats[i + 1], _tcslen(strSurfaceFormats[i + 1]), RGB(0, 0, 192));
|
| | 1884 | + }
|
| | 1885 | + else
|
| | 1886 | + {
|
| | 1887 | + SetTextColor(hdc, RGB(192, 192, 192));
|
| | 1888 | + posx = ((cols / 2) + 3) * charsize.cx;
|
| | 1889 | + TextOut(hdc, posx, posy, strSurfaceFormats[i + 1], _tcslen(strSurfaceFormats[i + 1]));
|
| | 1890 | + }
|
| | 1891 | + posy += charsize.cy;
|
| | 1892 | + }
|
| 1788 | 1893 | }
|
| 1789 | 1894 | // Display error if present
|
| 1790 | | - if (error)
|
| | 1895 | + if (error != 0)
|
| 1791 | 1896 | {
|
| 1792 | 1897 | SetBkMode(hdc, OPAQUE);
|
| 1793 | 1898 | SetBkColor(hdc, RGB(255, 0, 0));
|
| — | — | @@ -1793,6 +1898,13 @@ |
| 1794 | 1899 | SetTextColor(hdc, RGB(255, 255, 255));
|
| 1795 | 1900 | if (errorlocation < 0) errorlocation = 0;
|
| 1796 | 1901 | if (errorlocation > 7) errorlocation = 0;
|
| | 1902 | + posx = 0;
|
| | 1903 | + posy = charsize.cy * (rows - 1);
|
| | 1904 | + _tcscpy(buffer, strErrorMessages[errorlocation]);
|
| | 1905 | + _tcscat(buffer, _T("0x"));
|
| | 1906 | + _itot(error, number, 16);
|
| | 1907 | + _tcscat(buffer, number);
|
| | 1908 | + TextOutShadow(hdc, posx, posy, buffer, _tcslen(buffer), RGB(192, 0, 0));
|
| 1797 | 1909 | }
|
| 1798 | 1910 | SelectObject(hdc, DefaultFont);
|
| 1799 | 1911 | DeleteObject(newfont);
|
| Index: dxglcfg/surfacegen.h |
| — | — | @@ -30,5 +30,7 @@ |
| 31 | 31 | void DrawColorKeyCompPatterns(DDSURFACEDESC2 ddsd, unsigned char *buffer, int bpp, int index);
|
| 32 | 32 | void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud,
|
| 33 | 33 | int testpattern, int testmethod, int x, int y, int errorlocation, HRESULT error);
|
| | 34 | +extern const DDPIXELFORMAT surfaceformats[];
|
| | 35 | +extern const int numsurfaceformats;
|
| 34 | 36 |
|
| 35 | 37 | #endif //_SURFACEGEN_H |
| \ No newline at end of file |
| Index: dxglcfg/tests.cpp |
| — | — | @@ -55,8 +55,10 @@ |
| 56 | 56 | static int testpattern = 0;
|
| 57 | 57 | static int testmethod = 0;
|
| 58 | 58 | static BOOL d3dfail = FALSE;
|
| | 59 | +static int errorlocation;
|
| | 60 | +static int errornumber;
|
| | 61 | +void RunSurfaceFormatTest();
|
| 59 | 62 |
|
| 60 | | -
|
| 61 | 63 | #define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
|
| 62 | 64 | struct COLORVERTEX
|
| 63 | 65 | {
|
| — | — | @@ -213,7 +215,11 @@ |
| 214 | 216 | case WM_DESTROY:
|
| 215 | 217 | StopTimer();
|
| 216 | 218 | for(int i = 0; i < 16; i++)
|
| 217 | | - if(sprites[i].surface) sprites[i].surface->Release();
|
| | 219 | + if (sprites[i].surface)
|
| | 220 | + {
|
| | 221 | + sprites[i].surface->Release();
|
| | 222 | + sprites[i].surface = NULL;
|
| | 223 | + }
|
| 218 | 224 | for (int i = 0; i < 8; i++)
|
| 219 | 225 | {
|
| 220 | 226 | if (textures[i])
|
| — | — | @@ -297,10 +303,27 @@ |
| 298 | 304 | switch (wParam)
|
| 299 | 305 | {
|
| 300 | 306 | case VK_SPACE: // Show/hide HUD
|
| | 307 | + showhud++;
|
| | 308 | + if (showhud > 2) showhud = 0;
|
| | 309 | + RunSurfaceFormatTest();
|
| 301 | 310 | break;
|
| 302 | 311 | case VK_UP: // Source format -
|
| | 312 | + srcformat--;
|
| | 313 | + if (srcformat < 0)
|
| | 314 | + {
|
| | 315 | + srcformat = 0;
|
| | 316 | + break;
|
| | 317 | + }
|
| | 318 | + RunSurfaceFormatTest();
|
| 303 | 319 | break;
|
| 304 | 320 | case VK_DOWN: // Source format +
|
| | 321 | + srcformat++;
|
| | 322 | + if (srcformat > numsurfaceformats - 2)
|
| | 323 | + {
|
| | 324 | + srcformat = numsurfaceformats - 2;
|
| | 325 | + break;
|
| | 326 | + }
|
| | 327 | + RunSurfaceFormatTest();
|
| 305 | 328 | break;
|
| 306 | 329 | case VK_LEFT: // Test pattern -
|
| 307 | 330 | break;
|
| — | — | @@ -307,8 +330,22 @@ |
| 308 | 331 | case VK_RIGHT: // Test pattern +
|
| 309 | 332 | break;
|
| 310 | 333 | case VK_PRIOR: // Dest format - (PgUp)
|
| | 334 | + destformat--;
|
| | 335 | + if (destformat < -1)
|
| | 336 | + {
|
| | 337 | + destformat = -1;
|
| | 338 | + break;
|
| | 339 | + }
|
| | 340 | + RunSurfaceFormatTest();
|
| 311 | 341 | break;
|
| 312 | 342 | case VK_NEXT: // Dest format + (PgDn)
|
| | 343 | + destformat++;
|
| | 344 | + if (destformat > numsurfaceformats - 2)
|
| | 345 | + {
|
| | 346 | + destformat = numsurfaceformats - 2;
|
| | 347 | + break;
|
| | 348 | + }
|
| | 349 | + RunSurfaceFormatTest();
|
| 313 | 350 | break;
|
| 314 | 351 | case VK_TAB: // Render method
|
| 315 | 352 | break;
|
| — | — | @@ -2257,6 +2294,78 @@ |
| 2258 | 2295 | }
|
| 2259 | 2296 | }
|
| 2260 | 2297 |
|
| | 2298 | +void RunSurfaceFormatTest()
|
| | 2299 | +{
|
| | 2300 | + HRESULT error;
|
| | 2301 | + DDSURFACEDESC2 ddsd;
|
| | 2302 | + DDBLTFX bltfx;
|
| | 2303 | + errorlocation = 0;
|
| | 2304 | + errornumber = 0;
|
| | 2305 | + if (ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| | 2306 | + else ddsd.dwSize = sizeof(DDSURFACEDESC);
|
| | 2307 | + if (sprites[0].surface)
|
| | 2308 | + {
|
| | 2309 | + sprites[0].surface->Release();
|
| | 2310 | + sprites[0].surface = NULL;
|
| | 2311 | + }
|
| | 2312 | + if (sprites[1].surface)
|
| | 2313 | + {
|
| | 2314 | + sprites[1].surface->Release();
|
| | 2315 | + sprites[1].surface = NULL;
|
| | 2316 | + }
|
| | 2317 | + ddsrender->GetSurfaceDesc(&ddsd);
|
| | 2318 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
| | 2319 | + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
| | 2320 | + if (srcformat > 0)
|
| | 2321 | + {
|
| | 2322 | + ddsd.dwFlags |= DDSD_PIXELFORMAT;
|
| | 2323 | + ddsd.ddpfPixelFormat = surfaceformats[srcformat];
|
| | 2324 | + }
|
| | 2325 | + error = ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL);
|
| | 2326 | + if(error)
|
| | 2327 | + {
|
| | 2328 | + errorlocation = 1;
|
| | 2329 | + errornumber = error;
|
| | 2330 | + bltfx.dwSize = sizeof(DDBLTFX);
|
| | 2331 | + bltfx.dwFillColor = 0;
|
| | 2332 | + ddsrender->Blt(NULL,NULL,NULL,DDBLT_WAIT|DDBLT_COLORFILL,&bltfx);
|
| | 2333 | + }
|
| | 2334 | + else
|
| | 2335 | + {
|
| | 2336 | + // FIXME: Select pattern
|
| | 2337 | + error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
| | 2338 | + if(error)
|
| | 2339 | + {
|
| | 2340 | + errorlocation = 2;
|
| | 2341 | + errornumber = error;
|
| | 2342 | + bltfx.dwSize = sizeof(DDBLTFX);
|
| | 2343 | + bltfx.dwFillColor = 0;
|
| | 2344 | + ddsrender->Blt(NULL,NULL,NULL,DDBLT_WAIT|DDBLT_COLORFILL,&bltfx);
|
| | 2345 | + sprites[0].surface->Release();
|
| | 2346 | + sprites[0].surface = NULL;
|
| | 2347 | + }
|
| | 2348 | + else
|
| | 2349 | + {
|
| | 2350 | + DrawPalette(ddsd, (unsigned char*)ddsd.lpSurface);
|
| | 2351 | + error = sprites[0].surface->Unlock(NULL);
|
| | 2352 | + // FIXME: Get dest surface type
|
| | 2353 | + error = ddsrender->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
| | 2354 | + if(error)
|
| | 2355 | + {
|
| | 2356 | + errorlocation = 5;
|
| | 2357 | + errornumber = error;
|
| | 2358 | + bltfx.dwSize = sizeof(DDBLTFX);
|
| | 2359 | + bltfx.dwFillColor = 0;
|
| | 2360 | + ddsrender->Blt(NULL,NULL,NULL,DDBLT_WAIT|DDBLT_COLORFILL,&bltfx);
|
| | 2361 | + sprites[0].surface->Release();
|
| | 2362 | + sprites[0].surface = NULL;
|
| | 2363 | + }
|
| | 2364 | + }
|
| | 2365 | + }
|
| | 2366 | + DrawFormatTestHUD(ddsrender, srcformat, destformat, showhud, testpattern,
|
| | 2367 | + testmethod, ddsd.dwWidth, ddsd.dwHeight, errorlocation, errornumber);
|
| | 2368 | +}
|
| | 2369 | +
|
| 2261 | 2370 | void RunTestLooped(int test)
|
| 2262 | 2371 | {
|
| 2263 | 2372 | randnum += rand(); // Improves randomness of "snow" patterns at certain resolutions
|