Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -71,14 +71,12 @@ |
72 | 72 | 0x16: 1-bit palette index (future)
|
73 | 73 | 0x18: 24-bit Depth
|
74 | 74 | 0x19: 24-bit Depth, 8-bit Stencil
|
75 | | -0x20: (first entry for specific RGB formats) (future)
|
76 | | -0x80: UYVY / UYNV
|
77 | | -0x81: YUY2 / YUNV
|
| 75 | +0x20: 16-bit RGBG
|
| 76 | +0x21: 16-bit GRGB
|
| 77 | +0x80: UYVY / UYNV / Y422
|
| 78 | +0x81: YUY2 / YUYV / YUNV
|
78 | 79 | 0x82: YVYU
|
79 | 80 | 0x83: AYUV
|
80 | | -0x9E: RGBG
|
81 | | -0x9F: GRGB
|
82 | | -0x84: AYUV
|
83 | 81 | 0xC0: (first entry for compressed) (future)
|
84 | 82 | */
|
85 | 83 |
|
— | — | @@ -148,6 +146,7 @@ |
149 | 147 | pattern = ivec4(texture2D(patterntex,patternst)*vec4(colorsizedest)+.5);\n";
|
150 | 148 | static const char op_destoutdestblend[] = "gl_FragColor = (vec4(pixel)/vec4(colorsizedest)) * texture2D(desttex,gl_TexCoord[1].st);\n";
|
151 | 149 | static const char op_destout[] = "gl_FragColor = vec4(pixel)/vec4(colorsizedest);\n";
|
| 150 | +static const char op_destoutyuvrgb[] = "gl_FragColor = yuvatorgba(vec4(pixel)/vec4(colorsizedest));\n";
|
152 | 151 | static const char op_vertex[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
|
153 | 152 | mat4 proj = mat4(\n\
|
154 | 153 | vec4(2.0 / (view[1] - view[0]), 0, 0, 0),\n\
|
— | — | @@ -169,11 +168,24 @@ |
170 | 169 | static const char op_clip[] = "if(texture2D(stenciltex, gl_TexCoord[3].st).r < .5) discard;\n";
|
171 | 170 |
|
172 | 171 | // Functions
|
173 | | -static const char func_yuvtorgb[] = "";
|
174 | | -static const char func_readuyvy[] = "";
|
175 | | -static const char func_readyuy2[] = "";
|
| 172 | +static const char func_yuvatorgba[] =
|
| 173 | +"vec4 yuvatorgba(vec4 yuva)\n\
|
| 174 | +{\n\
|
| 175 | + vec4 rgba;\n\
|
| 176 | + yuva.r = 1.1643 * (yuva.r - 0.0625);\n\
|
| 177 | + yuva.g = yuva.g - 0.5;\n\
|
| 178 | + yuva.b = yuva.b - 0.5;\n\
|
| 179 | + rgba.r = yuva.r + (1.5958 * yuva.b);\n\
|
| 180 | + rgba.g = yuva.r - (0.39173 * yuva.g) - (0.8129 * yuva.b);\n\
|
| 181 | + rgba.b = yuva.r + (2.017 * yuva.g);\n\
|
| 182 | + rgba.a = yuva.a;\n\
|
| 183 | + return rgba;\n\
|
| 184 | +}\n\n";
|
176 | 185 | static const char func_readrgbg[] = "";
|
177 | 186 | static const char func_readgrgb[] = "";
|
| 187 | +static const char func_readuyvy[] = "";
|
| 188 | +static const char func_readyuyv[] = "";
|
| 189 | +static const char func_readyvyu[] = "";
|
178 | 190 |
|
179 | 191 | // ROP Operations
|
180 | 192 | static const char *op_ROP[256] = {
|
— | — | @@ -871,12 +883,14 @@ |
872 | 884 | {
|
873 | 885 | switch (srctype)
|
874 | 886 | {
|
| 887 | + case 0x20:
|
| 888 | + case 0x21:
|
875 | 889 | case 0x80:
|
876 | 890 | case 0x81:
|
877 | 891 | case 0x82:
|
878 | | - case 0x83:
|
879 | 892 | String_Append(fsrc, unif_srctexrect);
|
880 | 893 | break;
|
| 894 | + case 0x83:
|
881 | 895 | default:
|
882 | 896 | String_Append(fsrc, unif_srctex);
|
883 | 897 | break;
|
— | — | @@ -934,6 +948,10 @@ |
935 | 949 | // Functions
|
936 | 950 | switch (srctype2)
|
937 | 951 | {
|
| 952 | + case 0x20:
|
| 953 | + break;
|
| 954 | + case 0x21:
|
| 955 | + break;
|
938 | 956 | case 0x80:
|
939 | 957 | break;
|
940 | 958 | case 0x81:
|
— | — | @@ -941,6 +959,7 @@ |
942 | 960 | case 0x82:
|
943 | 961 | break;
|
944 | 962 | case 0x83:
|
| 963 | + String_Append(fsrc, func_yuvatorgba);
|
945 | 964 | break;
|
946 | 965 | default:
|
947 | 966 | break;
|
— | — | @@ -954,7 +973,8 @@ |
955 | 974 | {
|
956 | 975 | switch (srctype2)
|
957 | 976 | {
|
958 | | - case 0x00:
|
| 977 | + case 0x00: // Classic RGB
|
| 978 | + case 0x83: // AYUV
|
959 | 979 | default:
|
960 | 980 | String_Append(fsrc, op_pixel);
|
961 | 981 | break;
|
— | — | @@ -971,6 +991,10 @@ |
972 | 992 | case 0x19:
|
973 | 993 | String_Append(fsrc, op_pixelmul256);
|
974 | 994 | break;
|
| 995 | + case 0x20:
|
| 996 | + break;
|
| 997 | + case 0x21:
|
| 998 | + break;
|
975 | 999 | case 0x80:
|
976 | 1000 | break;
|
977 | 1001 | case 0x81:
|
— | — | @@ -977,8 +1001,6 @@ |
978 | 1002 | break;
|
979 | 1003 | case 0x82:
|
980 | 1004 | break;
|
981 | | - case 0x83:
|
982 | | - break;
|
983 | 1005 | }
|
984 | 1006 | }
|
985 | 1007 | if (id & DDBLT_KEYSRC) String_Append(fsrc, op_src);
|
— | — | @@ -1004,7 +1026,18 @@ |
1005 | 1027 | }
|
1006 | 1028 | if (dxglcfg.DebugBlendDestColorKey && (id & DDBLT_KEYDEST))
|
1007 | 1029 | String_Append(fsrc, op_destoutdestblend);
|
1008 | | - else String_Append(fsrc, op_destout);
|
| 1030 | + else
|
| 1031 | + {
|
| 1032 | + switch (srctype2)
|
| 1033 | + {
|
| 1034 | + case 0x83:
|
| 1035 | + String_Append(fsrc, op_destoutyuvrgb);
|
| 1036 | + break;
|
| 1037 | + default:
|
| 1038 | + String_Append(fsrc, op_destout);
|
| 1039 | + break;
|
| 1040 | + }
|
| 1041 | + }
|
1009 | 1042 | String_Append(fsrc, mainend);
|
1010 | 1043 | #ifdef _DEBUG
|
1011 | 1044 | OutputDebugStringA("2D blitter fragment shader:\n");
|