Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -165,22 +165,26 @@ |
166 | 166 | static const char unif_ckeysrc[] = "uniform ivec3 ckeysrc;\n";
|
167 | 167 | static const char unif_ckeydest[] = "uniform ivec3 ckeydest;\n";
|
168 | 168 | static const char unif_patternsize[] = "uniform ivec2 patternsize;\n";
|
| 169 | +static const char unif_colorsizesrc[] = "uniform ivec4 colorsizesrc;\n";
|
| 170 | +static const char unif_colorsizedest[] = "uniform ivec4 colorsizedest;\n";
|
| 171 | +static const char unif_fillcolor[] = "uniform ivec4 fillcolor;\n";
|
169 | 172 |
|
170 | | -
|
171 | 173 | // Variables
|
172 | 174 | static const char var_dest[] = "ivec4 dest;\n";
|
173 | 175 | static const char var_pattern[] = "ivec4 pattern;\n";
|
174 | 176 | static const char var_pixel[] = "ivec4 pixel;\n";
|
| 177 | +static const char var_src[] = "ivec4 src;\n";
|
175 | 178 | static const char var_patternst[] = "vec2 patternst;\n";
|
176 | 179 |
|
177 | 180 | // Operations
|
178 | | -static const char op_src[] = "pixel = ivec4(texture2D(srctex,gl_TexCoord[0].st)*255.5);\n";
|
179 | | -static const char op_color[] = "pixel = ivec4(gl_Color*255.5);\n";
|
180 | | -static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*255.5);\n";
|
| 181 | +static const char op_src[] = "src = ivec4(texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizesrc)+.5);\n";
|
| 182 | +static const char op_pixel[] = "pixel = ivec4(texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizedest)+.5);\n";
|
| 183 | +static const char op_color[] = "pixel = fillcolor;\n";
|
| 184 | +static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*vec4(colorsizedest)+.5);\n";
|
181 | 185 | static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
|
182 | 186 | mod(gl_FragCoord.y, float(patternsize.y)) / float(patternsize.y));\n\
|
183 | | -pattern = ivec4(texture2D(patterntex,patternst)*255.5);\n";
|
184 | | -static const char op_destout[] = "gl_FragColor = vec4(pixel)/255.0;\n";
|
| 187 | +pattern = ivec4(texture2D(patterntex,patternst)*vec4(colorsizedest)+.5);\n";
|
| 188 | +static const char op_destout[] = "gl_FragColor = vec4(pixel)/vec4(colorsizedest);\n";
|
185 | 189 | static const char op_vertex[] = "vec4 xyzw = vec4(xy[0],xy[1],0,1);\n\
|
186 | 190 | mat4 proj = mat4(\n\
|
187 | 191 | vec4(2.0 / (view[1] - view[0]), 0, 0, 0),\n\
|
— | — | @@ -216,9 +220,9 @@ |
217 | 221 | "",
|
218 | 222 | "",
|
219 | 223 | "",
|
220 | | -"pixel = pattern ^ ivec4(255);\n",//0F
|
| 224 | +"pixel = pattern ^ colorsizedest;\n",//0F
|
221 | 225 | "",//10
|
222 | | -"pixel = (dest | pixel) ^ ivec4(255);\n",//11 NOTSRCERASE
|
| 226 | +"pixel = (dest | pixel) ^ colorsizedest;\n",//11 NOTSRCERASE
|
223 | 227 | "",
|
224 | 228 | "",
|
225 | 229 | "",
|
— | — | @@ -252,7 +256,7 @@ |
253 | 257 | "",//30
|
254 | 258 | "",
|
255 | 259 | "",
|
256 | | -"pixel = pixel ^ ivec4(255);\n",//33 NOTSRCCOPY
|
| 260 | +"pixel = pixel ^ colorsizedest;\n",//33 NOTSRCCOPY
|
257 | 261 | "",
|
258 | 262 | "",
|
259 | 263 | "",
|
— | — | @@ -269,7 +273,7 @@ |
270 | 274 | "",
|
271 | 275 | "",
|
272 | 276 | "",
|
273 | | -"pixel = pixel & (dest ^ ivec4(255));\n",//44 SRCERASE
|
| 277 | +"pixel = pixel & (dest ^ colorsizedest);\n",//44 SRCERASE
|
274 | 278 | "",
|
275 | 279 | "",
|
276 | 280 | "",
|
— | — | @@ -286,7 +290,7 @@ |
287 | 291 | "",
|
288 | 292 | "",
|
289 | 293 | "",
|
290 | | -"pixel = dest ^ ivec4(255);\n",//55 DSTINVERT
|
| 294 | +"pixel = dest ^ colorsizedest;\n",//55 DSTINVERT
|
291 | 295 | "",
|
292 | 296 | "",
|
293 | 297 | "",
|
— | — | @@ -388,7 +392,7 @@ |
389 | 393 | "",
|
390 | 394 | "",
|
391 | 395 | "",
|
392 | | -"pixel = dest | (pixel ^ ivec4(255));\n",//BB MERGEPAINT
|
| 396 | +"pixel = dest | (pixel ^ colorsizedest);\n",//BB MERGEPAINT
|
393 | 397 | "",
|
394 | 398 | "",
|
395 | 399 | "",
|
— | — | @@ -452,11 +456,11 @@ |
453 | 457 | "",
|
454 | 458 | "",
|
455 | 459 | "",
|
456 | | -"pixel = dest | pattern | (pixel ^ 255);\n",//FB PATPAINT
|
| 460 | +"pixel = dest | pattern | (pixel ^ colorsizedest);\n",//FB PATPAINT
|
457 | 461 | "",
|
458 | 462 | "",
|
459 | 463 | "",
|
460 | | -"pixel = ivec4(255);\n",//FF WHITENESS
|
| 464 | +"pixel = colorsizedest;\n",//FF WHITENESS
|
461 | 465 | };
|
462 | 466 |
|
463 | 467 | static const char *op_ROP_float[256] = {
|
— | — | @@ -813,8 +817,7 @@ |
814 | 818 |
|
815 | 819 | // Attributes
|
816 | 820 | String_Append(vsrc, attr_xy);
|
817 | | - if (id & DDBLT_COLORFILL) String_Append(vsrc, attr_rgb);
|
818 | | - else String_Append(vsrc, attr_srcst);
|
| 821 | + if (!(id & DDBLT_COLORFILL)) String_Append(vsrc, attr_srcst);
|
819 | 822 | if (id & DDBLT_ROP)
|
820 | 823 | {
|
821 | 824 | if (rop_texture_usage[rop] & 2) usedest = TRUE;
|
— | — | @@ -829,8 +832,7 @@ |
830 | 833 | // Main
|
831 | 834 | String_Append(vsrc, mainstart);
|
832 | 835 | String_Append(vsrc, op_vertex);
|
833 | | - if (id & DDBLT_COLORFILL) String_Append(vsrc, op_vertcolorrgb);
|
834 | | - else String_Append(vsrc, op_texcoord0);
|
| 836 | + if (!(id & DDBLT_COLORFILL)) String_Append(vsrc, op_texcoord0);
|
835 | 837 | if(usedest) String_Append(vsrc, op_texcoord1);
|
836 | 838 | if (id & 0x10000000) String_Append(vsrc, op_texcoord3);
|
837 | 839 | String_Append(vsrc, mainend);
|
— | — | @@ -887,7 +889,8 @@ |
888 | 890 | String_Append(fsrc, idstring);
|
889 | 891 |
|
890 | 892 | // Uniforms
|
891 | | - if (!(id & DDBLT_COLORFILL)) String_Append(fsrc, unif_srctex);
|
| 893 | + if (id & DDBLT_COLORFILL) String_Append(fsrc, unif_fillcolor);
|
| 894 | + else String_Append(fsrc, unif_srctex);
|
892 | 895 | if (id & DDBLT_KEYDEST) usedest = TRUE;
|
893 | 896 | if (id & DDBLT_ROP)
|
894 | 897 | {
|
— | — | @@ -900,11 +903,17 @@ |
901 | 904 | }
|
902 | 905 | if (usedest) String_Append(fsrc, unif_desttex);
|
903 | 906 | if (id & 0x10000000) String_Append(fsrc, unif_stenciltex);
|
904 | | - if (id & DDBLT_KEYSRC) String_Append(fsrc, unif_ckeysrc);
|
| 907 | + if (id & DDBLT_KEYSRC)
|
| 908 | + {
|
| 909 | + String_Append(fsrc, unif_ckeysrc);
|
| 910 | + String_Append(fsrc, unif_colorsizesrc);
|
| 911 | + }
|
| 912 | + String_Append(fsrc, unif_colorsizedest);
|
905 | 913 | if (id & DDBLT_KEYDEST) String_Append(fsrc, unif_ckeydest);
|
906 | 914 |
|
907 | 915 | // Variables
|
908 | 916 | String_Append(fsrc, var_pixel);
|
| 917 | + if (id & DDBLT_KEYSRC) String_Append(fsrc, var_src);
|
909 | 918 | if (id & DDBLT_ROP)
|
910 | 919 | {
|
911 | 920 | if (rop_texture_usage[rop] & 4)
|
— | — | @@ -919,7 +928,8 @@ |
920 | 929 | String_Append(fsrc, mainstart);
|
921 | 930 | if (id & 0x10000000) String_Append(fsrc, op_clip);
|
922 | 931 | if (id & DDBLT_COLORFILL) String_Append(fsrc, op_color);
|
923 | | - else String_Append(fsrc, op_src);
|
| 932 | + else String_Append(fsrc, op_pixel);
|
| 933 | + if (id & DDBLT_KEYSRC) String_Append(fsrc, op_src);
|
924 | 934 | if (usedest) String_Append(fsrc, op_dest);
|
925 | 935 | if (id & DDBLT_KEYSRC) String_Append(fsrc, op_ckeysrc);
|
926 | 936 | if (id & DDBLT_KEYDEST) String_Append(fsrc, op_ckeydest);
|
— | — | @@ -992,4 +1002,8 @@ |
993 | 1003 | gen->genshaders2D[index].shader.uniforms[7] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "ckeysrchigh");
|
994 | 1004 | gen->genshaders2D[index].shader.uniforms[8] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "ckeydesthigh");
|
995 | 1005 | gen->genshaders2D[index].shader.uniforms[9] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "patternsize");
|
| 1006 | + gen->genshaders2D[index].shader.uniforms[10] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "colorsizesrc");
|
| 1007 | + gen->genshaders2D[index].shader.uniforms[11] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "colorsizedest");
|
| 1008 | + gen->genshaders2D[index].shader.uniforms[12] = gen->ext->glGetUniformLocation(gen->genshaders2D[index].shader.prog, "fillcolor");
|
| 1009 | +
|
996 | 1010 | } |
\ No newline at end of file |
Index: ddraw/TextureManager.c |
— | — | @@ -145,6 +145,15 @@ |
146 | 146 | texture->format = GL_LUMINANCE;
|
147 | 147 | }
|
148 | 148 | texture->type = GL_UNSIGNED_BYTE;
|
| 149 | + texture->colororder = 4;
|
| 150 | + texture->colorsizes[0] = 255;
|
| 151 | + texture->colorsizes[1] = 255;
|
| 152 | + texture->colorsizes[2] = 255;
|
| 153 | + texture->colorsizes[3] = 255;
|
| 154 | + texture->colorbits[0] = 8;
|
| 155 | + texture->colorbits[1] = 0;
|
| 156 | + texture->colorbits[2] = 0;
|
| 157 | + texture->colorbits[3] = 0;
|
149 | 158 | break;
|
150 | 159 | case 1: // 8-bit RGB332
|
151 | 160 | texture->internalformats[0] = GL_R3_G3_B2;
|
— | — | @@ -152,6 +161,15 @@ |
153 | 162 | texture->internalformats[2] = GL_RGBA8;
|
154 | 163 | texture->format = GL_RGB;
|
155 | 164 | texture->type = GL_UNSIGNED_BYTE_3_3_2;
|
| 165 | + texture->colororder = 1;
|
| 166 | + texture->colorsizes[0] = 7;
|
| 167 | + texture->colorsizes[1] = 7;
|
| 168 | + texture->colorsizes[2] = 3;
|
| 169 | + texture->colorsizes[3] = 1;
|
| 170 | + texture->colorbits[0] = 3;
|
| 171 | + texture->colorbits[1] = 3;
|
| 172 | + texture->colorbits[2] = 2;
|
| 173 | + texture->colorbits[3] = 0;
|
156 | 174 | break;
|
157 | 175 | case 2: // 16-bit RGB555
|
158 | 176 | texture->internalformats[0] = GL_RGB5_A1;
|
— | — | @@ -158,6 +176,15 @@ |
159 | 177 | texture->internalformats[1] = GL_RGBA8;
|
160 | 178 | texture->format = GL_BGRA;
|
161 | 179 | texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 180 | + texture->colororder = 1;
|
| 181 | + texture->colorsizes[0] = 31;
|
| 182 | + texture->colorsizes[1] = 31;
|
| 183 | + texture->colorsizes[2] = 31;
|
| 184 | + texture->colorsizes[3] = 1;
|
| 185 | + texture->colorbits[0] = 5;
|
| 186 | + texture->colorbits[1] = 5;
|
| 187 | + texture->colorbits[2] = 5;
|
| 188 | + texture->colorbits[3] = 1;
|
162 | 189 | break;
|
163 | 190 | case 3: // 16-bit RGB565
|
164 | 191 | texture->internalformats[0] = GL_RGB565;
|
— | — | @@ -165,6 +192,15 @@ |
166 | 193 | texture->internalformats[2] = GL_RGBA8;
|
167 | 194 | texture->format = GL_RGB;
|
168 | 195 | texture->type = GL_UNSIGNED_SHORT_5_6_5;
|
| 196 | + texture->colororder = 1;
|
| 197 | + texture->colorsizes[0] = 31;
|
| 198 | + texture->colorsizes[1] = 63;
|
| 199 | + texture->colorsizes[2] = 31;
|
| 200 | + texture->colorsizes[3] = 1;
|
| 201 | + texture->colorbits[0] = 5;
|
| 202 | + texture->colorbits[1] = 6;
|
| 203 | + texture->colorbits[2] = 5;
|
| 204 | + texture->colorbits[3] = 0;
|
169 | 205 | break;
|
170 | 206 | case 4: // 24-bit RGB888
|
171 | 207 | texture->internalformats[0] = GL_RGB8;
|
— | — | @@ -171,19 +207,55 @@ |
172 | 208 | texture->internalformats[1] = GL_RGBA8;
|
173 | 209 | texture->format = GL_BGR;
|
174 | 210 | texture->type = GL_UNSIGNED_BYTE;
|
| 211 | + texture->colororder = 1;
|
| 212 | + texture->colorsizes[0] = 255;
|
| 213 | + texture->colorsizes[1] = 255;
|
| 214 | + texture->colorsizes[2] = 255;
|
| 215 | + texture->colorsizes[3] = 1;
|
| 216 | + texture->colorbits[0] = 8;
|
| 217 | + texture->colorbits[1] = 8;
|
| 218 | + texture->colorbits[2] = 8;
|
| 219 | + texture->colorbits[3] = 0;
|
175 | 220 | break;
|
176 | 221 | case 5: // 32-bit RGB888
|
177 | 222 | texture->internalformats[0] = GL_RGBA8;
|
178 | 223 | texture->format = GL_BGRA;
|
179 | 224 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 225 | + texture->colororder = 1;
|
| 226 | + texture->colorsizes[0] = 255;
|
| 227 | + texture->colorsizes[1] = 255;
|
| 228 | + texture->colorsizes[2] = 255;
|
| 229 | + texture->colorsizes[3] = 1;
|
| 230 | + texture->colorbits[0] = 8;
|
| 231 | + texture->colorbits[1] = 8;
|
| 232 | + texture->colorbits[2] = 8;
|
| 233 | + texture->colorbits[3] = 0;
|
180 | 234 | break;
|
181 | 235 | case 6: // 32-bit BGR888
|
182 | 236 | texture->internalformats[0] = GL_RGBA8;
|
183 | 237 | texture->format = GL_RGBA;
|
184 | 238 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 239 | + texture->colororder = 0;
|
| 240 | + texture->colorsizes[0] = 255;
|
| 241 | + texture->colorsizes[1] = 255;
|
| 242 | + texture->colorsizes[2] = 255;
|
| 243 | + texture->colorsizes[3] = 1;
|
| 244 | + texture->colorbits[0] = 8;
|
| 245 | + texture->colorbits[1] = 8;
|
| 246 | + texture->colorbits[2] = 8;
|
| 247 | + texture->colorbits[3] = 0;
|
185 | 248 | break;
|
186 | 249 | case 7: // 16-bit RGBA8332
|
187 | 250 | FIXME("Unusual texture format RGBA8332 not supported");
|
| 251 | + texture->colororder = 1;
|
| 252 | + texture->colorsizes[0] = 7;
|
| 253 | + texture->colorsizes[1] = 7;
|
| 254 | + texture->colorsizes[2] = 3;
|
| 255 | + texture->colorsizes[3] = 255;
|
| 256 | + texture->colorbits[0] = 3;
|
| 257 | + texture->colorbits[1] = 3;
|
| 258 | + texture->colorbits[2] = 2;
|
| 259 | + texture->colorbits[3] = 8;
|
188 | 260 | break;
|
189 | 261 | case 8: // 16-bit RGBA4444
|
190 | 262 | texture->internalformats[0] = GL_RGBA4;
|
— | — | @@ -190,6 +262,15 @@ |
191 | 263 | texture->internalformats[1] = GL_RGBA8;
|
192 | 264 | texture->format = GL_BGRA;
|
193 | 265 | texture->type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
|
| 266 | + texture->colororder = 1;
|
| 267 | + texture->colorsizes[0] = 15;
|
| 268 | + texture->colorsizes[1] = 15;
|
| 269 | + texture->colorsizes[2] = 15;
|
| 270 | + texture->colorsizes[3] = 15;
|
| 271 | + texture->colorbits[0] = 4;
|
| 272 | + texture->colorbits[1] = 4;
|
| 273 | + texture->colorbits[2] = 4;
|
| 274 | + texture->colorbits[3] = 4;
|
194 | 275 | break;
|
195 | 276 | case 9: // 16-bit RGBA1555
|
196 | 277 | texture->internalformats[0] = GL_RGB5_A1;
|
— | — | @@ -196,11 +277,24 @@ |
197 | 278 | texture->internalformats[1] = GL_RGBA8;
|
198 | 279 | texture->format = GL_BGRA;
|
199 | 280 | texture->type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| 281 | + texture->colorbits[0] = 5;
|
| 282 | + texture->colorbits[1] = 5;
|
| 283 | + texture->colorbits[2] = 5;
|
| 284 | + texture->colorbits[3] = 1;
|
200 | 285 | break;
|
201 | 286 | case 10: // 32-bit RGBA8888
|
202 | 287 | texture->internalformats[0] = GL_RGBA8;
|
203 | 288 | texture->format = GL_BGRA;
|
204 | 289 | texture->type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
| 290 | + texture->colororder = 1;
|
| 291 | + texture->colorsizes[0] = 255;
|
| 292 | + texture->colorsizes[1] = 255;
|
| 293 | + texture->colorsizes[2] = 255;
|
| 294 | + texture->colorsizes[3] = 255;
|
| 295 | + texture->colorbits[0] = 8;
|
| 296 | + texture->colorbits[1] = 8;
|
| 297 | + texture->colorbits[2] = 8;
|
| 298 | + texture->colorbits[3] = 8;
|
205 | 299 | break;
|
206 | 300 | case 11: // 8-bit Luminance
|
207 | 301 | texture->internalformats[0] = GL_LUMINANCE8;
|
— | — | @@ -208,11 +302,29 @@ |
209 | 303 | texture->internalformats[2] = GL_RGBA8;
|
210 | 304 | texture->format = GL_LUMINANCE;
|
211 | 305 | texture->type = GL_UNSIGNED_BYTE;
|
| 306 | + texture->colororder = 5;
|
| 307 | + texture->colorsizes[0] = 255;
|
| 308 | + texture->colorsizes[1] = 255;
|
| 309 | + texture->colorsizes[2] = 255;
|
| 310 | + texture->colorsizes[3] = 255;
|
| 311 | + texture->colorbits[0] = 8;
|
| 312 | + texture->colorbits[1] = 0;
|
| 313 | + texture->colorbits[2] = 0;
|
| 314 | + texture->colorbits[3] = 0;
|
212 | 315 | break;
|
213 | 316 | case 12: // 8-bit Alpha
|
214 | 317 | texture->internalformats[0] = GL_ALPHA8;
|
215 | 318 | texture->format = GL_ALPHA;
|
216 | 319 | texture->type = GL_UNSIGNED_BYTE;
|
| 320 | + texture->colororder = 6;
|
| 321 | + texture->colorsizes[0] = 255;
|
| 322 | + texture->colorsizes[1] = 255;
|
| 323 | + texture->colorsizes[2] = 255;
|
| 324 | + texture->colorsizes[3] = 255;
|
| 325 | + texture->colorbits[0] = 0;
|
| 326 | + texture->colorbits[1] = 0;
|
| 327 | + texture->colorbits[2] = 0;
|
| 328 | + texture->colorbits[3] = 8;
|
217 | 329 | break;
|
218 | 330 | case 13: // 16-bit Luminance Alpha
|
219 | 331 | texture->internalformats[0] = GL_LUMINANCE8_ALPHA8;
|
— | — | @@ -219,36 +331,99 @@ |
220 | 332 | texture->internalformats[1] = GL_RGBA8;
|
221 | 333 | texture->format = GL_LUMINANCE_ALPHA;
|
222 | 334 | texture->type = GL_UNSIGNED_BYTE;
|
| 335 | + texture->colororder = 7;
|
| 336 | + texture->colorsizes[0] = 255;
|
| 337 | + texture->colorsizes[1] = 255;
|
| 338 | + texture->colorsizes[2] = 255;
|
| 339 | + texture->colorsizes[3] = 255;
|
| 340 | + texture->colorbits[0] = 8;
|
| 341 | + texture->colorbits[1] = 0;
|
| 342 | + texture->colorbits[2] = 0;
|
| 343 | + texture->colorbits[3] = 8;
|
223 | 344 | break;
|
224 | 345 | case 14: // 16-bit Z buffer
|
225 | 346 | texture->internalformats[0] = GL_DEPTH_COMPONENT16;
|
226 | 347 | texture->format = GL_DEPTH_COMPONENT;
|
227 | 348 | texture->type = GL_UNSIGNED_SHORT;
|
| 349 | + texture->colororder = 4;
|
| 350 | + texture->colorsizes[0] = 65535;
|
| 351 | + texture->colorsizes[1] = 65535;
|
| 352 | + texture->colorsizes[2] = 65535;
|
| 353 | + texture->colorsizes[3] = 65535;
|
| 354 | + texture->colorbits[0] = 16;
|
| 355 | + texture->colorbits[1] = 0;
|
| 356 | + texture->colorbits[2] = 0;
|
| 357 | + texture->colorbits[3] = 0;
|
228 | 358 | break;
|
229 | 359 | case 15: // 24-bit Z buffer
|
230 | 360 | texture->internalformats[0] = GL_DEPTH_COMPONENT24;
|
231 | 361 | texture->format = GL_DEPTH_COMPONENT;
|
232 | 362 | texture->type = GL_UNSIGNED_INT;
|
| 363 | + texture->colororder = 4;
|
| 364 | + texture->colorsizes[0] = 16777215;
|
| 365 | + texture->colorsizes[1] = 16777215;
|
| 366 | + texture->colorsizes[2] = 16777215;
|
| 367 | + texture->colorsizes[3] = 16777215;
|
| 368 | + texture->colorbits[0] = 24;
|
| 369 | + texture->colorbits[1] = 0;
|
| 370 | + texture->colorbits[2] = 0;
|
| 371 | + texture->colorbits[3] = 0;
|
233 | 372 | break;
|
234 | 373 | case 16: // 32/24 bit Z buffer
|
235 | 374 | texture->internalformats[0] = GL_DEPTH_COMPONENT24;
|
236 | 375 | texture->format = GL_DEPTH_COMPONENT;
|
237 | 376 | texture->type = GL_UNSIGNED_INT;
|
| 377 | + texture->colororder = 4;
|
| 378 | + texture->colorsizes[0] = 16777215;
|
| 379 | + texture->colorsizes[1] = 16777215;
|
| 380 | + texture->colorsizes[2] = 16777215;
|
| 381 | + texture->colorsizes[3] = 16777215;
|
| 382 | + texture->colorbits[0] = 24;
|
| 383 | + texture->colorbits[1] = 0;
|
| 384 | + texture->colorbits[2] = 0;
|
| 385 | + texture->colorbits[3] = 0;
|
238 | 386 | break;
|
239 | 387 | case 17: // 32-bit Z buffer
|
240 | 388 | texture->internalformats[0] = GL_DEPTH_COMPONENT32;
|
241 | 389 | texture->format = GL_DEPTH_COMPONENT;
|
242 | 390 | texture->type = GL_UNSIGNED_INT;
|
| 391 | + texture->colororder = 4;
|
| 392 | + texture->colorsizes[0] = 4294967295;
|
| 393 | + texture->colorsizes[1] = 4294967295;
|
| 394 | + texture->colorsizes[2] = 4294967295;
|
| 395 | + texture->colorsizes[3] = 4294967295;
|
| 396 | + texture->colorbits[0] = 32;
|
| 397 | + texture->colorbits[1] = 0;
|
| 398 | + texture->colorbits[2] = 0;
|
| 399 | + texture->colorbits[3] = 0;
|
243 | 400 | break;
|
244 | 401 | case 18: // 32-bit Z/Stencil buffer, depth LSB
|
245 | 402 | texture->internalformats[0] = GL_DEPTH24_STENCIL8;
|
246 | 403 | texture->format = GL_DEPTH_STENCIL;
|
247 | 404 | texture->type = GL_UNSIGNED_INT_24_8;
|
| 405 | + texture->colororder = 7;
|
| 406 | + texture->colorsizes[0] = 16777215;
|
| 407 | + texture->colorsizes[1] = 16777215;
|
| 408 | + texture->colorsizes[2] = 16777215;
|
| 409 | + texture->colorsizes[3] = 255;
|
| 410 | + texture->colorbits[0] = 24;
|
| 411 | + texture->colorbits[1] = 0;
|
| 412 | + texture->colorbits[2] = 0;
|
| 413 | + texture->colorbits[3] = 8;
|
248 | 414 | break;
|
249 | 415 | case 19: // 32-bit Z/Stencil buffer, depth MSB
|
250 | 416 | texture->internalformats[0] = GL_DEPTH24_STENCIL8;
|
251 | 417 | texture->format = GL_DEPTH_STENCIL;
|
252 | 418 | texture->type = GL_UNSIGNED_INT_24_8;
|
| 419 | + texture->colororder = 7;
|
| 420 | + texture->colorsizes[0] = 16777215;
|
| 421 | + texture->colorsizes[1] = 16777215;
|
| 422 | + texture->colorsizes[2] = 16777215;
|
| 423 | + texture->colorsizes[3] = 255;
|
| 424 | + texture->colorbits[0] = 24;
|
| 425 | + texture->colorbits[1] = 0;
|
| 426 | + texture->colorbits[2] = 0;
|
| 427 | + texture->colorbits[3] = 8;
|
253 | 428 | break;
|
254 | 429 | }
|
255 | 430 | texture->width = width;
|
Index: ddraw/TextureManager.h |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | // version 2.1 of the License, or (at your option) any later version.
|
9 | 9 |
|
10 | 10 | // This library is distributed in the hope that it will be useful,
|
11 | | -// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 | +// but WITHOUT ANY W ARRANTY; without even the implied warranty of
|
12 | 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 | 13 | // Lesser General Public License for more details.
|
14 | 14 |
|
— | — | @@ -35,6 +35,9 @@ |
36 | 36 | GLint miplevel;
|
37 | 37 | DWORD bordercolor;
|
38 | 38 | GLint internalformats[8];
|
| 39 | + DWORD colorsizes[4];
|
| 40 | + DWORD colorbits[4];
|
| 41 | + int colororder;
|
39 | 42 | GLenum format;
|
40 | 43 | GLenum type;
|
41 | 44 | GLuint pbo;
|
— | — | @@ -41,6 +44,16 @@ |
42 | 45 | DDPIXELFORMAT pixelformat;
|
43 | 46 | } TEXTURE;
|
44 | 47 |
|
| 48 | +// Color orders:
|
| 49 | +// 0 - ABGR
|
| 50 | +// 1 - ARGB
|
| 51 | +// 2 - BGRA
|
| 52 | +// 3 - RGBA
|
| 53 | +// 4 - R or Indexed
|
| 54 | +// 5 - Luminance
|
| 55 | +// 6 - Alpha
|
| 56 | +// 7 - Luminance Alpha
|
| 57 | +
|
45 | 58 | typedef struct
|
46 | 59 | {
|
47 | 60 | GLuint id;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -943,6 +943,134 @@ |
944 | 944 | return TRUE;
|
945 | 945 | }
|
946 | 946 |
|
| 947 | +void SetColorFillUniform(DWORD color, DWORD *colorsizes, int colororder, DWORD *colorbits, GLint uniform, glExtensions *ext)
|
| 948 | +{
|
| 949 | + DWORD r, g, b, a;
|
| 950 | + switch (colororder)
|
| 951 | + {
|
| 952 | + case 0:
|
| 953 | + r = color & colorsizes[0];
|
| 954 | + color >>= colorbits[0];
|
| 955 | + g = color & colorsizes[1];
|
| 956 | + color >>= colorbits[1];
|
| 957 | + b = color & colorsizes[2];
|
| 958 | + color >>= colorbits[2];
|
| 959 | + a = color & colorsizes[3];
|
| 960 | + ext->glUniform4i(uniform, r, g, b, a);
|
| 961 | + break;
|
| 962 | + case 1:
|
| 963 | + b = color & colorsizes[2];
|
| 964 | + color >>= colorbits[2];
|
| 965 | + g = color & colorsizes[1];
|
| 966 | + color >>= colorbits[1];
|
| 967 | + r = color & colorsizes[0];
|
| 968 | + color >>= colorbits[0];
|
| 969 | + a = color & colorsizes[3];
|
| 970 | + ext->glUniform4i(uniform, r, g, b, a);
|
| 971 | + break;
|
| 972 | + case 2:
|
| 973 | + a = color & colorsizes[3];
|
| 974 | + color >>= colorbits[3];
|
| 975 | + r = color & colorsizes[0];
|
| 976 | + color >>= colorbits[0];
|
| 977 | + g = color & colorsizes[1];
|
| 978 | + color >>= colorbits[1];
|
| 979 | + b = color & colorsizes[2];
|
| 980 | + ext->glUniform4i(uniform, r, g, b, a);
|
| 981 | + break;
|
| 982 | + case 3:
|
| 983 | + a = color & colorsizes[3];
|
| 984 | + color >>= colorbits[3];
|
| 985 | + b = color & colorsizes[2];
|
| 986 | + color >>= colorbits[2];
|
| 987 | + g = color & colorsizes[1];
|
| 988 | + color >>= colorbits[1];
|
| 989 | + r = color & colorsizes[0];
|
| 990 | + ext->glUniform4i(uniform, r, g, b, a);
|
| 991 | + break;
|
| 992 | + case 4:
|
| 993 | + r = color & colorsizes[0];
|
| 994 | + ext->glUniform4i(uniform, r, r, r, r);
|
| 995 | + break;
|
| 996 | + case 5:
|
| 997 | + r = color & colorsizes[0];
|
| 998 | + ext->glUniform4i(uniform, r, r, r, r);
|
| 999 | + break;
|
| 1000 | + case 6:
|
| 1001 | + a = color & colorsizes[3];
|
| 1002 | + ext->glUniform4i(uniform, a, a, a, a);
|
| 1003 | + break;
|
| 1004 | + case 7:
|
| 1005 | + r = color & colorsizes[0];
|
| 1006 | + color >>= colorbits[0];
|
| 1007 | + a = color & colorsizes[3];
|
| 1008 | + ext->glUniform4i(uniform, r, r, r, a);
|
| 1009 | + break;
|
| 1010 | + }
|
| 1011 | +}
|
| 1012 | +
|
| 1013 | +void SetColorKeyUniform(DWORD key, DWORD *colorsizes, int colororder, GLint uniform, DWORD *colorbits, glExtensions *ext)
|
| 1014 | +{
|
| 1015 | + DWORD r, g, b, a;
|
| 1016 | + switch (colororder)
|
| 1017 | + {
|
| 1018 | + case 0:
|
| 1019 | + r = key & colorsizes[0];
|
| 1020 | + key >>= colorbits[0];
|
| 1021 | + g = key & colorsizes[1];
|
| 1022 | + key >>= colorbits[1];
|
| 1023 | + b = key & colorsizes[2];
|
| 1024 | + ext->glUniform3i(uniform, r, g, b);
|
| 1025 | + break;
|
| 1026 | + case 1:
|
| 1027 | + b = key & colorsizes[2];
|
| 1028 | + key >>= colorbits[2];
|
| 1029 | + g = key & colorsizes[1];
|
| 1030 | + key >>= colorbits[1];
|
| 1031 | + r = key & colorsizes[0];
|
| 1032 | + ext->glUniform3i(uniform, r, g, b);
|
| 1033 | + break;
|
| 1034 | + case 2:
|
| 1035 | + a = key & colorsizes[3];
|
| 1036 | + key >>= colorbits[3];
|
| 1037 | + r = key & colorsizes[0];
|
| 1038 | + key >>= colorbits[0];
|
| 1039 | + g = key & colorsizes[1];
|
| 1040 | + key >>= colorbits[1];
|
| 1041 | + b = key & colorsizes[2];
|
| 1042 | + ext->glUniform3i(uniform, r, g, b);
|
| 1043 | + break;
|
| 1044 | + case 3:
|
| 1045 | + a = key & colorsizes[3];
|
| 1046 | + key >>= colorbits[3];
|
| 1047 | + b = key & colorsizes[2];
|
| 1048 | + key >>= colorbits[2];
|
| 1049 | + g = key & colorsizes[1];
|
| 1050 | + key >>= colorbits[1];
|
| 1051 | + r = key & colorsizes[0];
|
| 1052 | + ext->glUniform3i(uniform, r, g, b);
|
| 1053 | + break;
|
| 1054 | + case 4:
|
| 1055 | + r = key & colorsizes[0];
|
| 1056 | + if (ext->glver_major >= 3) ext->glUniform3i(uniform, r, 0, 0);
|
| 1057 | + else ext->glUniform3i(uniform, r, r, r);
|
| 1058 | + break;
|
| 1059 | + case 5:
|
| 1060 | + r = key & colorsizes[0];
|
| 1061 | + ext->glUniform3i(uniform, r, r, r);
|
| 1062 | + break;
|
| 1063 | + case 6:
|
| 1064 | + a = key & colorsizes[3];
|
| 1065 | + ext->glUniform4i(uniform, 0, 0, 0, a);
|
| 1066 | + break;
|
| 1067 | + case 7:
|
| 1068 | + r = key & colorsizes[0];
|
| 1069 | + key >>= colorbits[0];
|
| 1070 | + a = key & colorsizes[3];
|
| 1071 | + ext->glUniform4i(uniform, r, r, r, a);
|
| 1072 | + break;
|
| 1073 | + }
|
| 1074 | +}
|
947 | 1075 | void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
948 | 1076 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
949 | 1077 | {
|
— | — | @@ -1022,105 +1150,15 @@ |
1023 | 1151 | This->blttexcoords[2].stencilt = This->blttexcoords[3].stencilt = This->bltvertices[2].y / (GLfloat)dest->fakey;
|
1024 | 1152 | }
|
1025 | 1153 | if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
|
1026 | | - if(dwFlags & DDBLT_COLORFILL)
|
1027 | | - {
|
1028 | | - switch(This->ddInterface->GetBPP())
|
1029 | | - {
|
1030 | | - case 8:
|
1031 | | - This->bltvertices[0].r = This->bltvertices[0].g = This->bltvertices[0].b =
|
1032 | | - This->bltvertices[1].r = This->bltvertices[1].g = This->bltvertices[1].b =
|
1033 | | - This->bltvertices[2].r = This->bltvertices[2].g = This->bltvertices[2].b =
|
1034 | | - This->bltvertices[3].r = This->bltvertices[3].g = This->bltvertices[3].b = (GLubyte)lpDDBltFx->dwFillColor;
|
1035 | | - break;
|
1036 | | - case 15:
|
1037 | | - This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
|
1038 | | - _5to8bit((lpDDBltFx->dwFillColor>>10) & 31);
|
1039 | | - This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
|
1040 | | - _5to8bit((lpDDBltFx->dwFillColor>>5) & 31);
|
1041 | | - This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
|
1042 | | - _5to8bit(lpDDBltFx->dwFillColor & 31);
|
1043 | | - break;
|
1044 | | - case 16:
|
1045 | | - This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
|
1046 | | - _5to8bit((lpDDBltFx->dwFillColor>>11) & 31);
|
1047 | | - This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
|
1048 | | - _6to8bit((lpDDBltFx->dwFillColor>>5) & 63);
|
1049 | | - This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
|
1050 | | - _5to8bit(lpDDBltFx->dwFillColor & 31);
|
1051 | | - break;
|
1052 | | - case 24:
|
1053 | | - case 32:
|
1054 | | - This->bltvertices[0].r = This->bltvertices[1].r = This->bltvertices[2].r = This->bltvertices[3].r =
|
1055 | | - ((lpDDBltFx->dwFillColor>>16) & 255);
|
1056 | | - This->bltvertices[0].g = This->bltvertices[1].g = This->bltvertices[2].g = This->bltvertices[3].g =
|
1057 | | - ((lpDDBltFx->dwFillColor>>8) & 255);
|
1058 | | - This->bltvertices[0].b = This->bltvertices[1].b = This->bltvertices[2].b = This->bltvertices[3].b =
|
1059 | | - (lpDDBltFx->dwFillColor & 255);
|
1060 | | - default:
|
1061 | | - break;
|
1062 | | - }
|
1063 | | - }
|
1064 | | - if((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
1065 | | - {
|
1066 | | - switch(This->ddInterface->GetBPP())
|
1067 | | - {
|
1068 | | - case 8:
|
1069 | | - if(This->ext->glver_major >= 3) This->ext->glUniform3i(shader->shader.uniforms[5],src->colorkey[0].key.dwColorSpaceHighValue,0,0);
|
1070 | | - else This->ext->glUniform3i(shader->shader.uniforms[5],src->colorkey[0].key.dwColorSpaceHighValue,src->colorkey[0].key.dwColorSpaceHighValue,
|
1071 | | - src->colorkey[0].key.dwColorSpaceHighValue);
|
1072 | | - break;
|
1073 | | - case 15:
|
1074 | | - This->ext->glUniform3i(shader->shader.uniforms[5],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>10 & 31),
|
1075 | | - _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 31),
|
1076 | | - _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
1077 | | - break;
|
1078 | | - case 16:
|
1079 | | - This->ext->glUniform3i(shader->shader.uniforms[5],_5to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>11 & 31),
|
1080 | | - _6to8bit(src->colorkey[0].key.dwColorSpaceHighValue>>5 & 63),
|
1081 | | - _5to8bit(src->colorkey[0].key.dwColorSpaceHighValue & 31));
|
1082 | | - break;
|
1083 | | - case 24:
|
1084 | | - case 32:
|
1085 | | - default:
|
1086 | | - This->ext->glUniform3i(shader->shader.uniforms[5],(src->colorkey[0].key.dwColorSpaceHighValue>>16 & 255),
|
1087 | | - (src->colorkey[0].key.dwColorSpaceHighValue>>8 & 255),
|
1088 | | - (src->colorkey[0].key.dwColorSpaceHighValue & 255));
|
1089 | | - break;
|
1090 | | - }
|
1091 | | - This->ext->glUniform1i(shader->shader.uniforms[1],0);
|
1092 | | - }
|
| 1154 | + if (dwFlags & DDBLT_COLORFILL) SetColorFillUniform(lpDDBltFx->dwFillColor, dest->texture->colorsizes,
|
| 1155 | + dest->texture->colororder, dest->texture->colorbits, shader->shader.uniforms[12], This->ext);
|
| 1156 | + if ((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
| 1157 | + SetColorKeyUniform(src->colorkey[0].key.dwColorSpaceLowValue, src->texture->colorsizes,
|
| 1158 | + src->texture->colororder, shader->shader.uniforms[5], src->texture->colorbits, This->ext);
|
| 1159 | + if (!(dwFlags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 0);
|
1093 | 1160 | if ((dwFlags & DDBLT_KEYDEST) && (This && dest->colorkey[1].enabled))
|
1094 | | - {
|
1095 | | - switch (This->ddInterface->GetBPP())
|
1096 | | - {
|
1097 | | - case 8:
|
1098 | | - if (This->ext->glver_major >= 3) This->ext->glUniform3i(shader->shader.uniforms[6], dest->colorkey[1].key.dwColorSpaceHighValue, 0, 0);
|
1099 | | - else This->ext->glUniform3i(shader->shader.uniforms[6], dest->colorkey[1].key.dwColorSpaceHighValue, dest->colorkey[1].key.dwColorSpaceHighValue,
|
1100 | | - dest->colorkey[1].key.dwColorSpaceHighValue);
|
1101 | | - break;
|
1102 | | - case 15:
|
1103 | | - This->ext->glUniform3i(shader->shader.uniforms[6], _5to8bit(dest->colorkey[1].key.dwColorSpaceHighValue >> 10 & 31),
|
1104 | | - _5to8bit(dest->colorkey[1].key.dwColorSpaceHighValue >> 5 & 31),
|
1105 | | - _5to8bit(dest->colorkey[1].key.dwColorSpaceHighValue & 31));
|
1106 | | - break;
|
1107 | | - case 16:
|
1108 | | - This->ext->glUniform3i(shader->shader.uniforms[6], _5to8bit(dest->colorkey[1].key.dwColorSpaceHighValue >> 11 & 31),
|
1109 | | - _6to8bit(dest->colorkey[1].key.dwColorSpaceHighValue >> 5 & 63),
|
1110 | | - _5to8bit(dest->colorkey[1].key.dwColorSpaceHighValue & 31));
|
1111 | | - break;
|
1112 | | - case 24:
|
1113 | | - case 32:
|
1114 | | - default:
|
1115 | | - This->ext->glUniform3i(shader->shader.uniforms[5], (dest->colorkey[1].key.dwColorSpaceHighValue >> 16 & 255),
|
1116 | | - (dest->colorkey[1].key.dwColorSpaceHighValue >> 8 & 255),
|
1117 | | - (dest->colorkey[1].key.dwColorSpaceHighValue & 255));
|
1118 | | - break;
|
1119 | | - }
|
1120 | | - }
|
1121 | | - else if (!(dwFlags & DDBLT_COLORFILL))
|
1122 | | - {
|
1123 | | - This->ext->glUniform1i(shader->shader.uniforms[1],0);
|
1124 | | - }
|
| 1161 | + SetColorKeyUniform(dest->colorkey[1].key.dwColorSpaceLowValue, dest->texture->colorsizes,
|
| 1162 | + dest->texture->colororder, shader->shader.uniforms[6], dest->texture->colorbits, This->ext);
|
1125 | 1163 | if (usedest && (shader->shader.uniforms[2] != -1))
|
1126 | 1164 | {
|
1127 | 1165 | TextureManager_SetTexture(This->texman, 1, This->backbuffer);
|
— | — | @@ -1152,6 +1190,10 @@ |
1153 | 1191 | }
|
1154 | 1192 | else TextureManager_SetTexture(This->texman,0,NULL);
|
1155 | 1193 | This->ext->glUniform4f(shader->shader.uniforms[0],0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
|
| 1194 | + if(src) This->ext->glUniform4i(shader->shader.uniforms[10], src->texture->colorsizes[0], src->texture->colorsizes[1],
|
| 1195 | + src->texture->colorsizes[2], src->texture->colorsizes[3]);
|
| 1196 | + if(dest) This->ext->glUniform4i(shader->shader.uniforms[11], dest->texture->colorsizes[0], dest->texture->colorsizes[1],
|
| 1197 | + dest->texture->colorsizes[2], dest->texture->colorsizes[3]);
|
1156 | 1198 | dest->dirty |= 2;
|
1157 | 1199 | This->util->EnableArray(shader->shader.attribs[0],true);
|
1158 | 1200 | This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,false,sizeof(BltVertex),&This->bltvertices[0].x);
|