DXGL r902 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r901‎ | r902 | r903 >
Date:23:28, 9 March 2019
Author:admin
Status:new
Tags:
Comment:
Fix bitmask for 24-bit Z buffer.
Add reversed-order 24-bit Z buffer stored in 32-bit space.
Modified paths:
  • /ddraw/glTexture.cpp (modified) (history)
  • /dxglcfg/surfacegen.cpp (modified) (history)

Diff [purge]

Index: ddraw/glTexture.cpp
@@ -88,8 +88,9 @@
8989 {sizeof(DDPIXELFORMAT), DDPF_ALPHA, 0, 8, 0, 0, 0, 0}, // 8-bit alpha
9090 {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE|DDPF_ALPHAPIXELS,0, 16, 0xFF, 0, 0, 0xFF00}, // 8-bit luminance alpha
9191 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 16, 0, 0xFFFF, 0, 0}, // 16 bit Z buffer
92 - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer
93 - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space
 92+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF, 0, 0}, // 24 bit Z buffer
 93+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF, 0, 0}, // 24 bit Z buffer, 32-bit space
 94+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space, reversed
9495 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0}, // 32 bit Z buffer
9596 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0}, // 32 bit Z buffer with stencil
9697 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0} // 32 bit Z buffer with stencil, reversed
@@ -1191,7 +1192,22 @@
11921193 This->colorbits[2] = 0;
11931194 This->colorbits[3] = 0;
11941195 break;
1195 - case 21: // 32-bit Z buffer
 1196+ case 21: // 32/24 bit Z buffer reversed
 1197+ This->internalformats[0] = GL_DEPTH_COMPONENT24;
 1198+ This->format = GL_DEPTH_COMPONENT;
 1199+ This->type = GL_UNSIGNED_INT;
 1200+ if (!This->target) This->target = GL_TEXTURE_2D;
 1201+ This->colororder = 4;
 1202+ This->colorsizes[0] = 16777215;
 1203+ This->colorsizes[1] = 16777215;
 1204+ This->colorsizes[2] = 16777215;
 1205+ This->colorsizes[3] = 16777215;
 1206+ This->colorbits[0] = 24;
 1207+ This->colorbits[1] = 0;
 1208+ This->colorbits[2] = 0;
 1209+ This->colorbits[3] = 0;
 1210+ break;
 1211+ case 22: // 32-bit Z buffer
11961212 This->internalformats[0] = GL_DEPTH_COMPONENT32;
11971213 This->format = GL_DEPTH_COMPONENT;
11981214 This->type = GL_UNSIGNED_INT;
@@ -1206,8 +1222,7 @@
12071223 This->colorbits[2] = 0;
12081224 This->colorbits[3] = 0;
12091225 break;
1210 - case 22: // 32-bit Z/Stencil buffer, depth LSB
1211 - This->blttype = 0x18;
 1226+ case 23: // 32-bit Z/Stencil buffer, depth LSB
12121227 This->internalformats[0] = GL_DEPTH24_STENCIL8;
12131228 This->format = GL_DEPTH_STENCIL;
12141229 This->type = GL_UNSIGNED_INT_24_8;
@@ -1222,7 +1237,7 @@
12231238 This->colorbits[2] = 0;
12241239 This->colorbits[3] = 8;
12251240 break;
1226 - case 23: // 32-bit Z/Stencil buffer, depth MSB
 1241+ case 24: // 32-bit Z/Stencil buffer, depth MSB
12271242 This->blttype = 0x18;
12281243 This->internalformats[0] = GL_DEPTH24_STENCIL8;
12291244 This->format = GL_DEPTH_STENCIL;
Index: dxglcfg/surfacegen.cpp
@@ -323,6 +323,16 @@
324324 }
325325 }
326326 }
 327+ else if ((ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER) && (ddsd.ddpfPixelFormat.dwZBitMask == 0xFFFFFF00))
 328+ {
 329+ for (y = 0; y < ddsd.dwHeight; y++)
 330+ {
 331+ for (x = 0; x < ddsd.dwWidth; x++)
 332+ {
 333+ buffer32[x + ((ddsd.lPitch / 4) * y)] = (unsigned long)((x / (ddsd.dwWidth / 4096.)) + 4096 * floor((y / (ddsd.dwHeight / 4096.)))) << 8;
 334+ }
 335+ }
 336+ }
327337 else
328338 {
329339 for (y = 0; y < ddsd.dwHeight; y++)
@@ -1740,6 +1750,7 @@
17411751 _T("16-bit Zbuffer"),
17421752 _T("24-bit Zbuffer"),
17431753 _T("24-bit Z, 32bit"),
 1754+ _T("24-bit Z,32b.rev"),
17441755 _T("32-bit Zbuffer"),
17451756 _T("32-bit Z/stencil"),
17461757 _T("32-bit Z/st.rev")
@@ -1769,8 +1780,9 @@
17701781 {sizeof(DDPIXELFORMAT), DDPF_ALPHA, 0, 8, 0, 0, 0, 0}, // 8-bit alpha
17711782 {sizeof(DDPIXELFORMAT), DDPF_LUMINANCE|DDPF_ALPHAPIXELS,0, 16, 0xFF, 0, 0, 0xFF00}, // 8-bit luminance alpha
17721783 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 16, 0, 0xFFFF, 0, 0}, // 16 bit Z buffer
1773 - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer
1774 - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space
 1784+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 24, 0, 0xFFFFFF, 0, 0}, // 24 bit Z buffer
 1785+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF, 0, 0}, // 24 bit Z buffer, 32-bit space
 1786+ {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space, reversed
17751787 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0}, // 32 bit Z buffer
17761788 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0}, // 32 bit Z buffer with stencil
17771789 {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0} // 32 bit Z buffer with stencil, reversed