Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -51,8 +51,8 @@ |
52 | 52 | Bit 26: ROP index bit 6
|
53 | 53 | Bit 27: ROP index bit 7
|
54 | 54 | Bit 28: (DXGL) Use Clipper
|
55 | | -Bit 29: reserved for DXGL usage
|
56 | | -Bit 30: reserved for DXGL usage
|
| 55 | +Bit 29: (DXGL) Source color key range
|
| 56 | +Bit 30: (DXGL) Dest. color key range
|
57 | 57 | Bit 31: reserved for DXGL usage
|
58 | 58 | AND the dwFlags by 0xF2FAADFF before packing ROP index bits
|
59 | 59 | */
|
— | — | @@ -164,6 +164,8 @@ |
165 | 165 | static const char unif_stenciltex[] = "uniform sampler2D stenciltex;\n";
|
166 | 166 | static const char unif_ckeysrc[] = "uniform ivec3 ckeysrc;\n";
|
167 | 167 | static const char unif_ckeydest[] = "uniform ivec3 ckeydest;\n";
|
| 168 | +static const char unif_ckeysrchigh[] = "uniform ivec3 ckeysrchigh;\n";
|
| 169 | +static const char unif_ckeydesthigh[] = "uniform ivec3 ckeydesthigh;\n";
|
168 | 170 | static const char unif_patternsize[] = "uniform ivec2 patternsize;\n";
|
169 | 171 | static const char unif_colorsizesrc[] = "uniform ivec4 colorsizesrc;\n";
|
170 | 172 | static const char unif_colorsizedest[] = "uniform ivec4 colorsizedest;\n";
|
— | — | @@ -197,9 +199,13 @@ |
198 | 200 | static const char op_texcoord0[] = "gl_TexCoord[0] = vec4(srcst,0.0,1.0);\n";
|
199 | 201 | static const char op_texcoord1[] = "gl_TexCoord[1] = vec4(destst,0.0,1.0);\n";
|
200 | 202 | static const char op_texcoord3[] = "gl_TexCoord[3] = vec4(stencilst,0.0,1.0);\n";
|
201 | | -static const char op_ckeysrc[] = "if(pixel.rgb == ckeysrc) discard;\n";
|
| 203 | +static const char op_ckeysrc[] = "if(src.rgb == ckeysrc) discard;\n";
|
202 | 204 | static const char op_ckeydest[] = "if(dest.rgb != ckeydest) discard;\n";
|
203 | | -static const char op_clip[] = "if(texture2D(stenciltex, gl_TexCoord[3].st).r < .5) discard;";
|
| 205 | +static const char op_ckeysrcrange[] = "if(!((src.r < ckeysrc.r) || (src.g < ckeysrc.g) || (src.b < ckeysrc.b) ||\
|
| 206 | + (src.r > ckeysrchigh.r) || (src.g > ckeysrchigh.g) || (src.b > ckeysrchigh.b))) discard;\n";
|
| 207 | +static const char op_ckeydestrange[] = "if((dest.r < ckeydest.r) || (dest.g < ckeydest.g) || (dest.b < ckeydest.b) ||\
|
| 208 | + (dest.r > ckeydesthigh.r) || (dest.g > ckeydesthigh.g) || (dest.b > ckeydesthigh.b)) discard;\n";
|
| 209 | +static const char op_clip[] = "if(texture2D(stenciltex, gl_TexCoord[3].st).r < .5) discard;\n";
|
204 | 210 |
|
205 | 211 | // Functions
|
206 | 212 |
|
— | — | @@ -906,10 +912,15 @@ |
907 | 913 | if (id & DDBLT_KEYSRC)
|
908 | 914 | {
|
909 | 915 | String_Append(fsrc, unif_ckeysrc);
|
| 916 | + if (id & 0x20000000) String_Append(fsrc, unif_ckeysrchigh);
|
910 | 917 | String_Append(fsrc, unif_colorsizesrc);
|
911 | 918 | }
|
912 | 919 | String_Append(fsrc, unif_colorsizedest);
|
913 | | - if (id & DDBLT_KEYDEST) String_Append(fsrc, unif_ckeydest);
|
| 920 | + if (id & DDBLT_KEYDEST)
|
| 921 | + {
|
| 922 | + String_Append(fsrc, unif_ckeydest);
|
| 923 | + if (id & 0x40000000) String_Append(fsrc, unif_ckeydesthigh);
|
| 924 | + }
|
914 | 925 |
|
915 | 926 | // Variables
|
916 | 927 | String_Append(fsrc, var_pixel);
|
— | — | @@ -931,8 +942,16 @@ |
932 | 943 | else String_Append(fsrc, op_pixel);
|
933 | 944 | if (id & DDBLT_KEYSRC) String_Append(fsrc, op_src);
|
934 | 945 | if (usedest) String_Append(fsrc, op_dest);
|
935 | | - if (id & DDBLT_KEYSRC) String_Append(fsrc, op_ckeysrc);
|
936 | | - if (id & DDBLT_KEYDEST) String_Append(fsrc, op_ckeydest);
|
| 946 | + if (id & DDBLT_KEYSRC)
|
| 947 | + {
|
| 948 | + if (id & 0x20000000) String_Append(fsrc, op_ckeysrcrange);
|
| 949 | + else String_Append(fsrc, op_ckeysrc);
|
| 950 | + }
|
| 951 | + if (id & DDBLT_KEYDEST)
|
| 952 | + {
|
| 953 | + if (id & 0x40000000) String_Append(fsrc, op_ckeydestrange);
|
| 954 | + else String_Append(fsrc, op_ckeydest);
|
| 955 | + }
|
937 | 956 | if (id & DDBLT_ROP)
|
938 | 957 | {
|
939 | 958 | if (rop_texture_usage[rop] & 4) String_Append(fsrc, op_pattern);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -613,6 +613,7 @@ |
614 | 614 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
615 | 615 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
616 | 616 | if((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 617 | + if((dwFlags & DDBLT_DDFX) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
617 | 618 | if (dwFlags & DDBLT_ROP)
|
618 | 619 | {
|
619 | 620 | if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
— | — | @@ -627,6 +628,12 @@ |
628 | 629 | pattern->ddsd.ddpfPixelFormat.dwRGBBitCount);
|
629 | 630 | }
|
630 | 631 | }
|
| 632 | + if (dwFlags & DDBLT_KEYSRC)
|
| 633 | + {
|
| 634 | + if (!lpDDSrcSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 635 | + if (((glDirectDrawSurface7*)lpDDSrcSurface)->colorkey[0].colorspace) dwFlags |= 0x20000000;
|
| 636 | + }
|
| 637 | + if ((dwFlags & DDBLT_KEYDEST) && colorkey[1].colorspace) dwFlags |= 0x40000000;
|
631 | 638 | glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
|
632 | 639 | if(dirty & 1)
|
633 | 640 | {
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -1191,12 +1191,20 @@ |
1192 | 1192 | if (dwFlags & DDBLT_COLORFILL) SetColorFillUniform(lpDDBltFx->dwFillColor, dest->texture->colorsizes,
|
1193 | 1193 | dest->texture->colororder, dest->texture->colorbits, shader->shader.uniforms[12], This->ext);
|
1194 | 1194 | if ((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
| 1195 | + {
|
1195 | 1196 | SetColorKeyUniform(src->colorkey[0].key.dwColorSpaceLowValue, src->texture->colorsizes,
|
1196 | | - src->texture->colororder, shader->shader.uniforms[5], src->texture->colorbits, This->ext);
|
| 1197 | + src->texture->colororder, shader->shader.uniforms[5], src->texture->colorbits, This->ext);
|
| 1198 | + if (dwFlags & 0x20000000) SetColorKeyUniform(src->colorkey[0].key.dwColorSpaceHighValue, src->texture->colorsizes,
|
| 1199 | + src->texture->colororder, shader->shader.uniforms[7], src->texture->colorbits, This->ext);
|
| 1200 | + }
|
1197 | 1201 | if (!(dwFlags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 0);
|
1198 | 1202 | if ((dwFlags & DDBLT_KEYDEST) && (This && dest->colorkey[1].enabled))
|
| 1203 | + {
|
1199 | 1204 | SetColorKeyUniform(dest->colorkey[1].key.dwColorSpaceLowValue, dest->texture->colorsizes,
|
1200 | | - dest->texture->colororder, shader->shader.uniforms[6], dest->texture->colorbits, This->ext);
|
| 1205 | + dest->texture->colororder, shader->shader.uniforms[6], dest->texture->colorbits, This->ext);
|
| 1206 | + if(dwFlags & 0x40000000) SetColorKeyUniform(dest->colorkey[1].key.dwColorSpaceHighValue, dest->texture->colorsizes,
|
| 1207 | + dest->texture->colororder, shader->shader.uniforms[8], dest->texture->colorbits, This->ext);
|
| 1208 | + }
|
1201 | 1209 | if (usedest && (shader->shader.uniforms[2] != -1))
|
1202 | 1210 | {
|
1203 | 1211 | TextureManager_SetTexture(This->texman, 1, This->backbuffer);
|