Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -72,7 +72,10 @@ |
73 | 73 | 0x18: 24-bit Depth
|
74 | 74 | 0x19: 24-bit Depth, 8-bit Stencil
|
75 | 75 | 0x20: (first entry for specific RGB formats) (future)
|
76 | | -0x80: (first entry for specific YUV formats) (future)
|
| 76 | +0x80: UYVY / UYNV
|
| 77 | +0x81: YUY2 / YUNV
|
| 78 | +0x82: RGBG
|
| 79 | +0x83: GRGB
|
77 | 80 | 0xC0: (first entry for compressed) (future)
|
78 | 81 | */
|
79 | 82 |
|
Index: ddraw/glTexture.cpp |
— | — | @@ -93,11 +93,51 @@ |
94 | 94 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space, reversed
|
95 | 95 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0}, // 32 bit Z buffer
|
96 | 96 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0}, // 32 bit Z buffer with stencil
|
97 | | - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0} // 32 bit Z buffer with stencil, reversed
|
| 97 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0}, // 32 bit Z buffer with stencil, reversed
|
| 98 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0}, // UYVY YUV surface
|
| 99 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','N','V'), 0, 0, 0, 0, 0}, // UYVY YUV surface (NVIDIA alias)
|
| 100 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0}, // YUY2 YUV surface
|
| 101 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','N','V'), 0, 0, 0, 0, 0}, // YUY2 YUV surface (NVIDIA alias)
|
| 102 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0}, // RGBG 16-bit pixelformat
|
| 103 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0}, // GRGB 16-bit pixelformat
|
98 | 104 | };
|
99 | 105 | static const int END_TEXFORMATS = __LINE__ - 4;
|
100 | 106 | int numtexformats;
|
101 | 107 |
|
| 108 | +// Pixel format constants
|
| 109 | +#define DXGLPIXELFORMAT_INVALID -1
|
| 110 | +#define DXGLPIXELFORMAT_PAL1 0
|
| 111 | +#define DXGLPIXELFORMAT_PAL2 1
|
| 112 | +#define DXGLPIXELFORMAT_PAL4 2
|
| 113 | +#define DXGLPIXELFORMAT_PAL8 3
|
| 114 | +#define DXGLPIXELFORMAT_RGB332 4
|
| 115 | +#define DXGLPIXELFORMAT_RGB555 5
|
| 116 | +#define DXGLPIXELFORMAT_RGB565 6
|
| 117 | +#define DXGLPIXELFORMAT_RGB888 7
|
| 118 | +#define DXGLPIXELFORMAT_RGB888_REV 8
|
| 119 | +#define DXGLPIXELFORMAT_RGBX8888 9
|
| 120 | +#define DXGLPIXELFORMAT_RGBX8888_REV 10
|
| 121 | +#define DXGLPIXELFORMAT_RGBA8332 11
|
| 122 | +#define DXGLPIXELFORMAT_RGBA4444 12
|
| 123 | +#define DXGLPIXELFORMAT_RGBA1555 13
|
| 124 | +#define DXGLPIXELFORMAT_RGBA8888 14
|
| 125 | +#define DXGLPIXELFORMAT_LUM8 15
|
| 126 | +#define DXGLPIXELFORMAT_ALPHA8 16
|
| 127 | +#define DXGLPIXELFORMAT_LUM_ALPHA88 17
|
| 128 | +#define DXGLPIXELFORMAT_Z16 18
|
| 129 | +#define DXGLPIXELFORMAT_Z24 19
|
| 130 | +#define DXGLPIXELFORMAT_X8_Z24 20
|
| 131 | +#define DXGLPIXELFORMAT_X8_Z24_REV 21
|
| 132 | +#define DXGLPIXELFORMAT_Z32 22
|
| 133 | +#define DXGLPIXELFORMAT_S8_Z32 23
|
| 134 | +#define DXGLPIXELFORMAT_S8_Z32_REV 24
|
| 135 | +#define DXGLPIXELFORMAT_FOURCC_UYVY 25
|
| 136 | +#define DXGLPIXELFORMAT_FOURCC_UYNV 26
|
| 137 | +#define DXGLPIXELFORMAT_FOURCC_YUY2 27
|
| 138 | +#define DXGLPIXELFORMAT_FOURCC_YUNV 28
|
| 139 | +#define DXGLPIXELFORMAT_FOURCC_RGBG 29
|
| 140 | +#define DXGLPIXELFORMAT_FOURCC_GRGB 30
|
| 141 | +
|
102 | 142 | void ClearError()
|
103 | 143 | {
|
104 | 144 | do
|
— | — | @@ -226,14 +266,34 @@ |
227 | 267 | }
|
228 | 268 | else
|
229 | 269 | {
|
230 | | - if (ddsd->ddpfPixelFormat.dwRGBBitCount == 1)
|
231 | | - newtexture->levels[0].ddsd.lPitch = NextMultipleOf8(newtexture->levels[0].ddsd.dwWidth) / 8;
|
232 | | - else if (ddsd->ddpfPixelFormat.dwRGBBitCount == 2)
|
233 | | - newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth) / 4;
|
234 | | - else if (ddsd->ddpfPixelFormat.dwRGBBitCount == 4)
|
235 | | - newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth) / 2;
|
236 | | - else newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth *
|
237 | | - (newtexture->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
|
| 270 | + if (ddsd->ddpfPixelFormat.dwFlags & DDPF_FOURCC)
|
| 271 | + {
|
| 272 | + switch (ddsd->ddpfPixelFormat.dwFourCC)
|
| 273 | + {
|
| 274 | + case MAKEFOURCC('U', 'Y', 'V', 'Y'):
|
| 275 | + case MAKEFOURCC('U', 'Y', 'N', 'V'):
|
| 276 | + case MAKEFOURCC('Y', 'U', 'Y', '2'):
|
| 277 | + case MAKEFOURCC('Y', 'U', 'N', 'V'):
|
| 278 | + case MAKEFOURCC('R', 'G', 'B', 'G'):
|
| 279 | + case MAKEFOURCC('G', 'R', 'G', 'B'):
|
| 280 | + newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth * 2);
|
| 281 | + break;
|
| 282 | + default:
|
| 283 | + newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth * 4);
|
| 284 | + break;
|
| 285 | + }
|
| 286 | + }
|
| 287 | + else
|
| 288 | + {
|
| 289 | + if (ddsd->ddpfPixelFormat.dwRGBBitCount == 1)
|
| 290 | + newtexture->levels[0].ddsd.lPitch = NextMultipleOf8(newtexture->levels[0].ddsd.dwWidth) / 8;
|
| 291 | + else if (ddsd->ddpfPixelFormat.dwRGBBitCount == 2)
|
| 292 | + newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth) / 4;
|
| 293 | + else if (ddsd->ddpfPixelFormat.dwRGBBitCount == 4)
|
| 294 | + newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth) / 2;
|
| 295 | + else newtexture->levels[0].ddsd.lPitch = NextMultipleOf4(newtexture->levels[0].ddsd.dwWidth *
|
| 296 | + (newtexture->levels[0].ddsd.ddpfPixelFormat.dwRGBBitCount / 8));
|
| 297 | + }
|
238 | 298 | }
|
239 | 299 | /*if (!(newtexture->levels[0].ddsd.ddsCaps.dwCaps2 & DDSCAPS2_MIPMAPSUBLEVEL))
|
240 | 300 | {
|
— | — | @@ -564,6 +624,7 @@ |
565 | 625 | int inpitch, outpitch;
|
566 | 626 | int i;
|
567 | 627 | char *writebuffer;
|
| 628 | + width = DivCeiling(width, This->packsize);
|
568 | 629 | if (dorealloc)
|
569 | 630 | {
|
570 | 631 | This->levels[level].ddsd.dwWidth = width;
|
— | — | @@ -744,9 +805,9 @@ |
745 | 806 | This->internalformats[7] = 0;
|
746 | 807 | ClearError();
|
747 | 808 | if ((This->levels[0].ddsd.dwWidth != This->bigwidth) || (This->levels[0].ddsd.dwHeight != This->bigheight))
|
748 | | - glTexImage2D(This->target, i, This->internalformats[0], This->bigwidth,
|
| 809 | + glTexImage2D(This->target, i, This->internalformats[0], DivCeiling(This->bigwidth, This->packsize),
|
749 | 810 | This->bigheight, 0, This->format, This->type, This->levels[i].bigbuffer);
|
750 | | - else glTexImage2D(This->target, i, This->internalformats[0], This->levels[i].ddsd.dwWidth,
|
| 811 | + else glTexImage2D(This->target, i, This->internalformats[0], DivCeiling(This->levels[i].ddsd.dwWidth, This->packsize),
|
751 | 812 | This->levels[i].ddsd.dwHeight, 0, This->format, This->type, This->levels[i].buffer);
|
752 | 813 | error = glGetError();
|
753 | 814 | if (error != GL_NO_ERROR)
|
— | — | @@ -797,6 +858,7 @@ |
798 | 859 | {
|
799 | 860 | int texformat = -1;
|
800 | 861 | int i;
|
| 862 | + int bytes;
|
801 | 863 | DWORD x, y;
|
802 | 864 | GLenum error;
|
803 | 865 | numtexformats = END_TEXFORMATS - START_TEXFORMATS;
|
— | — | @@ -811,7 +873,7 @@ |
812 | 874 | ZeroMemory(This->internalformats, 8 * sizeof(GLint));
|
813 | 875 | switch (texformat)
|
814 | 876 | {
|
815 | | - case 0: // 1-bit palette
|
| 877 | + case DXGLPIXELFORMAT_PAL1: // 1-bit palette
|
816 | 878 | This->useconv = TRUE;
|
817 | 879 | This->convfunctionupload = 11;
|
818 | 880 | This->convfunctiondownload = 14;
|
— | — | @@ -838,8 +900,9 @@ |
839 | 901 | This->colorbits[1] = 0;
|
840 | 902 | This->colorbits[2] = 0;
|
841 | 903 | This->colorbits[3] = 0;
|
| 904 | + This->packsize = 1;
|
842 | 905 | break;
|
843 | | - case 1: // 2-bit palette
|
| 906 | + case DXGLPIXELFORMAT_PAL2: // 2-bit palette
|
844 | 907 | This->useconv = TRUE;
|
845 | 908 | This->convfunctionupload = 12;
|
846 | 909 | This->convfunctiondownload = 15;
|
— | — | @@ -866,8 +929,9 @@ |
867 | 930 | This->colorbits[1] = 0;
|
868 | 931 | This->colorbits[2] = 0;
|
869 | 932 | This->colorbits[3] = 0;
|
| 933 | + This->packsize = 1;
|
870 | 934 | break;
|
871 | | - case 2: // 4-bit palette
|
| 935 | + case DXGLPIXELFORMAT_PAL4: // 4-bit palette
|
872 | 936 | This->useconv = TRUE;
|
873 | 937 | This->convfunctionupload = 13;
|
874 | 938 | This->convfunctiondownload = 16;
|
— | — | @@ -894,8 +958,9 @@ |
895 | 959 | This->colorbits[1] = 0;
|
896 | 960 | This->colorbits[2] = 0;
|
897 | 961 | This->colorbits[3] = 0;
|
| 962 | + This->packsize = 1;
|
898 | 963 | break;
|
899 | | - case 3: // 8-bit palette
|
| 964 | + case DXGLPIXELFORMAT_PAL8: // 8-bit palette
|
900 | 965 | This->blttype = 0x10;
|
901 | 966 | if (This->renderer->ext->glver_major >= 3)
|
902 | 967 | {
|
— | — | @@ -918,8 +983,9 @@ |
919 | 984 | This->colorbits[1] = 0;
|
920 | 985 | This->colorbits[2] = 0;
|
921 | 986 | This->colorbits[3] = 0;
|
| 987 | + This->packsize = 1;
|
922 | 988 | break;
|
923 | | - case 4: // 8-bit RGB332
|
| 989 | + case DXGLPIXELFORMAT_RGB332: // 8-bit RGB332
|
924 | 990 | This->internalformats[0] = GL_R3_G3_B2;
|
925 | 991 | This->internalformats[1] = GL_RGB8;
|
926 | 992 | This->internalformats[2] = GL_RGBA8;
|
— | — | @@ -935,8 +1001,9 @@ |
936 | 1002 | This->colorbits[1] = 3;
|
937 | 1003 | This->colorbits[2] = 2;
|
938 | 1004 | This->colorbits[3] = 0;
|
| 1005 | + This->packsize = 1;
|
939 | 1006 | break;
|
940 | | - case 5: // 16-bit RGB555
|
| 1007 | + case DXGLPIXELFORMAT_RGB555: // 16-bit RGB555
|
941 | 1008 | This->internalformats[0] = GL_RGB5_A1;
|
942 | 1009 | This->internalformats[1] = GL_RGBA8;
|
943 | 1010 | This->format = GL_BGRA;
|
— | — | @@ -951,8 +1018,9 @@ |
952 | 1019 | This->colorbits[1] = 5;
|
953 | 1020 | This->colorbits[2] = 5;
|
954 | 1021 | This->colorbits[3] = 1;
|
| 1022 | + This->packsize = 1;
|
955 | 1023 | break;
|
956 | | - case 6: // 16-bit RGB565
|
| 1024 | + case DXGLPIXELFORMAT_RGB565: // 16-bit RGB565
|
957 | 1025 | This->internalformats[0] = GL_RGB565;
|
958 | 1026 | This->internalformats[1] = GL_RGB8;
|
959 | 1027 | This->internalformats[2] = GL_RGBA8;
|
— | — | @@ -968,8 +1036,9 @@ |
969 | 1037 | This->colorbits[1] = 6;
|
970 | 1038 | This->colorbits[2] = 5;
|
971 | 1039 | This->colorbits[3] = 0;
|
| 1040 | + This->packsize = 1;
|
972 | 1041 | break;
|
973 | | - case 7: // 24-bit RGB888
|
| 1042 | + case DXGLPIXELFORMAT_RGB888: // 24-bit RGB888
|
974 | 1043 | This->internalformats[0] = GL_RGB8;
|
975 | 1044 | This->internalformats[1] = GL_RGBA8;
|
976 | 1045 | This->format = GL_BGR;
|
— | — | @@ -984,14 +1053,15 @@ |
985 | 1054 | This->colorbits[1] = 8;
|
986 | 1055 | This->colorbits[2] = 8;
|
987 | 1056 | This->colorbits[3] = 0;
|
| 1057 | + This->packsize = 1;
|
988 | 1058 | break;
|
989 | | - case 8: // 24-bit BGR888
|
| 1059 | + case DXGLPIXELFORMAT_RGB888_REV: // 24-bit BGR888
|
990 | 1060 | This->internalformats[0] = GL_RGB8;
|
991 | 1061 | This->internalformats[1] = GL_RGBA8;
|
992 | 1062 | This->format = GL_RGB;
|
993 | 1063 | This->type = GL_UNSIGNED_BYTE;
|
994 | 1064 | if (!This->target) This->target = GL_TEXTURE_2D;
|
995 | | - This->colororder = 1;
|
| 1065 | + This->colororder = 0;
|
996 | 1066 | This->colorsizes[0] = 255;
|
997 | 1067 | This->colorsizes[1] = 255;
|
998 | 1068 | This->colorsizes[2] = 255;
|
— | — | @@ -1000,8 +1070,9 @@ |
1001 | 1071 | This->colorbits[1] = 8;
|
1002 | 1072 | This->colorbits[2] = 8;
|
1003 | 1073 | This->colorbits[3] = 0;
|
| 1074 | + This->packsize = 1;
|
1004 | 1075 | break;
|
1005 | | - case 9: // 32-bit RGB888
|
| 1076 | + case DXGLPIXELFORMAT_RGBX8888: // 32-bit RGB888
|
1006 | 1077 | This->internalformats[0] = GL_RGBA8;
|
1007 | 1078 | This->format = GL_BGRA;
|
1008 | 1079 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
— | — | @@ -1015,8 +1086,9 @@ |
1016 | 1087 | This->colorbits[1] = 8;
|
1017 | 1088 | This->colorbits[2] = 8;
|
1018 | 1089 | This->colorbits[3] = 0;
|
| 1090 | + This->packsize = 1;
|
1019 | 1091 | break;
|
1020 | | - case 10: // 32-bit BGR888
|
| 1092 | + case DXGLPIXELFORMAT_RGBX8888_REV: // 32-bit BGR888
|
1021 | 1093 | This->internalformats[0] = GL_RGBA8;
|
1022 | 1094 | This->format = GL_RGBA;
|
1023 | 1095 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
— | — | @@ -1030,8 +1102,9 @@ |
1031 | 1103 | This->colorbits[1] = 8;
|
1032 | 1104 | This->colorbits[2] = 8;
|
1033 | 1105 | This->colorbits[3] = 0;
|
| 1106 | + This->packsize = 1;
|
1034 | 1107 | break;
|
1035 | | - case 11: // 16-bit RGBA8332
|
| 1108 | + case DXGLPIXELFORMAT_RGBA8332: // 16-bit RGBA8332
|
1036 | 1109 | This->useconv = TRUE;
|
1037 | 1110 | This->convfunctionupload = 0;
|
1038 | 1111 | This->convfunctiondownload = 1;
|
— | — | @@ -1049,8 +1122,9 @@ |
1050 | 1123 | This->colorbits[1] = 3;
|
1051 | 1124 | This->colorbits[2] = 2;
|
1052 | 1125 | This->colorbits[3] = 8;
|
| 1126 | + This->packsize = 1;
|
1053 | 1127 | break;
|
1054 | | - case 12: // 16-bit RGBA4444
|
| 1128 | + case DXGLPIXELFORMAT_RGBA4444: // 16-bit RGBA4444
|
1055 | 1129 | This->internalformats[0] = GL_RGBA4;
|
1056 | 1130 | This->internalformats[1] = GL_RGBA8;
|
1057 | 1131 | This->format = GL_BGRA;
|
— | — | @@ -1065,8 +1139,9 @@ |
1066 | 1140 | This->colorbits[1] = 4;
|
1067 | 1141 | This->colorbits[2] = 4;
|
1068 | 1142 | This->colorbits[3] = 4;
|
| 1143 | + This->packsize = 1;
|
1069 | 1144 | break;
|
1070 | | - case 13: // 16-bit RGBA1555
|
| 1145 | + case DXGLPIXELFORMAT_RGBA1555: // 16-bit RGBA1555
|
1071 | 1146 | This->internalformats[0] = GL_RGB5_A1;
|
1072 | 1147 | This->internalformats[1] = GL_RGBA8;
|
1073 | 1148 | This->format = GL_BGRA;
|
— | — | @@ -1076,9 +1151,10 @@ |
1077 | 1152 | This->colorbits[1] = 5;
|
1078 | 1153 | This->colorbits[2] = 5;
|
1079 | 1154 | This->colorbits[3] = 1;
|
| 1155 | + This->packsize = 1;
|
1080 | 1156 | break;
|
1081 | | - case -1:
|
1082 | | - case 14: // 32-bit RGBA8888
|
| 1157 | + case DXGLPIXELFORMAT_INVALID:
|
| 1158 | + case DXGLPIXELFORMAT_RGBA8888: // 32-bit RGBA8888
|
1083 | 1159 | This->internalformats[0] = GL_RGBA8;
|
1084 | 1160 | This->format = GL_BGRA;
|
1085 | 1161 | This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
— | — | @@ -1092,8 +1168,9 @@ |
1093 | 1169 | This->colorbits[1] = 8;
|
1094 | 1170 | This->colorbits[2] = 8;
|
1095 | 1171 | This->colorbits[3] = 8;
|
| 1172 | + This->packsize = 1;
|
1096 | 1173 | break;
|
1097 | | - case 15: // 8-bit Luminance
|
| 1174 | + case DXGLPIXELFORMAT_LUM8: // 8-bit Luminance
|
1098 | 1175 | This->internalformats[0] = GL_LUMINANCE8;
|
1099 | 1176 | This->internalformats[1] = GL_RGB8;
|
1100 | 1177 | This->internalformats[2] = GL_RGBA8;
|
— | — | @@ -1109,8 +1186,9 @@ |
1110 | 1187 | This->colorbits[1] = 0;
|
1111 | 1188 | This->colorbits[2] = 0;
|
1112 | 1189 | This->colorbits[3] = 0;
|
| 1190 | + This->packsize = 1;
|
1113 | 1191 | break;
|
1114 | | - case 16: // 8-bit Alpha
|
| 1192 | + case DXGLPIXELFORMAT_ALPHA8: // 8-bit Alpha
|
1115 | 1193 | This->internalformats[0] = GL_ALPHA8;
|
1116 | 1194 | This->format = GL_ALPHA;
|
1117 | 1195 | This->type = GL_UNSIGNED_BYTE;
|
— | — | @@ -1124,8 +1202,9 @@ |
1125 | 1203 | This->colorbits[1] = 0;
|
1126 | 1204 | This->colorbits[2] = 0;
|
1127 | 1205 | This->colorbits[3] = 8;
|
| 1206 | + This->packsize = 1;
|
1128 | 1207 | break;
|
1129 | | - case 17: // 16-bit Luminance Alpha
|
| 1208 | + case DXGLPIXELFORMAT_LUM_ALPHA88: // 16-bit Luminance Alpha
|
1130 | 1209 | This->internalformats[0] = GL_LUMINANCE8_ALPHA8;
|
1131 | 1210 | This->internalformats[1] = GL_RGBA8;
|
1132 | 1211 | This->format = GL_LUMINANCE_ALPHA;
|
— | — | @@ -1140,8 +1219,9 @@ |
1141 | 1220 | This->colorbits[1] = 0;
|
1142 | 1221 | This->colorbits[2] = 0;
|
1143 | 1222 | This->colorbits[3] = 8;
|
| 1223 | + This->packsize = 1;
|
1144 | 1224 | break;
|
1145 | | - case 18: // 16-bit Z buffer
|
| 1225 | + case DXGLPIXELFORMAT_Z16: // 16-bit Z buffer
|
1146 | 1226 | This->internalformats[0] = GL_DEPTH_COMPONENT16;
|
1147 | 1227 | This->format = GL_DEPTH_COMPONENT;
|
1148 | 1228 | This->type = GL_UNSIGNED_SHORT;
|
— | — | @@ -1155,8 +1235,9 @@ |
1156 | 1236 | This->colorbits[1] = 0;
|
1157 | 1237 | This->colorbits[2] = 0;
|
1158 | 1238 | This->colorbits[3] = 0;
|
| 1239 | + This->packsize = 1;
|
1159 | 1240 | break;
|
1160 | | - case 19: // 24-bit Z buffer
|
| 1241 | + case DXGLPIXELFORMAT_Z24: // 24-bit Z buffer
|
1161 | 1242 | This->useconv = TRUE;
|
1162 | 1243 | This->convfunctionupload = 17;
|
1163 | 1244 | This->convfunctiondownload = 18;
|
— | — | @@ -1175,8 +1256,9 @@ |
1176 | 1257 | This->colorbits[1] = 0;
|
1177 | 1258 | This->colorbits[2] = 0;
|
1178 | 1259 | This->colorbits[3] = 0;
|
| 1260 | + This->packsize = 1;
|
1179 | 1261 | break;
|
1180 | | - case 20: // 32/24 bit Z buffer
|
| 1262 | + case DXGLPIXELFORMAT_X8_Z24: // 32/24 bit Z buffer
|
1181 | 1263 | This->blttype = 0x18;
|
1182 | 1264 | This->internalformats[0] = GL_DEPTH_COMPONENT24;
|
1183 | 1265 | This->format = GL_DEPTH_COMPONENT;
|
— | — | @@ -1191,8 +1273,9 @@ |
1192 | 1274 | This->colorbits[1] = 0;
|
1193 | 1275 | This->colorbits[2] = 0;
|
1194 | 1276 | This->colorbits[3] = 0;
|
| 1277 | + This->packsize = 1;
|
1195 | 1278 | break;
|
1196 | | - case 21: // 32/24 bit Z buffer reversed
|
| 1279 | + case DXGLPIXELFORMAT_X8_Z24_REV: // 32/24 bit Z buffer reversed
|
1197 | 1280 | This->internalformats[0] = GL_DEPTH_COMPONENT24;
|
1198 | 1281 | This->format = GL_DEPTH_COMPONENT;
|
1199 | 1282 | This->type = GL_UNSIGNED_INT;
|
— | — | @@ -1206,8 +1289,9 @@ |
1207 | 1290 | This->colorbits[1] = 0;
|
1208 | 1291 | This->colorbits[2] = 0;
|
1209 | 1292 | This->colorbits[3] = 0;
|
| 1293 | + This->packsize = 1;
|
1210 | 1294 | break;
|
1211 | | - case 22: // 32-bit Z buffer
|
| 1295 | + case DXGLPIXELFORMAT_Z32: // 32-bit Z buffer
|
1212 | 1296 | This->internalformats[0] = GL_DEPTH_COMPONENT32;
|
1213 | 1297 | This->format = GL_DEPTH_COMPONENT;
|
1214 | 1298 | This->type = GL_UNSIGNED_INT;
|
— | — | @@ -1221,8 +1305,9 @@ |
1222 | 1306 | This->colorbits[1] = 0;
|
1223 | 1307 | This->colorbits[2] = 0;
|
1224 | 1308 | This->colorbits[3] = 0;
|
| 1309 | + This->packsize = 1;
|
1225 | 1310 | break;
|
1226 | | - case 23: // 32-bit Z/Stencil buffer, depth LSB
|
| 1311 | + case DXGLPIXELFORMAT_S8_Z32: // 32-bit Z/Stencil buffer, depth LSB
|
1227 | 1312 | This->internalformats[0] = GL_DEPTH24_STENCIL8;
|
1228 | 1313 | This->format = GL_DEPTH_STENCIL;
|
1229 | 1314 | This->type = GL_UNSIGNED_INT_24_8;
|
— | — | @@ -1236,8 +1321,9 @@ |
1237 | 1322 | This->colorbits[1] = 0;
|
1238 | 1323 | This->colorbits[2] = 0;
|
1239 | 1324 | This->colorbits[3] = 8;
|
| 1325 | + This->packsize = 1;
|
1240 | 1326 | break;
|
1241 | | - case 24: // 32-bit Z/Stencil buffer, depth MSB
|
| 1327 | + case DXGLPIXELFORMAT_S8_Z32_REV: // 32-bit Z/Stencil buffer, depth MSB
|
1242 | 1328 | This->blttype = 0x18;
|
1243 | 1329 | This->internalformats[0] = GL_DEPTH24_STENCIL8;
|
1244 | 1330 | This->format = GL_DEPTH_STENCIL;
|
— | — | @@ -1252,7 +1338,39 @@ |
1253 | 1339 | This->colorbits[1] = 0;
|
1254 | 1340 | This->colorbits[2] = 0;
|
1255 | 1341 | This->colorbits[3] = 8;
|
| 1342 | + This->packsize = 1;
|
1256 | 1343 | break;
|
| 1344 | + case DXGLPIXELFORMAT_FOURCC_UYVY:
|
| 1345 | + case DXGLPIXELFORMAT_FOURCC_UYNV:
|
| 1346 | + This->blttype = 0x80;
|
| 1347 | + This->internalformats[0] = GL_RGBA8;
|
| 1348 | + This->format = GL_BGRA;
|
| 1349 | + This->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 1350 | + if (!This->target) This->target = GL_TEXTURE_RECTANGLE;
|
| 1351 | + This->colororder = 1;
|
| 1352 | + This->colorsizes[0] = 255;
|
| 1353 | + This->colorsizes[1] = 255;
|
| 1354 | + This->colorsizes[2] = 255;
|
| 1355 | + This->colorsizes[3] = 255;
|
| 1356 | + This->colorbits[0] = 8;
|
| 1357 | + This->colorbits[0] = 8;
|
| 1358 | + This->colorbits[0] = 8;
|
| 1359 | + This->colorbits[0] = 8;
|
| 1360 | + This->packsize = 2;
|
| 1361 | + break;
|
| 1362 | + case DXGLPIXELFORMAT_FOURCC_YUY2:
|
| 1363 | + case DXGLPIXELFORMAT_FOURCC_YUNV:
|
| 1364 | + FIXME("Add YUY2/YUNV mode");
|
| 1365 | + This->packsize = 2;
|
| 1366 | + break;
|
| 1367 | + case DXGLPIXELFORMAT_FOURCC_RGBG:
|
| 1368 | + FIXME("Add RGBG mode");
|
| 1369 | + This->packsize = 2;
|
| 1370 | + break;
|
| 1371 | + case DXGLPIXELFORMAT_FOURCC_GRGB:
|
| 1372 | + FIXME("Add GRGB mode");
|
| 1373 | + This->packsize = 2;
|
| 1374 | + break;
|
1257 | 1375 | }
|
1258 | 1376 | glGenTextures(1, &This->id);
|
1259 | 1377 | glUtil_SetTexture(This->renderer->util, 0, This);
|
— | — | @@ -1294,7 +1412,7 @@ |
1295 | 1413 | do
|
1296 | 1414 | {
|
1297 | 1415 | ClearError();
|
1298 | | - glTexImage2D(This->target, i, This->internalformats[0], x, y, 0, This->format, This->type, NULL);
|
| 1416 | + glTexImage2D(This->target, i, This->internalformats[0], DivCeiling(x, This->packsize), y, 0, This->format, This->type, NULL);
|
1299 | 1417 | This->levels[i].dirty |= 2;
|
1300 | 1418 | ShrinkMip(&x, &y);
|
1301 | 1419 | error = glGetError();
|
— | — | @@ -1310,11 +1428,28 @@ |
1311 | 1429 | }
|
1312 | 1430 | else break;
|
1313 | 1431 | } while (1);
|
1314 | | - This->levels[i].buffer = (char*)malloc(NextMultipleOf4((This->levels[i].ddsd.ddpfPixelFormat.dwRGBBitCount *
|
1315 | | - This->levels[i].ddsd.dwWidth) / 8) * This->levels[i].ddsd.dwHeight);
|
| 1432 | + if (This->levels[i].ddsd.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
|
| 1433 | + {
|
| 1434 | + switch (This->levels[i].ddsd.ddpfPixelFormat.dwFourCC)
|
| 1435 | + {
|
| 1436 | + case MAKEFOURCC('U', 'Y', 'V', 'Y'):
|
| 1437 | + case MAKEFOURCC('U', 'Y', 'N', 'V'):
|
| 1438 | + case MAKEFOURCC('Y', 'U', 'Y', '2'):
|
| 1439 | + case MAKEFOURCC('Y', 'U', 'N', 'V'):
|
| 1440 | + case MAKEFOURCC('R', 'G', 'B', 'G'):
|
| 1441 | + case MAKEFOURCC('G', 'R', 'G', 'B'):
|
| 1442 | + bytes = 2 * This->levels[i].ddsd.dwWidth;
|
| 1443 | + break;
|
| 1444 | + default:
|
| 1445 | + bytes = 4 * This->levels[i].ddsd.dwWidth;
|
| 1446 | + break;
|
| 1447 | + }
|
| 1448 | + }
|
| 1449 | + else bytes = NextMultipleOf4((This->levels[i].ddsd.ddpfPixelFormat.dwRGBBitCount *
|
| 1450 | + This->levels[i].ddsd.dwWidth) / 8);
|
| 1451 | + This->levels[i].buffer = (char*)malloc(bytes * This->levels[i].ddsd.dwHeight);
|
1316 | 1452 | if ((i == 0) && ((This->levels[i].ddsd.dwWidth != This->bigwidth) || (This->levels[i].ddsd.dwHeight != This->bigheight)))
|
1317 | | - This->levels[i].bigbuffer = (char *)malloc(NextMultipleOf4((This->levels[i].ddsd.ddpfPixelFormat.dwRGBBitCount *
|
1318 | | - This->bigwidth) / 8) * This->bigheight);
|
| 1453 | + This->levels[i].bigbuffer = (char *)malloc(bytes * This->bigheight);
|
1319 | 1454 | }
|
1320 | 1455 | }
|
1321 | 1456 | void glTexture__Destroy(glTexture *This)
|
Index: ddraw/struct.h |
— | — | @@ -317,6 +317,7 @@ |
318 | 318 | int convfunctionupload;
|
319 | 319 | int convfunctiondownload;
|
320 | 320 | int internalsize;
|
| 321 | + int packsize;
|
321 | 322 | unsigned char blttype;
|
322 | 323 | struct glTexture *palette;
|
323 | 324 | struct glTexture *stencil;
|
Index: ddraw/util.c |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2013-2017 William Feely
|
| 3 | +// Copyright (C) 2013-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -199,3 +199,9 @@ |
200 | 200 | wndclassdxgltempatom = 0;
|
201 | 201 | }
|
202 | 202 | }
|
| 203 | +
|
| 204 | +int DivCeiling(int dividend, int divisor)
|
| 205 | +{
|
| 206 | + return (dividend / divisor) + (dividend % divisor != 0);
|
| 207 | +}
|
| 208 | +
|
Index: ddraw/util.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2013-2017 William Feely
|
| 3 | +// Copyright (C) 2013-2019 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -35,6 +35,8 @@ |
36 | 36 | void RegisterDXGLTempWindowClass();
|
37 | 37 | void UnregisterDXGLTempWindowClass();
|
38 | 38 |
|
| 39 | +int DivCeiling(int dividend, int divisor);
|
| 40 | +
|
39 | 41 | #ifdef __cplusplus
|
40 | 42 | }
|
41 | 43 | #endif
|
Index: dxglcfg/surfacegen.cpp |
— | — | @@ -1753,7 +1753,13 @@ |
1754 | 1754 | _T("24-bit Z,32b.rev"),
|
1755 | 1755 | _T("32-bit Zbuffer"),
|
1756 | 1756 | _T("32-bit Z/stencil"),
|
1757 | | - _T("32-bit Z/st.rev")
|
| 1757 | + _T("32-bit Z/st.rev"),
|
| 1758 | + _T("16-bit UYVY"),
|
| 1759 | + _T("16-bit UYNV"),
|
| 1760 | + _T("16-bit YUY2"),
|
| 1761 | + _T("16-bit YUNV"),
|
| 1762 | + _T("16-bit RGBG"),
|
| 1763 | + _T("16-bit GRGB"),
|
1758 | 1764 | };
|
1759 | 1765 | static const int END_SURFACEFORMATS = __LINE__ - 4;
|
1760 | 1766 | const int numsurfaceformats = END_SURFACEFORMATS - START_SURFACEFORMATS;
|
— | — | @@ -1785,7 +1791,13 @@ |
1786 | 1792 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFF00, 0, 0}, // 24 bit Z buffer, 32-bit space, reversed
|
1787 | 1793 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 0, 0xFFFFFFFF, 0, 0}, // 32 bit Z buffer
|
1788 | 1794 | {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFFFFFF00, 0xFF, 0}, // 32 bit Z buffer with stencil
|
1789 | | - {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0} // 32 bit Z buffer with stencil, reversed
|
| 1795 | + {sizeof(DDPIXELFORMAT), DDPF_ZBUFFER, 0, 32, 8, 0xFF, 0xFFFFFF00, 0}, // 32 bit Z buffer with stencil, reversed
|
| 1796 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0}, // UYVY YUV surface
|
| 1797 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('U','Y','N','V'), 0, 0, 0, 0, 0}, // UYVY YUV surface (NVIDIA alias)
|
| 1798 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0}, // YUY2 YUV surface
|
| 1799 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('Y','U','N','V'), 0, 0, 0, 0, 0}, // YUY2 YUV surface (NVIDIA alias)
|
| 1800 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0}, // RGBG 16-bit pixelformat
|
| 1801 | + {sizeof(DDPIXELFORMAT), DDPF_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0}, // GRGB 16-bit pixelformat
|
1790 | 1802 | };
|
1791 | 1803 |
|
1792 | 1804 | static const LPTSTR strErrorMessages[] =
|