Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -116,25 +116,25 @@ |
117 | 117 | };
|
118 | 118 |
|
119 | 119 | const DWORD supported_rops[8] = {
|
120 | | - 0x00000001,
|
| 120 | + 0x00008001,
|
121 | 121 | 0x00080000,
|
| 122 | + 0x00200000,
|
122 | 123 | 0x00000000,
|
123 | 124 | 0x00000000,
|
124 | | - 0x00000000,
|
125 | 125 | 0x00000400,
|
126 | 126 | 0x00001000,
|
127 | | - 0x80000000
|
| 127 | + 0x80010000
|
128 | 128 | };
|
129 | 129 |
|
130 | 130 | const DWORD supported_rops_gl2[8] = {
|
131 | | - 0x00000001,
|
| 131 | + 0x00008001,
|
132 | 132 | 0x00080000,
|
| 133 | + 0x00200000,
|
133 | 134 | 0x00000000,
|
134 | 135 | 0x00000000,
|
135 | | - 0x00000000,
|
136 | 136 | 0x00000400,
|
137 | 137 | 0x00001000,
|
138 | | - 0x80000000
|
| 138 | + 0x80010000
|
139 | 139 | };
|
140 | 140 |
|
141 | 141 | static const char revheader[] =
|
— | — | @@ -164,6 +164,7 @@ |
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_patternsize[] = "uniform ivec2 patternsize;\n";
|
168 | 169 |
|
169 | 170 |
|
170 | 171 | // Variables
|
— | — | @@ -170,12 +171,15 @@ |
171 | 172 | static const char var_dest[] = "ivec4 dest;\n";
|
172 | 173 | static const char var_pattern[] = "ivec4 pattern;\n";
|
173 | 174 | static const char var_pixel[] = "ivec4 pixel;\n";
|
| 175 | +static const char var_patternst[] = "vec2 patternst;\n";
|
174 | 176 |
|
175 | 177 | // Operations
|
176 | 178 | static const char op_src[] = "pixel = ivec4(texture2D(srctex,gl_TexCoord[0].st)*255.0);\n";
|
177 | 179 | static const char op_color[] = "pixel = ivec4(gl_Color*255.0);\n";
|
178 | 180 | static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*255.0);\n";
|
179 | | -static const char op_pattern[] = "pattern = ivec4(texture2D(patterntex,gl_TexCoord[2].st)*255.0);\n";
|
| 181 | +static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
|
| 182 | +mod(gl_FragCoord.y, float(patternsize.y)) / float(patternsize.y));\n\
|
| 183 | +pattern = ivec4(texture2D(patterntex,patternst)*255.0);\n";
|
180 | 184 | static const char op_destout[] = "gl_FragColor = vec4(pixel)/255.0;\n";
|
181 | 185 | static const char op_vertex[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
|
182 | 186 | mat4 proj = mat4(\n\
|
— | — | @@ -211,7 +215,7 @@ |
212 | 216 | "",
|
213 | 217 | "",
|
214 | 218 | "",
|
215 | | -"",//0F
|
| 219 | +"pixel = pattern ^ ivec4(255);\n",//0F
|
216 | 220 | "",//10
|
217 | 221 | "",
|
218 | 222 | "",
|
— | — | @@ -281,6 +285,7 @@ |
282 | 286 | "",
|
283 | 287 | "",
|
284 | 288 | "",
|
| 289 | +"pixel = dest ^ ivec4(255);\n",//55 DSTINVERT
|
285 | 290 | "",
|
286 | 291 | "",
|
287 | 292 | "",
|
— | — | @@ -290,7 +295,6 @@ |
291 | 296 | "",
|
292 | 297 | "",
|
293 | 298 | "",
|
294 | | -"",
|
295 | 299 | "",//5F
|
296 | 300 | "",//60
|
297 | 301 | "",
|
— | — | @@ -436,7 +440,7 @@ |
437 | 441 | "",
|
438 | 442 | "",
|
439 | 443 | "",//EF
|
440 | | -"",//F0
|
| 444 | +"pixel = pattern;\n",//F0 PATCOPY
|
441 | 445 | "",
|
442 | 446 | "",
|
443 | 447 | "",
|
— | — | @@ -470,7 +474,7 @@ |
471 | 475 | "",
|
472 | 476 | "",
|
473 | 477 | "",
|
474 | | -"",//0F
|
| 478 | +"pixel = ivec4(255) - pattern;\n",//0F
|
475 | 479 | "",//10
|
476 | 480 | "",
|
477 | 481 | "",
|
— | — | @@ -540,6 +544,7 @@ |
541 | 545 | "",
|
542 | 546 | "",
|
543 | 547 | "",
|
| 548 | +"pixel = ivec4(255) - dest;\n",//55 DSTINVERT
|
544 | 549 | "",
|
545 | 550 | "",
|
546 | 551 | "",
|
— | — | @@ -549,7 +554,6 @@ |
550 | 555 | "",
|
551 | 556 | "",
|
552 | 557 | "",
|
553 | | -"",
|
554 | 558 | "",//5F
|
555 | 559 | "",//60
|
556 | 560 | "",
|
— | — | @@ -695,7 +699,7 @@ |
696 | 700 | "",
|
697 | 701 | "",
|
698 | 702 | "",//EF
|
699 | | -"",//F0
|
| 703 | +"pixel = pattern;\n",//F0 PATCOPY
|
700 | 704 | "",
|
701 | 705 | "",
|
702 | 706 | "",
|
— | — | @@ -881,6 +885,11 @@ |
882 | 886 | if (id & DDBLT_ROP)
|
883 | 887 | {
|
884 | 888 | if (rop_texture_usage[rop] & 2) String_Append(fsrc, unif_desttex);
|
| 889 | + if (rop_texture_usage[rop] & 4)
|
| 890 | + {
|
| 891 | + String_Append(fsrc, unif_patterntex);
|
| 892 | + String_Append(fsrc, unif_patternsize);
|
| 893 | + }
|
885 | 894 | }
|
886 | 895 | if (id & 0x10000000) String_Append(fsrc, unif_stenciltex);
|
887 | 896 | if (id & DDBLT_KEYSRC) String_Append(fsrc, unif_ckeysrc);
|
— | — | @@ -890,6 +899,11 @@ |
891 | 900 | if (id & DDBLT_ROP)
|
892 | 901 | {
|
893 | 902 | if (rop_texture_usage[rop] & 2) String_Append(fsrc, var_dest);
|
| 903 | + if (rop_texture_usage[rop] & 4)
|
| 904 | + {
|
| 905 | + String_Append(fsrc, var_pattern);
|
| 906 | + String_Append(fsrc, var_patternst);
|
| 907 | + }
|
894 | 908 | }
|
895 | 909 |
|
896 | 910 | // Main
|
— | — | @@ -901,6 +915,7 @@ |
902 | 916 | if (id & DDBLT_ROP)
|
903 | 917 | {
|
904 | 918 | if (rop_texture_usage[rop] & 2) String_Append(fsrc, op_dest);
|
| 919 | + if (rop_texture_usage[rop] & 4) String_Append(fsrc, op_pattern);
|
905 | 920 | if (intproc) String_Append(fsrc, op_ROP[rop]);
|
906 | 921 | else String_Append(fsrc, op_ROP_float[rop]);
|
907 | 922 | }
|
— | — | @@ -957,4 +972,5 @@ |
958 | 973 | gen->genshaders2D[index].shader.uniforms[4] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "stenciltex");
|
959 | 974 | gen->genshaders2D[index].shader.uniforms[5] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "ckeysrc");
|
960 | 975 | gen->genshaders2D[index].shader.uniforms[6] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "ckeydest");
|
| 976 | + gen->genshaders2D[index].shader.uniforms[7] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "patternsize");
|
961 | 977 | } |
\ No newline at end of file |
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -609,10 +609,24 @@ |
610 | 610 | {
|
611 | 611 | HRESULT error;
|
612 | 612 | RECT tmprect;
|
| 613 | + glDirectDrawSurface7 *pattern;
|
613 | 614 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
614 | 615 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
615 | 616 | if((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
616 | | - if((dwFlags & DDBLT_ROP) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 617 | + if (dwFlags & DDBLT_ROP)
|
| 618 | + {
|
| 619 | + if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 620 | + if ((rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4))
|
| 621 | + {
|
| 622 | + if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 623 | + pattern = (glDirectDrawSurface7*)lpDDBltFx->lpDDSPattern;
|
| 624 | + if (pattern->dirty & 1)
|
| 625 | + glRenderer_UploadTexture(ddInterface->renderer, pattern->buffer, pattern->bigbuffer, pattern->texture,
|
| 626 | + pattern->ddsd.dwWidth, pattern->ddsd.dwHeight, pattern->fakex, pattern->fakey, pattern->ddsd.lPitch,
|
| 627 | + (NextMultipleOf4((ddInterface->GetBPPMultipleOf8() / 8)*pattern->fakex)),
|
| 628 | + pattern->ddsd.ddpfPixelFormat.dwRGBBitCount);
|
| 629 | + }
|
| 630 | + }
|
617 | 631 | glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
|
618 | 632 | if(dirty & 1)
|
619 | 633 | {
|
— | — | @@ -1598,6 +1612,20 @@ |
1599 | 1613 | {
|
1600 | 1614 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,14,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
1601 | 1615 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 1616 | + DDBLTFX bltfx;
|
| 1617 | + if (dwFlags & DDBLT_ROP)
|
| 1618 | + {
|
| 1619 | + if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1620 | + bltfx = *lpDDBltFx;
|
| 1621 | + if ((rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4))
|
| 1622 | + {
|
| 1623 | + if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1624 | + glDirectDrawSurface1 *pattern = (glDirectDrawSurface1*)lpDDBltFx->lpDDSPattern;
|
| 1625 | + bltfx.lpDDSPattern = (LPDIRECTDRAWSURFACE)pattern->GetDDS7();
|
| 1626 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface1*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, &bltfx)) }
|
| 1627 | + else TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, NULL, lpSrcRect, dwFlags, &bltfx));
|
| 1628 | + }
|
| 1629 | + }
|
1602 | 1630 | if(lpDDSrcSurface) {TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,((glDirectDrawSurface1*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx))}
|
1603 | 1631 | else TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx));
|
1604 | 1632 | }
|
— | — | @@ -1872,7 +1900,21 @@ |
1873 | 1901 | {
|
1874 | 1902 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
1875 | 1903 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1876 | | - if(lpDDSrcSurface) {TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,((glDirectDrawSurface2*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx));}
|
| 1904 | + DDBLTFX bltfx;
|
| 1905 | + if (dwFlags & DDBLT_ROP)
|
| 1906 | + {
|
| 1907 | + if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1908 | + bltfx = *lpDDBltFx;
|
| 1909 | + if ((rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4))
|
| 1910 | + {
|
| 1911 | + if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1912 | + glDirectDrawSurface2 *pattern = (glDirectDrawSurface2*)lpDDBltFx->lpDDSPattern;
|
| 1913 | + bltfx.lpDDSPattern = (LPDIRECTDRAWSURFACE)pattern->GetDDS7();
|
| 1914 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface2*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, &bltfx)) }
|
| 1915 | + else TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, NULL, lpSrcRect, dwFlags, &bltfx));
|
| 1916 | + }
|
| 1917 | + }
|
| 1918 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface2*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, lpDDBltFx)); }
|
1877 | 1919 | else TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx));
|
1878 | 1920 | }
|
1879 | 1921 | HRESULT WINAPI glDirectDrawSurface2::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
— | — | @@ -2170,7 +2212,21 @@ |
2171 | 2213 | {
|
2172 | 2214 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
2173 | 2215 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2174 | | - if(lpDDSrcSurface) {TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,((glDirectDrawSurface3*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx));}
|
| 2216 | + DDBLTFX bltfx;
|
| 2217 | + if (dwFlags & DDBLT_ROP)
|
| 2218 | + {
|
| 2219 | + if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2220 | + bltfx = *lpDDBltFx;
|
| 2221 | + if ((rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4))
|
| 2222 | + {
|
| 2223 | + if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2224 | + glDirectDrawSurface3 *pattern = (glDirectDrawSurface3*)lpDDBltFx->lpDDSPattern;
|
| 2225 | + bltfx.lpDDSPattern = (LPDIRECTDRAWSURFACE)pattern->GetDDS7();
|
| 2226 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface3*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, &bltfx)) }
|
| 2227 | + else TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, NULL, lpSrcRect, dwFlags, &bltfx));
|
| 2228 | + }
|
| 2229 | + }
|
| 2230 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface3*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, lpDDBltFx)); }
|
2175 | 2231 | else TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx));
|
2176 | 2232 | }
|
2177 | 2233 | HRESULT WINAPI glDirectDrawSurface3::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
— | — | @@ -2474,7 +2530,21 @@ |
2475 | 2531 | {
|
2476 | 2532 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
2477 | 2533 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
2478 | | - if(lpDDSrcSurface) {TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,((glDirectDrawSurface4*)lpDDSrcSurface)->GetDDS7(),lpSrcRect,dwFlags,lpDDBltFx));}
|
| 2534 | + DDBLTFX bltfx;
|
| 2535 | + if (dwFlags & DDBLT_ROP)
|
| 2536 | + {
|
| 2537 | + if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2538 | + bltfx = *lpDDBltFx;
|
| 2539 | + if ((rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4))
|
| 2540 | + {
|
| 2541 | + if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 2542 | + glDirectDrawSurface4 *pattern = (glDirectDrawSurface4*)lpDDBltFx->lpDDSPattern;
|
| 2543 | + bltfx.lpDDSPattern = (LPDIRECTDRAWSURFACE)pattern->GetDDS7();
|
| 2544 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface4*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, &bltfx)) }
|
| 2545 | + else TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, NULL, lpSrcRect, dwFlags, &bltfx));
|
| 2546 | + }
|
| 2547 | + }
|
| 2548 | + if (lpDDSrcSurface) { TRACE_RET(HRESULT, 23, glDDS7->Blt(lpDestRect, ((glDirectDrawSurface4*)lpDDSrcSurface)->GetDDS7(), lpSrcRect, dwFlags, lpDDBltFx)); }
|
2479 | 2549 | else TRACE_RET(HRESULT,23,glDDS7->Blt(lpDestRect,NULL,lpSrcRect,dwFlags,lpDDBltFx));
|
2480 | 2550 | }
|
2481 | 2551 | HRESULT WINAPI glDirectDrawSurface4::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -946,6 +946,7 @@ |
947 | 947 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
948 | 948 | {
|
949 | 949 | BOOL usedest = FALSE;
|
| 950 | + BOOL usepattern = FALSE;
|
950 | 951 | LONG sizes[6];
|
951 | 952 | RECT srcrect;
|
952 | 953 | RECT destrect;
|
— | — | @@ -966,6 +967,7 @@ |
967 | 968 | {
|
968 | 969 | shaderid = PackROPBits(lpDDBltFx->dwROP, dwFlags);
|
969 | 970 | if (rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 2) usedest = TRUE;
|
| 971 | + if (rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
|
970 | 972 | }
|
971 | 973 | else shaderid = dwFlags & 0xF2FAADFF;
|
972 | 974 | if (usedest)
|
— | — | @@ -1086,6 +1088,13 @@ |
1087 | 1089 | TextureManager_SetTexture(This->texman, 1, This->backbuffer);
|
1088 | 1090 | This->ext->glUniform1i(shader->shader.uniforms[2], 1);
|
1089 | 1091 | }
|
| 1092 | + if (usepattern && (shader->shader.uniforms[3] != -1))
|
| 1093 | + {
|
| 1094 | + glDirectDrawSurface7 *pattern = (glDirectDrawSurface7*)lpDDBltFx->lpDDSPattern;
|
| 1095 | + TextureManager_SetTexture(This->texman, 2, pattern->texture);
|
| 1096 | + This->ext->glUniform1i(shader->shader.uniforms[3], 2);
|
| 1097 | + This->ext->glUniform2i(shader->shader.uniforms[7], pattern->texture->width, pattern->texture->height);
|
| 1098 | + }
|
1090 | 1099 | if (dwFlags & 0x10000000) // Use clipper
|
1091 | 1100 | {
|
1092 | 1101 | TextureManager_SetTexture(This->texman, 3, dest->stencil);
|