DXGL r891 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r890‎ | r891 | r892 >
Date:22:33, 8 February 2019
Author:admin
Status:new
Tags:
Comment:
Fix indexed pixel format definitions.
Use system memory surfaces for software D3D textures and DDSCAPS2_TEXTUREMANAGE for hardware D3D.
Modified paths:
  • /ddraw/glTexture.cpp (modified) (history)
  • /dxglcfg/surfacegen.cpp (modified) (history)
  • /dxglcfg/tests.cpp (modified) (history)

Diff [purge]

Index: ddraw/glTexture.cpp
@@ -69,7 +69,7 @@
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_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
 73+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
7474 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
7575 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
7676 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0}, // 16 bit 565
Index: dxglcfg/surfacegen.cpp
@@ -1703,10 +1703,10 @@
17041704 const DDPIXELFORMAT surfaceformats[] =
17051705 {
17061706 {0, 0, 0, 0, 0, 0, 0, 0}, // reserved
1707 - {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED1, 0, 1, 0, 0, 0, 0}, // 8-bit paletted
1708 - {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED2, 0, 2, 0, 0, 0, 0}, // 8-bit paletted
1709 - {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED4, 0, 4, 0, 0, 0, 0}, // 8-bit paletted
1710 - {sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
 1707+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED1, 0, 1, 0, 0, 0, 0}, // 8-bit paletted
 1708+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED2, 0, 2, 0, 0, 0, 0}, // 8-bit paletted
 1709+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED4, 0, 4, 0, 0, 0, 0}, // 8-bit paletted
 1710+ {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_PALETTEINDEXED8, 0, 8, 0, 0, 0, 0}, // 8-bit paletted
17111711 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 8, 0xE0, 0x1C, 0x3, 0}, // 8 bit 332
17121712 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x3E0, 0x1F, 0}, // 15 bit 555
17131713 {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0}, // 16 bit 565
Index: dxglcfg/tests.cpp
@@ -28,6 +28,7 @@
2929 void InitTest(int test);
3030 void RunTestTimed(int test);
3131 void RunTestLooped(int test);
 32+void RunSurfaceFormatTest();
3233
3334
3435 static MultiDirectDraw *ddinterface;
@@ -57,7 +58,7 @@
5859 static BOOL d3dfail = FALSE;
5960 static int errorlocation;
6061 static int errornumber;
61 -void RunSurfaceFormatTest();
 62+static BOOL softd3d;
6263
6364 #define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
6465 struct COLORVERTEX
@@ -454,6 +455,7 @@
455456 ::height = height;
456457 ::bpp = bpp;
457458 ::refresh = refresh;
 459+ ::softd3d = softd3d;
458460 if(fullscreen)::backbuffers = backbuffers;
459461 else ::backbuffers = backbuffers = 0;
460462 ::fps = fps;
@@ -561,6 +563,8 @@
562564 {
563565 error = d3d7->CreateDevice(IID_IDirect3DRefDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
564566 if(error != D3D_OK)
 567+ error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
 568+ if(error == D3D_OK)
565569 error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
566570 }
567571 else error = d3d7->EnumZBufferFormats(IID_IDirect3DHALDevice, zcallback, &ddpfz);
@@ -587,7 +591,10 @@
588592 {
589593 error = d3d7->CreateDevice(IID_IDirect3DRefDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
590594 if(error != D3D_OK)
 595+ {
 596+ ::softd3d = TRUE;
591597 error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
 598+ }
592599 if (error != D3D_OK)
593600 {
594601 d3dfail = TRUE;
@@ -2535,6 +2542,8 @@
25362543 ddsrender->GetSurfaceDesc(&ddsd);
25372544 ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
25382545 ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
 2546+ if(softd3d) ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
 2547+ else ddsd.ddsCaps.dwCaps2 = DDSCAPS2_TEXTUREMANAGE;
25392548 if (destformat > 0)
25402549 {
25412550 ddsd.dwFlags |= DDSD_PIXELFORMAT;