DXGL r899 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r898‎ | r899 | r900 >
Date:23:23, 8 March 2019
Author:admin
Status:new
Tags:
Comment:
Multiply 24-bit depth buffers by 256 when sampling as color for Blt operations.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -69,6 +69,8 @@
7070 0x14: 4-bit palette index (future)
7171 0x15: 2-bit palette index (future)
7272 0x16: 1-bit palette index (future)
 73+0x18: 24-bit Depth
 74+0x19: 24-bit Depth, 8-bit Stencil
7375 0x20: (first entry for specific RGB formats) (future)
7476 0x80: (first entry for specific YUV formats) (future)
7577 0xC0: (first entry for compressed) (future)
@@ -123,6 +125,7 @@
124126 static const char op_palpixel[] = "vec4 myindex = texture2D(srctex, gl_TexCoord[0].xy);\n\
125127 vec2 index = vec2(((myindex.x*(255.0/256.0))+(0.5/256.0)),0.5);\n\
126128 pixel = ivec4(texture2D(srcpal, index)*vec4(colorsizedest)+.5);\n";
 129+static const char op_pixelmul256[] = "pixel = ivec4(vec4(256.0)*texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizedest)+.5);\n";
127130 static const char op_color[] = "pixel = fillcolor;\n";
128131 static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*vec4(colorsizedest)+.5);\n";
129132 static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
@@ -912,6 +915,10 @@
913916 case 0x13:
914917 String_Append(fsrc, op_palpixel);
915918 break;
 919+ case 0x18:
 920+ case 0x19:
 921+ String_Append(fsrc, op_pixelmul256);
 922+ break;
916923 }
917924 }
918925 if (id & DDBLT_KEYSRC) String_Append(fsrc, op_src);
Index: ddraw/glTexture.cpp
@@ -1140,6 +1140,7 @@
11411141 This->convfunctionupload = 17;
11421142 This->convfunctiondownload = 18;
11431143 This->internalsize = 4;
 1144+ This->blttype = 0x18;
11441145 This->internalformats[0] = GL_DEPTH_COMPONENT24;
11451146 This->format = GL_DEPTH_COMPONENT;
11461147 This->type = GL_UNSIGNED_INT;
@@ -1154,6 +1155,7 @@
11551156 This->colorbits[3] = 0;
11561157 break;
11571158 case 20: // 32/24 bit Z buffer
 1159+ This->blttype = 0x18;
11581160 This->internalformats[0] = GL_DEPTH_COMPONENT24;
11591161 This->format = GL_DEPTH_COMPONENT;
11601162 This->type = GL_UNSIGNED_INT;
@@ -1182,6 +1184,7 @@
11831185 This->colorbits[3] = 0;
11841186 break;
11851187 case 22: // 32-bit Z/Stencil buffer, depth LSB
 1188+ This->blttype = 0x18;
11861189 This->internalformats[0] = GL_DEPTH24_STENCIL8;
11871190 This->format = GL_DEPTH_STENCIL;
11881191 This->type = GL_UNSIGNED_INT_24_8;
@@ -1196,6 +1199,7 @@
11971200 This->colorbits[3] = 8;
11981201 break;
11991202 case 23: // 32-bit Z/Stencil buffer, depth MSB
 1203+ This->blttype = 0x18;
12001204 This->internalformats[0] = GL_DEPTH24_STENCIL8;
12011205 This->format = GL_DEPTH_STENCIL;
12021206 This->type = GL_UNSIGNED_INT_24_8;