Index: ThirdParty.txt |
— | — | @@ -220,5 +220,37 @@ |
221 | 221 |
|
222 | 222 | ------------------------------------------------------------------------------
|
223 | 223 |
|
| 224 | +Contains some GLSL code derived from Nervous Systems ffmpeg-opengl YUV feature,
|
| 225 | +original code from:
|
| 226 | +https://github.com/nervous-systems/ffmpeg-opengl/blob/feature/yuv/vf_genericshader.c
|
| 227 | +
|
| 228 | +Released under the Unlicense:
|
| 229 | +This is free and unencumbered software released into the public domain.
|
| 230 | +
|
| 231 | +Anyone is free to copy, modify, publish, use, compile, sell, or
|
| 232 | +distribute this software, either in source code form or as a compiled
|
| 233 | +binary, for any purpose, commercial or non-commercial, and by any
|
| 234 | +means.
|
| 235 | +
|
| 236 | +In jurisdictions that recognize copyright laws, the author or authors
|
| 237 | +of this software dedicate any and all copyright interest in the
|
| 238 | +software to the public domain. We make this dedication for the benefit
|
| 239 | +of the public at large and to the detriment of our heirs and
|
| 240 | +successors. We intend this dedication to be an overt act of
|
| 241 | +relinquishment in perpetuity of all present and future rights to this
|
| 242 | +software under copyright law.
|
| 243 | +
|
| 244 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 245 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 246 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 247 | +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 248 | +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 249 | +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 250 | +OTHER DEALINGS IN THE SOFTWARE.
|
| 251 | +
|
| 252 | +For more information, please refer to <http://unlicense.org/>
|
| 253 | +
|
| 254 | +------------------------------------------------------------------------------
|
| 255 | +
|
224 | 256 | Contains code contributed from the following:
|
225 | 257 | Syahmi Azhar (mouse cursor hacks) |
\ No newline at end of file |
Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -14,6 +14,14 @@ |
15 | 15 | // You should have received a copy of the GNU Lesser General Public
|
16 | 16 | // License along with this library; if not, write to the Free Software
|
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +// Contains some GLSL code derived from Nervous Systems ffmpeg-opengl YUV feature,
|
| 20 | +// original code from:
|
| 21 | +// https://github.com/nervous-systems/ffmpeg-opengl/blob/feature/yuv/vf_genericshader.c
|
| 22 | +// Original code was released under the Unlicense and thus dedicated to the public
|
| 23 | +// domain, as evidenced by the following repository license:
|
| 24 | +// https://github.com/nervous-systems/ffmpeg-opengl/blob/feature/yuv/LICENSE
|
| 25 | +
|
18 | 26 | #include "common.h"
|
19 | 27 | #include "string.h"
|
20 | 28 | #include "glExtensions.h"
|
— | — | @@ -60,8 +68,9 @@ |
61 | 69 | AND the dwFlags by 0xF2FAADFF before packing ROP index bits
|
62 | 70 |
|
63 | 71 | Texture types:
|
64 | | -0x00: Classic DXGL processing
|
| 72 | +0x00: Standard RGBA
|
65 | 73 | 0x01: Luminance-only (write to red)
|
| 74 | +0x02: Luminance-only (Calculate Y on Blt)
|
66 | 75 | 0x10: 8-bit palette
|
67 | 76 | 0x11: 4-bit palette
|
68 | 77 | 0x12: 2-bit palette
|
— | — | @@ -92,6 +101,13 @@ |
93 | 102 | static const char linefeed[] = "\n";
|
94 | 103 | static const char mainstart[] = "void main()\n{\n";
|
95 | 104 | static const char mainend[] = "} ";
|
| 105 | +
|
| 106 | +// Constants
|
| 107 | +static const char const_bt601_coeff[] =
|
| 108 | +"const mat3 bt601_coeff = mat3(1.164,1.164,1.164,0.0,-0.392,2.017,1.596,-0.813,0.0);\n\
|
| 109 | +const vec3 yuv_offsets = vec3(-0.0625, -0.5, -0.5);\n";
|
| 110 | +
|
| 111 | +
|
96 | 112 | // Attributes
|
97 | 113 | static const char attr_xy[] = "attribute vec2 xy;\n";
|
98 | 114 | static const char attr_rgb[] = "attribute vec3 rgb;\n";
|
— | — | @@ -171,15 +187,7 @@ |
172 | 188 | static const char func_yuvatorgba[] =
|
173 | 189 | "vec4 yuvatorgba(vec4 yuva)\n\
|
174 | 190 | {\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\
|
| 191 | + return vec4(vec3(bt601_coeff * (yuva.rgb + yuv_offsets)),yuva.a);\n\
|
184 | 192 | }\n\n";
|
185 | 193 | static const char func_readrgbg[] = "";
|
186 | 194 | static const char func_readgrgb[] = "";
|
— | — | @@ -877,6 +885,21 @@ |
878 | 886 | String_Append(fsrc, idheader);
|
879 | 887 | String_Append(fsrc, idstring);
|
880 | 888 |
|
| 889 | + // Constants
|
| 890 | + switch (srctype)
|
| 891 | + {
|
| 892 | + case 0:
|
| 893 | + default:
|
| 894 | + break;
|
| 895 | + case 0x80:
|
| 896 | + case 0x81:
|
| 897 | + case 0x82:
|
| 898 | + case 0x83:
|
| 899 | + if ((desttype >= 0x80) && (desttype <= 0x83)) break;
|
| 900 | + String_Append(fsrc, const_bt601_coeff);
|
| 901 | + break;
|
| 902 | + }
|
| 903 | +
|
881 | 904 | // Uniforms
|
882 | 905 | if (id & DDBLT_COLORFILL) String_Append(fsrc, unif_fillcolor);
|
883 | 906 | else
|
— | — | @@ -979,6 +1002,7 @@ |
980 | 1003 | String_Append(fsrc, op_pixel);
|
981 | 1004 | break;
|
982 | 1005 | case 0x01:
|
| 1006 | + case 0x02:
|
983 | 1007 | String_Append(fsrc, op_lumpixel);
|
984 | 1008 | break;
|
985 | 1009 | case 0x10:
|
— | — | @@ -1028,10 +1052,12 @@ |
1029 | 1053 | String_Append(fsrc, op_destoutdestblend);
|
1030 | 1054 | else
|
1031 | 1055 | {
|
1032 | | - switch (srctype2)
|
| 1056 | + switch (srctype)
|
1033 | 1057 | {
|
1034 | 1058 | case 0x83:
|
1035 | | - String_Append(fsrc, op_destoutyuvrgb);
|
| 1059 | + if ((desttype >= 0x80) && (desttype <= 0x83))
|
| 1060 | + String_Append(fsrc, op_destout);
|
| 1061 | + else String_Append(fsrc, op_destoutyuvrgb);
|
1036 | 1062 | break;
|
1037 | 1063 | default:
|
1038 | 1064 | String_Append(fsrc, op_destout);
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -3380,7 +3380,7 @@ |
3381 | 3381 | }
|
3382 | 3382 | else shaderid = cmd->flags & 0xF2FAADFF;
|
3383 | 3383 | if (cmd->src) shaderid |= ((long long)cmd->src->blttype << 32);
|
3384 | | - //TODO: Add src/dest texture types
|
| 3384 | + if (cmd->dest) shaderid |= ((long long)cmd->dest->blttype << 40);
|
3385 | 3385 | if (cmd->flags & DDBLT_KEYDEST) usedest = TRUE;
|
3386 | 3386 | if (IsAlphaCKey())
|
3387 | 3387 | {
|
Index: ddraw/glTexture.cpp |
— | — | @@ -1196,11 +1196,37 @@ |
1197 | 1197 | This->colorbits[3] = 8;
|
1198 | 1198 | This->packsize = 1;
|
1199 | 1199 | break;
|
| 1200 | + case DXGLPIXELFORMAT_LUM8: // 8-bit Luminance
|
| 1201 | + This->blttype = 0x01;
|
| 1202 | + if (This->renderer->ext->glver_major >= 3 && !(This->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
| 1203 | + {
|
| 1204 | + This->internalformats[0] = GL_R8;
|
| 1205 | + This->format = GL_RED;
|
| 1206 | + }
|
| 1207 | + else
|
| 1208 | + {
|
| 1209 | + This->internalformats[0] = GL_LUMINANCE8;
|
| 1210 | + This->format = GL_LUMINANCE;
|
| 1211 | + }
|
| 1212 | + This->internalformats[1] = GL_RGB8;
|
| 1213 | + This->internalformats[2] = GL_RGBA8;
|
| 1214 | + This->type = GL_UNSIGNED_BYTE;
|
| 1215 | + if (!This->target) This->target = GL_TEXTURE_2D;
|
| 1216 | + This->colororder = 5;
|
| 1217 | + This->colorsizes[0] = 255;
|
| 1218 | + This->colorsizes[1] = 255;
|
| 1219 | + This->colorsizes[2] = 255;
|
| 1220 | + This->colorsizes[3] = 255;
|
| 1221 | + This->colorbits[0] = 8;
|
| 1222 | + This->colorbits[1] = 0;
|
| 1223 | + This->colorbits[2] = 0;
|
| 1224 | + This->colorbits[3] = 0;
|
| 1225 | + This->packsize = 1;
|
| 1226 | + break;
|
1200 | 1227 | case DXGLPIXELFORMAT_FOURCC_Y8: // 8-bit Y-only
|
1201 | 1228 | case DXGLPIXELFORMAT_FOURCC_Y800:
|
1202 | 1229 | case DXGLPIXELFORMAT_FOURCC_GREY:
|
1203 | | - case DXGLPIXELFORMAT_LUM8: // 8-bit Luminance
|
1204 | | - This->blttype = 0x01;
|
| 1230 | + This->blttype = 0x02;
|
1205 | 1231 | if (This->renderer->ext->glver_major >= 3 && !(This->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
1206 | 1232 | {
|
1207 | 1233 | This->internalformats[0] = GL_R8;
|
— | — | @@ -1379,7 +1405,7 @@ |
1380 | 1406 | This->packsize = 1;
|
1381 | 1407 | break;
|
1382 | 1408 | case DXGLPIXELFORMAT_FOURCC_Y16:
|
1383 | | - This->blttype = 0x01;
|
| 1409 | + This->blttype = 0x02;
|
1384 | 1410 | if (This->renderer->ext->glver_major >= 3 && !(This->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
|
1385 | 1411 | {
|
1386 | 1412 | This->internalformats[0] = GL_R16;
|