| Index: ddraw/ShaderGen2D.cpp |
| — | — | @@ -156,6 +156,8 @@ |
| 157 | 157 | vec2 index = vec2(((myindex.x*(255.0/256.0))+(0.5/256.0)),0.5);\n\
|
| 158 | 158 | pixel = ivec4(texture2D(srcpal, index)*vec4(colorsizedest)+.5);\n";
|
| 159 | 159 | static const char op_pixelmul256[] = "pixel = ivec4(vec4(256.0)*texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizedest)+.5);\n";
|
| | 160 | +static const char op_pixelrgbg[] = "pixel = ivec4(readrgbg(srctex)*vec4(colorsizedest)+.5);\n";
|
| | 161 | +static const char op_pixelgrgb[] = "pixel = ivec4(readgrgb(srctex)*vec4(colorsizedest)+.5);\n";
|
| 160 | 162 | static const char op_pixeluyvy[] = "pixel = ivec4(readuyvy(srctex)*vec4(colorsizedest)+.5);\n";
|
| 161 | 163 | static const char op_pixelyuyv[] = "pixel = ivec4(readyuyv(srctex)*vec4(colorsizedest)+.5);\n";
|
| 162 | 164 | static const char op_pixelyvyu[] = "pixel = ivec4(readyvyu(srctex)*vec4(colorsizedest)+.5);\n";
|
| — | — | @@ -200,7 +202,24 @@ |
| 201 | 203 | {\n\
|
| 202 | 204 | return vec4(vec3((bt601_coeff_inv * rgba.rgb) + yuv_offsets_inv),rgba.a);\n\
|
| 203 | 205 | }\n\n";
|
| 204 | | -static const char func_readuyvy_nearest[] =
|
| | 206 | +
|
| | 207 | +static const char func_readrgbg_nearest[] =
|
| | 208 | +"vec4 readrgbg(sampler2DRect texture)\n\
|
| | 209 | +{\n\
|
| | 210 | + float x = floor(gl_TexCoord[0].s);\n\
|
| | 211 | + float y = floor(gl_TexCoord[0].t);\n\
|
| | 212 | + float x2 = floor(gl_TexCoord[0].s/2.0)*2.0;\n\
|
| | 213 | + return vec4(texture2DRect(texture,vec2(x2,y)).r,texture2DRect(texture,vec2(x,y)).g,texture2DRect(texture,vec2(x2+1.0,y)).r,1.0);\n\
|
| | 214 | +}\n\n";
|
| | 215 | +static const char func_readgrgb_nearest[] =
|
| | 216 | +"vec4 readgrgb(sampler2DRect texture)\n\
|
| | 217 | +{\n\
|
| | 218 | + float x = floor(gl_TexCoord[0].s);\n\
|
| | 219 | + float y = floor(gl_TexCoord[0].t);\n\
|
| | 220 | + float x2 = floor(gl_TexCoord[0].s/2.0)*2.0;\n\
|
| | 221 | + return vec4(texture2DRect(texture,vec2(x2,y)).g,texture2DRect(texture,vec2(x,y)).r,texture2DRect(texture,vec2(x2+1.0,y)).g,1.0);\n\
|
| | 222 | +}\n\n";
|
| | 223 | +static const char func_readuyvy_nearest[] =
|
| 205 | 224 | "vec4 readuyvy(sampler2DRect texture)\n\
|
| 206 | 225 | {\n\
|
| 207 | 226 | float x = floor(gl_TexCoord[0].s);\n\
|
| — | — | @@ -1029,8 +1048,10 @@ |
| 1030 | 1049 | switch (srctype)
|
| 1031 | 1050 | {
|
| 1032 | 1051 | case 0x20:
|
| | 1052 | + String_Append(fsrc, func_readrgbg_nearest);
|
| 1033 | 1053 | break;
|
| 1034 | 1054 | case 0x21:
|
| | 1055 | + String_Append(fsrc, func_readgrgb_nearest);
|
| 1035 | 1056 | break;
|
| 1036 | 1057 | case 0x80:
|
| 1037 | 1058 | String_Append(fsrc, func_readuyvy_nearest);
|
| — | — | @@ -1104,8 +1125,10 @@ |
| 1105 | 1126 | String_Append(fsrc, op_pixelmul256);
|
| 1106 | 1127 | break;
|
| 1107 | 1128 | case 0x20:
|
| | 1129 | + String_Append(fsrc, op_pixelrgbg);
|
| 1108 | 1130 | break;
|
| 1109 | 1131 | case 0x21:
|
| | 1132 | + String_Append(fsrc, op_pixelgrgb);
|
| 1110 | 1133 | break;
|
| 1111 | 1134 | case 0x80:
|
| 1112 | 1135 | String_Append(fsrc, op_pixeluyvy);
|
| Index: ddraw/fourcc.c |
| — | — | @@ -33,7 +33,9 @@ |
| 34 | 34 | MAKEFOURCC('Y','8',' ',' '),
|
| 35 | 35 | MAKEFOURCC('Y','8','0','0'),
|
| 36 | 36 | MAKEFOURCC('G','R','E','Y'),
|
| 37 | | - MAKEFOURCC('Y','1','6',' ')
|
| | 37 | + MAKEFOURCC('Y','1','6',' '),
|
| | 38 | + MAKEFOURCC('R','G','B','G'),
|
| | 39 | + MAKEFOURCC('G','R','G','B')
|
| 38 | 40 | };
|
| 39 | 41 | static const int END_FOURCC = __LINE__ - 4;
|
| 40 | 42 |
|
| Index: ddraw/glTexture.cpp |
| — | — | @@ -1521,10 +1521,22 @@ |
| 1522 | 1522 | This->packsize = 1;
|
| 1523 | 1523 | break;
|
| 1524 | 1524 | case DXGLPIXELFORMAT_FOURCC_RGBG:
|
| 1525 | | - This->blttype = 0x9E;
|
| 1526 | | - This->internalformats[0] = GL_RGBA8;
|
| 1527 | | - This->format = GL_BGRA;
|
| 1528 | | - This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| | 1525 | + if (This->renderer->ext->glver_major >= 3)
|
| | 1526 | + {
|
| | 1527 | + This->internalformats[0] = GL_RG8;
|
| | 1528 | + This->format = GL_RG;
|
| | 1529 | + }
|
| | 1530 | + else
|
| | 1531 | + {
|
| | 1532 | + This->useconv = TRUE;
|
| | 1533 | + This->convfunctionupload = 9;
|
| | 1534 | + This->convfunctiondownload = 10;
|
| | 1535 | + This->internalsize = 4;
|
| | 1536 | + This->internalformats[0] = GL_RGBA8;
|
| | 1537 | + This->format = GL_RGBA;
|
| | 1538 | + }
|
| | 1539 | + This->blttype = 0x20;
|
| | 1540 | + This->type = GL_UNSIGNED_BYTE;
|
| 1529 | 1541 | if (!This->target) This->target = GL_TEXTURE_RECTANGLE;
|
| 1530 | 1542 | This->colororder = 1;
|
| 1531 | 1543 | This->colorsizes[0] = 255;
|
| — | — | @@ -1535,13 +1547,25 @@ |
| 1536 | 1548 | This->colorbits[1] = 8;
|
| 1537 | 1549 | This->colorbits[2] = 8;
|
| 1538 | 1550 | This->colorbits[3] = 8;
|
| 1539 | | - This->packsize = 2;
|
| | 1551 | + This->packsize = 1;
|
| 1540 | 1552 | break;
|
| 1541 | 1553 | case DXGLPIXELFORMAT_FOURCC_GRGB:
|
| 1542 | | - This->blttype = 0x9F;
|
| 1543 | | - This->internalformats[0] = GL_RGBA8;
|
| 1544 | | - This->format = GL_BGRA;
|
| 1545 | | - This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| | 1554 | + if (This->renderer->ext->glver_major >= 3)
|
| | 1555 | + {
|
| | 1556 | + This->internalformats[0] = GL_RG8;
|
| | 1557 | + This->format = GL_RG;
|
| | 1558 | + }
|
| | 1559 | + else
|
| | 1560 | + {
|
| | 1561 | + This->useconv = TRUE;
|
| | 1562 | + This->convfunctionupload = 9;
|
| | 1563 | + This->convfunctiondownload = 10;
|
| | 1564 | + This->internalsize = 4;
|
| | 1565 | + This->internalformats[0] = GL_RGBA8;
|
| | 1566 | + This->format = GL_RGBA;
|
| | 1567 | + }
|
| | 1568 | + This->blttype = 0x21;
|
| | 1569 | + This->type = GL_UNSIGNED_BYTE;
|
| 1546 | 1570 | if (!This->target) This->target = GL_TEXTURE_RECTANGLE;
|
| 1547 | 1571 | This->colororder = 1;
|
| 1548 | 1572 | This->colorsizes[0] = 255;
|
| — | — | @@ -1552,7 +1576,7 @@ |
| 1553 | 1577 | This->colorbits[1] = 8;
|
| 1554 | 1578 | This->colorbits[2] = 8;
|
| 1555 | 1579 | This->colorbits[3] = 8;
|
| 1556 | | - This->packsize = 2;
|
| | 1580 | + This->packsize = 1;
|
| 1557 | 1581 | break;
|
| 1558 | 1582 | case DXGLPIXELFORMAT_FOURCC_AYUV: // 32-bit AYUV
|
| 1559 | 1583 | This->blttype = 0x83;
|
| Index: dxglcfg/surfacegen.cpp |
| — | — | @@ -240,6 +240,18 @@ |
| 241 | 241 | else return (y | (v << 8));
|
| 242 | 242 | }
|
| 243 | 243 |
|
| | 244 | +unsigned short EncodeRGBG(unsigned long value, DWORD x)
|
| | 245 | +{
|
| | 246 | + if (x % 2) return ((value & 0xff) | ((value >> 8) & 0xff) << 8);
|
| | 247 | + else return (((value >> 16) & 0xff) | ((value >> 8) & 0xff) << 8);
|
| | 248 | +}
|
| | 249 | +
|
| | 250 | +unsigned short EncodeGRGB(unsigned long value, DWORD x)
|
| | 251 | +{
|
| | 252 | + if (x % 2) return (((value >> 8) & 0xff) | (value & 0xff) << 8);
|
| | 253 | + else return (((value >> 8) & 0xff) | ((value >> 16) & 0xff) << 8);
|
| | 254 | +}
|
| | 255 | +
|
| 244 | 256 | unsigned long EncodeAYUV(unsigned long value)
|
| 245 | 257 | {
|
| 246 | 258 | short r = (value >> 16) & 0xff;
|
| — | — | @@ -371,6 +383,24 @@ |
| 372 | 384 | }
|
| 373 | 385 | }
|
| 374 | 386 | break;
|
| | 387 | + case MAKEFOURCC('R', 'G', 'B', 'G'):
|
| | 388 | + for (y = 0; y < ddsd.dwHeight; y++)
|
| | 389 | + {
|
| | 390 | + for (x = 0; x < ddsd.dwWidth; x++)
|
| | 391 | + {
|
| | 392 | + buffer16[x + ((ddsd.lPitch / 2) * y)] = EncodeRGBG((unsigned long)((x / (ddsd.dwWidth / 4096.)) + 4096 * floor((y / (ddsd.dwHeight / 4096.)))), x);
|
| | 393 | + }
|
| | 394 | + }
|
| | 395 | + break;
|
| | 396 | + case MAKEFOURCC('G', 'R', 'G', 'B'):
|
| | 397 | + for (y = 0; y < ddsd.dwHeight; y++)
|
| | 398 | + {
|
| | 399 | + for (x = 0; x < ddsd.dwWidth; x++)
|
| | 400 | + {
|
| | 401 | + buffer16[x + ((ddsd.lPitch / 2) * y)] = EncodeGRGB((unsigned long)((x / (ddsd.dwWidth / 4096.)) + 4096 * floor((y / (ddsd.dwHeight / 4096.)))), x);
|
| | 402 | + }
|
| | 403 | + }
|
| | 404 | + break;
|
| 375 | 405 | default:
|
| 376 | 406 | for (y = 0; y < ddsd.dwHeight; y++)
|
| 377 | 407 | {
|