DXGL r469 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r468‎ | r469 | r470 >
Date:02:21, 25 July 2014
Author:admin
Status:new
Tags:
Comment:
Select ROP support table based on OpenGL capabilities.
On graphics cards that support boolean operations, add the following ROPs: NOTSRCERASE, SRCERASE, PATINVERT, SRCINVERT, SRCAND, MERGEPAINT, MERGECOPY, SRCPAINT, and PATPAINT.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -116,14 +116,14 @@
117117 };
118118
119119 const DWORD supported_rops[8] = {
120 - 0x00008001,
 120+ 0x00028001,
121121 0x00080000,
122 - 0x00200000,
123 - 0x00000000,
124 - 0x00000000,
125 - 0x00000400,
126 - 0x00001000,
127 - 0x80010000
 122+ 0x04200010,
 123+ 0x00000040,
 124+ 0x00000100,
 125+ 0x08000400,
 126+ 0x00001001,
 127+ 0x88014000
128128 };
129129
130130 const DWORD supported_rops_gl2[8] = {
@@ -217,6 +217,7 @@
218218 "",
219219 "pixel = pattern ^ ivec4(255);\n",//0F
220220 "",//10
 221+"pixel = (dest | pixel) ^ ivec4(255);\n",//11 NOTSRCERASE
221222 "",
222223 "",
223224 "",
@@ -230,7 +231,6 @@
231232 "",
232233 "",
233234 "",
234 -"",
235235 "",//1F
236236 "",//20
237237 "",
@@ -268,6 +268,7 @@
269269 "",
270270 "",
271271 "",
 272+"pixel = pixel & (dest ^ ivec4(255));\n",//44 SRCERASE
272273 "",
273274 "",
274275 "",
@@ -278,7 +279,6 @@
279280 "",
280281 "",
281282 "",
282 -"",
283283 "",//4F
284284 "",//50
285285 "",
@@ -290,11 +290,11 @@
291291 "",
292292 "",
293293 "",
 294+"pixel = dest ^ pattern;\n",//5A PATINVERT
294295 "",
295296 "",
296297 "",
297298 "",
298 -"",
299299 "",//5F
300300 "",//60
301301 "",
@@ -302,6 +302,7 @@
303303 "",
304304 "",
305305 "",
 306+"pixel = pixel ^ dest;\n",//66 SRCINVERT
306307 "",
307308 "",
308309 "",
@@ -310,7 +311,6 @@
311312 "",
312313 "",
313314 "",
314 -"",
315315 "",//6F
316316 "",//70
317317 "",
@@ -336,6 +336,7 @@
337337 "",
338338 "",
339339 "",
 340+"pixel = pixel & dest;\n",//88 SRCAND
340341 "",
341342 "",
342343 "",
@@ -342,7 +343,6 @@
343344 "",
344345 "",
345346 "",
346 -"",
347347 "",//8F
348348 "",//90
349349 "",
@@ -387,12 +387,12 @@
388388 "",
389389 "",
390390 "",
 391+"pixel = dest | (pixel ^ ivec4(255));\n",//BB MERGEPAINT
391392 "",
392393 "",
393394 "",
394 -"",
395395 "",//BF
396 -"",//C0
 396+"pixel = pixel & pattern;\n",//C0 MERGECOPY
397397 "",
398398 "",
399399 "",
@@ -438,7 +438,7 @@
439439 "",
440440 "",
441441 "",
442 -"",
 442+"pixel = pixel | dest;\n",//EE SRCPAINT
443443 "",//EF
444444 "pixel = pattern;\n",//F0 PATCOPY
445445 "",
@@ -451,10 +451,10 @@
452452 "",
453453 "",
454454 "",
 455+"pixel = dest | pattern | (pixel ^ 255);\n",//FB PATPAINT
455456 "",
456457 "",
457458 "",
458 -"",
459459 "pixel = ivec4(255);\n",//FF WHITENESS
460460 };
461461
Index: ddraw/glDirectDraw.cpp
@@ -962,11 +962,41 @@
963963 DDSCAPS_FRONTBUFFER | DDSCAPS_OFFSCREENPLAIN | DDSCAPS_PALETTE |
964964 DDSCAPS_SYSTEMMEMORY | DDSCAPS_VIDEOMEMORY | DDSCAPS_3DDEVICE;
965965 ddCaps.dwCKeyCaps = DDCKEYCAPS_SRCBLT;
966 - memcpy(ddCaps.dwRops,supported_rops,8*sizeof(DWORD));
967 - memcpy(ddCaps.dwNLVBRops,supported_rops,8*sizeof(DWORD));
968 - memcpy(ddCaps.dwSSBRops,supported_rops,8*sizeof(DWORD));
969 - memcpy(ddCaps.dwSVBRops,supported_rops,8*sizeof(DWORD));
970 - memcpy(ddCaps.dwVSBRops,supported_rops,8*sizeof(DWORD));
 966+ BOOL fullrop = FALSE;
 967+ if (!renderer)
 968+ {
 969+ HWND hGLWnd = CreateWindow(_T("Test"), NULL, WS_POPUP, 0, 0, 16, 16, NULL, NULL, NULL, NULL);
 970+ glRenderer *tmprenderer = (glRenderer*)malloc(sizeof(glRenderer));
 971+ DEVMODE mode;
 972+ mode.dmSize = sizeof(DEVMODE);
 973+ EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
 974+ glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL);
 975+ if (tmprenderer->ext->glver_major >= 3) fullrop = TRUE;
 976+ if (tmprenderer->ext->GLEXT_EXT_gpu_shader4) fullrop = TRUE;
 977+ glRenderer_Delete(tmprenderer);
 978+ free(tmprenderer);
 979+ }
 980+ else
 981+ {
 982+ if (renderer->ext->glver_major >= 3) fullrop = TRUE;
 983+ if (renderer->ext->GLEXT_EXT_gpu_shader4) fullrop = TRUE;
 984+ }
 985+ if (fullrop)
 986+ {
 987+ memcpy(ddCaps.dwRops, supported_rops, 8 * sizeof(DWORD));
 988+ memcpy(ddCaps.dwNLVBRops, supported_rops, 8 * sizeof(DWORD));
 989+ memcpy(ddCaps.dwSSBRops, supported_rops, 8 * sizeof(DWORD));
 990+ memcpy(ddCaps.dwSVBRops, supported_rops, 8 * sizeof(DWORD));
 991+ memcpy(ddCaps.dwVSBRops, supported_rops, 8 * sizeof(DWORD));
 992+ }
 993+ else
 994+ {
 995+ memcpy(ddCaps.dwRops, supported_rops_gl2, 8 * sizeof(DWORD));
 996+ memcpy(ddCaps.dwNLVBRops, supported_rops_gl2, 8 * sizeof(DWORD));
 997+ memcpy(ddCaps.dwSSBRops, supported_rops_gl2, 8 * sizeof(DWORD));
 998+ memcpy(ddCaps.dwSVBRops, supported_rops_gl2, 8 * sizeof(DWORD));
 999+ memcpy(ddCaps.dwVSBRops, supported_rops_gl2, 8 * sizeof(DWORD));
 1000+ }
9711001 GetAvailableVidMem(NULL,&ddCaps.dwVidMemTotal,&ddCaps.dwVidMemFree);
9721002 if(lpDDDriverCaps)
9731003 {