DXGL r782 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r781‎ | r782 | r783 >
Date:04:49, 25 December 2017
Author:admin
Status:new
Tags:
Comment:
Add and implement debug option to blend destination with source when using destination colorkey.
Add option for nearest-neighbor sampling of color keys.
Add shaders for preparing enhanced color key sampling.
Modified paths:
  • /cfgmgr/ReadMe.txt (modified) (history)
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /cfgmgr/cfgmgr.h (modified) (history)
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/ShaderManager.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)
  • /ddraw/struct.h (modified) (history)
  • /ddraw/util.c (modified) (history)
  • /ddraw/util.h (modified) (history)
  • /dxgl-example.ini (modified) (history)
  • /dxgl.sln (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)

Diff [purge]

Index: cfgmgr/ReadMe.txt
@@ -155,8 +155,9 @@
156156 Valid settings:
157157 0 - Nearest-neighbor stretching
158158 1 - Bilinear interpolation
159 -2 - Bilinear interpolation, sharp color key
160 -3 - Bilinear interpolation, soft color key
 159+2 - Bilinear interpolation, nearest-neighbor color key
 160+3 - Bilinear interpolation, sharp color key
 161+4 - Bilinear interpolation, soft color key
161162
162163 Member BltThreshold
163164 INI Entry BltThreshold
@@ -428,6 +429,13 @@
429430 If nonzero, disables use of GLSL version 1.30. When combined with
430431 DebugNoGpuShader4 this will disable raster operations in DirectDraw.
431432
 433+Member DebugBlendDestColorKey
 434+INI Entry DebugBlendDestColorKey
 435+INI Group debug
 436+REG_DWORD HKCU\DXGL\Profiles\<app>\DebugBlendDestColorKey
 437+If nonzero, blends the texture used for destination color keying with the
 438+source. For testing purposes only.
 439+
432440 Member DebugMaxGLVersionMajor
433441 INI Entry DebugMaxGLVersionMajor
434442 INI Group debug
Index: cfgmgr/cfgmgr.c
@@ -578,6 +578,7 @@
579579 cfg->DebugNoSamplerObjects = ReadBool(hKey, cfg->DebugNoSamplerObjects, &cfgmask->DebugNoSamplerObjects, _T("DebugNoSamplerObjects"));
580580 cfg->DebugNoGpuShader4 = ReadBool(hKey, cfg->DebugNoGpuShader4, &cfgmask->DebugNoGpuShader4, _T("DebugNoGpuShader4"));
581581 cfg->DebugNoGLSL130 = ReadBool(hKey, cfg->DebugNoGLSL130, &cfgmask->DebugNoGLSL130, _T("DebugNoGLSL130"));
 582+ cfg->DebugBlendDestColorKey = ReadBool(hKey, cfg->DebugBlendDestColorKey, &cfgmask->DebugBlendDestColorKey, _T("DebugBlendDestColorKey"));
582583 cfg->DebugMaxGLVersionMajor = ReadDWORD(hKey, cfg->DebugMaxGLVersionMajor, &cfgmask->DebugMaxGLVersionMajor, _T("DebugMaxGLVersionMajor"));
583584 cfg->DebugMaxGLVersionMinor = ReadDWORD(hKey, cfg->DebugMaxGLVersionMinor, &cfgmask->DebugMaxGLVersionMinor, _T("DebugMaxGLVersionMinor"));
584585 cfg->HackCrop640480to640400 = ReadBool(hKey, cfg->HackCrop640480to640400, &cfgmask->HackCrop640480to640400, _T("HackCrop640480to640400"));
@@ -716,6 +717,7 @@
717718 WriteBool(hKey, cfg->DebugNoSamplerObjects, cfgmask->DebugNoSamplerObjects, _T("DebugNoSamplerObjects"));
718719 WriteBool(hKey, cfg->DebugNoGpuShader4, cfgmask->DebugNoGpuShader4, _T("DebugNoGpuShader4"));
719720 WriteBool(hKey, cfg->DebugNoGLSL130, cfgmask->DebugNoGLSL130, _T("DebugNoGLSL130"));
 721+ WriteBool(hKey, cfg->DebugBlendDestColorKey, cfgmask->DebugBlendDestColorKey, _T("DebugBlendDestColorKey"));
720722 WriteDWORD(hKey, cfg->DebugMaxGLVersionMajor, cfgmask->DebugMaxGLVersionMajor, _T("DebugMaxGLVersionMajor"));
721723 WriteDWORD(hKey, cfg->DebugMaxGLVersionMinor, cfgmask->DebugMaxGLVersionMinor, _T("DebugMaxGLVersionMinor"));
722724 WriteBool(hKey, cfg->HackCrop640480to640400, cfgmask->HackCrop640480to640400, _T("HackCrop640480to640400"));
@@ -967,6 +969,7 @@
968970 if (!stricmp(name, "DebugNoSamplerObjects")) cfg->DebugNoSamplerObjects = INIBoolValue(value);
969971 if (!stricmp(name, "DebugNoGpuShader4")) cfg->DebugNoGpuShader4 = INIBoolValue(value);
970972 if (!stricmp(name, "DebugNoGLSL130")) cfg->DebugNoGLSL130 = INIBoolValue(value);
 973+ if (!stricmp(name, "DebugBlendDestColorKey")) cfg->DebugBlendDestColorKey = INIBoolValue(value);
971974 if (!stricmp(name, "DebugMaxGLVersionMajor")) cfg->DebugMaxGLVersionMajor = INIIntValue(value);
972975 if (!stricmp(name, "DebugMaxGLVersionMinor")) cfg->DebugMaxGLVersionMinor = INIIntValue(value);
973976 }
Index: cfgmgr/cfgmgr.h
@@ -76,6 +76,7 @@
7777 BOOL DebugNoSamplerObjects;
7878 BOOL DebugNoGpuShader4;
7979 BOOL DebugNoGLSL130;
 80+ BOOL DebugBlendDestColorKey;
8081 DWORD DebugMaxGLVersionMajor;
8182 DWORD DebugMaxGLVersionMinor;
8283 // [hacks]
Index: ddraw/ShaderGen2D.cpp
@@ -107,6 +107,7 @@
108108 static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
109109 mod(gl_FragCoord.y, float(patternsize.y)) / float(patternsize.y));\n\
110110 pattern = ivec4(texture2D(patterntex,patternst)*vec4(colorsizedest)+.5);\n";
 111+static const char op_destoutdestblend[] = "gl_FragColor = (vec4(pixel)/vec4(colorsizedest)) * texture2D(desttex,gl_TexCoord[1].st);\n";
111112 static const char op_destout[] = "gl_FragColor = vec4(pixel)/vec4(colorsizedest);\n";
112113 static const char op_vertex[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
113114 mat4 proj = mat4(\n\
@@ -870,8 +871,11 @@
871872 }
872873 if (id & DDBLT_KEYDEST)
873874 {
874 - if (id & 0x40000000) String_Append(fsrc, op_ckeydestrange);
875 - else String_Append(fsrc, op_ckeydest);
 875+ if (!dxglcfg.DebugBlendDestColorKey)
 876+ {
 877+ if (id & 0x40000000) String_Append(fsrc, op_ckeydestrange);
 878+ else String_Append(fsrc, op_ckeydest);
 879+ }
876880 }
877881 if (id & DDBLT_ROP)
878882 {
@@ -879,8 +883,9 @@
880884 if (intproc) String_Append(fsrc, op_ROP[rop]);
881885 else String_Append(fsrc, op_ROP_float[rop]);
882886 }
883 -
884 - String_Append(fsrc, op_destout);
 887+ if (dxglcfg.DebugBlendDestColorKey && (id & DDBLT_KEYDEST))
 888+ String_Append(fsrc, op_destoutdestblend);
 889+ else String_Append(fsrc, op_destout);
885890 String_Append(fsrc, mainend);
886891 #ifdef _DEBUG
887892 OutputDebugStringA("2D blitter fragment shader:\n");
Index: ddraw/ShaderManager.cpp
@@ -30,30 +30,58 @@
3131 const char frag_Texture[] = "\
3232 #version 110\n\
3333 uniform sampler2D tex0;\n\
34 -void main() \n\
35 -{ \n\
36 - gl_FragColor = texture2D( tex0, gl_TexCoord[0].st ); \n\
37 -} ";
 34+void main()\n\
 35+{\n\
 36+ gl_FragColor = texture2D( tex0, gl_TexCoord[0].st);\n\
 37+}";
3838
3939 const char frag_Pal256[] = "\
4040 #version 110\n\
41 -uniform sampler2D pal; \n\
42 -uniform sampler2D tex0; \n\
43 -void main() \n\
44 -{ \n\
45 - vec4 myindex = texture2D(tex0, gl_TexCoord[0].xy); \n\
 41+uniform sampler2D pal;\n\
 42+uniform sampler2D tex0;\n\
 43+void main()\n\
 44+{\n\
 45+ vec4 myindex = texture2D(tex0, gl_TexCoord[0].xy);\n\
4646 vec2 index = vec2(((myindex.x*(255.0/256.0))+(0.5/256.0)),0.5);\n\
47 - vec4 texel = texture2D(pal, index); \n\
48 - gl_FragColor = texel; \n\
49 -} ";
 47+ vec4 texel = texture2D(pal, index);\n\
 48+ gl_FragColor = texel;\n\
 49+}";
5050
5151 const char frag_clipstencil[] = "\
5252 #version 110\n\
53 -void main (void)\n\
 53+void main ()\n\
5454 {\n\
55 - gl_FragColor = vec4(1.0,0.0,0.0,0.0);\n\
56 -} ";
 55+ gl_FragColor = vec4(1.0,0.0,0.0,0.0);\n\
 56+}";
5757
 58+const char frag_prepsrckey[] = "\
 59+#version 110\n\
 60+uniform sampler2D tex0;\n\
 61+uniform ivec3 ckey;\n\
 62+uniform ivec4 colorsize;\n\
 63+ivec4 pixel;\n\
 64+void main()\n\
 65+{\n\
 66+ pixel = ivec4(texture2D(tex0, gl_TexCoord[0].st)*vec4(colorsize) + .5);\n\
 67+ if (pixel.rgb == ckey) pixel.a = 0;\n\
 68+ else pixel.a = colorsize.a;\n\
 69+ gl_FragColor = vec4(pixel) / vec4(colorsize);\n\
 70+}";
 71+
 72+const char frag_prepdestkey[] = "\
 73+#version 110\n\
 74+uniform sampler2D tex0;\n\
 75+uniform ivec4 colorsize;\n\
 76+uniform ivec3 ckey;\n\
 77+ivec4 pixel;\n\
 78+void main()\n\
 79+{\n\
 80+ pixel = ivec4(texture2D(tex0, gl_TexCoord[0].st)*vec4(colorsize) + .5);\n\
 81+ if (pixel.rgb != ckey) pixel.a = 0;\n\
 82+ else pixel.a = colorsize.a;\n\
 83+ gl_FragColor = vec4(pixel) / vec4(colorsize);\n\
 84+}";
 85+
5886 const char vert_ortho[] = "\
5987 #version 110\n\
6088 uniform vec4 view;\n\
@@ -78,9 +106,11 @@
79107 const int SHADER_START = __LINE__;
80108 const SHADER shader_template[] =
81109 {
82 - {0,0, vert_ortho, frag_Texture, 0,-1,-1,-1},
83 - {0,0, vert_ortho, frag_Pal256, 0,-1,-1,-1},
84 - {0,0, vert_ortho, frag_clipstencil, 0,-1,-1,-1}
 110+ {0,0, vert_ortho, frag_Texture, 0,-1,-1,-1,-1,-1,-1,-1,-1},
 111+ {0,0, vert_ortho, frag_Pal256, 0,-1,-1,-1,-1,-1,-1,-1,-1},
 112+ {0,0, vert_ortho, frag_clipstencil, 0,-1,-1,-1,-1,-1,-1,-1,-1},
 113+ {0,0, vert_ortho, frag_prepsrckey, 0,-1,-1,-1,-1,-1,-1,-1,-1},
 114+ {0,0, vert_ortho, frag_prepdestkey, 0,-1,-1,-1,-1,-1,-1,-1,-1}
85115 };
86116 const int SHADER_END = __LINE__ - 4;
87117 const int NumberOfShaders = SHADER_END - SHADER_START;
@@ -120,6 +150,7 @@
121151 shaderman->shaders[i].tex0 = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog,"tex0");
122152 shaderman->shaders[i].tex1 = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog,"tex1");
123153 shaderman->shaders[i].ckey = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog,"ckey");
 154+ shaderman->shaders[i].colorsize = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog, "colorsize");
124155 shaderman->shaders[i].pal = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog,"pal");
125156 shaderman->shaders[i].view = shaderman->ext->glGetUniformLocation(shaderman->shaders[i].prog,"view");
126157 }
Index: ddraw/glRenderer.cpp
@@ -3035,7 +3035,7 @@
30363036 BOOL usepattern = FALSE;
30373037 LONG sizes[6];
30383038 RECT srcrect;
3039 - RECT destrect;
 3039+ RECT destrect, destrect2;
30403040 This->ddInterface->GetSizes(sizes);
30413041 DWORD shaderid;
30423042 DDSURFACEDESC2 ddsd;
@@ -3046,8 +3046,16 @@
30473047 destrect.top = 0;
30483048 destrect.right = ddsd.dwWidth;
30493049 destrect.bottom = ddsd.dwHeight;
 3050+ destrect2 = destrect;
30503051 }
3051 - else destrect = cmd->destrect;
 3052+ else
 3053+ {
 3054+ destrect = cmd->destrect;
 3055+ destrect2.left = 0;
 3056+ destrect2.top = 0;
 3057+ destrect2.right = destrect.right - destrect.left;
 3058+ destrect2.bottom = destrect.bottom - destrect.top;
 3059+ }
30523060 if ((cmd->bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->flags & DDBLT_ROP))
30533061 {
30543062 shaderid = PackROPBits(cmd->bltfx.dwROP, cmd->flags);
@@ -3056,14 +3064,19 @@
30573065 }
30583066 else shaderid = cmd->flags & 0xF2FAADFF;
30593067 if (cmd->flags & DDBLT_KEYDEST) usedest = TRUE;
3060 - if (usedest)
 3068+ if (IsAlphaCKey())
30613069 {
 3070+
 3071+ }
 3072+ else if (usedest)
 3073+ {
 3074+ if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
30623075 ShaderManager_SetShader(This->shaders, PROG_TEXTURE, NULL, 0);
3063 - glRenderer__DrawBackbufferRect(This, cmd->dest, destrect, PROG_TEXTURE);
 3076+ glRenderer__DrawBackbufferRect(This, cmd->dest, destrect, destrect2, PROG_TEXTURE);
30643077 This->bltvertices[1].dests = This->bltvertices[3].dests = 0.;
30653078 This->bltvertices[0].dests = This->bltvertices[2].dests = (GLfloat)(destrect.right - destrect.left) / (GLfloat)This->backbuffer->levels[0].ddsd.dwWidth;
30663079 This->bltvertices[0].destt = This->bltvertices[1].destt = 1.;
3067 - This->bltvertices[2].destt = This->bltvertices[3].destt = 1.0-((GLfloat)(destrect.bottom - destrect.top) / (GLfloat)This->backbuffer->levels[0].ddsd.dwHeight);
 3080+ This->bltvertices[2].destt = This->bltvertices[3].destt = 1.0 - ((GLfloat)(destrect.bottom - destrect.top) / (GLfloat)This->backbuffer->levels[0].ddsd.dwHeight);
30683081 }
30693082 ShaderManager_SetShader(This->shaders, shaderid, NULL, 1);
30703083 GenShader2D *shader = (GenShader2D*)This->shaders->gen3d->current_genshader;
@@ -3287,32 +3300,36 @@
32883301 glUtil_SetFBO(This->util, NULL);
32893302 }
32903303
3291 -void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype)
 3304+void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, RECT destrect, int progtype)
32923305 {
32933306 GLfloat view[4];
32943307 DDSURFACEDESC2 ddsd;
3295 - int x = srcrect.right - srcrect.left;
3296 - int y = srcrect.bottom - srcrect.top;
 3308+ int x1 = destrect.left;
 3309+ int x2 = destrect.right;
 3310+ int y1 = destrect.top;
 3311+ int y2 = destrect.bottom;
32973312 glUtil_SetActiveTexture(This->util, 0);
32983313 if (!This->backbuffer)
32993314 {
33003315 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
33013316 memcpy(&ddsd, &ddsdbackbuffer, sizeof(DDSURFACEDESC2));
3302 - ddsd.dwWidth = x;
3303 - ddsd.lPitch = x * 4;
3304 - ddsd.dwHeight = y;
3305 - glTexture_Create(&ddsd, &This->backbuffer, This, x, y, FALSE, TRUE);
 3317+ ddsd.dwWidth = x2;
 3318+ ddsd.lPitch = x2 * 4;
 3319+ ddsd.dwHeight = y2;
 3320+ glTexture_Create(&ddsd, &This->backbuffer, This, x2, y2, FALSE, TRUE);
33063321 }
3307 - if ((This->backbuffer->levels[0].ddsd.dwWidth < x) || (This->backbuffer->levels[0].ddsd.dwHeight < y))
 3322+ if ((This->backbuffer->levels[0].ddsd.dwWidth < x2) || (This->backbuffer->levels[0].ddsd.dwHeight < y2))
33083323 {
3309 - if (This->backbuffer->levels[0].ddsd.dwWidth > x) x = This->backbuffer->levels[0].ddsd.dwWidth;
3310 - if (This->backbuffer->levels[0].ddsd.dwHeight > y) y = This->backbuffer->levels[0].ddsd.dwHeight;
 3324+ if (This->backbuffer->levels[0].ddsd.dwWidth > x2) x2 = This->backbuffer->levels[0].ddsd.dwWidth;
 3325+ if (This->backbuffer->levels[0].ddsd.dwHeight > y2) y2 = This->backbuffer->levels[0].ddsd.dwHeight;
33113326 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
33123327 ddsd.dwSize = sizeof(DDSURFACEDESC2);
3313 - ddsd.dwWidth = x;
3314 - ddsd.dwHeight = y;
 3328+ ddsd.dwWidth = x2;
 3329+ ddsd.dwHeight = y2;
33153330 ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
33163331 glTexture__SetSurfaceDesc(This->backbuffer, &ddsd);
 3332+ x2 = destrect.right;
 3333+ y2 = destrect.bottom;
33173334 }
33183335 glUtil_SetFBOTextures(This->util, &This->fbo, This->backbuffer, NULL, 0, 0, FALSE);
33193336 view[0] = view[2] = 0;
@@ -3328,10 +3345,10 @@
33293346 This->bltvertices[0].s = This->bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)texture->levels[0].ddsd.dwWidth;
33303347 This->bltvertices[0].t = This->bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)texture->levels[0].ddsd.dwHeight;
33313348 This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)texture->levels[0].ddsd.dwHeight;
3332 - This->bltvertices[1].x = This->bltvertices[3].x = 0.;
3333 - This->bltvertices[0].x = This->bltvertices[2].x = (float)x;
3334 - This->bltvertices[0].y = This->bltvertices[1].y = 0.;
3335 - This->bltvertices[2].y = This->bltvertices[3].y = (float)y;
 3349+ This->bltvertices[1].x = This->bltvertices[3].x = (float)x1;
 3350+ This->bltvertices[0].x = This->bltvertices[2].x = (float)x2;
 3351+ This->bltvertices[0].y = This->bltvertices[1].y = (float)y1;
 3352+ This->bltvertices[2].y = This->bltvertices[3].y = (float)y2;
33363353 glUtil_EnableArray(This->util, This->shaders->shaders[progtype].pos, TRUE);
33373354 This->ext->glVertexAttribPointer(This->shaders->shaders[progtype].pos, 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].x);
33383355 glUtil_EnableArray(This->util, This->shaders->shaders[progtype].texcoord, TRUE);
Index: ddraw/glRenderer.h
@@ -208,7 +208,7 @@
209209 void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous, BOOL setsync);
210210 void glRenderer__DeleteTexture(glRenderer *This, glTexture *texture);
211211 void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype, BOOL paletted, BOOL firstpass);
212 -void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype);
 212+void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, RECT destrect, int progtype);
213213 void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y);
214214 void glRenderer__Clear(glRenderer *This, ClearCommand *cmd);
215215 void glRenderer__UpdateFVF(glRenderer *This, DWORD fvf);
Index: ddraw/struct.h
@@ -337,6 +337,7 @@
338338 GLint tex0;
339339 GLint tex1;
340340 GLint ckey;
 341+ GLint colorsize;
341342 GLint pal;
342343 GLint view;
343344 } SHADER;
Index: ddraw/util.c
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2013-2016 William Feely
 3+// Copyright (C) 2013-2017 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -15,8 +15,6 @@
1616 // License along with this library; if not, write to the Free Software
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
19 -// Note: Requires a SSE2 and AVX compatible compiler.
20 -
2119 #include "common.h"
2220 #include "util.h"
2321 #include "const.h"
@@ -137,6 +135,7 @@
138136 {0,0}, // ddckDestColorkey
139137 {0,0} // ddckSrcColorkey
140138 };
 139+
141140 BOOL comp_bltfx(DDBLTFX *a, DDBLTFX *b, DWORD flags)
142141 {
143142 DDBLTFX comp_mask;
@@ -158,4 +157,11 @@
159158 AndMem(&comp_b, b, &comp_mask, sizeof(DDBLTFX));
160159 if (!memcmp(&comp_a, &comp_b, sizeof(DDBLTFX))) return FALSE;
161160 else return TRUE;
 161+}
 162+
 163+BOOL IsAlphaCKey()
 164+{
 165+ if ((dxglcfg.BltScale == 2) || (dxglcfg.BltScale == 3) || (dxglcfg.BltScale == 4))
 166+ return TRUE;
 167+ else return FALSE;
162168 }
\ No newline at end of file
Index: ddraw/util.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2013-2016 William Feely
 3+// Copyright (C) 2013-2017 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,7 @@
2828 char IsWritablePointer(void *ptr, LONG_PTR size, BOOL preserve);
2929 void AndMem(void *dest, const void *a, const void *b, size_t size);
3030 BOOL comp_bltfx(DDBLTFX *a, DDBLTFX *b, DWORD flags);
 31+BOOL IsAlphaCKey();
3132
3233 #ifdef __cplusplus
3334 }
Index: dxgl-example.ini
@@ -193,8 +193,9 @@
194194 ; The following values are valid:
195195 ; 0 - Nearest-neighbor stretching
196196 ; 1 - Bilinear interpolation
197 -; 2 - Bilinear interpolation, sharp color key
198 -; 3 - Bilinear interpolation, soft color key
 197+; 2 - Bilinear interpolation, nearest-neighbor color key
 198+; 3 - Bilinear interpolation, sharp color key
 199+; 4 - Bilinear interpolation, soft color key
199200 BltScale = 0
200201
201202 ; BltThreshold - Integer
@@ -482,6 +483,14 @@
483484 ; Default is false
484485 DebugNoGLSL130 = false
485486
 487+; DebugBlendDestColorKey - Boolean
 488+; Blends the temporary texture used for destination color keying with the
 489+; source. This can reveal if the temporary texture is aligning correctly
 490+; with the destination coordinates being used for a Blt operation. This
 491+; should only be enabled for development and regression testing purposes.
 492+; Default is false
 493+DebugBlendDestColorKey = false
 494+
486495 ; DebugMaxGLVersionMajor - Integer
487496 ; Determines the maximum OpenGL major version available to DXGL.
488497 ; If the system has a lower OpenGL version that will take precedence.
Index: dxgl.sln
@@ -1,6 +1,8 @@
22 
3 -Microsoft Visual Studio Solution File, Format Version 11.00
4 -# Visual C++ Express 2010
 3+Microsoft Visual Studio Solution File, Format Version 12.00
 4+# Visual Studio 15
 5+VisualStudioVersion = 15.0.27130.2010
 6+MinimumVisualStudioVersion = 10.0.40219.1
57 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ddraw", "ddraw\ddraw.vcxproj", "{9F051466-EA2C-4195-80B1-1B7C5B3F4AC2}"
68 ProjectSection(ProjectDependencies) = postProject
79 {F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE}
@@ -38,11 +40,11 @@
3941 EndProject
4042 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Installer", "Installer\Installer.vcxproj", "{4DC98095-5F42-4A44-962C-346ABEE2C9B6}"
4143 ProjectSection(ProjectDependencies) = postProject
 44+ {C59AC409-F7D0-4153-9874-184CA00D537B} = {C59AC409-F7D0-4153-9874-184CA00D537B}
4245 {8041FD11-3A2E-4EE9-A3FF-A9755803B7FB} = {8041FD11-3A2E-4EE9-A3FF-A9755803B7FB}
4346 {9F051466-EA2C-4195-80B1-1B7C5B3F4AC2} = {9F051466-EA2C-4195-80B1-1B7C5B3F4AC2}
4447 {3A14A469-504B-4E32-8F23-063F8A2A8B5D} = {3A14A469-504B-4E32-8F23-063F8A2A8B5D}
4548 {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0} = {34883A93-DFE4-42EF-9DAE-BEE4D3FC87D0}
46 - {DF380DA1-90DE-4174-9A1F-EEC16C5B5879} = {DF380DA1-90DE-4174-9A1F-EEC16C5B5879}
4749 {F822EDB0-63E2-4EB8-B80D-F72481CDE3E1} = {F822EDB0-63E2-4EB8-B80D-F72481CDE3E1}
4850 EndProjectSection
4951 EndProject
@@ -211,4 +213,7 @@
212214 GlobalSection(SolutionProperties) = preSolution
213215 HideSolutionNode = FALSE
214216 EndGlobalSection
 217+ GlobalSection(ExtensibilityGlobals) = postSolution
 218+ SolutionGuid = {8D61F2B9-4A44-441A-AE4C-9C589C9290B8}
 219+ EndGlobalSection
215220 EndGlobal
Index: dxglcfg/dxglcfg.cpp
@@ -2006,7 +2006,11 @@
20072007 *value = cfg->DebugNoGLSL130;
20082008 *mask = cfgmask->DebugNoGLSL130;
20092009 break;
2010 - /*case 8:
 2010+ case 8:
 2011+ *value = cfg->DebugBlendDestColorKey;
 2012+ *mask = cfgmask->DebugBlendDestColorKey;
 2013+ break;
 2014+ /*case 9:
20112015 *value = cfg->DebugDisableErrors;
20122016 *mask = cfgmask->DebugDisableErrors;
20132017 break;*/
@@ -2053,7 +2057,11 @@
20542058 cfg->DebugNoGLSL130 = value;
20552059 cfgmask->DebugNoGLSL130 = mask;
20562060 break;
2057 - /*case 8:
 2061+ case 8:
 2062+ cfg->DebugBlendDestColorKey = value;
 2063+ cfgmask->DebugBlendDestColorKey = mask;
 2064+ break;
 2065+ /*case 9:
20582066 cfg->DebugDisableErrors = value;
20592067 cfgmask->DebugDisableErrors = mask;
20602068 break;*/
@@ -2679,10 +2687,12 @@
26802688 SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 0, (LPARAM)buffer);
26812689 _tcscpy(buffer, _T("Bilinear"));
26822690 SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 1, (LPARAM)buffer);
 2691+ _tcscpy(buffer, _T("Bilinear, nearest colorkey"));
 2692+ SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 2, (LPARAM)buffer);
26832693 _tcscpy(buffer, _T("Bilinear, sharp colorkey"));
2684 - SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 2, (LPARAM)buffer);
 2694+ SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 3, (LPARAM)buffer);
26852695 _tcscpy(buffer, _T("Bilinear, soft colorkey"));
2686 - SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 3, (LPARAM)buffer);
 2696+ SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_ADDSTRING, 4, (LPARAM)buffer);
26872697 SendDlgItemMessage(hTabs[1], IDC_BLTFILTER, CB_SETCURSEL, cfg->BltScale, 0);
26882698 // Blt scaling threshold
26892699 SendDlgItemMessage(hTabs[1], IDC_BLTTHRESHOLDSLIDER, TBM_SETRANGE, 0, 0xFE0000);
@@ -2909,6 +2919,8 @@
29102920 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
29112921 _tcscpy(buffer, _T("Disable GLSL 1.30 support"));
29122922 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
 2923+ _tcscpy(buffer, _T("DEBUG: Blend destination color key texture with source"));
 2924+ SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);
29132925 /*_tcscpy(buffer, _T("Disable OpenGL errors (OpenGL 4.6+)"));
29142926 SendDlgItemMessage(hTabs[4], IDC_DEBUGLIST, LB_ADDSTRING, 0, (LPARAM)buffer);*/
29152927 // Max OpenGL